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 |
|---|---|---|---|---|---|---|
298,370 | <p>Is it possible to change java lookandfeel without modifying the program in a real-world environment?</p>
<p>I know that theoretically the answer is yes. I also created demo applications and changed the lookandfeel even at runtime and it worked. But when I created a real application with lots of controls lookandfeel... | [
{
"answer_id": 298407,
"author": "Stein G. Strindhaug",
"author_id": 26115,
"author_profile": "https://Stackoverflow.com/users/26115",
"pm_score": 0,
"selected": false,
"text": "<p>The look and feel <em>should</em> change fonts and behaveour, that's the purouse of the look and feel syste... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21348/"
] | Is it possible to change java lookandfeel without modifying the program in a real-world environment?
I know that theoretically the answer is yes. I also created demo applications and changed the lookandfeel even at runtime and it worked. But when I created a real application with lots of controls lookandfeel change wa... | Yes, there are different ways to start your application with a certain look and fell without modifying the code of your application. An easy way is to set a system property at startup of your application. E.g. if you have a shell script or batch file starting your application you just change the command from
```
java ... |
298,373 | <p>Normally, in Delphi one would declare a function with a variable number of arguments using the 'array of const' method. However, for compatibility with code written in C, there's an much-unknown 'varargs' directive that can be added to a function declaration (I learned this while reading Rudy's excellent '<a href="... | [
{
"answer_id": 298427,
"author": "Uli Gerhardt",
"author_id": 1431618,
"author_profile": "https://Stackoverflow.com/users/1431618",
"pm_score": 2,
"selected": false,
"text": "<p>I found <a href=\"http://groups.google.de/group/borland.public.delphi.objectpascal/msg/22347fdb88dbf7bd\" rel=... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12170/"
] | Normally, in Delphi one would declare a function with a variable number of arguments using the 'array of const' method. However, for compatibility with code written in C, there's an much-unknown 'varargs' directive that can be added to a function declaration (I learned this while reading Rudy's excellent '[Pitfalls of ... | OK, I see the clarification in your question to mean that you need to implement a C import in Delphi. In that case, you need to implement varargs yourself.
The basic knowledge needed is the C calling convention on the x86: the stack grows downwards, and C pushes arguments from right to left. Thus, a pointer to the las... |
298,385 | <p>Is it possible to get a list of all instances with a name in a flash movie using actionscript 2. Like an array containing all named text areas, or all movieClip instances etc. I would like to get this so the designer can add or remove text areas etc. and the actionscript can dynamically find these and get the texts ... | [
{
"answer_id": 299578,
"author": "defmeta",
"author_id": 10875,
"author_profile": "https://Stackoverflow.com/users/10875",
"pm_score": 0,
"selected": false,
"text": "<p>It's been a while since I did any AS2 coding but perhaps you could use a combination of MovieClip.getInstanceAtDepth() ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26115/"
] | Is it possible to get a list of all instances with a name in a flash movie using actionscript 2. Like an array containing all named text areas, or all movieClip instances etc. I would like to get this so the designer can add or remove text areas etc. and the actionscript can dynamically find these and get the texts fro... | @Stein Gauslaa Strindhaug
This is pretty rough, but it should do the trick!
```
private function traceAllChildren(rootContainer:DisplayObjectContainer):void {
for(var i=0; i < rootContainer.numChildren; i++) {
var item:* = rootContainer.getChildAt(i);
try {
traceAllChildren(item);
... |
298,391 | <p>I'm a little bit stuck with a asp.net project that i'm doing! I have got a class that is called from the code behind and many of its function have no return type ie, being void. How does one do exception handling then??? Also, if the function within the class does have a return type of, for instance, a dataset how w... | [
{
"answer_id": 298404,
"author": "OJ.",
"author_id": 611,
"author_profile": "https://Stackoverflow.com/users/611",
"pm_score": 1,
"selected": false,
"text": "<p>Only catch the exceptions where you intend to handle them properly. If you want to reflect the errors in the UI, catch them at ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm a little bit stuck with a asp.net project that i'm doing! I have got a class that is called from the code behind and many of its function have no return type ie, being void. How does one do exception handling then??? Also, if the function within the class does have a return type of, for instance, a dataset how woul... | Only catch the exceptions where you intend to handle them properly. If you want to reflect the errors in the UI, catch them at the UI. If you want to handle them and try to deal with the issue in the business logic, then catch them and handle them at that point.
By the way, your code is susceptable to [SQL injection](... |
298,446 | <p>I've just started building a prototype application in Django. I started out by working through the <a href="http://docs.djangoproject.com/en/dev/intro/tutorial01/" rel="nofollow noreferrer">Django app tutorial on the Django site</a> which was pretty helpful, and gave me what I needed to get started. Now I have a cou... | [
{
"answer_id": 298489,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 4,
"selected": true,
"text": "<p>You need to look at the Django <a href=\"http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index\" rel=\"no... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11522/"
] | I've just started building a prototype application in Django. I started out by working through the [Django app tutorial on the Django site](http://docs.djangoproject.com/en/dev/intro/tutorial01/) which was pretty helpful, and gave me what I needed to get started. Now I have a couple of what I hope are very simple quest... | You need to look at the Django [forms](http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index).
You should never build your own form like that.
You should declare a Form class which includes a [ChoiceField](http://docs.djangoproject.com/en/dev/ref/forms/fields/#choicefield) and provide the domain of ch... |
298,449 | <p>I have the following code for my masterpage:</p>
<pre><code><%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/x... | [
{
"answer_id": 298858,
"author": "Panos",
"author_id": 8049,
"author_profile": "https://Stackoverflow.com/users/8049",
"pm_score": 1,
"selected": false,
"text": "<p>Check these related questions for solutions:</p>\n\n<ul>\n<li><a href=\"https://stackoverflow.com/questions/42294/how-do-yo... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have the following code for my masterpage:
```
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ht... | Use the following in your css for the footer div:
```
bottom:0px;
position:absolute;
``` |
298,460 | <p>I'm working on a <a href="http://userstyles.org/styles/12154" rel="nofollow noreferrer">Youtube userstyle script</a> that displays comments side by side with the video so you can watch the video and read the comments at the same time (what a marvelous idea - duh). You can see in the screenshots how far I've got. Tha... | [
{
"answer_id": 298506,
"author": "Ola Tuvesson",
"author_id": 6903,
"author_profile": "https://Stackoverflow.com/users/6903",
"pm_score": 1,
"selected": false,
"text": "<p>You shouldn't need position: absolute; on your right hand div, nor the right: 0; positioning. Floating the div right... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1269037/"
] | I'm working on a [Youtube userstyle script](http://userstyles.org/styles/12154) that displays comments side by side with the video so you can watch the video and read the comments at the same time (what a marvelous idea - duh). You can see in the screenshots how far I've got. That means I only care about Firefox, and t... | ```
#main {
border: 1px solid;
width: 50%;
float: left;
}
#rightnav {
background-color: yellow;
opacity: 0.5;
border: 1px dotted;
width: 48%;
float: right;
}
#footer {
clear: both;
}
```
that'll do it
edit: if you say liquid that usually means percent based dimensions, start associatin... |
298,463 | <p>This is the HTML:</p>
<pre><code><div id="testBlue">
<span>hello</span>
<span id="testGreen" class="testGreen">hello2</span>
</div>
</code></pre>
<p>If I have set in CSS:</p>
<pre><code>#testBlue span { color:Blue; }
.testGreen, #testGreen { color:Green; }
</code></... | [
{
"answer_id": 298468,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 2,
"selected": false,
"text": "<pre><code>#testGreen { color: red !important;}\n</code></pre>\n\n<p>or </p>\n\n<pre><code>.testGreen { color: red !import... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4264/"
] | This is the HTML:
```
<div id="testBlue">
<span>hello</span>
<span id="testGreen" class="testGreen">hello2</span>
</div>
```
If I have set in CSS:
```
#testBlue span { color:Blue; }
.testGreen, #testGreen { color:Green; }
```
How can I override the general style in the second SPAN?
I have tried both ... | In CSS, selectors with higher specificity override selectors that are more general.
In your example you defined a style for a **span inside a div with id = "testBlue"**. This selector is **more specific** than the simple selector for the class or id **testGreen**, so it wins. You just need a selector more specific tha... |
298,466 | <p>[This code is called from within the <code>Inspector.Activate</code> event handler (first call), i.e. right before the inspector window is actually shown.]</p>
<p>For "native" mail inspectors I can simply QI the <code>Inspector</code> interface to <code>IOleWindow</code> and call its <code>GetWindow</code> method. ... | [
{
"answer_id": 5181280,
"author": "Oliver Giesen",
"author_id": 9784,
"author_profile": "https://Stackoverflow.com/users/9784",
"pm_score": 2,
"selected": true,
"text": "<p>I have now come up with something new that I haven't yet been able to break but it still feels a lot like voodoo. B... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9784/"
] | [This code is called from within the `Inspector.Activate` event handler (first call), i.e. right before the inspector window is actually shown.]
For "native" mail inspectors I can simply QI the `Inspector` interface to `IOleWindow` and call its `GetWindow` method. However, this will not work for Word inspectors which ... | I have now come up with something new that I haven't yet been able to break but it still feels a lot like voodoo. By observation I found that the window I want always appears to be the first one returned by [`EnumWindows`](http://msdn.microsoft.com/en-us/library/ms633497.aspx) that is not (yet) visible, i.e. [`IsWindow... |
298,491 | <p>I want to close a System.Windows.Forms.Form if the user clicks anywhere outside it. I've tried using IMessageFilter, but even then none of the messages are passed to PreFilterMessage. How do I receive clicks outside a form's window?</p>
| [
{
"answer_id": 298496,
"author": "Galwegian",
"author_id": 3201,
"author_profile": "https://Stackoverflow.com/users/3201",
"pm_score": 0,
"selected": false,
"text": "<p>If it is a child form in an MDI application, you could trap the click in the parent form, otherwise the solution will b... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] | I want to close a System.Windows.Forms.Form if the user clicks anywhere outside it. I've tried using IMessageFilter, but even then none of the messages are passed to PreFilterMessage. How do I receive clicks outside a form's window? | With thanks to [p-daddy](https://stackoverflow.com/users/36388/p-daddy) in [this question](https://stackoverflow.com/questions/298626/what-do-these-wndproc-codes-mean), I've found this solution which allows me to use ShowDialog:
```
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
this.Capture =... |
298,494 | <p>I have many jobs that have a step to send 1 specific email out to a list of people. That list of reciepients is hardcoded in the step command and I need to remove one person from that list, in all jobs.</p>
<p>How do I loop through ALL the jobs in the Sql Server Agent and modify the command text to find+replace a ... | [
{
"answer_id": 298792,
"author": "Tim C",
"author_id": 7585,
"author_profile": "https://Stackoverflow.com/users/7585",
"pm_score": 4,
"selected": true,
"text": "<p>You could try to update the System tables that hold the information on jobs of the SQL server directly. The relevant ones fo... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11989/"
] | I have many jobs that have a step to send 1 specific email out to a list of people. That list of reciepients is hardcoded in the step command and I need to remove one person from that list, in all jobs.
How do I loop through ALL the jobs in the Sql Server Agent and modify the command text to find+replace a specific pi... | You could try to update the System tables that hold the information on jobs of the SQL server directly. The relevant ones for you would be:
```
msdb.dbo.SysJobs
msdb.dbo.SysJobSteps
```
If you have a specific email address to remove, you could update the **Command** field in the **SysJobSteps** table with a single U... |
298,503 | <p>I have some jQuery/JavaScript code that I want to run only when there is a hash (<code>#</code>) anchor link in a URL. How can you check for this character using JavaScript? I need a simple catch-all test that would detect URLs like these:</p>
<ul>
<li><code>example.com/page.html#anchor</code></li>
<li><code>example... | [
{
"answer_id": 298513,
"author": "Gareth",
"author_id": 31582,
"author_profile": "https://Stackoverflow.com/users/31582",
"pm_score": 12,
"selected": true,
"text": "<p>Simple use of <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Location/hash\" rel=\"noreferrer\">location has... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21709/"
] | I have some jQuery/JavaScript code that I want to run only when there is a hash (`#`) anchor link in a URL. How can you check for this character using JavaScript? I need a simple catch-all test that would detect URLs like these:
* `example.com/page.html#anchor`
* `example.com/page.html#anotheranchor`
Basically someth... | Simple use of [location hash](https://developer.mozilla.org/en-US/docs/Web/API/Location/hash):
```
if(window.location.hash) {
// Fragment exists
} else {
// Fragment doesn't exist
}
``` |
298,510 | <p>I'm making a C program where I need to get the directory that the program is started from. This program is written for UNIX computers. I've been looking at <code>opendir()</code> and <code>telldir()</code>, but <code>telldir()</code> returns a <code>off_t (long int)</code>, so it really doesn't help me. </p>
<p>Ho... | [
{
"answer_id": 298516,
"author": "CAdaker",
"author_id": 30579,
"author_profile": "https://Stackoverflow.com/users/30579",
"pm_score": 6,
"selected": false,
"text": "<p>Look up the man page for <code>getcwd</code>.</p>\n"
},
{
"answer_id": 298518,
"author": "Mic",
"author... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm making a C program where I need to get the directory that the program is started from. This program is written for UNIX computers. I've been looking at `opendir()` and `telldir()`, but `telldir()` returns a `off_t (long int)`, so it really doesn't help me.
How can I get the current path in a string (char array)? | Have you had a look at [`getcwd()`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html)?
```
#include <unistd.h>
char *getcwd(char *buf, size_t size);
```
Simple example:
```
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
int main() {
char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(... |
298,511 | <p>On windows mobile when there is no internet connection and I try to
browse the web using internet explorer i get cannot connect
information at the top of the screen. It says cannot connect with
current connection settings. To change your connection settings, tap
settings. And I am able to tap Settings and setup netw... | [
{
"answer_id": 298516,
"author": "CAdaker",
"author_id": 30579,
"author_profile": "https://Stackoverflow.com/users/30579",
"pm_score": 6,
"selected": false,
"text": "<p>Look up the man page for <code>getcwd</code>.</p>\n"
},
{
"answer_id": 298518,
"author": "Mic",
"author... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | On windows mobile when there is no internet connection and I try to
browse the web using internet explorer i get cannot connect
information at the top of the screen. It says cannot connect with
current connection settings. To change your connection settings, tap
settings. And I am able to tap Settings and setup network... | Have you had a look at [`getcwd()`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html)?
```
#include <unistd.h>
char *getcwd(char *buf, size_t size);
```
Simple example:
```
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
int main() {
char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(... |
298,521 | <p>I'm using Tomcat 5.5 as my servlet container. My web application deploys via .jar and has some resource files (textual files with strings and configuration parameters) located under its WEB-INF directory. Tomcat 5.5 runs on ubuntu linux. The resource file is read with a file reader:<br>
<code>fr = new FileReader("me... | [
{
"answer_id": 298574,
"author": "diciu",
"author_id": 2811,
"author_profile": "https://Stackoverflow.com/users/2811",
"pm_score": 4,
"selected": true,
"text": "<p>I'm guessing the problem is you're trying to use a relative path to access the file.\nUsing absolute path should help (i.e. ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7337/"
] | I'm using Tomcat 5.5 as my servlet container. My web application deploys via .jar and has some resource files (textual files with strings and configuration parameters) located under its WEB-INF directory. Tomcat 5.5 runs on ubuntu linux. The resource file is read with a file reader:
`fr = new FileReader("messages.pr... | I'm guessing the problem is you're trying to use a relative path to access the file.
Using absolute path should help (i.e. "/home/tomcat5/properties/messages.properties").
However, the usual solution to this problem is to use the getResourceAsStream method of the ClassLoader. Deploying the properties file to "WEB-INF/... |
298,535 | <p>In PHP 5.2 there was a nice security function added called "input_filter", so instead of saying:</p>
<pre><code>$name = $_GET['name'];
</code></pre>
<p>you can now say:</p>
<pre><code>$name = filter_input (INPUT_GET, 'name', FILTER_SANITIZE_STRING);
</code></pre>
<p>and it automatically sanitizes your string, th... | [
{
"answer_id": 298547,
"author": "Rich Bradshaw",
"author_id": 16511,
"author_profile": "https://Stackoverflow.com/users/16511",
"pm_score": 2,
"selected": false,
"text": "<p>If you are manually changing the array, surely you don't need to sanatise it anyway? Why are you changing the arr... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | In PHP 5.2 there was a nice security function added called "input\_filter", so instead of saying:
```
$name = $_GET['name'];
```
you can now say:
```
$name = filter_input (INPUT_GET, 'name', FILTER_SANITIZE_STRING);
```
and it automatically sanitizes your string, there is also:
* `FILTER_SANITIZE_ENCODED`
* `FIL... | You could manually force it to read the arrays again by using [filter\_var](http://uk3.php.net/manual/en/function.filter-var.php) and [filter\_var\_array](http://uk3.php.net/manual/en/function.filter-var-array.php)
```
$name = filter_var ( $_GET['name'], FILTER_SANITIZE_STRING );
``` |
298,554 | <pre><code>$sourcePath = 'images/'; // Path of original image
$sourceUrl = '';
$sourceName = 'photo1.jpg'; // Name of original image
$thumbPath = 'thumbs/'; // Writeable thumb path
$thumbUrl = 'thumbs/';
$thumbName = "test_thumb.jpg"; // Tip: Name dynamically
$thumbWidth = 100; // Intended dimension of thumb
// Beyond... | [
{
"answer_id": 298558,
"author": "Dominic Rodger",
"author_id": 20972,
"author_profile": "https://Stackoverflow.com/users/20972",
"pm_score": 1,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code>imagejpeg($targetImage, \"$thumbPath/$thumbName\", 100);\n</code></pre>\n"
},
{
"... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31677/"
] | ```
$sourcePath = 'images/'; // Path of original image
$sourceUrl = '';
$sourceName = 'photo1.jpg'; // Name of original image
$thumbPath = 'thumbs/'; // Writeable thumb path
$thumbUrl = 'thumbs/';
$thumbName = "test_thumb.jpg"; // Tip: Name dynamically
$thumbWidth = 100; // Intended dimension of thumb
// Beyond this p... | Use [imagecreatetruecolor](http://pl2.php.net/manual/en/function.imagecreatetruecolor.php) instead of imagecreate and [imagecopyresampled](http://pl2.php.net/manual/en/function.imagecopyresampled.php) instead of imagecopyresized. |
298,563 | <p>I am getting the following error when trying to <code>Save as Document Object</code> while trying to implement a word automation in C#:</p>
<blockquote>
<pre><code>System.Runtime.InteropServices.COMException
</code></pre>
<p>(0x80020005): Type mismatch.
(Exception from HRESULT: 0x80020005
(DISP_E_TYPEMISMA... | [
{
"answer_id": 298584,
"author": "kenny",
"author_id": 3225,
"author_profile": "https://Stackoverflow.com/users/3225",
"pm_score": 3,
"selected": false,
"text": "<p>'Tis painful. I remember getting that working with the Word/Excel Interop. Not to be flippant, but one of the parameters ha... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am getting the following error when trying to `Save as Document Object` while trying to implement a word automation in C#:
>
>
> ```
> System.Runtime.InteropServices.COMException
>
> ```
>
> (0x80020005): Type mismatch.
> (Exception from HRESULT: 0x80020005
> (DISP\_E\_TYPEMISMATCH))
>
>
>
> ```
> at Mic... | 'Tis painful. I remember getting that working with the Word/Excel Interop. Not to be flippant, but one of the parameters has an incorrect type. Hopefully the following helps, but I did a number of these types of definitions.
```
static object s_missing = System.Reflection.Missing.Value;
static object s_true = true;
st... |
298,568 | <p>I'm trying to import a large SQL file; created by mysqldump on one server, then converted with iconv; using these commands:</p>
<pre><code>$ mysqldump -uxxx -p xxx > data.sql
$ iconv -f UTF-8 -t ISO-8859-1//TRANSLIT data.sql data.iconv.sql
</code></pre>
<p>I noticed that the "\x91" in the database had turned in... | [
{
"answer_id": 298583,
"author": "James Anderson",
"author_id": 38207,
"author_profile": "https://Stackoverflow.com/users/38207",
"pm_score": 0,
"selected": false,
"text": "<p>If your data is cp1252 why are you telling iconv its utf-8?</p>\n"
},
{
"answer_id": 302033,
"author... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21580/"
] | I'm trying to import a large SQL file; created by mysqldump on one server, then converted with iconv; using these commands:
```
$ mysqldump -uxxx -p xxx > data.sql
$ iconv -f UTF-8 -t ISO-8859-1//TRANSLIT data.sql data.iconv.sql
```
I noticed that the "\x91" in the database had turned into "\xc3\x82\xc2\x91" in the ... | On my system, mysqld defaults to saving data in latin1 with swedish collation. Similarly, the mysql command-line client defaults to providing data in latin1. mysqldump, on the other hand, defaults to utf-8.
This causes problems when exporting data via mysqldump and then importing using the mysql command-line client - ... |
298,577 | <p>I have run into a bit of a tricky problem in some C++ code, which is most easily described using code. I have classes that are something like:</p>
<pre><code>class MyVarBase
{
}
class MyVar : public MyVarBase
{
int Foo();
}
class MyBase
{
public:
MyBase(MyVarBase* v) : m_var(v) {}
virtual MyVarBase* ... | [
{
"answer_id": 298590,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 5,
"selected": true,
"text": "<p>The correct way to do this is to have the variable only in the base class. As the derived class knows it ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20925/"
] | I have run into a bit of a tricky problem in some C++ code, which is most easily described using code. I have classes that are something like:
```
class MyVarBase
{
}
class MyVar : public MyVarBase
{
int Foo();
}
class MyBase
{
public:
MyBase(MyVarBase* v) : m_var(v) {}
virtual MyVarBase* GetVar() { ret... | The correct way to do this is to have the variable only in the base class. As the derived class knows it must be of dynamic type `MyVar`, this is totally reasonable:
```
class MyClass : public MyBase
{
public:
MyClass(MyVar* v) : MyBase(v) {}
MyVar* GetVar() { return static_cast<MyVar*>(MyBase::GetVar()); }
}
... |
298,580 | <p>For those of you who are decent with subsonic!</p>
<pre><code> TblNewsCollection col =
new Select().From(Tables.TblNews)
.InnerJoin(Tables.TblContent)
.Paged(currentPage, pageSize)
.OrderDesc(TblContent.Columns.PubDate)
.ExecuteAsCol... | [
{
"answer_id": 298605,
"author": "asleep",
"author_id": 29445,
"author_profile": "https://Stackoverflow.com/users/29445",
"pm_score": 0,
"selected": false,
"text": "<pre><code>Northwind.CustomerCollection customersByCategory = new Select()\n .From(Northwind.Customer.Schema)\n .Inne... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29445/"
] | For those of you who are decent with subsonic!
```
TblNewsCollection col =
new Select().From(Tables.TblNews)
.InnerJoin(Tables.TblContent)
.Paged(currentPage, pageSize)
.OrderDesc(TblContent.Columns.PubDate)
.ExecuteAsCollection<TblNew... | I found that joins work better using the TableColumnSchema as in the above Northwind example as opposed to the column name. |
298,588 | <p>How can I figure out the CRC algorithm if a given code + CRC string is given? </p>
<p>I have got several strings consisting of code + matching CRCs but don't know how to calculate the CRC in question so that I could produce more code strings. Here are some samples (16bit code + 4bit CRC):</p>
<pre>
001010100001110... | [
{
"answer_id": 298596,
"author": "mana",
"author_id": 12016,
"author_profile": "https://Stackoverflow.com/users/12016",
"pm_score": 2,
"selected": false,
"text": "<p>Guessing is the very right word. If this RF device is not proprietary, try reading the <strong>specifications</strong>! Th... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I figure out the CRC algorithm if a given code + CRC string is given?
I have got several strings consisting of code + matching CRCs but don't know how to calculate the CRC in question so that I could produce more code strings. Here are some samples (16bit code + 4bit CRC):
```
0010101000011101 + 0000
001010... | What makes you think it is a CRC? Usually CRCs are not used for such small pieces of data.
To me this rather looks like some kind of parity, ECC (actually [FEC](http://en.wikipedia.org/wiki/Forward_error_correction)) or [Reed-Solomon](https://en.wikipedia.org/wiki/Reed%E2%80%93Solomon_error_correction) code. Might be ... |
298,593 | <p>When I call a static method like:</p>
<pre><code>Something.action();
</code></pre>
<p>Since a instance isn't created how long will the Class of the static method be held in memory?</p>
<p>If I call the same method will the Class be reloaded for each call since no instance exists?</p>
<p>And are only individual s... | [
{
"answer_id": 298599,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 5,
"selected": true,
"text": "<p>Unless you have configured garbage collection of permgenspace, the class stays in memory until the vm exits. The full... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4857/"
] | When I call a static method like:
```
Something.action();
```
Since a instance isn't created how long will the Class of the static method be held in memory?
If I call the same method will the Class be reloaded for each call since no instance exists?
And are only individual static methods loaded when called or are ... | Unless you have configured garbage collection of permgenspace, the class stays in memory until the vm exits. The full class is loaded with all static methods. |
298,644 | <p>I have a rails app that uses heavily js (over 1MB total). I'd like to compress them in order to reduce the overall load time of the site.</p>
<p>I did a fast search and found that most browsers accept compressed content.</p>
<p>I'd like to know what can I do to make my rails app send compressed content and thus ma... | [
{
"answer_id": 298672,
"author": "Michael",
"author_id": 35500,
"author_profile": "https://Stackoverflow.com/users/35500",
"pm_score": 3,
"selected": true,
"text": "<p>You should always have the web server proxying to your mongrels handle the serving of static content and it's compressio... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19224/"
] | I have a rails app that uses heavily js (over 1MB total). I'd like to compress them in order to reduce the overall load time of the site.
I did a fast search and found that most browsers accept compressed content.
I'd like to know what can I do to make my rails app send compressed content and thus make the user exper... | You should always have the web server proxying to your mongrels handle the serving of static content and it's compression. Requests for static content should never be passed to the mongrels.
e.g. with nginx it's simply a matter of adding gzip directives to your config file.
<http://topfunky.net/svn/shovel/nginx/conf/... |
298,660 | <p>Is it possible to generate a XML Schema of a Database programatically with .Net and C#? I want to look into NDbUnit but for big databases it would not really be feasible to make a Schema manually? </p>
| [
{
"answer_id": 298866,
"author": "George Stocker",
"author_id": 16587,
"author_profile": "https://Stackoverflow.com/users/16587",
"pm_score": 6,
"selected": true,
"text": "<blockquote>\n <p>Is it possible to generate a XML\n Schema from a Database?</p>\n</blockquote>\n\n<p>It sure is, ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35454/"
] | Is it possible to generate a XML Schema of a Database programatically with .Net and C#? I want to look into NDbUnit but for big databases it would not really be feasible to make a Schema manually? | >
> Is it possible to generate a XML
> Schema from a Database?
>
>
>
It sure is, [XMLSpy](http://www.altova.com/dev_portal_xml_schema.html) can generate XML Schema from a database.
There's [another way](http://dwightrau.blogspot.com/2008/02/generate-or-create-xsd-schema-from.html), though I've never tested it:
... |
298,677 | <p>can anyome help me find an elegant design for splitting, traversing and tracking objects.</p>
<p>The diagram below shows an object with an initial size of 100 which is spilt into two (50, 75) then one of the child objects (75) is subsequently split into three (25, 25 ,25).</p>
<p>My question is can anyone think of... | [
{
"answer_id": 298684,
"author": "thAAAnos",
"author_id": 36557,
"author_profile": "https://Stackoverflow.com/users/36557",
"pm_score": 0,
"selected": false,
"text": "<p>Why you have difficulty in locating the root? go from parent to parent until parent is not set.</p>\n\n<p>BTW Are you ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | can anyome help me find an elegant design for splitting, traversing and tracking objects.
The diagram below shows an object with an initial size of 100 which is spilt into two (50, 75) then one of the child objects (75) is subsequently split into three (25, 25 ,25).
My question is can anyone think of an elegant desig... | Homework?
```
set RootObject to the current object.
while the parent of RootObject is not undefined, set RootObject to its parent.
Finally, return RootObject.
``` |
298,689 | <p>The code below always return an empty array from <code>GetModifiedMembers(object)</code>
but <code>dx.GetChangeSet().Updates.Contains( foo )</code> returns true.</p>
<pre><code>DataContext dx = new DataContext( string.Empty );
MockLinqDataObject foo = new MockLinqDataObject();
dx.GetTable( foo.GetType() ).Attach( f... | [
{
"answer_id": 298684,
"author": "thAAAnos",
"author_id": 36557,
"author_profile": "https://Stackoverflow.com/users/36557",
"pm_score": 0,
"selected": false,
"text": "<p>Why you have difficulty in locating the root? go from parent to parent until parent is not set.</p>\n\n<p>BTW Are you ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20382/"
] | The code below always return an empty array from `GetModifiedMembers(object)`
but `dx.GetChangeSet().Updates.Contains( foo )` returns true.
```
DataContext dx = new DataContext( string.Empty );
MockLinqDataObject foo = new MockLinqDataObject();
dx.GetTable( foo.GetType() ).Attach( foo );
foo.PK = Guid.NewGuid();
// ... | Homework?
```
set RootObject to the current object.
while the parent of RootObject is not undefined, set RootObject to its parent.
Finally, return RootObject.
``` |
298,692 | <p>For the project I'm working on I noticed that file transfer* speed is really bad if I'm using IIS FTP and HTTP services. I know that the last thing I should think is "it's a Windows bug", but the fact that simply by using IIS on Windows Server or by changing IIS on that Windows XP machine to FileZilla and LightHTTPd... | [
{
"answer_id": 298695,
"author": "Simon Johnson",
"author_id": 854,
"author_profile": "https://Stackoverflow.com/users/854",
"pm_score": 1,
"selected": false,
"text": "<p>There is a limit of ten concurrent connections. This can be increased to 30 using the IIS metabase editing tool.</p>\... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21952/"
] | For the project I'm working on I noticed that file transfer\* speed is really bad if I'm using IIS FTP and HTTP services. I know that the last thing I should think is "it's a Windows bug", but the fact that simply by using IIS on Windows Server or by changing IIS on that Windows XP machine to FileZilla and LightHTTPd, ... | As other people have said, by default there is a 10 simultaneous connection limit for IIS 5 in Win XP. This can be increased to a maximum of 40 via the metabase variable setting script.
```
cd \inetpub\adminscripts
cscript adsutil.vbs set w3svc/MaxConnections 40
iisreset
```
The first command changes ... |
298,702 | <p>How to create a windows toolbar-dockable application - like <a href="http://www.winamp.com/plugins/details/82271" rel="nofollow noreferrer">Winamp Desk Band</a> - in .NET?</p>
| [
{
"answer_id": 298695,
"author": "Simon Johnson",
"author_id": 854,
"author_profile": "https://Stackoverflow.com/users/854",
"pm_score": 1,
"selected": false,
"text": "<p>There is a limit of ten concurrent connections. This can be increased to 30 using the IIS metabase editing tool.</p>\... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3182/"
] | How to create a windows toolbar-dockable application - like [Winamp Desk Band](http://www.winamp.com/plugins/details/82271) - in .NET? | As other people have said, by default there is a 10 simultaneous connection limit for IIS 5 in Win XP. This can be increased to a maximum of 40 via the metabase variable setting script.
```
cd \inetpub\adminscripts
cscript adsutil.vbs set w3svc/MaxConnections 40
iisreset
```
The first command changes ... |
298,721 | <p>P1 and P2 are processes or nodes in a cluster. f1 and f2 are their flags. Supposing strong memory model, and that both processes may be restarted at any moment, and that restarting a process clears it's flag, here's an algorithm that I came up with and couldn't yet break, but that bothers me for it's not theoretica... | [
{
"answer_id": 298752,
"author": "Michael Madsen",
"author_id": 27528,
"author_profile": "https://Stackoverflow.com/users/27528",
"pm_score": 3,
"selected": false,
"text": "<p>If the \"if X set then clear Y\" operation is not atomic, there's a potential race condition that could prevent ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23420/"
] | P1 and P2 are processes or nodes in a cluster. f1 and f2 are their flags. Supposing strong memory model, and that both processes may be restarted at any moment, and that restarting a process clears it's flag, here's an algorithm that I came up with and couldn't yet break, but that bothers me for it's not theoretically ... | If the "if X set then clear Y" operation is not atomic, there's a potential race condition that could prevent either from getting inside the critical section. I've tried to outline the flow below:
```
P1: set f1
P2: set f2
P1: is f2 set?
P2: is f1 set?
P1: yes, clear f1
P2: yes, clear f2
P1: start wait
P2: start wait
... |
298,725 | <p>I have two tables, <code>movies</code> and <code>categories</code>, and I want to get an ordered list by <strong>categoryID</strong> first and then by <strong>Name</strong>.</p>
<p>The movie table has three columns <strong>ID, Name and CategoryID</strong>.
The category table has two columns <strong>ID and Name</stro... | [
{
"answer_id": 298741,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 13,
"selected": true,
"text": "<p>This should work for you:</p>\n\n<pre><code>var movies = _db.Movies.OrderBy(c => c.Category).ThenBy(n => n.Name)\n... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2246271/"
] | I have two tables, `movies` and `categories`, and I want to get an ordered list by **categoryID** first and then by **Name**.
The movie table has three columns **ID, Name and CategoryID**.
The category table has two columns **ID and Name**.
I tried something like the following, but it didn't work.
```
var movies = _... | This should work for you:
```
var movies = _db.Movies.OrderBy(c => c.Category).ThenBy(n => n.Name)
``` |
298,733 | <p>I seemed to get the following exception when trying to deploy my application:</p>
<pre><code>Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
java.util.List is an interface, and JAXB can't handle interfaces.
this problem is related to the following loca... | [
{
"answer_id": 298914,
"author": "Henning",
"author_id": 7034,
"author_profile": "https://Stackoverflow.com/users/7034",
"pm_score": 6,
"selected": true,
"text": "<p>In my understanding, you will not be able to process a plain <code>List</code> via JAXB, as JAXB has no idea how to transf... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37298/"
] | I seemed to get the following exception when trying to deploy my application:
```
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
java.util.List is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at j... | In my understanding, you will not be able to process a plain `List` via JAXB, as JAXB has no idea how to transform that into XML.
Instead, you will need to define a JAXB type which holds a `List<RelationCanonical>` (I'll call it `Type1`), and another one to hold a list of those types, in turn (as you're dealing with ... |
298,745 | <p>How do I send a cross-domain POST request via JavaScript?</p>
<p>Notes - it shouldn't refresh the page, and I need to grab and parse the response afterwards.</p>
| [
{
"answer_id": 298763,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 6,
"selected": false,
"text": "<ol>\n<li>Create an iFrame, </li>\n<li>put a form in it with Hidden inputs, </li>\n<li>set the form's action to the URL, ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33046/"
] | How do I send a cross-domain POST request via JavaScript?
Notes - it shouldn't refresh the page, and I need to grab and parse the response afterwards. | **Update:** Before continuing everyone should read and understand the [html5rocks tutorial](http://www.html5rocks.com/en/tutorials/cors/) on CORS. It is easy to understand and very clear.
If you control the server being POSTed, simply leverage the "Cross-Origin Resource Sharing standard" by setting response headers on... |
298,750 | <p>I would like to get all descendant text nodes of an element, as a jQuery collection. What is the best way to do that?</p>
| [
{
"answer_id": 298758,
"author": "Christian Oudard",
"author_id": 3757,
"author_profile": "https://Stackoverflow.com/users/3757",
"pm_score": 8,
"selected": false,
"text": "<p>Jauco posted a good solution in a comment, so I'm copying it here:</p>\n\n<pre><code>$(elem)\n .contents()\n .... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3757/"
] | I would like to get all descendant text nodes of an element, as a jQuery collection. What is the best way to do that? | jQuery doesn't have a convenient function for this. You need to combine `contents()`, which will give just child nodes but includes text nodes, with `find()`, which gives all descendant elements but no text nodes. Here's what I've come up with:
```
var getTextNodesIn = function(el) {
return $(el).find(":not(iframe... |
298,760 | <p>I'm trying to ensure a script remains running on a development server. It collates stats and provides a web service so it's supposed to persist, yet a few times a day, it dies off for unknown reasons. When we notice we just launch it again, but it's a pain in the rear and some users don't have permission (or the kno... | [
{
"answer_id": 298769,
"author": "Gareth",
"author_id": 31582,
"author_profile": "https://Stackoverflow.com/users/31582",
"pm_score": 6,
"selected": false,
"text": "<p><a href=\"http://mmonit.com/monit/\" rel=\"noreferrer\">Monit</a> is perfect for this :)</p>\n\n<p>You can write simple ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12870/"
] | I'm trying to ensure a script remains running on a development server. It collates stats and provides a web service so it's supposed to persist, yet a few times a day, it dies off for unknown reasons. When we notice we just launch it again, but it's a pain in the rear and some users don't have permission (or the knowho... | Notice: Upstart is in maintenance mode and was [abandoned](https://www.linuxjournal.com/content/ubuntu-ditches-upstart) by Ubuntu which uses systemd. One should check the systemd' [manual](https://www.freedesktop.org/software/systemd/man/systemd.service.html) for details how to write service definition.
Since you're u... |
298,772 | <p>When I render a page using the Django template renderer, I can pass in a dictionary variable containing various values to manipulate them in the page using <code>{{ myVar }}</code>.</p>
<p>Is there a way to access the same variable in Javascript (perhaps using the DOM, I don't know how Django makes the variables ac... | [
{
"answer_id": 298793,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 10,
"selected": true,
"text": "<p>The <code>{{variable}}</code> is substituted directly into the HTML. Do a view source; it isn't a \"variable\" or anythi... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38581/"
] | When I render a page using the Django template renderer, I can pass in a dictionary variable containing various values to manipulate them in the page using `{{ myVar }}`.
Is there a way to access the same variable in Javascript (perhaps using the DOM, I don't know how Django makes the variables accessible)? I want to ... | The `{{variable}}` is substituted directly into the HTML. Do a view source; it isn't a "variable" or anything like it. It's just rendered text.
Having said that, you can put this kind of substitution into your JavaScript.
```html
<script type="text/javascript">
var a = "{{someDjangoVariable}}";
</script>
```
Th... |
298,779 | <p>I'm working on my first Django application. In short, what it needs to do is to display a list of film titles, and allow users to give a rating (out of 10) to each film. I've been able to use the {{ form }} and {{ formset }} syntax in a template to produce a form which lets you rate one film at a time, which corresp... | [
{
"answer_id": 298835,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 3,
"selected": true,
"text": "<p>\"At first, I thought this was what formsets were for, but I can't see any way to automatically iterate over the contents... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11522/"
] | I'm working on my first Django application. In short, what it needs to do is to display a list of film titles, and allow users to give a rating (out of 10) to each film. I've been able to use the {{ form }} and {{ formset }} syntax in a template to produce a form which lets you rate one film at a time, which correspond... | "At first, I thought this was what formsets were for, but I can't see any way to automatically iterate over the contents of a database table to produce items to go in the form, if you see what I mean."
You need to get a queryset. And you need to provide that queryset to your form as initial data. See [using initial da... |
298,782 | <p>I have the following Python code: </p>
<pre><code>import xml.dom.minidom
import xml.parsers.expat
try:
domTree = ml.dom.minidom.parse(myXMLFileName)
except xml.parsers.expat.ExpatError, e:
return e.args[0]
</code></pre>
<p>which I am using to parse an XML file. Although it quite happily spots simple XML ... | [
{
"answer_id": 298827,
"author": "acrosman",
"author_id": 24215,
"author_profile": "https://Stackoverflow.com/users/24215",
"pm_score": 0,
"selected": false,
"text": "<p>I believe you need to switch from expat to xmlproc.<br>\nSee:\n<a href=\"http://code.activestate.com/recipes/220472/\"... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11677/"
] | I have the following Python code:
```
import xml.dom.minidom
import xml.parsers.expat
try:
domTree = ml.dom.minidom.parse(myXMLFileName)
except xml.parsers.expat.ExpatError, e:
return e.args[0]
```
which I am using to parse an XML file. Although it quite happily spots simple XML errors like mismatched tags... | See [this question](https://stackoverflow.com/questions/15798/how-do-i-validate-xml-against-a-dtd-file-in-python) - the accepted answer is to use [lxml validation](http://codespeak.net/lxml/validation.html). |
298,786 | <p>I have a header </p>
<pre><code><h1>My Header</h1>
</code></pre>
<p>It has a height of <code>150px</code> and a <code>font-size</code> of say <code>1.3em;</code>
How can I make the header text vertically centered with CSS.
I would rather not wrap it in a container DIV (wrapping divs really defeat the w... | [
{
"answer_id": 298827,
"author": "acrosman",
"author_id": 24215,
"author_profile": "https://Stackoverflow.com/users/24215",
"pm_score": 0,
"selected": false,
"text": "<p>I believe you need to switch from expat to xmlproc.<br>\nSee:\n<a href=\"http://code.activestate.com/recipes/220472/\"... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | I have a header
```
<h1>My Header</h1>
```
It has a height of `150px` and a `font-size` of say `1.3em;`
How can I make the header text vertically centered with CSS.
I would rather not wrap it in a container DIV (wrapping divs really defeat the whole CSS idea). | See [this question](https://stackoverflow.com/questions/15798/how-do-i-validate-xml-against-a-dtd-file-in-python) - the accepted answer is to use [lxml validation](http://codespeak.net/lxml/validation.html). |
298,812 | <p>I have two Tables.</p>
<p>Order - With Columns OrderID, OrderStatusID<br />
OrderStatus - With Columns OrderStatusID, Description</p>
<p>I have an Order Object which calls to the database and fills its properties for use in my code. Right now I have access to Order.OrderStatusID, but in my application I really ne... | [
{
"answer_id": 298845,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 0,
"selected": false,
"text": "<p>You can use a SQL select statement with a Join to the OrderStatus table, and include the columns yo want from e... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37347/"
] | I have two Tables.
Order - With Columns OrderID, OrderStatusID
OrderStatus - With Columns OrderStatusID, Description
I have an Order Object which calls to the database and fills its properties for use in my code. Right now I have access to Order.OrderStatusID, but in my application I really need access to the "Des... | Usually I prefer to handle lookups as [Value objects](http://martinfowler.com/bliki/ValueObject.html). I also use [Null Object pattern](http://en.wikipedia.org/wiki/Null_Object_pattern).
```
public class Order {
private int statusID;
public OrderStatus Status {
get {
return OrderStatus.Resolve(statusID)... |
298,829 | <p>I have a client that's been struggling with slow loading pdf files on the web.
My client has some very large pdf files that are almost 10 Mb. They take upwards of 3-4 minutes to download. The files will not display until the whole file is loaded.
We and they have seen other's sites where the pdfs load one page at ... | [
{
"answer_id": 299591,
"author": "Toni Ruža",
"author_id": 6267,
"author_profile": "https://Stackoverflow.com/users/6267",
"pm_score": 0,
"selected": false,
"text": "<p>You could try <a href=\"http://www.develer.com/oss/GccWinBinaries\" rel=\"nofollow noreferrer\">this</a> unofficial Min... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1433/"
] | I have a client that's been struggling with slow loading pdf files on the web.
My client has some very large pdf files that are almost 10 Mb. They take upwards of 3-4 minutes to download. The files will not display until the whole file is loaded.
We and they have seen other's sites where the pdfs load one page at a t... | That's just another stupidness of distutils. I personally remove this annoying check in my distutils installation on every windows machine I have to use.
Installing another mingw version would work as long as it passes the version check - but really, the whole idea of checking version of the tools does not make much s... |
298,830 | <p>I have a single string that contains the command-line parameters to be passed to another executable and I need to extract the string[] containing the individual parameters in the same way that C# would if the commands had been specified on the command-line. The string[] will be used when executing another assemblies... | [
{
"answer_id": 298838,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": -1,
"selected": false,
"text": "<p>Yes, the string object has a built in function called <code>Split()</code> that takes a single parameter spec... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/341413/"
] | I have a single string that contains the command-line parameters to be passed to another executable and I need to extract the string[] containing the individual parameters in the same way that C# would if the commands had been specified on the command-line. The string[] will be used when executing another assemblies en... | In addition to the [good and pure managed solution](https://stackoverflow.com/questions/298830/split-string-containing-command-line-parameters-into-string-in-c/298990#298990) by [Earwicker](https://stackoverflow.com/users/27423/earwicker), it may be worth mentioning, for sake of completeness, that Windows also provides... |
298,840 | <p>I have a .NET Web app which consumes a Java-based Web service. One of the objects, named Optional, contains search criteria fields. The schema is the following:</p>
<pre><code><xsd:complexType name="Optional">
<xsd:sequence>
<xsd:element name="FromAmount" nillable="true" type="xsd:float" minOccurs... | [
{
"answer_id": 300992,
"author": "Dimitre Novatchev",
"author_id": 36305,
"author_profile": "https://Stackoverflow.com/users/36305",
"pm_score": 0,
"selected": false,
"text": "<p>This schema does not define any xml document type. It just provides a declaration for a compex type named \"O... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15883/"
] | I have a .NET Web app which consumes a Java-based Web service. One of the objects, named Optional, contains search criteria fields. The schema is the following:
```
<xsd:complexType name="Optional">
<xsd:sequence>
<xsd:element name="FromAmount" nillable="true" type="xsd:float" minOccurs="0" />
<xsd:element name=... | in .NET WS for non-nullable types (in .NET) that are marked optional in the schema have an additional specified property generated for them that control if the element appears. Very annoyingly, the setter for the value does not set the additional specified flag, so you need do this.
```
x.ToAmmount = 24.0f;
x.ToAmmoun... |
298,841 | <p>Is there a way to read the properties inside an <a href="https://en.wikipedia.org/wiki/Windows_Installer" rel="nofollow noreferrer">MSI</a> file?</p>
<p>For example, given a MSI file named <em>Testpackage.msi</em>, I need to find</p>
<pre><code>productName
PackageCode
version
</code></pre>
<p>This I am going to use ... | [
{
"answer_id": 298862,
"author": "csexton",
"author_id": 19839,
"author_profile": "https://Stackoverflow.com/users/19839",
"pm_score": 3,
"selected": false,
"text": "<p>You can use <a href=\"http://msdn.microsoft.com/en-us/library/aa370557.aspx\" rel=\"noreferrer\">Microsoft's Orca.exe</... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32670/"
] | Is there a way to read the properties inside an [MSI](https://en.wikipedia.org/wiki/Windows_Installer) file?
For example, given a MSI file named *Testpackage.msi*, I need to find
```
productName
PackageCode
version
```
This I am going to use it with WMI uninstall
```
string objPath = string.Format("Win32_Product.I... | You can use the [COM-based API for working with MSI](http://msdn.microsoft.com/en-us/library/aa367810(VS.85).aspx), and do something like
```vb
Function GetVersion(ByVal msiName)
Const msiOpenDatabaseModeReadOnly = 0
Dim msi, db, view
Set msi = CreateObject("WindowsInstaller.Installer")
Set db = msi.... |
298,867 | <p>How do I export all of the names and email addresses from a distribution list in Outlook using code? I have access to an Outlook 2000 or Outlook 2007 client. Ideally I would like the code to be in C#.</p>
| [
{
"answer_id": 298885,
"author": "Mladen Prajdic",
"author_id": 31345,
"author_profile": "https://Stackoverflow.com/users/31345",
"pm_score": -1,
"selected": false,
"text": "<p>use outlook component model\n<a href=\"http://www.dotnetjunkies.ddj.com/Tutorial/2E1EEEAF-C78A-4A38-A830-AC204B... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636/"
] | How do I export all of the names and email addresses from a distribution list in Outlook using code? I have access to an Outlook 2000 or Outlook 2007 client. Ideally I would like the code to be in C#. | I realize you asked about c#, but the following script from <http://www.microsoft.com/technet/scriptcenter/resources/officetips/may05/tips0524.mspx> may be of some use.
```
Const olFolderContacts = 10
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set colConta... |
298,873 | <p>I'm wondering what good ways there would be make assertions about synchronization or something so that I could detect synchronization violations (while testing).</p>
<p>That would be used for example for the case that I'd have a class that is not thread-safe and that isn't going to be thread-safe. With some way I w... | [
{
"answer_id": 298892,
"author": "John M",
"author_id": 20734,
"author_profile": "https://Stackoverflow.com/users/20734",
"pm_score": 0,
"selected": false,
"text": "<p>For the specific example you give, SwingLabs has some helper code to detect event thread violations and hangs. <a href=... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28482/"
] | I'm wondering what good ways there would be make assertions about synchronization or something so that I could detect synchronization violations (while testing).
That would be used for example for the case that I'd have a class that is not thread-safe and that isn't going to be thread-safe. With some way I would have ... | You are looking for the holy grail, I think. AFAIK it doesn't exist, and Java is not a language that allows such an approach to be easily created.
"Java Concurrency in Practice" has a section on testing for threading problems. It draws special attention to how hard it is to do. |
298,886 | <p>Does .NET have a way to pull email from a POP3 server out of the box or you have to code/buy a 3rd party component?</p>
| [
{
"answer_id": 298894,
"author": "Robert Wilkinson",
"author_id": 2184,
"author_profile": "https://Stackoverflow.com/users/2184",
"pm_score": 0,
"selected": false,
"text": "<p>Check out the EasyMail objects from <a href=\"http://www.quiksoft.com\" rel=\"nofollow noreferrer\">Quiksoft</a>... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Does .NET have a way to pull email from a POP3 server out of the box or you have to code/buy a 3rd party component? | You can check [Mail.dll .NET mail component](http://www.limilabs.com/mail), it has SSL support, unicode, and multi-national email support:
```
using(Pop3 pop3 = new Pop3())
{
pop3.Connect("mail.host.com"); // Connect to server
pop3.Login("user", "password");
foreach(string uid in pop3.GetAll())
{... |
298,909 | <p>I'm wondering why the <code>assert</code> keyword is so underused in Java? I've almost never seen them used, but I think they're a great idea. I certainly much prefer the brevity of:</p>
<pre><code>assert param != null : "Param cannot be null";
</code></pre>
<p>to the verbosity of:</p>
<pre><code>if (param == nul... | [
{
"answer_id": 298929,
"author": "Denis R.",
"author_id": 32015,
"author_profile": "https://Stackoverflow.com/users/32015",
"pm_score": 0,
"selected": false,
"text": "<p>In fact they arrived in Java 1.4.</p>\n\n<p>I think the main problem is that when you code in an environment where you... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I'm wondering why the `assert` keyword is so underused in Java? I've almost never seen them used, but I think they're a great idea. I certainly much prefer the brevity of:
```
assert param != null : "Param cannot be null";
```
to the verbosity of:
```
if (param == null) {
throw new IllegalArgumentException("Par... | *assertions* are, in theory, for testing [invariants](http://en.wikipedia.org/wiki/Invariant_(computer_science)), assumptions that **must** be true in order for the code to complete properly.
The example shown is testing for valid input, which isn't a typical usage for an assertion because it is, generally, user supp... |
298,926 | <p>In vb.net / winforms, how can a hashtable be bound to a drop down list or any other datasource-driven control?</p>
| [
{
"answer_id": 298935,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 2,
"selected": false,
"text": "<p>Just use the dropdown lists's Datasource property</p>\n\n<pre><code> DropDownList dd = new DropDownList();\n ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3259/"
] | In vb.net / winforms, how can a hashtable be bound to a drop down list or any other datasource-driven control? | Is this winforms, wpf, or asp.net? [update: ahh... winforms ;-p]
winforms wants data to be `IList` (or, indirectly, via `IListSource`) - so I'm guessing (from the comment) that you are using winforms. None of the inbuilt dictionary-like collections implement `IList`, but to be honest it doesn't matter: if you are data... |
298,962 | <p>Clearly separation of concerns is a desirable trait in our code and the first obvious step most people take is to separate data access from presentation. In my situation, LINQ To SQL is being used within data access objects for the data access.</p>
<p>My question is, where should the use of the entity object stop? ... | [
{
"answer_id": 299008,
"author": "Codewerks",
"author_id": 17729,
"author_profile": "https://Stackoverflow.com/users/17729",
"pm_score": 3,
"selected": false,
"text": "<p>I return IQueryable of POCOs from my DAL (which uses LINQ2SQL), so no Linq entity object ever leaves the DAL. These P... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Clearly separation of concerns is a desirable trait in our code and the first obvious step most people take is to separate data access from presentation. In my situation, LINQ To SQL is being used within data access objects for the data access.
My question is, where should the use of the entity object stop? To clarify... | I return IQueryable of POCOs from my DAL (which uses LINQ2SQL), so no Linq entity object ever leaves the DAL. These POCOs are returned to the service and UI layers, and are also used to pass data back into the DAL for processing. Linq handles this very well:
```
IQueryable<MyObjects.Product> products = from p in linq... |
298,972 | <p>I am using a query like this on my postgres database:</p>
<pre><code>SELECT TableA.id FROM TableA , TableB WHERE TableA.id = 100;
</code></pre>
<p>Each TableA.id is unique (it's an autoincrement), I am getting more than 1 result. Am I missing something in here?</p>
| [
{
"answer_id": 298980,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>You're doing a cross-join - effectively every row in TableB against the single row in TableA. If you select something... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2220518/"
] | I am using a query like this on my postgres database:
```
SELECT TableA.id FROM TableA , TableB WHERE TableA.id = 100;
```
Each TableA.id is unique (it's an autoincrement), I am getting more than 1 result. Am I missing something in here? | You're doing a cross-join - effectively every row in TableB against the single row in TableA. If you select something from TableB as well, this will be more obvious :) The fact that you don't currently select anything from TableB doesn't stop the (TableA, TableB) pairs from being the result of the join, before the proj... |
298,976 | <p>Seeing as C# can't <code>switch</code> on a Type (which I gather wasn't added as a special case because <code>is</code> relationships mean that more than one distinct <code>case</code> might apply), is there a better way to simulate switching on type other than this?</p>
<pre><code>void Foo(object o)
{
if (o is... | [
{
"answer_id": 298994,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": false,
"text": "<p>One option is to have a dictionary from <code>Type</code> to <code>Action</code> (or some other delegate). Look up th... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/82/"
] | Seeing as C# can't `switch` on a Type (which I gather wasn't added as a special case because `is` relationships mean that more than one distinct `case` might apply), is there a better way to simulate switching on type other than this?
```
void Foo(object o)
{
if (o is A)
{
((A)o).Hop();
}
else ... | Switching on types is definitely lacking in C# (**UPDATE: in C#7 / VS 2017 switching on types is supported - [see Zachary Yates's answer](https://stackoverflow.com/questions/298976/is-there-a-better-alternative-than-this-to-switch-on-type/299001#299001)**). In order to do this without a large if/else if/else statement,... |
298,981 | <p>I'm trying to have an XSLT that copies most of the tags but removes empty "<code><b/></code>" tags. That is, it should copy as-is "<code><b> </b></code>" or "<code><b>toto</b></code>" but completely remove "<code><b/></code>".</p>
<p>I think the template would look like :</p>
<p... | [
{
"answer_id": 298997,
"author": "Darren Steinweg",
"author_id": 418,
"author_profile": "https://Stackoverflow.com/users/418",
"pm_score": 3,
"selected": true,
"text": "<p>I wonder if this will work?</p>\n\n<pre><code><xsl:template match=\"b\">\n <xsl:if test=\"b/text()\">\n... | 2008/11/18 | [
"https://Stackoverflow.com/questions/298981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23704/"
] | I'm trying to have an XSLT that copies most of the tags but removes empty "`<b/>`" tags. That is, it should copy as-is "`<b> </b>`" or "`<b>toto</b>`" but completely remove "`<b/>`".
I think the template would look like :
```
<xsl:template match="b">
<xsl:if test=".hasChildren()">
<xsl:element name="b">
<... | I wonder if this will work?
```
<xsl:template match="b">
<xsl:if test="b/text()">
...
``` |
299,045 | <p>We use PVCS for source control for all our code. We have 7 Servers across the EU covering 17 countries. PVCS mimics our folder structure in production:</p>
<pre><code>folderA
|
|--folderB
| |
| | -- folderC
| |
| | -- folder
| --folderD
| |
| | -- folderE
| |
| | -- folderF
</code>... | [
{
"answer_id": 299063,
"author": "NotMe",
"author_id": 2424,
"author_profile": "https://Stackoverflow.com/users/2424",
"pm_score": 2,
"selected": false,
"text": "<p>Check out <a href=\"http://nant.sourceforge.net/\" rel=\"nofollow noreferrer\">nAnt</a> and <a href=\"http://cruisecontrol.... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6486/"
] | We use PVCS for source control for all our code. We have 7 Servers across the EU covering 17 countries. PVCS mimics our folder structure in production:
```
folderA
|
|--folderB
| |
| | -- folderC
| |
| | -- folder
| --folderD
| |
| | -- folderE
| |
| | -- folderF
```
Our projects can ... | Check out [nAnt](http://nant.sourceforge.net/) and [Cruise Control](http://cruisecontrol.sourceforge.net/index.html)
**edit:**
With Cruise Control you can always write your own plug ins to better handle your environment. |
299,068 | <p>Question: Is exception handling in Java actually slow?</p>
<p>Conventional wisdom, as well as a lot of Google results, says that exceptional logic shouldn't be used for normal program flow in Java. Two reasons are usually given,</p>
<ol>
<li>it is really slow - even an order of magnitude slower than regular code... | [
{
"answer_id": 299082,
"author": "user38051",
"author_id": 38051,
"author_profile": "https://Stackoverflow.com/users/38051",
"pm_score": 2,
"selected": false,
"text": "<p>Even if throwing an exception isn't slow, it's still a bad idea to throw exceptions for normal program flow. Used thi... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/69572/"
] | Question: Is exception handling in Java actually slow?
Conventional wisdom, as well as a lot of Google results, says that exceptional logic shouldn't be used for normal program flow in Java. Two reasons are usually given,
1. it is really slow - even an order of magnitude slower than regular code (the reasons given va... | It depends how exceptions are implemented. The simplest way is using setjmp and longjmp. That means all registers of the CPU are written to the stack (which already takes some time) and possibly some other data needs to be created... all this already happens in the try statement. The throw statement needs to unwind the... |
299,079 | <p>While looking at a micro-optimization question that I asked yesterday (<a href="https://stackoverflow.com/questions/295579/fastest-way-to-determine-if-an-integers-square-root-is-an-integer">here</a>), I found something strange: an <code>or</code> statement in Java is running <em>slightly</em> faster than looking up... | [
{
"answer_id": 299105,
"author": "asalamon74",
"author_id": 21348,
"author_profile": "https://Stackoverflow.com/users/21348",
"pm_score": 1,
"selected": false,
"text": "<p>According to <a href=\"http://www.javaworld.com/javaworld/jw-09-1998/jw-09-speed.html?page=6\" rel=\"nofollow norefe... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18511/"
] | While looking at a micro-optimization question that I asked yesterday ([here](https://stackoverflow.com/questions/295579/fastest-way-to-determine-if-an-integers-square-root-is-an-integer)), I found something strange: an `or` statement in Java is running *slightly* faster than looking up a boolean value in an array of b... | Loading some random piece of data is generally slower than a little non-branching code.
It all depends upon processor architecture, of course. Your first if statement could be implemented as four instructions. The second may potentially need null pointer checking, bounds checking as well as the load and compare. Also ... |
299,086 | <p>I'm working with a WinForm app in C#, after I type something in a textbox I want to hit the Enter key but the textbox still has focus (flashing cursor is still in textbox), how can I achieve this?</p>
| [
{
"answer_id": 299093,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": false,
"text": "<p>The simple option is just to set the forms's AcceptButton to the button you want pressed (usually \"OK\" etc):</p>... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm working with a WinForm app in C#, after I type something in a textbox I want to hit the Enter key but the textbox still has focus (flashing cursor is still in textbox), how can I achieve this? | The simple option is just to set the forms's AcceptButton to the button you want pressed (usually "OK" etc):
```
TextBox tb = new TextBox();
Button btn = new Button { Dock = DockStyle.Bottom };
btn.Click += delegate { Debug.WriteLine("Submit: " + tb.Text); };
Application.Run(new Form { AcceptButton = b... |
299,094 | <p>i want the result of an equation rounded to the nearest integer.
e.g. </p>
<pre><code>137 * (3/4) = 103
</code></pre>
<p>Consider the following incorrect code. </p>
<pre><code>int width1 = 4;
int height1 = 3;
int width2 = 137;
int height2 = width2 * (height1 / width1);
</code></pre>
<p>What is the proper way to... | [
{
"answer_id": 299102,
"author": "Jeffrey L Whitledge",
"author_id": 10174,
"author_profile": "https://Stackoverflow.com/users/10174",
"pm_score": 2,
"selected": false,
"text": "<pre><code>int height2 = (width2 * height1) / width1;\n</code></pre>\n"
},
{
"answer_id": 299119,
... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12597/"
] | i want the result of an equation rounded to the nearest integer.
e.g.
```
137 * (3/4) = 103
```
Consider the following incorrect code.
```
int width1 = 4;
int height1 = 3;
int width2 = 137;
int height2 = width2 * (height1 / width1);
```
What is the proper way to perform "integer" math in C#?
Do i really have ... | As said above, you should do the multiplication before the division.
Anyway you could write your expression with casting only the divisor:
```
int height2 = (int)Math.Round(width2 * (height1 / (float)width1));
``` |
299,106 | <p>I have a following xslt code :</p>
<pre><code><xsl:template match="table_terms_and_abbr">
<informaltable frame='none' colsep='none' rowsep='none'>
<tgroup cols='2' align='left'>
<colspec colnum="1" colwidth='1*'/>
<colspec colnum="2" colwidth='1*'/>
... | [
{
"answer_id": 299145,
"author": "ddaa",
"author_id": 11549,
"author_profile": "https://Stackoverflow.com/users/11549",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>I know how to pass the attributes to the template i.e:</p>\n\n<pre><code><xsl:with-param name=\"is_make... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6807/"
] | I have a following xslt code :
```
<xsl:template match="table_terms_and_abbr">
<informaltable frame='none' colsep='none' rowsep='none'>
<tgroup cols='2' align='left'>
<colspec colnum="1" colwidth='1*'/>
<colspec colnum="2" colwidth='1*'/>
<xsl:apply-templates/>
<... | >
> I know how to pass the attributes to the template i.e:
>
>
>
> ```
> <xsl:with-param name="is_make_first_bold" select = "1" as="xs:integer"/>
>
> ```
>
> but how to pass free text ?
>
>
>
Pass the text as the content of an `xsl:with-param` element.
[XSL Transformations 11.6 Passing Parameters to Templat... |
299,114 | <p>The vim * star / asterisk search (:help star) is a great feature which lets you find the next occurrence of the word the cursor is over. Unfortunately it treats dollar-prefixes as part of the string, so if I press * while over the "SearchTerm" in the class name it finds "SearchTerm" in the comment, and "$this->Searc... | [
{
"answer_id": 299154,
"author": "localshred",
"author_id": 29690,
"author_profile": "https://Stackoverflow.com/users/29690",
"pm_score": -1,
"selected": false,
"text": "<p>You should be able to escape the $ by placing a backslash before it: \\$</p>\n"
},
{
"answer_id": 299201,
... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20074/"
] | The vim \* star / asterisk search (:help star) is a great feature which lets you find the next occurrence of the word the cursor is over. Unfortunately it treats dollar-prefixes as part of the string, so if I press \* while over the "SearchTerm" in the class name it finds "SearchTerm" in the comment, and "$this->Search... | Actually using vim 7.2 on Mac, star search exactly works as you would like it to do.
EDIT: Check what your 'iskeyword' (:set iskeyword) is set to because star search is based on this option to find the word search term.
Alternatively, you could could use 'g\*' (:help gstar) to get a partial search for the word the cu... |
299,117 | <p>Everything I can find in linq for aggregation has a "group by" clause. How would I write this query in LINQ? I have a list of date-value pairs, and I want to take the average of the values:</p>
<pre><code>SELECT AVG(MySuff.Value) AS AvgValue FROM MyStuff
</code></pre>
| [
{
"answer_id": 299123,
"author": "Alan",
"author_id": 37843,
"author_profile": "https://Stackoverflow.com/users/37843",
"pm_score": 2,
"selected": false,
"text": "<p>morning Alan:</p>\n\n<pre><code>int count = (from a in myContext.MyStuff\n select a).Count();\n</code></pre>\n\... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7311/"
] | Everything I can find in linq for aggregation has a "group by" clause. How would I write this query in LINQ? I have a list of date-value pairs, and I want to take the average of the values:
```
SELECT AVG(MySuff.Value) AS AvgValue FROM MyStuff
``` | The answer to modified example (I believe) is:
```
var average = (from a in MyStuff
select a.Value).Average();
``` |
299,129 | <p>im trying to kick off a Runnable classes run method however i keep getting a NullPointerException, Im using WebSpheres commonj.workmanager to get an instance of executorService.this is the code im using.</p>
<pre><code>executorService.execute(new Runnable() {
public void run() {
System.out.println("Ins... | [
{
"answer_id": 299177,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "<p>Are you checking whether <code>executorService</code> is null before calling <code>execute()</code>? If not, it sounds... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24481/"
] | im trying to kick off a Runnable classes run method however i keep getting a NullPointerException, Im using WebSpheres commonj.workmanager to get an instance of executorService.this is the code im using.
```
executorService.execute(new Runnable() {
public void run() {
System.out.println("Inside run ()metho... | Are you checking whether `executorService` is null before calling `execute()`? If not, it sounds like you need to check the WebSphere docs. |
299,148 | <p>I'm playing with <a href="http://www.dncompute.com/blog/2007/03/19/seed-based-pseudorandom-number-generator-in-actionscript.html" rel="nofollow noreferrer">this ActionScript</a> which generates a random 'squiggle'.</p>
<p>Each time a 'squiggle' is placed, it appears within a sprite with a white background.</p>
<p>... | [
{
"answer_id": 299544,
"author": "defmeta",
"author_id": 10875,
"author_profile": "https://Stackoverflow.com/users/10875",
"pm_score": 0,
"selected": false,
"text": "<p>That is not an actual Sprite (Sprite is an AS3 datatype) it's just a MovieClip that's called 'sprite'. I see that in th... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25773/"
] | I'm playing with [this ActionScript](http://www.dncompute.com/blog/2007/03/19/seed-based-pseudorandom-number-generator-in-actionscript.html) which generates a random 'squiggle'.
Each time a 'squiggle' is placed, it appears within a sprite with a white background.
If I change the background colour of the flash file to... | In RandomSquiggle.as change line 76 from
```
bitmapData = new BitmapData(width,height,false,0xfafafa);
```
to
```
bitmapData = new BitmapData(width,height,true,0x000000);
```
the third param is for transparency |
299,158 | <p>What does the SQL Action keyword do? Can I use this keyword in a trigger and determine if the trigger was called by an Insert, Delete or Update?</p>
| [
{
"answer_id": 299187,
"author": "Kevin Fairchild",
"author_id": 3743,
"author_profile": "https://Stackoverflow.com/users/3743",
"pm_score": 1,
"selected": false,
"text": "<p>No, you can't use it for that. But you can look at the <a href=\"http://msdn.microsoft.com/en-us/library/aa214435... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38613/"
] | What does the SQL Action keyword do? Can I use this keyword in a trigger and determine if the trigger was called by an Insert, Delete or Update? | ACTION is reserved for use in ODBC function calls. [These words do not constrain the minimum SQL grammar; however, to ensure compatibility with drivers that support the core SQL grammar, applications should avoid using these keywords.](http://msdn.microsoft.com/en-us/library/aa238507.aspx)
To create a trigger on certa... |
299,160 | <p>Just started getting into jQuery and have an issue with a jQuery Post call working perfectly on my local dev box (VS 2008 built-in web server), but failing when I deploy to a windows 2003 server (IIS 6) box.</p>
<p>The post works and the page being posted to process things correctly, but a response is never receive... | [
{
"answer_id": 299204,
"author": "Eduardo Molteni",
"author_id": 2385,
"author_profile": "https://Stackoverflow.com/users/2385",
"pm_score": 1,
"selected": false,
"text": "<p>The problem is probably due to caching.<br>\nTry adding a random number to the post URL</p>\n\n<pre><code>$.post(... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38615/"
] | Just started getting into jQuery and have an issue with a jQuery Post call working perfectly on my local dev box (VS 2008 built-in web server), but failing when I deploy to a windows 2003 server (IIS 6) box.
The post works and the page being posted to process things correctly, but a response is never received by the c... | The problem is probably due to caching.
Try adding a random number to the post URL
```
$.post('CustomPostHandler.aspx?step=criteria&random=' + Math.random().toString(), {
selected: idString
},
``` |
299,168 | <p>I need to style links for a Blackberry browser that has disabled CSS.</p>
<p>The following is what I try to achieve: </p>
<pre><code><style type="text/css">
a.hover {
border:0;
}
a {
text-decoration: none;
}
</style>
</code></pre>
<p>Is it even possible, just using html?</p>
| [
{
"answer_id": 299202,
"author": "Mecki",
"author_id": 15809,
"author_profile": "https://Stackoverflow.com/users/15809",
"pm_score": 4,
"selected": true,
"text": "<p>You can only set the color.</p>\n\n<pre><code><body link=\"XXX\" alink=\"YYY\" vlink=\"ZZZ\"> \n</code></pre>\n\n<p>... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1532/"
] | I need to style links for a Blackberry browser that has disabled CSS.
The following is what I try to achieve:
```
<style type="text/css">
a.hover {
border:0;
}
a {
text-decoration: none;
}
</style>
```
Is it even possible, just using html? | You can only set the color.
```
<body link="XXX" alink="YYY" vlink="ZZZ">
```
XXX being the color used for links, YYY the color when mouse hovers the link and ZZZ the color for already visited links. Color can be given in hex notation just like with stylesheets
```
#AABBCC
```
You cannot set whether links are un... |
299,176 | <p>I've been running into some problems duplicating some old ASP files into some newer .NET 2.0 code. One of the tasks is to merge the 4-5 SQL statements into one. While I have done this and had some success in performance boosts, Oracle is a new bag for me. This problem however surpasses my own SQL skills as I haven't... | [
{
"answer_id": 299220,
"author": "Dheer",
"author_id": 17266,
"author_profile": "https://Stackoverflow.com/users/17266",
"pm_score": 0,
"selected": false,
"text": "<p>Right now I can't access to Oracle. Check out this query:</p>\n\n<pre><code>SELECT rth.CODE, rth.NUMBER, rth.QUANTITY, rt... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've been running into some problems duplicating some old ASP files into some newer .NET 2.0 code. One of the tasks is to merge the 4-5 SQL statements into one. While I have done this and had some success in performance boosts, Oracle is a new bag for me. This problem however surpasses my own SQL skills as I haven't do... | You could also use the Coalesce function, with a subquery...
< Coalesce(arg0, arg1, arg2, ..... etc argN)
evaluates each argument in turn and returns the first one it finds that is not Null. >
```
Select D.CODE, D.NUMBER, D.QUANTITY, D.sale_code,
D.quantity * Coalesce((Select conversion
... |
299,198 | <p>I am looking for good ideas for implementing a generic way to have a single line (or anonymous delegate) of code execute with a timeout.</p>
<pre><code>TemperamentalClass tc = new TemperamentalClass();
tc.DoSomething(); // normally runs in 30 sec. Want to error at 1 min
</code></pre>
<p>I'm looking for a solutio... | [
{
"answer_id": 299212,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": false,
"text": "<p>Well, you could do things with delegates (BeginInvoke, with a callback setting a flag - and the original code wait... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28736/"
] | I am looking for good ideas for implementing a generic way to have a single line (or anonymous delegate) of code execute with a timeout.
```
TemperamentalClass tc = new TemperamentalClass();
tc.DoSomething(); // normally runs in 30 sec. Want to error at 1 min
```
I'm looking for a solution that can elegantly be im... | The really tricky part here was killing the long running task through passing the executor thread from the Action back to a place where it could be aborted. I accomplished this with the use of a wrapped delegate that passes out the thread to kill into a local variable in the method that created the lambda.
I submit th... |
299,209 | <p>i'm a long-time newbie to c#, and this question may be too obvious, so please forgive if i'm "doing it wrong."</p>
<p>Using Visual Studio 2005 Pro, C#, SQL Server 2000 EE SP3.</p>
<p>I have a stored proc that takes one input param and returns several output params pertaining to that input. I am also calling it suc... | [
{
"answer_id": 299228,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 2,
"selected": true,
"text": "<pre><code>//set up the datatable\nDataTable dt = new DataTable(\"parms\");\ndt.Columns.Add(\"ParmName\",typeof(string... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4126/"
] | i'm a long-time newbie to c#, and this question may be too obvious, so please forgive if i'm "doing it wrong."
Using Visual Studio 2005 Pro, C#, SQL Server 2000 EE SP3.
I have a stored proc that takes one input param and returns several output params pertaining to that input. I am also calling it successfully, and St... | ```
//set up the datatable
DataTable dt = new DataTable("parms");
dt.Columns.Add("ParmName",typeof(string));
dt.Columns.Add("ParmValue",typeof(string));
//bind to a gui object
myDataGridView.DataSource = dt;
//do this after each sproc call
foreach (SqlParameter parm in cmd.Parameters)
{
if (parm.Direction == Param... |
299,217 | <p>I am trying to monitor my outlook inbox so whenever new emails come in with attachments I save the attachment to some other location. Can anyone help me out?</p>
| [
{
"answer_id": 299234,
"author": "Adam Davis",
"author_id": 2915,
"author_profile": "https://Stackoverflow.com/users/2915",
"pm_score": 1,
"selected": false,
"text": "<p>This is not a complete solution, but it describes some of the fundamental tools you'll be using in the Outlook API.</p... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to monitor my outlook inbox so whenever new emails come in with attachments I save the attachment to some other location. Can anyone help me out? | This is not a complete solution, but it describes some of the fundamental tools you'll be using in the Outlook API.
From [Access Outlook Emails with ASP.NET, C#](http://hspinfo.wordpress.com/tag/outlook-email-using-c/):
```
using Outlook;
Outlook.Application oOutlook;
Outlook.NameSpace oNs;
Outlook.MAPIFolder oFl... |
299,249 | <p>I am familiar with using the <em>os.system</em> to run from the command line. However, I would like to be able to run a jar file from inside of a specific folder, eg. my 'test' folder. This is because my jar (located in my 'test' folder) requires a file inside of my 'test' folder. So, how would I write a function in... | [
{
"answer_id": 299262,
"author": "Martin v. Löwis",
"author_id": 33006,
"author_profile": "https://Stackoverflow.com/users/33006",
"pm_score": 1,
"selected": false,
"text": "<p>In general: Use os.chdir to change the directory of the parent process, then os.system to run the jar file. If ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37804/"
] | I am familiar with using the *os.system* to run from the command line. However, I would like to be able to run a jar file from inside of a specific folder, eg. my 'test' folder. This is because my jar (located in my 'test' folder) requires a file inside of my 'test' folder. So, how would I write a function in my script... | Here is a small script to get you started. There are ways to make it "better", but not knowing the full scope of what you are trying to accomplish this should be sufficient.
```
import os
if __name__ == "__main__":
startingDir = os.getcwd() # save our current directory
testDir = "\\test" # note that \ is window... |
299,251 | <p>I am attempting to write a component in C# to be consumed by classic ASP that allows me to access the indexer of the component (aka default property).</p>
<p>For example:<br>
C# component:</p>
<pre><code>public class MyCollection {
public string this[string key] {
get { /* return the value associated w... | [
{
"answer_id": 299338,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 3,
"selected": true,
"text": "<p>Try setting the DispId attribute of the property to be 0, as described here in the <a href=\"http://msdn.microsoft.com/... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14934/"
] | I am attempting to write a component in C# to be consumed by classic ASP that allows me to access the indexer of the component (aka default property).
For example:
C# component:
```
public class MyCollection {
public string this[string key] {
get { /* return the value associated with key */ }
}
... | Try setting the DispId attribute of the property to be 0, as described here in the [MSDN documentation](http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dispidattribute(VS.71).aspx). |
299,255 | <p>I'm starting to try and test my Doctrine objects with PHPUnit, and would like to reload the DB from my model objects afresh each time.</p>
<p>My first attempt looks something like this:</p>
<pre><code>class Tests_User extends PHPUnit_Framework_TestCase
{
public function setUp()
{
Doctrine_Manager... | [
{
"answer_id": 299338,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 3,
"selected": true,
"text": "<p>Try setting the DispId attribute of the property to be 0, as described here in the <a href=\"http://msdn.microsoft.com/... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34024/"
] | I'm starting to try and test my Doctrine objects with PHPUnit, and would like to reload the DB from my model objects afresh each time.
My first attempt looks something like this:
```
class Tests_User extends PHPUnit_Framework_TestCase
{
public function setUp()
{
Doctrine_Manager::connection('mysql:/... | Try setting the DispId attribute of the property to be 0, as described here in the [MSDN documentation](http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dispidattribute(VS.71).aspx). |
299,272 | <p>Assuming I have a tree structure</p>
<pre><code>UL
--LI
---INPUT (checkbox)
</code></pre>
<p>And I want to grab the checked inputs, I would select </p>
<pre><code>$('ul li input:checked')
</code></pre>
<p>However, I want to select the checked inputs of a specific object $myUL that doesn't have an ID.</p>
<pre><... | [
{
"answer_id": 299302,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 2,
"selected": true,
"text": "<p>use <code>$myUL.find('li>input:checked')</code></p>\n"
},
{
"answer_id": 3108313,
"author": "Thach Lockev... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37731/"
] | Assuming I have a tree structure
```
UL
--LI
---INPUT (checkbox)
```
And I want to grab the checked inputs, I would select
```
$('ul li input:checked')
```
However, I want to select the checked inputs of a specific object $myUL that doesn't have an ID.
```
$myUL.children('li input:checked')
```
returns all li... | use `$myUL.find('li>input:checked')` |
299,291 | <p>Does anyone know if its possible to create a new property on an existing Entity Type which is based on 2 other properties concatenated together?</p>
<p>E.g. My Person Entity Type has these fields "ID", "Forename", "Surname", "DOB"</p>
<p>I want to create a new field called "Fullname" which is </p>
<pre><code>Fore... | [
{
"answer_id": 299599,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 3,
"selected": true,
"text": "<p>Not yet, but maybe soon. First, note that your suggested query will not work at all in LINQ to Entities, with or wit... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30317/"
] | Does anyone know if its possible to create a new property on an existing Entity Type which is based on 2 other properties concatenated together?
E.g. My Person Entity Type has these fields "ID", "Forename", "Surname", "DOB"
I want to create a new field called "Fullname" which is
```
Forenames + " " + Surname
```
... | Not yet, but maybe soon. First, note that your suggested query will not work at all in LINQ to Entities, with or without the property, because, at present, it doesn't support Contains. The new version of the Entity Framework in .NET 4.0, however, is supposed to support custom methods in LINQ to Entities queries. You ca... |
299,304 | <p>Per the Java documentation, the <a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html#hashCode()" rel="noreferrer">hash code</a> for a <code>String</code> object is computed as:</p>
<blockquote>
<pre><code>s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
</code></pre>
<p>using <code>int</code> arith... | [
{
"answer_id": 299369,
"author": "Dave L.",
"author_id": 3093,
"author_profile": "https://Stackoverflow.com/users/3093",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not sure, but I would guess they tested some sample of prime numbers and found that 31 gave the best distribution ove... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1318/"
] | Per the Java documentation, the [hash code](http://java.sun.com/javase/6/docs/api/java/lang/String.html#hashCode()) for a `String` object is computed as:
>
>
> ```
> s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
>
> ```
>
> using `int` arithmetic, where `s[i]` is the
> *i*th character of the string, `n` is the len... | According to Joshua Bloch's [Effective Java](https://rads.stackoverflow.com/amzn/click/com/0321356683) (a book that can't be recommended enough, and which I bought thanks to continual mentions on stackoverflow):
>
> The value 31 was chosen because it is an odd prime. If it were even and the multiplication overflowed,... |
299,332 | <p>I'm doing a basic homework assignment which looks like this:</p>
<pre><code> While input <> -1
input = CDbl(InputBox("Enter numbers to add, enter -1 to stop"))
values = values + input
End While
</code></pre>
<p>It works fine until I press 'cancel' on the input box. Then the string inp... | [
{
"answer_id": 299352,
"author": "Jason Down",
"author_id": 9732,
"author_profile": "https://Stackoverflow.com/users/9732",
"pm_score": 2,
"selected": false,
"text": "<p>You could try using Double.TryParse or using a try catch block with Double.Parse. Since it's a homework assignment, I'... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28658/"
] | I'm doing a basic homework assignment which looks like this:
```
While input <> -1
input = CDbl(InputBox("Enter numbers to add, enter -1 to stop"))
values = values + input
End While
```
It works fine until I press 'cancel' on the input box. Then the string input is "", and I get the following... | Try using Double.TryParse
```
Dim value as Double = Nothing
If Double.TryParse(InputBox("Enter numbers..."), value) Then
values = values + value
End If
```
My syntax may be a bit off, but you should get the idea |
299,370 | <p>I'm trying to use <code>SetWindowsHookEx</code> to set up a <code>WH_SHELL</code> hook to get notified of system-wide <code>HSHELL_WINDOWCREATED</code> and <code>HSHELL_WINDOWDESTROYED</code> events. I pass 0 for the final <code>dwThreadId</code> argument which, according to <a href="http://msdn.microsoft.com/en-us/... | [
{
"answer_id": 308328,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 0,
"selected": false,
"text": "<p>Lol, it looks like the error is in the test code.</p>\n\n<p>If you create two separate buttons, one for Init and o... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9784/"
] | I'm trying to use `SetWindowsHookEx` to set up a `WH_SHELL` hook to get notified of system-wide `HSHELL_WINDOWCREATED` and `HSHELL_WINDOWDESTROYED` events. I pass 0 for the final `dwThreadId` argument which, according to [the docs](http://msdn.microsoft.com/en-us/library/ms644990(VS.85).aspx), should "associate the hoo... | The problem is that your hook DLL is actually being loaded into several different address spaces. Any time Windows detects an event in some foreign process that must be processed by your hook, it loads the hook DLL into that process (if it's not already loaded, of course).
However, each process has its own address spa... |
299,382 | <p>I am looking for example code that provides a unit test to serialize and deserialize an object from a memory stream. I have found <a href="https://stackoverflow.com/questions/236599/how-to-unit-test-if-my-object-is-really-serializablable">examples using C# 2.0</a>, however my current project uses VB.NET 1.1 (don't ... | [
{
"answer_id": 299401,
"author": "Paul Kapustin",
"author_id": 38325,
"author_profile": "https://Stackoverflow.com/users/38325",
"pm_score": 0,
"selected": false,
"text": "<p>Hmm...so you are trying to write a unit test for serialization? Or for streams? This is hopefully done by MS alre... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19063/"
] | I am looking for example code that provides a unit test to serialize and deserialize an object from a memory stream. I have found [examples using C# 2.0](https://stackoverflow.com/questions/236599/how-to-unit-test-if-my-object-is-really-serializablable), however my current project uses VB.NET 1.1 (don't ask me why...),... | This is the pattern I've settled upon:
```
<Test()> _
Public Sub SerializationTest()
Dim obj As New MySerializableObject()
'Perform additional construction as necessary
Dim obj2 As MySerializableObject
Dim formatter As New BinaryFormatter
Dim memoryStream As New MemoryStream()
'Run through se... |
299,387 | <p>I'm serializing class which contains DateTime property.</p>
<pre><code>public DateTime? Delivered { get; set; }
</code></pre>
<p>After serializing Delivered node contains DateTime formatted like this:</p>
<pre><code>2008-11-20T00:00:00
</code></pre>
<p>How can I change this property to make it look like this:</p... | [
{
"answer_id": 299428,
"author": "Sunny Milenov",
"author_id": 8220,
"author_profile": "https://Stackoverflow.com/users/8220",
"pm_score": 1,
"selected": false,
"text": "<p>Take a look at <a href=\"http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlattributeoverrides(VS.... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23280/"
] | I'm serializing class which contains DateTime property.
```
public DateTime? Delivered { get; set; }
```
After serializing Delivered node contains DateTime formatted like this:
```
2008-11-20T00:00:00
```
How can I change this property to make it look like this:
```
2008-11-20 00:00:00
```
Thanks in advance | The hack I use for odd formatting during XmlSerialization is to have a special property that is only used during XmlSerialization
```
//normal DateTime accessor
[XmlIgnore]
public DateTime Delivered { get; set; }
//special XmlSerialization accessor
[XmlAttribute("DateTime")]
public string XmlDateTime
{
get { retu... |
299,390 | <p>Say I have the following Objective-C class:</p>
<pre><code>@interface Foo {
int someNumber;
NSString *someString;
}
</code></pre>
<p>and for reasons I won't get into here, I want to use KVC to update, in a generic fashion, the values for those variables:</p>
<pre><code>[f setValue:object forKey:@"someNu... | [
{
"answer_id": 299496,
"author": "wisequark",
"author_id": 33159,
"author_profile": "https://Stackoverflow.com/users/33159",
"pm_score": 2,
"selected": true,
"text": "<p>You should do the conversion yourself with a number formatter, it gives you finer control than anything that the frame... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1967/"
] | Say I have the following Objective-C class:
```
@interface Foo {
int someNumber;
NSString *someString;
}
```
and for reasons I won't get into here, I want to use KVC to update, in a generic fashion, the values for those variables:
```
[f setValue:object forKey:@"someNumber"];
or
[f setValue:object forKe... | You should do the conversion yourself with a number formatter, it gives you finer control than anything that the framework might consider to be appropriate. It is also, probably, not a good idea to use a single instance of an object to update the values for your ivars. More appropriately, you could perform your update ... |
299,392 | <p>How do I create a batch file timer to execute / call another batch through out the day Maybe on given times to run but not to run on weekends ? Must run on system times can also be .cmd to run on xp server 2003 </p>
| [
{
"answer_id": 299430,
"author": "Jeff Kotula",
"author_id": 1382162,
"author_profile": "https://Stackoverflow.com/users/1382162",
"pm_score": 1,
"selected": false,
"text": "<p>I did it by writing a little C# app that just wakes up to launch periodic tasks -- don't know if it is doable f... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I create a batch file timer to execute / call another batch through out the day Maybe on given times to run but not to run on weekends ? Must run on system times can also be .cmd to run on xp server 2003 | For the timer part of your script i highly reccomend using:
```
echo.
echo Waiting For One Hour...
TIMEOUT /T 3600 /NOBREAK
echo.
echo (Put some Other Processes Here)
echo.
pause >nul
```
This script waits for 1 hour (3600 seconds) and then continues on with the script and the user cannot press any buttons to bypas... |
299,414 | <p>I have several aspx pages that can be opened either normally (full screen in browser), or called from another page as a popup (I am using Greybox, fwiw)</p>
<p>If the page is opened as a popup in Greybox, I would like to NOT display the master page content (which displays common top and left menus, etc).</p>
<p>As... | [
{
"answer_id": 299438,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 1,
"selected": false,
"text": "<p>Well you could conditionally render the navigation controls etc. based on a querystring, pass the string in wh... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8678/"
] | I have several aspx pages that can be opened either normally (full screen in browser), or called from another page as a popup (I am using Greybox, fwiw)
If the page is opened as a popup in Greybox, I would like to NOT display the master page content (which displays common top and left menus, etc).
As far as I know, t... | Create a simplified master page for the popup. Override the OnPreInit method (of the actual page) and switch out the masterpage based on a querystring argument:
```
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
if(Request["PopUp"] == "Y")
{
MasterPageFile = "~... |
299,416 | <p>I'm working with a existing database and trying to write a sql query to get out all the account information including permission levels. This is for a security audit. We want to dump all of this information out in a readible fashion to make it easy to compare. My problem is that there is a bridge/link table for the ... | [
{
"answer_id": 299505,
"author": "Tony Andrews",
"author_id": 18747,
"author_profile": "https://Stackoverflow.com/users/18747",
"pm_score": 2,
"selected": false,
"text": "<p>You could do something like this:</p>\n\n<pre><code>select userid, username\n, max(case when permissionid=10 ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8664/"
] | I'm working with a existing database and trying to write a sql query to get out all the account information including permission levels. This is for a security audit. We want to dump all of this information out in a readible fashion to make it easy to compare. My problem is that there is a bridge/link table for the per... | You could do something like this:
```
select userid, username
, max(case when permissionid=10 then rights end) as permission10_rights
, max(case when permissionid=11 then rights end) as permission11_rights
, max(case when permissionid=12 then rights end) as permission12_rights
from userpermissions
gro... |
299,433 | <p>Is there a way to programatically access the DragHandleTemplate of a ReorderList (ASP.NET AJAX Control Toolkit) ... Specifically during ItemDataBound for the ReorderList, in order to change its appearance at the per item level?</p>
| [
{
"answer_id": 492082,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 0,
"selected": false,
"text": "<p>You can not access DragHandleTemplate programatically <strong>on the server</strong>, but if you create the surrounding elem... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36263/"
] | Is there a way to programatically access the DragHandleTemplate of a ReorderList (ASP.NET AJAX Control Toolkit) ... Specifically during ItemDataBound for the ReorderList, in order to change its appearance at the per item level? | Unfortunately there is no way of getting drag holder from ReorderListItem. Instead, you can create a server control inside DragHandleTemplate (e.g. PlaceHolder) and then find it in your ItemDataBound event handler:
In aspx file:
```
<DragHandleTemplate>
<div class="dragHandle">
<asp:Label ID="lblDragHandle" run... |
299,437 | <p>How do you feel about VS making you hunt for a tab that you used just minutes ago when you have a bazillion open tabs? What about constantly dragging tabs around to keep the ones you use close together?</p>
<p>Oh, so you think <em>AARGH</em>, too? Then read on.</p>
<p>I work on a piece of software with dozens of p... | [
{
"answer_id": 299473,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 3,
"selected": false,
"text": "<p>I mostly use <kbd>Ctrl</kbd>-<kbd>TAB</kbd> to cycle through the tabs I have most recently been working on. I can see... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11545/"
] | How do you feel about VS making you hunt for a tab that you used just minutes ago when you have a bazillion open tabs? What about constantly dragging tabs around to keep the ones you use close together?
Oh, so you think *AARGH*, too? Then read on.
I work on a piece of software with dozens of projects and hundreds of ... | ReSharper and its Recent Files feature works a lot better for me. |
299,439 | <p>I'm looking for a library or source code that provides guard methods such as checking for null arguments. Obviously this is rather simple to build, but I'm wondering if there are any out there for .NET already. A basic Google search didn't reveal much.</p>
| [
{
"answer_id": 299460,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>Given Microsoft's <a href=\"http://research.microsoft.com/contracts\" rel=\"noreferrer\">Code Contracts</a> coming ou... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2656/"
] | I'm looking for a library or source code that provides guard methods such as checking for null arguments. Obviously this is rather simple to build, but I'm wondering if there are any out there for .NET already. A basic Google search didn't reveal much. | There is [CuttingEdge.Conditions](http://conditions.codeplex.com/). Usage example from the page:
```
public ICollection GetData(Nullable<int> id, string xml, ICollection col)
{
// Check all preconditions:
id.Requires("id")
.IsNotNull() // throws ArgumentNullException on failure
.IsInRa... |
299,441 | <p>I have a simple class in my WCF service that doesn't seem to be showing up properly for the client that accesses my WCF.</p>
<p>My class has 4 public properties that are of type string.</p>
<p>I marked the class with [DataContract()] and each member with [DataMember].</p>
<p>Why is my constructor not visible? Is... | [
{
"answer_id": 299453,
"author": "Michael Kniskern",
"author_id": 26327,
"author_profile": "https://Stackoverflow.com/users/26327",
"pm_score": 0,
"selected": false,
"text": "<p>The parenthesises are not required when you mark a class as a data contract. Can you provide a code sample of... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a simple class in my WCF service that doesn't seem to be showing up properly for the client that accesses my WCF.
My class has 4 public properties that are of type string.
I marked the class with [DataContract()] and each member with [DataMember].
Why is my constructor not visible? Is there a special [attribu... | Data contracts do not have anything to do with constructors. So, when you create your proxy on the client, you will only get a class that implements the data contract.
If you want to add a similar constructor on the client side (assume the type generated is named SomeDataItem), you can add it using a partial class:
`... |
299,446 | <p>I have a function that resembles the one below. I'm not sure how to use the os module to get back to my original working directory at the conclusion of the jar's execution. </p>
<pre><code>def run():
owd = os.getcwd()
#first change dir to build_dir path
os.chdir(testDir)
#run jar from test director... | [
{
"answer_id": 299462,
"author": "grieve",
"author_id": 34329,
"author_profile": "https://Stackoverflow.com/users/34329",
"pm_score": 6,
"selected": true,
"text": "<p>You simply need to add the line:</p>\n\n<pre><code>os.chdir(owd)\n</code></pre>\n\n<p>Just a note this was also answered ... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37804/"
] | I have a function that resembles the one below. I'm not sure how to use the os module to get back to my original working directory at the conclusion of the jar's execution.
```
def run():
owd = os.getcwd()
#first change dir to build_dir path
os.chdir(testDir)
#run jar from test directory
os.syste... | You simply need to add the line:
```
os.chdir(owd)
```
Just a note this was also answered in your other [question](http://stackoverflow.com/questions/299249/how-can-i-get-my-python-version-25-script-to-run-a-jar-file-inside-a-folder-ins). |
299,461 | <p>I went to <a href="http://www.json.org/js.html" rel="nofollow noreferrer">http://www.json.org/js.html</a> and downloaded the json2.js, thinking i'd be fine, afterall that site is on the top in a google search for 'json javascript' - also they have this really cool url :)</p>
<p>So i've been working a bit with it an... | [
{
"answer_id": 299457,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 5,
"selected": true,
"text": "<p><a href=\"https://blog.codinghorror.com/obscenity-filters-bad-idea-or-incredibly-intercoursing-bad-idea/\" rel=\"nofollow... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11619/"
] | I went to <http://www.json.org/js.html> and downloaded the json2.js, thinking i'd be fine, afterall that site is on the top in a google search for 'json javascript' - also they have this really cool url :)
So i've been working a bit with it and it seemed fine, but now i start running into trouble with it - it simply w... | [Obscenity Filters: Bad Idea, or Incredibly Intercoursing Bad Idea?](https://blog.codinghorror.com/obscenity-filters-bad-idea-or-incredibly-intercoursing-bad-idea/ "Obscenity Filters: Bad Idea, or Incredibly Intercoursing Bad Idea?") ^\_^
Also see [How do you implement a good profanity filter?](https://stackoverflow.c... |
299,490 | <p>I need to query Active Directory for a list of users whose password is about to expire. The obvious (and easy) way to do this is with:</p>
<pre><code>dsquery user -stalepwd n
</code></pre>
<p>The problem is that I need to add additional filters to only look for users who are in certain security groups. This is ... | [
{
"answer_id": 300169,
"author": "benPearce",
"author_id": 4490,
"author_profile": "https://Stackoverflow.com/users/4490",
"pm_score": 2,
"selected": false,
"text": "<p>There are better tools than dsquery to use.</p>\n\n<p><a href=\"http://www.joeware.net/freetools/tools/findexpacc/usage... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to query Active Directory for a list of users whose password is about to expire. The obvious (and easy) way to do this is with:
```
dsquery user -stalepwd n
```
The problem is that I need to add additional filters to only look for users who are in certain security groups. This is hard to do with the "dsquery... | There are better tools than dsquery to use.
[FindExpAcc](http://www.joeware.net/freetools/tools/findexpacc/usage.htm) from joeware will do the same as stalepwd and allow a filter through its -f switch.
The filter would then look like:
```
&(objectCategory=user)(memberof=CN=User Group,OU=Test,DC=foo,dc=com)
```
Als... |
299,495 | <p>I have a <a href="http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/JPanel.html" rel="noreferrer">JPanel</a> to which I'd like to add JPEG and PNG images that I generate on the fly.</p>
<p>All the examples I've seen so far in the <a href="http://java.sun.com/docs/books/tutorial/uiswing/" rel="noreferrer"... | [
{
"answer_id": 299545,
"author": "Lawrence Dol",
"author_id": 8946,
"author_profile": "https://Stackoverflow.com/users/8946",
"pm_score": 3,
"selected": false,
"text": "<p>You can subclass JPanel - here is an extract from my ImagePanel, which puts an image in any one of 5 locations, top/... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15649/"
] | I have a [JPanel](http://download.oracle.com/javase/1.4.2/docs/api/javax/swing/JPanel.html) to which I'd like to add JPEG and PNG images that I generate on the fly.
All the examples I've seen so far in the [Swing Tutorials](http://java.sun.com/docs/books/tutorial/uiswing/), specially in the [Swing examples](http://jav... | Here's how I do it (with a little more info on how to load an image):
```
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
public cla... |
299,497 | <p>I've created a windows form control which works successfully hosted in Internet Explorer. I'd like to give it an event and be able to respond to the event through javascript. I found a link that talks about it <a href="http://msdn.microsoft.com/en-ca/magazine/cc301932.aspx" rel="nofollow noreferrer">here</a>. It ... | [
{
"answer_id": 299551,
"author": "Brian Genisio",
"author_id": 36687,
"author_profile": "https://Stackoverflow.com/users/36687",
"pm_score": 1,
"selected": false,
"text": "<p>You are implementing it wrong in your CardReader class:</p>\n\n<pre><code>public event Error;\npublic event Succe... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9266/"
] | I've created a windows form control which works successfully hosted in Internet Explorer. I'd like to give it an event and be able to respond to the event through javascript. I found a link that talks about it [here](http://msdn.microsoft.com/en-ca/magazine/cc301932.aspx). It shows me how to create the interfaces but I... | You are implementing it wrong in your CardReader class:
```
public event Error;
public event Success;
protected void OnError()
{
if(Error != null)
Error();
}
protected void OnSuccess()
{
if(Success != null)
Success();
}
```
If your ICardReaderEvents interface changes to have Error and Succe... |
299,504 | <p>I'm trying to use cygwin sqlplus to connect to a remote oracle installation located at myserver.mycompany.com port 1530. When I try</p>
<pre><code>sqlplus username@myserver.mycompany.com:1530/orcl
</code></pre>
<p>I get the error:</p>
<pre><code>ORA-12154: TNS:could not resolve the connect identifier specified
<... | [
{
"answer_id": 299558,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 3,
"selected": true,
"text": "<p>I wasn't aware there was a native cygwin client for Oracle (correct me if I'm wrong here but I can't f... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1094969/"
] | I'm trying to use cygwin sqlplus to connect to a remote oracle installation located at myserver.mycompany.com port 1530. When I try
```
sqlplus username@myserver.mycompany.com:1530/orcl
```
I get the error:
```
ORA-12154: TNS:could not resolve the connect identifier specified
```
When I set `ORACLE_HOME` to /`cyg... | I wasn't aware there was a native cygwin client for Oracle (correct me if I'm wrong here but I can't find any mention of it on Oracle's web site either). If you're using Cygwin with the Windows client you need to use a native windows path. It won't understand your /cygdrive path.
However, I have used Win32 Oracle clie... |
299,512 | <p>What steps do I take? Any gotchas to be aware of or tips to enhance the IDE experience that are specific to SQL Server when using Emacs?</p>
| [
{
"answer_id": 299816,
"author": "Ray",
"author_id": 4872,
"author_profile": "https://Stackoverflow.com/users/4872",
"pm_score": 6,
"selected": true,
"text": "<p><strong>Connecting</strong></p>\n\n<p>To connect to a SQL Server database instance from Emacs:</p>\n\n<pre><code>M-x sql-ms RE... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | What steps do I take? Any gotchas to be aware of or tips to enhance the IDE experience that are specific to SQL Server when using Emacs? | **Connecting**
To connect to a SQL Server database instance from Emacs:
```
M-x sql-ms RET
M-x sql-mode
```
You will be prompted for standard connection information specifically the following:
* User
* Password
* Server
* Database
For SQL Server Authentication, type in the necessary user and password info. ... |
299,515 | <p>In C# is there a technique using reflection to determine if a method has been added to a class as an extension method?</p>
<p>Given an extension method such as the one shown below is it possible to determine that Reverse() has been added to the string class?</p>
<pre><code>public static class StringExtensions
{
... | [
{
"answer_id": 299526,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 8,
"selected": true,
"text": "<p>You have to look in all the assemblies where the extension method may be defined.</p>\n\n<p>Look for classes decorated... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27887/"
] | In C# is there a technique using reflection to determine if a method has been added to a class as an extension method?
Given an extension method such as the one shown below is it possible to determine that Reverse() has been added to the string class?
```
public static class StringExtensions
{
public static strin... | You have to look in all the assemblies where the extension method may be defined.
Look for classes decorated with [`ExtensionAttribute`](http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.extensionattribute.aspx), and then methods within that class which are *also* decorated with `ExtensionAttribu... |
299,536 | <p>Is it possible to create an integer (or DataTime, etc) column in ListView? It is quite important, because I would like to properly sort the list according to this column.</p>
<p>The only way to add subItems to a ListViewItem I found are:</p>
<pre><code>listviewitem.SubItems.Add("1");
</code></pre>
<p>I would like... | [
{
"answer_id": 299572,
"author": "Mariusz",
"author_id": 13541,
"author_profile": "https://Stackoverflow.com/users/13541",
"pm_score": 1,
"selected": false,
"text": "<p>Rather than that you just add strings to the list and receive strings by using <code>.Text</code> property.</p>\n\n<p>E... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5363/"
] | Is it possible to create an integer (or DataTime, etc) column in ListView? It is quite important, because I would like to properly sort the list according to this column.
The only way to add subItems to a ListViewItem I found are:
```
listviewitem.SubItems.Add("1");
```
I would like to avoid parsing these strings t... | You could use the Tag property. These little helper functions take care of it:
```
private void setListItem(int row, int column, int value) {
ListViewItem.ListViewSubItem item = listView1.Items[row].SubItems[column];
item.Tag = value;
item.Text = value.ToString();
}
private int getListItem(int row, int column) {... |
299,546 | <p>I can query the AD and find all the IIS sites and their virtual directories, now I need to be able to update those home directories and save the changes.</p>
<p>After I fetch the directory entry I can display the site path using <code>$site.Path</code>, however setting it doesn't seem to have any effect. It never ... | [
{
"answer_id": 299561,
"author": "vfilby",
"author_id": 24279,
"author_profile": "https://Stackoverflow.com/users/24279",
"pm_score": 1,
"selected": true,
"text": "<p>Ok, I tried this and it seems to work:</p>\n\n<pre><code> $s.psbase.properties.path[0] = $siteConfig.path\n $s.psba... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24279/"
] | I can query the AD and find all the IIS sites and their virtual directories, now I need to be able to update those home directories and save the changes.
After I fetch the directory entry I can display the site path using `$site.Path`, however setting it doesn't seem to have any effect. It never changes the actual sto... | Ok, I tried this and it seems to work:
```
$s.psbase.properties.path[0] = $siteConfig.path
$s.psbase.CommitChanges()
```
Is there a better cleaner way of handling this? |
299,554 | <p>I am using a JSP bean and when I do an assignment to a new object, it gets over-written on a submit to the previous object.</p>
<pre><code><jsp:useBean id="base" class="com.example.StandardBase" scope="session" />
...
//base object id = 396
base = new Base()
//base object id = 1000
</code></pre>
<p>and on a... | [
{
"answer_id": 299564,
"author": "Tim Howland",
"author_id": 4276,
"author_profile": "https://Stackoverflow.com/users/4276",
"pm_score": 0,
"selected": false,
"text": "<p>would changing scope from session to request fix this for you?</p>\n"
},
{
"answer_id": 299568,
"author":... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17712/"
] | I am using a JSP bean and when I do an assignment to a new object, it gets over-written on a submit to the previous object.
```
<jsp:useBean id="base" class="com.example.StandardBase" scope="session" />
...
//base object id = 396
base = new Base()
//base object id = 1000
```
and on a resubmit of the page I get
```... | I'm not completely sure, but I think `base = new Base()` does not update the reference stored in the session scope. Therefore, the bean you created with the initial `<jsp:useBean/>` is still around while the one you create manually, and then updated, isn't.
Get rid of `base = new Base()` and you should be fine.
If yo... |
299,563 | <p>I don't understand why one method would work and the other would throw a NoMethodError if they come from the same lib file.</p>
<pre><code># app/views/bunnies/show.html.erb
<% if logged_in? %>
<%= current_user.login %> |
<%= link_to 'Logout', logout_path %> |
<% if authorized? %>
&... | [
{
"answer_id": 299764,
"author": "neezer",
"author_id": 32154,
"author_profile": "https://Stackoverflow.com/users/32154",
"pm_score": 1,
"selected": true,
"text": "<p>Right, so I still don't understand why that wasn't working, but I have found an alternative solution.</p>\n\n<p>(1) Leav... | 2008/11/18 | [
"https://Stackoverflow.com/questions/299563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32154/"
] | I don't understand why one method would work and the other would throw a NoMethodError if they come from the same lib file.
```
# app/views/bunnies/show.html.erb
<% if logged_in? %>
<%= current_user.login %> |
<%= link_to 'Logout', logout_path %> |
<% if authorized? %>
<%= link_to 'Edit Details', edit_bunny_... | Right, so I still don't understand why that wasn't working, but I have found an alternative solution.
(1) Leave authenticated\_system.rb as is.
(2) Add a helper method to controllers/application.rb:
```
helper_method :is_admin?
def is_admin?
if logged_in? && current_user.login == "admin"
true
else
false
... |