qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
284,904 | <p>When I compile an application with VS2008 I sometimes end up with 2 identical config files:</p>
<ul>
<li>*.exe.config</li>
<li>*.vshost.exe.config</li>
</ul>
<p>What is the latter one for?</p>
| [
{
"answer_id": 7253559,
"author": "robvon",
"author_id": 473704,
"author_profile": "https://Stackoverflow.com/users/473704",
"pm_score": 2,
"selected": false,
"text": "var s = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/284904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] |
284,906 | <p>What are some key UI design tips that every developer should know?</p>
<p>While there are a number of UI resources for developers (for example, Joel Spolsky's <a href="https://rads.stackoverflow.com/amzn/click/com/1893115941" rel="noreferrer" rel="nofollow noreferrer">User Interface Design for Programmers</a>), I'm interested in more of a bullet list that can be communicated in 1 to 2 pages.</p>
<p>I'm interested in more tactical, <b>day-to-day UI tips</b>, as opposed to overarching UI design goals that would be covered in a UI design meeting (presumably attended by at least one person with a good UI sense). A collection of these tips might cover about 80% of the cases that an everyday programmer would come across.</p>
| [
{
"answer_id": 285044,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 0,
"selected": false,
"text": "[Ok, Please Cancel my subscription ], [ Please do not cancel my subscription ] \n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/284906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2197/"
] |
284,921 | <p>I want to start using dependency injection in my WPF application, largely for better unit testability. My app is mostly constructed along the M-V-VM pattern.
I'm looking at <a href="https://code.google.com/p/autofac/" rel="nofollow noreferrer">Autofac</a> for my IoC container, but I don't think that matters too much for this discussion.</p>
<p>Injecting a service into the start window seems straightforward, as I can create the container and resolve from it in App.xaml.cs.</p>
<p>What I'm struggling with is how I can DI ViewModels and Services into User Controls? The user controls are instantiated via XAML markup, so there's no opportunity to <code>Resolve()</code> them.</p>
<p>The best I can think of is to place the container in a Singleton, and have the user controls resolve their ViewModels from the global container. This feels like a half-way solution, at best, as it still required my components to have a dependency on a ServiceLocator.</p>
<p>Is full IoC possible with WPF?</p>
<p>[edit] - Prism has been suggested, but even evaluating Prism seems like a big investment. I'm hoping for something smaller.</p>
<p>[edit] here's a code fragment where I'm stopped</p>
<pre class="lang-cs prettyprint-override"><code>//setup IoC container (in app.xaml.cs)
var builder = new ContainerBuilder();
builder.Register<NewsSource>().As<INewsSource>();
builder.Register<AViewModel>().FactoryScoped();
var container = builder.Build();
// in user control ctor -
// this doesn't work, where do I get the container from
VM = container.Resolve<AViewModel>();
// in app.xaml.cs
// this compiles, but I can't use this uc,
//as the one I want in created via xaml in the primary window
SomeUserControl uc = new SomeUserControl();
uc.VM = container.Resolve<AViewModel>();
</code></pre>
| [
{
"answer_id": 286024,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "public class MyDotNetcomponent<T> : SomeDotNetcomponent \n{\n // Inversion of Control Loader…\n // Next step add the Inv... | 2008/11/12 | [
"https://Stackoverflow.com/questions/284921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25201/"
] |
284,939 | <h1>UPDATE</h1>
<p>So it turns out internet exploder's stranglehold on "security" to "make up" for being so bad at security was causing my problems. I should have checked that out first haha. Thanks everyone for the input, it has given me ideas on how to optimize my application :D</p>
<hr>
<p>I am writing a web app (in ASP.NET 3.5) that integrates with a platform app. The platform app takes the user's credentials and puts them into an "empty" HTML page that consists of a form with hidden items containing said credentials and POSTS to the webapp (<strong><code>default.aspx</code></strong>):</p>
<pre><code><HTML>
<HEAD>
<SCRIPT LANGUAGE=JSCRIPT>
function OnLoad(){
try {
document.form1.submit();
}
catch(e){
}
}
</SCRIPT>
</HEAD>
<BODY OnLoad="OnLoad()">
<FORM ACTION="http://localhost:51816/gs_ontheweb/default.aspx" METHOD=POST NAME=form1 TARGET="_NEW">
<INPUT TYPE="HIDDEN" NAME="ClientID" VALUE="123456">
<INPUT TYPE="HIDDEN" NAME="Password" VALUE="2830088828">
<INPUT TYPE="HIDDEN" NAME="PracType" VALUE="051">
<INPUT TYPE="HIDDEN" NAME="Encrypt" VALUE="12345620081111">
</FORM>
</BODY>
</HTML>
</code></pre>
<p>When my <strong><code>default.aspx</code></strong> page gets loaded up, it calls the following function:</p>
<pre><code>Dim ClientID As String = Request.Form("ClientID")
Dim PassWord As String = Request.Form("Password")
Dim PracType As String = Request.Form("PracType")
</code></pre>
<p>Each one of them result in empty strings. Any ideas on why this is happening? Thanks in advance.</p>
<p>EDIT: Is there something I need to configure in my <strong><code>web.config</code></strong> file to make this work properly? Request.Params("<code><param name></code>") does not work.</p>
| [
{
"answer_id": 285528,
"author": "Moose",
"author_id": 19032,
"author_profile": "https://Stackoverflow.com/users/19032",
"pm_score": 0,
"selected": false,
"text": "System.Net.WebClient wc = new System.Net.WebClient();\nbyte[] b;\nbyte[] res;\nstring formdata = \"text=test text&password=s... | 2008/11/12 | [
"https://Stackoverflow.com/questions/284939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] |
284,947 | <p>Is there a simple way to retrieve the length of an associative array (implemented as an <code>Object</code>) in ActionScript 3.0?</p>
<p>I understand that there are two primary ways of creating associative arrays in AS3:</p>
<ol>
<li>Use a <code>Dictionary</code> object; especially handy when the key does not need to be a <code>string</code></li>
<li>Use an <code>Object</code>, and simply create properties for each desired element. The property name is the key, and the value is, well, the value.</li>
</ol>
<p>My application uses approach #2 (using the <code>Object</code> class to represent associative arrays). </p>
<p>I am hoping there is something more native than my <code>for</code> loop, which manually counts up all the elements.</p>
| [
{
"answer_id": 286647,
"author": "Iain",
"author_id": 11911,
"author_profile": "https://Stackoverflow.com/users/11911",
"pm_score": 3,
"selected": false,
"text": "var things:Array = [];\nthings.push(\"hi!\");\ntrace(things.length);\n// traces 1\ntrace(things);\n// traces hi!\n"
},
{
... | 2008/11/12 | [
"https://Stackoverflow.com/questions/284947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/863/"
] |
284,950 | <p>I finally got my group to switch from SourceSafe to Subversion. Unfortunately, my manager still wants to use exclusive locks on every single file. So I set the svn:needs-lock property on every file and created a pre-commit hook to make sure the property stays set.</p>
<p>We are running Subversion on a Linux server. Most of us use Windows machines and a few use Macs. We are using various SVN clients (TortoiseSVN, SmartSVN, Subclipse, etc.). </p>
<p>What we now need is a good/easy method to see all the files that are currently locked in the entire repository (and who has them locked). I have poked around a little in Tortoise and Subclipse, but haven't found what I am looking for. Our projects have many subdirectories that are multiple levels deep, so it would be too time consuming to look at each individual directory. </p>
<p>What I would like is a single report I can run that lists everything that is currently locked and who has it locked. What is the best way to get this type of information?</p>
| [
{
"answer_id": 284966,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 6,
"selected": true,
"text": "svnadmin lslocks"
},
{
"answer_id": 9785504,
"author": "ashirley",
"author_id": 6950,
"author_profile"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/284950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37036/"
] |
284,952 | <p>I am working on an embedded application where the device is controlled through a command interface. I mocked the command dispatcher in VC and had it working to my satisfaction; but when I then moved the code over to the embedded environment, I found out that the compiler has a broken implementation of pointer-to-func's.</p>
<p>Here's how I originally implemented the code (in VC):</p>
<pre><code>/* Relevant parts of header file */
typedef struct command {
const char *code;
void *set_dispatcher;
void *get_dispatcher;
const char *_description;
} command_t;
#define COMMAND_ENTRY(label,dispatcher,description) {(const char*)label, &set_##dispatcher, &get_##dispatcher, (const char*)description}
/* Dispatcher data structure in the C file */
const command_t commands[] = {
COMMAND_ENTRY("DH", Dhcp, "DHCP (0=off, 1=on)"),
COMMAND_ENTRY("IP", Ip, "IP Address (192.168.1.205)"),
COMMAND_ENTRY("SM", Subnet, "Subunet Mask (255.255.255.0)"),
COMMAND_ENTRY("DR", DefaultRoute, "Default router (192.168.1.1)"),
COMMAND_ENTRY("UN", Username, "Web username"),
COMMAND_ENTRY("PW", Password, "Web password"),
...
}
/* After matching the received command string to the command "label", the command is dispatched */
if (pc->isGetter)
return ((get_fn_t)(commands[i].get_dispatcher))(pc);
else
return ((set_fn_t)(commands[i].set_dispatcher))(pc);
}
</code></pre>
<p>Without the use of function pointers, it seems like my only hope is to use switch()/case statements to call functions. But I'd like to avoid having to manually maintain a large switch() statement. </p>
<p>What I was thinking of doing is moving all the COMMAND_ENTRY lines into a separate include file. Then wraps that include file with varying #define and #undefines. Something like:</p>
<pre><code>/* Create enum's labels */
#define COMMAND_ENTRY(label,dispatcher,description) SET_##dispatcher, GET_##dispatcher
typedef enum command_labels = {
#include "entries.cinc"
DUMMY_ENUM_ENTRY} command_labels_t;
#undefine COMMAND_ENTRY
/* Create command mapping table */
#define COMMAND_ENTRY(label,dispatcher,description) {(const char*)label, SET_##dispatcher, GET_##dispatcher, (const char*)description}
const command_t commands[] = {
#include "entries.cinc"
NULL /* dummy */ };
#undefine COMMAND_ENTRY
/*...*/
int command_dispatcher(command_labels_t dispatcher_id) {
/* Create dispatcher switch statement */
#define COMMAND_ENTRY(label,dispatcher,description) case SET_##dispatcher: return set_##dispatcher(pc); case GET_##dispatcher: return get_##dispatcher(pc);
switch(dispatcher_id) {
#include "entries.cinc"
default:
return NOT_FOUND;
}
#undefine COMMAND_ENTRY
}
</code></pre>
<p>Does anyone see a better way to handle this situation? Sadly, 'get another compiler' is not a viable option. :(</p>
<p>--- Edit to add:
Just to clarify, the particular embedded environment is broken in that the compiler is <em>supposed</em> to create a "function-pointer table" which is then used by the compiler to resolve calls to functions through a pointer. Unfortunately, the compiler is broken and doesn't generate a correct function-table.</p>
<p>So I don't have an easy way to extract the func address to invoke it.</p>
<p>--- Edit #2:
Ah, yes, the use of void *(set|get)_dispatcher was my attempt to see if the problem was with the typedefine of the func pointers. Originally, I had</p>
<pre><code>typedef int (*set_fn_t)(cmdContext_t *pCmdCtx);
typedef int (*get_fn_t)(cmdContext_t *pCmdCtx);
typedef struct command {
const char *code;
set_fn_t set_dispatcher;
get_fn_t get_dispatcher;
const char *_description;
} command_t;
</code></pre>
| [
{
"answer_id": 284987,
"author": "xtofl",
"author_id": 6610,
"author_profile": "https://Stackoverflow.com/users/6610",
"pm_score": 1,
"selected": false,
"text": "&getenv"
},
{
"answer_id": 284992,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https:... | 2008/11/12 | [
"https://Stackoverflow.com/questions/284952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22329/"
] |
284,984 | <p>Let's say we have these tables;</p>
<p>table user:<br>
- id<br>
- username<br>
- email</p>
<p>table user2group:<br>
- userid<br>
- groupid</p>
<p>table group:<br>
- id<br>
- groupname</p>
<p>How do I make one query that returns all users, and the groups they belong to (as an array in the resultset or something..)</p>
| [
{
"answer_id": 284988,
"author": "Eric Z Beard",
"author_id": 1219,
"author_profile": "https://Stackoverflow.com/users/1219",
"pm_score": 3,
"selected": false,
"text": "select u.id, u.username, u.email, g.groupid, g.groupname\nfrom user u \njoin user2group ug on u.userid=ug.userid\njoin ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/284984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
284,985 | <p>I would like to do something like add a nice-to-Excel-functions <code>Name</code> property to the <code>WorkBook</code> class. Is there a good way to do this?</p>
<p>More detailed problem: In VBA you can assign a formula to a range in an Excel worksheet. I want to do so, and I want my formula to refer to a second workbook, which is an object called <code>wb</code> in my code. I then use <code>wb.Name</code> in assigning a formula to a range. </p>
<p>The problem arises when <code>wb.Name</code> has a single-quote in it. Then you wind up with something like this:</p>
<pre><code>=MONTH('[Ryan's WB]Sheet1'A1)
</code></pre>
<p>in the spreadsheet, which fails because the single-quote in the workbook name matches to the first single-quote.</p>
<p>What I would like is a <code>FunName</code> property for the <code>WorkBook</code> class that replaces all single-quotes in the <code>Name</code> property with two single-quotes and returns that. Then the above formula would properly wind up looking like</p>
<pre><code>=MONTH('[Ryan''s WB]Sheet1'A1)
</code></pre>
| [
{
"answer_id": 285069,
"author": "DJ.",
"author_id": 10492,
"author_profile": "https://Stackoverflow.com/users/10492",
"pm_score": 1,
"selected": false,
"text": "WorksheetName = Replace(WB.Name, \"'\", \"''\")\n"
},
{
"answer_id": 285615,
"author": "dbb",
"author_id": 256... | 2008/11/12 | [
"https://Stackoverflow.com/questions/284985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15041/"
] |
285,005 | <p>I have to sort a number of integers, which can have values between 30.000.000 and 350.000.000. There will be between 0 and 65.535 integers, with the average count being 20.000. RAM usage is irrelevant and speed only is important.</p>
<p>Later on i will also have to split them into groups, with the divide always being set whenever the gap between two of these values is >65.535, which is what i need the algorithm for.</p>
<p>If it makes any difference, the algorithm will be used in a Perl script.</p>
<p>Edit: After thinking it over and reading the answers i've come to realize something: I don't actually care about the data itself. As i really only want to find the start and end values of groups with small gaps, the sorting only needs to create buckets and can discard the data.</p>
<p>Edit2: After some testing and trying out the answers provided, the fastest way i found was this:</p>
<pre><code>my @sort = sort {$a <=> $b} @item_offsets;
my @buckets;
my $start = shift @sort;
push @buckets, [$start,$start];
for my $item ( @sort ) {
if ( $item < $buckets[$#buckets][1]+$gap ) {
$buckets[$#buckets][1] = $item;
}
else {
push @buckets, [$item,$item];
}
}
say $#buckets;
</code></pre>
| [
{
"answer_id": 285025,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 0,
"selected": false,
"text": "while(morenumbers)\n sorted[[unsorted[number]]++\n number++\n"
},
{
"answer_id": 285038,
"author": "Michael Car... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/145119/"
] |
285,015 | <p>I'm working on a Linux machine through SSH (Putty). I need to leave a process running during the night, so I thought I could do that by starting the process in background (with an ampersand at the end of the command) and redirecting stdout to a file.</p>
<p>To my surprise, that doesn't work. As soon as I close the Putty window, the process is stopped.</p>
<p>How can I prevent that from happening??</p>
| [
{
"answer_id": 285040,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 6,
"selected": false,
"text": "nohup"
},
{
"answer_id": 285057,
"author": "Brian Knoblauch",
"author_id": 15689,
"author_profil... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25700/"
] |
285,031 | <p>It is possible to get stacktrace using System.Diagnostics.StackTrace, but thread has to be suspended. Suspend and Resume function are obsolete, so I expect that better way exists.</p>
| [
{
"answer_id": 285321,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 2,
"selected": false,
"text": "http://blogs.msdn.com/jmstall/archive/2005/11/07/views_on_cordbg_and_mdbg.aspx"
},
{
"answer_id": 9595704,
... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28912/"
] |
285,042 | <p>I'm trying to copy both an image from a file and text from a file to the clipboard. My intention is to then open a word document or an outlook email and paste both the text and the image in one standard paste command (CTRL-V for example). I can do both separately easily enough, but doing them both in one operation doesn't seem to work.</p>
<p>This is how I've got the two working as separate operations (only relevant code lines of course, with try/catch stripped out etc.):</p>
<p>Add Image to Clipboard:</p>
<p>...</p>
<pre><code>Bitmap imageToAdd = new Bitmap(imageFilePath);
Clipboard.SetImage(imageToAdd);
</code></pre>
<p>...</p>
<p>Add Text to Clipboard:</p>
<p>...</p>
<pre><code>StreamReader rdr = new StreamReader(textFilePath);
string text = rdr.ReadToEnd();
Clipboard.SetText(text);
</code></pre>
<p>...</p>
<p>I'm using c# and .net 2.0 framework and targeting Windows XP (and likely Vista in the near future).</p>
<p>TIA</p>
| [
{
"answer_id": 61739796,
"author": "Markus",
"author_id": 1332129,
"author_profile": "https://Stackoverflow.com/users/1332129",
"pm_score": 0,
"selected": false,
"text": "// Load a bitmap without locking it.\nprivate Bitmap LoadBitmapUnlocked(string path)\n{\n using (Bitmap bm = new B... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9732/"
] |
285,061 | <p>Suppose I have a python object <code>x</code> and a string <code>s</code>, how do I set the attribute <code>s</code> on <code>x</code>? So:</p>
<pre><code>>>> x = SomeObject()
>>> attr = 'myAttr'
>>> # magic goes here
>>> x.myAttr
'magic'
</code></pre>
<p>What's the magic? The goal of this, incidentally, is to cache calls to <code>x.__getattr__()</code>. </p>
| [
{
"answer_id": 285076,
"author": "Ali Afshar",
"author_id": 28380,
"author_profile": "https://Stackoverflow.com/users/28380",
"pm_score": 10,
"selected": true,
"text": "setattr(x, attr, 'magic')\n"
},
{
"answer_id": 285086,
"author": "S.Lott",
"author_id": 10661,
"aut... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5222/"
] |
285,068 | <p>Is there a way to make OpenGL transform a general vector I give it with the current modelview matrix and get the result back?</p>
<p>The obvious way is to query the modelview matrix and do the multiplication myself but
I am almost sure there should be a way to make OpenGL do this for me.</p>
| [
{
"answer_id": 285265,
"author": "Judge Maygarden",
"author_id": 1491,
"author_profile": "https://Stackoverflow.com/users/1491",
"pm_score": 2,
"selected": false,
"text": "float modelview[16];\nglGetFloatv(GL_MODELVIEW_MATRIX, modelview);\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9611/"
] |
285,074 | <p>I'm using the <a href="http://docs.jquery.com/UI/Sortables" rel="noreferrer">jQuery UI sortables</a> plugin to allow re-ordering of some list items. Inside each list item, I've got a couple of radio buttons which allow the item to be enabled or disabled.</p>
<p>When the item is dragged, both radio buttons get deselected, which doesn't seem like it should be happening. Is this correct behavior, and if not, what is the best way to work around this?</p>
<p>Here is a code sample demonstrating this problem:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>jQuery Sortables Problem</title>
<script src="jquery-1.2.6.min.js" type="text/javascript"></script>
<script src="jquery-ui.min.js" type="text/javascript"></script>
<style type="text/css">
.items
{
margin-top: 30px;
margin-left: 0px;
padding-left: 25px;
cursor: move;
}
.items li
{
padding: 10px;
font-size: 15px;
border: 1px solid #666;
background: #eee;
width: 400px;
margin-bottom: 15px;
float: left;
clear:both;
}
</style>
</head>
<body>
<ol id="itemlist" class="items">
<li id="1" class="item">
Item 1
<input name="status_1" type="radio" value="1" checked="checked" />enabled
<input name="status_1" type="radio" value="0" />disabled
</li>
<li id="2" class="item">
Item 2
<input name="status_2" type="radio" value="1" checked="checked" />enabled
<input name="status_2" type="radio" value="0" />disabled
</li>
<li id="3" class="item">
Item 3
<input name="status_3" type="radio" value="1" checked="checked" />enabled
<input name="status_3" type="radio" value="0" />disabled
</li>
<li id="4" class="item">
Item 4
<input name="status_4" type="radio" value="1" checked="checked" />enabled
<input name="status_4" type="radio" value="0" />disabled
</li>
</ol>
<script type="text/javascript">
$('#itemlist').sortable();
</script>
</body>
</html>
</code></pre>
<p>As soon as a list item is grabbed with the mouse, both the radio buttons get deselected.</p>
<p>If this is a bug, one workaround would be to automatically select the 'enabled' radio button when the item is moved, so any advice on how to achieve this would also be most appreciated.</p>
<p>Update: I've tested this in FireFox 3, Internet Explorer 7, Opera 9.5, and Safari 3.1.2, all on Windows XP x64, and this issue occurs in all of them.</p>
| [
{
"answer_id": 290738,
"author": "Ben Koehler",
"author_id": 11996,
"author_profile": "https://Stackoverflow.com/users/11996",
"pm_score": 1,
"selected": false,
"text": "$('#itemlist').sortable();\n"
},
{
"answer_id": 295153,
"author": "Serxipc",
"author_id": 34009,
"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/775/"
] |
285,083 | <p>I'm writing a custom JSP tag using the JSP 2 tag files. Inside my tag I would like to know which page called the tag in order to construct URLs. Is this possible with out passing it through an attribute?</p>
| [
{
"answer_id": 288438,
"author": "timdisney",
"author_id": 14481,
"author_profile": "https://Stackoverflow.com/users/14481",
"pm_score": 2,
"selected": false,
"text": "<form action=\"${pageContext.request.requestURI}\">\n"
},
{
"answer_id": 288516,
"author": "Johann Zacharee"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481/"
] |
285,095 | <p>Given a week-day (1-7), how can I calculate what that week-day's last date was?</p>
<p><strong>Example:</strong> Today is <strong>Wednesday</strong>, 2008/11/12, and I want to know what last <strong>Friday's</strong> date was.</p>
| [
{
"answer_id": 285113,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": true,
"text": "today"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15884/"
] |
285,104 | <p>For some reason sql server 2008 is not allowing me to add columns to an existing table.</p>
<p>The table is empty btw.</p>
<p>Is there a setting that prevents modifying tables in sql 2008?</p>
| [
{
"answer_id": 285113,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": true,
"text": "today"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,107 | <p>Trying to create several layers of folders at once C:\pie\applepie\recipies\
without using several different commands, is there an easy way similar to Directory.CreateDirectory()</p>
| [
{
"answer_id": 285131,
"author": "George Mastros",
"author_id": 1408129,
"author_profile": "https://Stackoverflow.com/users/1408129",
"pm_score": 4,
"selected": true,
"text": "Public Sub MakePath(ByVal Folder As String)\n\n Dim arTemp() As String\n Dim i As Long\n Dim FSO As Scr... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,139 | <p>I'm trying to duplicate the effect used in the Firefox search box where, if the search field does not have focus ( the user has not clicked inside of it ), it just says <i>Google</i> in gray text. Then, when the user clicks in the box, the text is removed and they can fill in their search term.</p>
<p>I want to use this to provide example field data for a web form.</p>
<p>JQuery syntax would be preferable to plain javascript, but plain JS would be fine too.</p>
<p>Thanks SO Hive Mind!</p>
| [
{
"answer_id": 285173,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 4,
"selected": true,
"text": "<style type='text/css'>\n input #ghost { color: #CCC; }\n input #normal { color: #OOO; }\n</style>\n\n<script type=... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,148 | <p>I've written a rails app that follows the regular directory structure (model code in models, controller code in controllers).</p>
<p>But I'm now working on a new feature and for that I have written some (what I would call) "service" code.<br>
The new feature is to import some data into the system, at the moment it's two classes to do the importing but could expand to more.</p>
<p>I don't believe the new code belongs in model as it's not modelling any object (it's not directly related to any single object either.
I certainly don't think it belongs in controller either as it's not presentation logic.</p>
<p>So, I've created a "app/services" directory and put it in there.
I've also created a "test/services" directory where I have put my tests.</p>
<p>All well and good I thought but when I run 'rake:test' or 'autotest' my new services tests are not run.<br>
Now I expect there is a way to make rake pick them up but is this a warning flag that I have done something wrong?<br>
Is there some other place the code should live or am I somehow not doing things "the Rails way"?</p>
<p>Generally whenever I've hit a problem like this before I've usually found that rails had a solution already, but I was not aware of the convention.
Is this one of those cases?</p>
| [
{
"answer_id": 285152,
"author": "Gareth",
"author_id": 31582,
"author_profile": "https://Stackoverflow.com/users/31582",
"pm_score": 6,
"selected": true,
"text": "class MyFoo\nend\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/151/"
] |
285,154 | <p>How can I access options that I set in a jQuery Datepicker?</p>
<pre><code>$("#testDatePicker").datepicker({
minDate: new Date(2005, 0, 26),
showOn: 'button',
buttonImage: 'js/themes/default/images/calendar.gif',
buttonImageOnly: true
});
var minDate = $("#testDatePicker").?????;
</code></pre>
| [
{
"answer_id": 285302,
"author": "Mauricio Scheffer",
"author_id": 21239,
"author_profile": "https://Stackoverflow.com/users/21239",
"pm_score": 2,
"selected": true,
"text": "var dpOptions = {minDate: new Date(2005, 0, 26), ...};\n$('#testDatePicker').datepicker(dpOptions);\n.\n.\n.\nvar... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10976/"
] |
285,177 | <p>Is it possible to call a constructor from another (within the same class, not from a subclass)? If yes how? And what could be the best way to call another constructor (if there are several ways to do it)?</p>
| [
{
"answer_id": 285184,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 13,
"selected": true,
"text": "public class Foo {\n private int x;\n\n public Foo() {\n this(1);\n }\n\n public Foo(int x) {\n ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33203/"
] |
285,197 | <p>I have a database table (sql server 2008) that I want to view data for, what is the quickest way of displaying this data?</p>
<p>(if it could have paging that would be perfect).</p>
<p>Would it be a gridview or ?</p>
<p>query: select * from testData</p>
| [
{
"answer_id": 285203,
"author": "Kon",
"author_id": 22303,
"author_profile": "https://Stackoverflow.com/users/22303",
"pm_score": 2,
"selected": false,
"text": "gridview.DataSource = yourDataTable;\ngridview.DataBind();\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,205 | <p>We are looking to improve our marketing email list by preventing fake emails from entering in the first place. We want to confirm that an email address exists (and that there is actually a mailbox for that email address). </p>
<p>Does anyone know of any services or components to validate an email address? </p>
| [
{
"answer_id": 285222,
"author": "Adam Alexander",
"author_id": 33164,
"author_profile": "https://Stackoverflow.com/users/33164",
"pm_score": 0,
"selected": false,
"text": "(\\w+@[a-zA-Z_]+?\\.[a-zA-Z]{2,6})\n"
},
{
"answer_id": 2795881,
"author": "Community",
"author_id"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21579/"
] |
285,214 | <p>I'm embedding an IE control into my C++ application. The problem is that although system-wide, ClearType is disabled, IE7 has its own separate setting, and unless I specifically disable that too, text inside the IE control will be antialiased while the rest of the app will not.</p>
<p>The same goes for IE7's font size setting.</p>
<p>It wouldn't be a problem for me to set up IE7 accordingly, but it would affect the experience of users of my app. Can the IE control's cleartype usage and font size be programmatically controlled?</p>
| [
{
"answer_id": 285222,
"author": "Adam Alexander",
"author_id": 33164,
"author_profile": "https://Stackoverflow.com/users/33164",
"pm_score": 0,
"selected": false,
"text": "(\\w+@[a-zA-Z_]+?\\.[a-zA-Z]{2,6})\n"
},
{
"answer_id": 2795881,
"author": "Community",
"author_id"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9665/"
] |
285,227 | <p><strong>SQL Server 2000:</strong> Is there a way to find out server memory / CPU parameters in Query Analyzer?</p>
| [
{
"answer_id": 285798,
"author": "Mladen Prajdic",
"author_id": 31345,
"author_profile": "https://Stackoverflow.com/users/31345",
"pm_score": 0,
"selected": false,
"text": "perfmon"
},
{
"answer_id": 285806,
"author": "Cade Roux",
"author_id": 18255,
"author_profile":... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,228 | <p>We have a system where customers, mainly European enter texts (in UTF-8) that has to be distributed to different systems, most of them accepting UTF-8, but now we must also distribute the texts to a US system which only accepts US-Ascii 7-bit</p>
<p>So now we'll need to translate all European characters to the nearest US-Ascii. Is there any Java libraries to help with this task?</p>
<p>Right now we've just started adding to a translation table, where Å (swedish AA)->A and so on and where we don't find any match for an entered character, we'll log it and replace with a question mark and try and fix that for the next release, but it seems very inefficient and somebody else must have done something similair before.</p>
| [
{
"answer_id": 285247,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 0,
"selected": false,
"text": "CharsetEncoder"
},
{
"answer_id": 1483057,
"author": "Rob",
"author_id": 179699,
"author_profile": "http... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30354/"
] |
285,238 | <p>Firstly I'm extending an existing class structure and cannot alter the original, with that caveat:</p>
<p>I would like to do this:</p>
<pre><code>class a
{
int val;
... // usual constructor, etc...
public int displayAlteredValue(int inp)
{
return (val*inp);
}
}
class b extends a
{
... // usual constructor, etc...
public in displayAlteredValue(int inp1, int inp2)
{
return (val*inp1*inp2);
}
}
</code></pre>
<p>As I said before I cannot alter <code>class a</code> and I want to maintain the function name <code>displayAlteredValue</code> rather than making a new function.
If this can be done I only have to change a few instantiations of <code>a</code> to instantiations of <code>b</code>. I don't want to spend a lot of time replacing the many function calls to <code>displayAlteredValue</code>. (And yes I do realise there are such things as search and replace however for other reasons, doing that would be problematic).</p>
<p>Any ideas?</p>
| [
{
"answer_id": 285258,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 1,
"selected": false,
"text": "public int displayAlteredValue(int inp)\n{\n return super.displayAlteredValue(inp);\n}\n"
},
{
"answer_id": 2852... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,251 | <p>I maintain the build system at my company, which is currently using CVS. This build system is used across multiple projects and multiple CVS repositories.</p>
<p>Whenever we have a release milestone, we create a tag. In CVS, this is easy:</p>
<pre><code>$ cvs tag TAG_NAME
</code></pre>
<p>That command works regardless of the CVS module or repository, as long as it is executed in a CVS working directory.</p>
<p>In order to do the same thing in subversion though, it looks like I will first have to parse the output of <code>svn info</code> to get the repository root. Then I can create the tag with:</p>
<pre><code>svn cp . $REPO_ROOT/tags/TAG_NAME -m"Created tag TAG_NAME"
</code></pre>
<p>This of course assumes that the svn repository has the recommended "trunk, tags, branches" directory structure. So to be safe I'll probably need to verify this first.</p>
<p>That seems like a lot of work just to map a revision number to a symbolic name. Is there a better way?</p>
| [
{
"answer_id": 285411,
"author": "bendin",
"author_id": 33412,
"author_profile": "https://Stackoverflow.com/users/33412",
"pm_score": 3,
"selected": false,
"text": "svnurl"
},
{
"answer_id": 344722,
"author": "Jason Day",
"author_id": 737,
"author_profile": "https://S... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/737/"
] |
285,276 | <p>SAP HR apparently has several models for describing the relationship between Position (S), Job (C), Organization (O) and Person (P) objects that the Organizational Management (OM) module is used to maintain.</p>
<p>P (Person) objects are usually Holders of Positions (S).</p>
<p>There is the S-S relationship model, which I am told is called Supervisory model. That is each Position reports to another position, and one of the positions is considered a manager.</p>
<p>There is another model whose name I am trying to locate, where the structure of Organizational reporting is between O objects first, in a tree structure. At each node, the S objects belong to the O object, with one of them flagged as the Manager. </p>
<p>No doubt there are other models, and if you know what they are called, and how they work, that would be very useful! </p>
<p>My perspective on this question is while trying to implement a Novell Identity Manager driver from SAP HR into an eDirectory identity vault, from there to provision users into Active Directory and Lotus Notes.</p>
<p>One of the key drivers for the project is the manager and directReports structure, so that Managers can all be identified, and the reporting structure visualized. Thus the importance of the SAP HR relationship modelling.</p>
| [
{
"answer_id": 397516,
"author": "PATRY Guillaume",
"author_id": 49804,
"author_profile": "https://Stackoverflow.com/users/49804",
"pm_score": 4,
"selected": true,
"text": "SELECT * from HRP1001 where OTYPE = 'S' \n AND RELAT = '012' \n and R... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32247/"
] |
285,277 | <p>I have some program settings that are currently stored in HKEY_LOCAL_MACHINE. Due to Vista and locked down users, some users don't have permission to HKEY_LOCAL_MACHINE, and those values don't really belong to HKEY_LOCAL_USER either (it has to be the same for all users), what's the best alternative location for storing these?</p>
<p>Majority of settings are stored in the DB already, but there are some that the program needs to know about before connecting to the DB. Ideally I'll like a way to implement this without needing to check what operating system is running.</p>
<p>This is for a desktop app written in Delphi.</p>
| [
{
"answer_id": 286027,
"author": "Rômulo Ceccon",
"author_id": 23193,
"author_profile": "https://Stackoverflow.com/users/23193",
"pm_score": 6,
"selected": true,
"text": "HKEY_CURRENT_USER"
},
{
"answer_id": 864969,
"author": "Ian Boyd",
"author_id": 12597,
"author_pr... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26305/"
] |
285,286 | <p>I have a number of string arrays. The string in every array are ordered the same way, according the same criteria. However, some string may be missing from some arrays, and there may be no array that has a complete set of strings. Moreover, the criteria used to compare the strings is not available to me: outside of the context of the array, I cannot tell which string should precede another.</p>
<p>I need a way to produce a complete set of strings, properly ordered. Or fail when the arrays do not have enough information for me to do so.</p>
<p>Is anyone familiar with this kind of problem? What is the proper algorithm?</p>
<p>Examples:</p>
<pre><code>A B D
A C D
</code></pre>
<p>Can't order correctly, can't decide the order of B and C </p>
<pre><code>A B D
A B C
A C D
</code></pre>
<p>This has enough information to order ABCD correctly.</p>
| [
{
"answer_id": 285447,
"author": "FallenAvatar",
"author_id": 36965,
"author_profile": "https://Stackoverflow.com/users/36965",
"pm_score": 3,
"selected": false,
"text": "A B D\nA B C\nA C D\n"
},
{
"answer_id": 285460,
"author": "Jay Kominek",
"author_id": 32878,
"au... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,289 | <p>I got a message saying <code>script xyz.py returned exit code 0</code>. What does this mean?</p>
<p>What do the exit codes in Python mean? How many are there? Which ones are important?</p>
| [
{
"answer_id": 285326,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 9,
"selected": true,
"text": "sys.exit()"
},
{
"answer_id": 285451,
"author": "Eigir",
"author_id": 37007,
"author_profile": "https:... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19731/"
] |
285,290 | <p>I'm having trouble sending out a simple HTTP request using Actionscript 3's Socket() object. My onConnect listener is below:</p>
<pre><code>function sConnect(e:Event):void {
trace('connected');
s.writeUTFBytes('GET /outernet/client/rss/reddit-feeds HTTP/1.1\r\n');
s.writeUTFBytes('Host: 208.43.71.50:8080\r\n');
s.writeUTFBytes('Connection: Keep-alive\r\n');
s.flush();
}
</code></pre>
<p>Using a packet sniffer, I can see the request does indeed get sent to the server, but the packet sniffer doesn't identify the protocol as HTTP like it does with other HTTP services. When I run this, the server just eventually disconnects me. I have tried to connect to other simple Apache Servers and just get a malformed request error.</p>
<p>What am I missing here?</p>
| [
{
"answer_id": 285350,
"author": "Mike Keen",
"author_id": 14182,
"author_profile": "https://Stackoverflow.com/users/14182",
"pm_score": 1,
"selected": false,
"text": "function sConnect(e:Event):void {\n trace('connected');\n s.writeUTFBytes('GET /outernet/client/rss/reddit-feeds H... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14182/"
] |
285,292 | <p>I have just started to look at .NET 3.5 so please forgive me if this type of question have been asked before. I am struggling with a decent usage for extension methods, in that I have just downloaded suteki shop an MVC ecommerce offering. In this project there is a pretty standard Repository pattern that extends IRepository. </p>
<p>In order to extend the basic functionality exposed by this interface, extention methods are used i.e.:</p>
<pre><code>public static class CategoryRepositoryExtensions
{
public static Category GetRootCategory(this IRepository<Category> categoryRepository)
{
return categoryRepository.GetById(1);
}
}
</code></pre>
<p>Now this is all well and good, but Interfaces, as far as I am concerned act as contracts to the objects that implement them. </p>
<p>The fact that the repository has been interfaced out suggests an attempt at a data layer agnostic approach. That said, if I were to create my own data layer I would be confused as to what extension methods I would have to create to ensure I have fulfilled the contractual requirement I have to the classes that implement my repository classes.</p>
<p>It seems that the older way of creating an IRepository and then extending that allows a much better visibility of what is required e.g.</p>
<pre><code>ICategoryRepoitory : IRepository<Category>
{
Category GetRootCategory();
}
</code></pre>
<p>So I guess my question is does this use of Extention methods seem wrong to anyone else? If not, why? Should I not be moaning about this?</p>
<p>EDIT:</p>
<p>The above example does seem to be a good example of why extention methods can be very helpful. </p>
<p>I suppose my issue is if data access specific implementations were stuck in the extention method in the data access mechanisms assembly. </p>
<p>That way if I were to swap it out for another mechanism I would have to create a similar extention method in that assembly. </p>
| [
{
"answer_id": 285368,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "IRepository<T>"
},
{
"answer_id": 285375,
"author": "Sunlight",
"author_id": 33650,
"author_profile":... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/425/"
] |
285,313 | <p>I have a field in a database that is nearly unique: 98% of the time the values will be unique, but it may have a few duplicates. I won't be doing many searches on this field; say twice a month. The table currently has ~5000 records and will gain about 150 per month.</p>
<p>Should this field have an index?</p>
<p>I am using MySQL.</p>
| [
{
"answer_id": 285342,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 4,
"selected": true,
"text": "select"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] |
285,314 | <p>I'm building a tool that automates a process then runs some tests on it's own results then goes to do some other stuff.</p>
<p>In trying to clean up my code I have created a separate file that just has the test cases class. Now before I can run these tests, I have to pass the class a couple of parameters/objects before they can be run. Now the problem is that I can't seem to find a way to pass a parameter/object to the test class.</p>
<p>Right now I am thinking to generate a Yaml file and read it in the test class but it feels "wrong" to use a temporary file for this. If anyone has a nicer solution that would be great!</p>
<p>**************Edit************</p>
<p>Example Code of what I am doing right now:</p>
<pre><code>#!/usr/bin/ruby
require 'test/unit/ui/console/testrunner'
require 'yaml'
require 'TS_SampleTestSuite'
automatingSomething()
importantInfo = getImportantInfo()
File.open('filename.yml', 'w') do |f|
f.puts importantInfo.to_yaml
end
Test::Unit::UI::Console::TestRunner.run(TS_SampleTestSuite)
</code></pre>
<p>Now in the example above TS_SampleTestSuite needs importantInfo, so the first "test case" is a method that just reads in the information from the Yaml file filname.yml. </p>
<p>I hope that clears up some confusion.</p>
| [
{
"answer_id": 285342,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 4,
"selected": true,
"text": "select"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37080/"
] |
285,320 | <p>I need your advice with converting plain text to an URL.</p>
<p>The scenario will be this: The user will select some entry and then click a "convert to link" button. </p>
<p>The entry text the user selected will convert to <code>(link: selected_text)</code>. I do it with JavaScript. And after that, when he clicks the Save button to save all his entry, I don't know how to store <code>(link: selected_text)</code> in tha database.</p>
<p>The URL will be like this: <code>www.mysite.aspx?t=selected_text</code>. </p>
<p>I can convert <code>(link: selected_text)</code> by using replace function in code-behind. But then I don't know how to show user as clickable and also by not showing <code><a href="www.mysite.aspx?t=selected_text"></code></p>
<p>It can be difficult to understand therefore I will show some of my codes to explain.</p>
<pre><code>Private Sub Save(ByVal Entry As String) ' Entry Comes from entry textbox '
Dim elected As String
selected = Entry.Replace("(link: ", "<a href http://www.mysite.com?link=")
selected = Entry.Replace(")", ">")
' then here starts save but not necessary to show '
End Sub
</code></pre>
| [
{
"answer_id": 286456,
"author": "Serhat Ozgel",
"author_id": 31505,
"author_profile": "https://Stackoverflow.com/users/31505",
"pm_score": 1,
"selected": false,
"text": "(link: here)\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,323 | <p>I have an <code>ICollection<T></code> called <code>foos</code> in my class which I want to expose as read-only (see <a href="https://stackoverflow.com/questions/284090/how-to-get-a-readonlycollectiont-of-the-keys-in-a-dictionaryt-s">this question</a>). I see that the interface defines a property <code>.IsReadOnly</code>, which seems appropriate... My question is this: how do I make it obvious to the consumer of the class that <code>foos</code> is read-only? </p>
<p>I don't want to rely on them remembering to query <code>.IsReadOnly</code> before trying a not-implemented method such as <code>.Add()</code>. Ideally, I would like to expose <code>foos</code> as a <code>ReadOnlyCollection<T></code>, but it does not implement <code>IList<T></code>. Should I expose <code>foo</code> via a method called, for example, <code>GetReadOnlyFooCollection</code> rather than via a property? If so, would this not confuse someone who then expects a <code>ReadOnlyCollection<T></code>? </p>
<p>This is C# 2.0, so extension methods like <code>ToList()</code> are not available...</p>
| [
{
"answer_id": 285360,
"author": "bruno conde",
"author_id": 31136,
"author_profile": "https://Stackoverflow.com/users/31136",
"pm_score": 4,
"selected": false,
"text": "ReadOnlyCollection<T> readOnlyCollection = foos.ToList<T>().AsReadOnly();\n"
},
{
"answer_id": 285389,
"au... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6091/"
] |
285,343 | <p>I've got an SQL query that looks like this:</p>
<pre><code>INSERT INTO DB..incident
(
incident_number --nvarchar(10)
)
VALUES
(
N'I?'
)
</code></pre>
<p>What does the ? do in the value statement?</p>
<p>EDIT:: Turns out there's some funny business via triggers and custom datatypes that occur on insert (we've got a bit of a messed up DB.) Given normal settings I've marked the answer appropriately.</p>
| [
{
"answer_id": 285366,
"author": "TGnat",
"author_id": 25121,
"author_profile": "https://Stackoverflow.com/users/25121",
"pm_score": 4,
"selected": true,
"text": "DECLARE @TestTable TABLE (test NVARCHAR(10))\n\nINSERT INTO @TestTable (\n test\n) VALUES ( \n N'I?' ) \n\n\nSELECT * \... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33226/"
] |
285,345 | <p>This exception is consistently thrown on a SOAP Request which takes almost three minutes to receive and is 2.25 megs in size. </p>
<p>When scouring the web I find all sorts of posts which all seem to be about setting headers on the Request, some want me to not send the "Expect:" header, some want me to send the "Keep-Alive:" header, but irregardless of the headers I send I still get this pesky error. I don't believe that setting any headers is my answer, because <em>I can recreate the exact same request using "curl" and a response does eventually come back with no problems what-so-ever</em>. </p>
<p>My <code><httpRuntime maxRequestLength="409600" executionTimeout="900"/></code>. </p>
<p>I feel as if I'm running out of options. If anyone can provide any assistance I would be most grateful. A few other things to note would be that the server I'm Requesting data from is out of my hands, also these requests are over https and other requests with smaller responses work flawlessly.</p>
<p>Thanks</p>
| [
{
"answer_id": 285542,
"author": "Robert Wagner",
"author_id": 10784,
"author_profile": "https://Stackoverflow.com/users/10784",
"pm_score": 4,
"selected": false,
"text": "<system.serviceModel>\n <bindings>\n <basicHttpBinding>\n <binding name=\"BasicHttpBinding\" maxBuffe... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21909/"
] |
285,372 | <p>Is there a way to have the compile deduce the template parameter automatically?</p>
<pre><code>template<class T>
struct TestA
{
TestA(T v) {}
};
template<class T>
void TestB(T v)
{
}
int main()
{
TestB (5);
}
</code></pre>
<p>Test B works fine, however when i change it to TestA it will not compile with the error " use of class template requires template argument list"</p>
| [
{
"answer_id": 285380,
"author": "Sunlight",
"author_id": 33650,
"author_profile": "https://Stackoverflow.com/users/33650",
"pm_score": 5,
"selected": true,
"text": "make_"
},
{
"answer_id": 285533,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "ht... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,383 | <p>Given my current .htaccess file, how would I modify it to check for an additional URL path like '/src/pub/<em>' and rewrite it to '/</em>' without affecting the current rewrite?</p>
<p>Here's the original .htaccess file:</p>
<pre><code>RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]
</code></pre>
<p>and here's my recent attempt (which doesn't work):</p>
<pre><code>RewriteEngine on
RewriteRule ^/src/pub/(.*)$ /$1 [R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]
</code></pre>
<p><strong>Edit:</strong> Here are some examples of what I want to accomplish:</p>
<p>New Additional Rule:</p>
<pre><code>From: http://www.mysite.com/src/pub/validfile.php
To: http://www.mysite.com/validfile.php
From: http://www.mysite.com/src/pub/user/detail/testuser
To: http://www.mysite.com/user/detail/testuser
</code></pre>
<p>Existing Rule (already working):</p>
<pre><code>From: http://www.mysite.com/user/detail/testuser
To: http://www.mysite.com/index.php?route=user/detail/testuser
</code></pre>
| [
{
"answer_id": 285420,
"author": "TimB",
"author_id": 4193,
"author_profile": "https://Stackoverflow.com/users/4193",
"pm_score": 4,
"selected": true,
"text": "RewriteRule ^/src/pub/(.*)$ /$1 [R,L]\n"
},
{
"answer_id": 285433,
"author": "Owen",
"author_id": 4853,
"aut... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] |
285,400 | <p>The Win32 API call <a href="http://msdn.microsoft.com/en-us/library/ms221570.aspx" rel="noreferrer">RegisterTypeLib()</a> is used to create the registry keys necessary to register a type library.</p>
<p>Unfortunatly, on Windows XP, it tries to write those registry key entries to </p>
<pre><code>HKEY_CLASSES_ROOT\TypeLib
</code></pre>
<p>rather than </p>
<pre><code>HKEY_CURRENT_USER\Software\Classes\TypeLib
</code></pre>
<p>Meaning that a standard user will not be able to run an ActiveX.</p>
<p>In May 2008 Microsoft released a <a href="http://support.microsoft.com/kb/935200" rel="noreferrer">hotfix for Vista</a> to correct this issue - but the problem remains on Windows XP.</p>
<p>What's a standard-user friendly developer to do?</p>
<hr>
<h2>Answer 1</h2>
<p>Use the API call that is designed for it:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms221504.aspx" rel="noreferrer">RegisterTypeLibraryForUser()</a></p>
<h2>Answer 2</h2>
<p>If you can't fix it, hack it:</p>
<pre><code>//begin hack
HKEY key;
RegOpenKeyW(HKEY_CURRENT_USER, @"Software\Classes", out key);
RegOverridePredefKey(HKEY_CLASSES_ROOT, key);
//do original work
RegisterTypeLibrary(...)
//stop hacking
RegOverridePredefKey(HKEY_CLASSES_ROOT, null);
RegCloseKey(key);
</code></pre>
| [
{
"answer_id": 285454,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 4,
"selected": true,
"text": "RegOverridePredefKey()"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12597/"
] |
285,408 | <p>I'm looking for a Python module that would take an arbitrary block of text, search it for something that looks like a date string, and build a DateTime object out of it. Something like <a href="http://search.cpan.org/~sartak/Date-Extract-0.03/lib/Date/Extract.pm" rel="noreferrer">Date::Extract</a> in Perl</p>
<p>Thank you in advance.</p>
| [
{
"answer_id": 285677,
"author": "Brian",
"author_id": 9493,
"author_profile": "https://Stackoverflow.com/users/9493",
"pm_score": 5,
"selected": true,
"text": ">>> from dateutil.parser import parse\n>>> parse(\"Wed, Nov 12\")\ndatetime.datetime(2008, 11, 12, 0, 0)\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37089/"
] |
285,421 | <p>I've asked a few <a href="https://stackoverflow.com/questions/150513/html-input-style-to-hide-the-box-but-show-the-contents">other questions</a> here about this system, so I'll try to avoid repeating a lot of detail.</p>
<p>The short version is that I have many html pages, each with a form that accepts input, but never saves the input anywhere- they are only ever printed out for mailing. A previously developer who had never heard of <code>@media print</code> did the initial work on most of them, and so he came up with some... <em>odd</em> solutions to hide the ugly text boxes on the printed page, usually resulting in two completely separate copies of nearly the same html. Unfortunately, that broke the back button in many cases, and so now I must go back and fix them. </p>
<hr>
<p>In some cases, these html forms really are form letters, with text inputs in the middle of the text. I can style the text inputs so that the box doesn't show, but they are still the wrong size. This results in a bunch of extra ugly whitespace where it doesn't belong. How can make the inputs fit the text entered by the user?</p>
<p>The best I can come up with at the moment is to have a hidden <span> next to each input that is styled to show instead of the input when printing, and use javascript to keep it in sync. But this is ugly. I'm looking for something better.</p>
<p><strong>Update:</strong><br>
Most of our users are still in IE6, but we have some IE7 and firefox out there.</p>
<p><strong>Update2:</strong><br>
I re-thought this a little to use a label rather than a span. I'll maintain the relationship using the label's <code>for</code> attribute. See <a href="https://stackoverflow.com/questions/285522/find-html-label-associated-with-a-given-input">this question</a> for my final code.</p>
| [
{
"answer_id": 285677,
"author": "Brian",
"author_id": 9493,
"author_profile": "https://Stackoverflow.com/users/9493",
"pm_score": 5,
"selected": true,
"text": ">>> from dateutil.parser import parse\n>>> parse(\"Wed, Nov 12\")\ndatetime.datetime(2008, 11, 12, 0, 0)\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3043/"
] |
285,422 | <p>When editing really long code blocks (which should definitely be refactored anyway, but that's beyond the scope of this question), I often long for the ability to collapse statement blocks like one can collapse function blocks. That is to say, it would be great if the minus icon appeared on the code outline for everything enclosed in braces. It seems to appear for functions, classes, regions, namespaces, usings, but not for conditional or iterative blocks. It would be fantastic if I could collapse things like ifs, switches, foreaches, that kind of thing!</p>
<p>Googling into that a bit, I discovered that apparently C++ outlining in VS allows this but C# outlining in VS does not. I don't really get why. Even notepad++ will so these collapses if I select the C# formatting, so I don't get why Visual Studio doesn't.</p>
<p>Does anyone know of a VS2008 add-in that will enable this behavior? Or some sort of hidden setting for it?</p>
<p>Edited to add: inserting regions is of course an option and it did already occur to me, but quite frankly, I shouldn't have to wrap things in a region that are already wrapped in braces... if I was going to edit the existing code, I would just refactor it to have better separation of concern anyway. ("wrapping" with new methods instead of regions ;)</p>
| [
{
"answer_id": 285430,
"author": "Kon",
"author_id": 22303,
"author_profile": "https://Stackoverflow.com/users/22303",
"pm_score": 4,
"selected": false,
"text": "foreach (Item i in Items)\n{\n #region something big happening here\n ...\n #endregion\n\n #region something big happening... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12975/"
] |
285,428 | <p>I am trying to make the <a href="http://docs.jquery.com/Plugins/Validation" rel="nofollow noreferrer">Validation plugin</a> work. It works fine for individual fields, but when I try to include the demo code for the error container that contains all of the errors, I have an issue. The problem is that it shows the container with all errors when I am in all fields, but I would like to display the error container only when the user presses the submit button (but still show inline errors beside the control when losing focus).</p>
<p>The problem is the message in the container. When I took off the code as mentioned in the answer below for the container, the container output just displays the number of errors in plain text. </p>
<p>What is the trick to get a list of detailed error messages? What I would like is to display "ERROR" next to the control in error when the user presses the tab button, and to have a summary of everything at the end when he presses submit. Is that possible?</p>
<p><strong>Code with all input from here:</strong></p>
<pre><code> $().ready(function() {
var container = $('div.containererreurtotal');
// validate signup form on keyup and submit
$("#frmEnregistrer").bind("invalid-form.validate", function(e, validator) {
var err = validator.numberOfInvalids();
if (err) {
container.html("THERE ARE "+ err + " ERRORS IN THE FORM")
container.show();
} else {
container.hide();
}
}).validate({
rules: {
nickname_in: {
required: true,
minLength: 4
},
prenom_in: {
required: true,
minLength: 4
},
nom_in: {
required: true,
minLength: 4
},
password_in: {
required: true,
minLength: 4
},
courriel_in: {
required: true,
email: true
},
userdigit: {
required: true
}
},
messages: {
nickname_in: "ERROR",
prenom_in: "ERROR",
nom_in: "ERROR",
password_in: "ERROR",
courriel_in: "ERROR",
userdigit: "ERROR"
}
,errorPlacement: function(error, element){
container.append(error.clone());
error.insertAfter(element);
}
});
});
</code></pre>
| [
{
"answer_id": 285799,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "<div id=\"container\" style=\"display:none;\"></div>\n"
},
{
"answer_id": 286032,
"author": "user19264",
"aut... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] |
285,429 | <p>Under normal circumstances, a VB.NET application of mine can check the ClientName environmental variable to get the name of the workstation the user is connecting from.</p>
<p>So when WorkstationX RDPs into ServerA:</p>
<ul>
<li>ComputerName=ServerA</li>
<li>ClientName=WorkstationX</li>
</ul>
<p>That works fine.</p>
<p>If I right-click on the application and choose Run As Administrator, the ClientName variable is not set.</p>
<p>Does anyone know of a way of easily getting the workstation name of the client connected to the terminal server, even when the application is launched via "Run As Administrator"?</p>
| [
{
"answer_id": 732558,
"author": "Dan Ports",
"author_id": 88885,
"author_profile": "https://Stackoverflow.com/users/88885",
"pm_score": 2,
"selected": false,
"text": "New Cassia.TerminalServicesManager().CurrentSession.ClientName\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3743/"
] |
285,440 | <p>In a .NET CF application I wrote, one of the features is to acquire frames from remote cameras. Frames are acquired as single jpeg images and displayed on the screen when available.</p>
<p>It was a good enough solution, but I don't like the fact that the time needed to convert the stream into an <code>Image</code> object, with the <code>Bitmap()</code> constructor, is <em>far far far larger</em> than the time needed to download the stream.</p>
<p>When I surfed some blogs to search about this issue, I found that some developers were using the <code>Image.FromStream()</code> method which has a <code>validateImageData</code> flag that seems to control some validation code. When <code>validateImageData</code> is false, the conversion gets dramatically faster.</p>
<p>Good, I thought .... but the Compact Framework does not implement this method !</p>
<p>Anyone knows how to get around it, or at least how to convert a stream into an <code>Image</code> without unnecessary delays ?</p>
| [
{
"answer_id": 732558,
"author": "Dan Ports",
"author_id": 88885,
"author_profile": "https://Stackoverflow.com/users/88885",
"pm_score": 2,
"selected": false,
"text": "New Cassia.TerminalServicesManager().CurrentSession.ClientName\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36728/"
] |
285,445 | <p>Simple yes or no question, and I'm 90% sure that it is no... but I'm not sure.</p>
<p>Can a Base64 string contain tabs?</p>
| [
{
"answer_id": 285457,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 0,
"selected": false,
"text": "Convert.FromBase64String()"
},
{
"answer_id": 285515,
"author": "Tim Jarvis",
"author_id": 10387,
... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16794/"
] |
285,446 | <p>I've got a Windows Forms application with two ListBox controls on the same form.
They both have their SelectionMode set to 'MultiExtended'. </p>
<p>When I change the selection of one the selection of the other changes.</p>
<p>Now I thought I'd done something stupid with my SelectedIndexChanged handlers so I removed them and re-wrote them from scratch, and got the problem.</p>
<p>So I created a brand new WinForms app and dragged two ListBoxes onto the forms surface.</p>
<p>In the constructor I populated them both with the following.</p>
<pre><code>List<Thing> data = new List<Thing>();
for ( int i = 0; i < 50; i++ ) {
Thing temp = new Thing();
temp.Letters = "abc " + i.ToString();
temp.Id = i;
data.Add(temp);
}
listBox1.DataSource = data;
listBox1.DisplayMember = "Letters";
listBox1.ValueMember = "Id";
List<Thing> data2 = new List<Thing>();
for ( int i = 0; i < 50; i++ ) {
Thing temp = new Thing();
temp.Letters = "abc " + i.ToString();
temp.Id = i;
data2.Add(temp);
}
listBox2.DataSource = data2;
listBox2.DisplayMember = "Letters";
listBox2.ValueMember = "Id";
</code></pre>
<p>And then I built and ran the app.</p>
<p>Started selecting some values to see if the symptoms were present.
And they were!</p>
<p>This is literally all the code I added to the form,I had not added any event handlers, I have tried it with the SelectionMode set to 'One' and 'MultiExtended'.</p>
<p>Can anyone give me a clue as to why this is happening.</p>
<p>Cheers</p>
| [
{
"answer_id": 285488,
"author": "Shaun Bowe",
"author_id": 1514,
"author_profile": "https://Stackoverflow.com/users/1514",
"pm_score": 0,
"selected": false,
"text": "public partial class Form1 : Form\n{\npublic Form1()\n{\n InitializeComponent();\n}\n\nprivate class Thing\n{\n public ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1741868/"
] |
285,455 | <p>I have some global variables in a Python script. Some functions in that script call into C - is it possible to set one of those variables while in C and if so, how?</p>
<p>I appreciate that this isn't a very nice design in the first place, but I need to make a small change to existing code, I don't want to embark on major refactoring of existing scripts.</p>
| [
{
"answer_id": 285498,
"author": "Sherm Pendley",
"author_id": 27631,
"author_profile": "https://Stackoverflow.com/users/27631",
"pm_score": 5,
"selected": true,
"text": "PyObject *m = PyImport_AddModule(\"__main__\");\nPyObject *v = PyObject_GetAttrString(m,\"foobar\");\n\nint foobar = ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22517/"
] |
285,456 | <p>Given the following, how could I insert rows in my db? (Or what should I correct in my schema?)</p>
<p>Models:</p>
<pre><code>class Item < ActiveRecord::Base
has_many :tran_items
has_many :transactions, :through => :tran_items
end
class TranItem < ActiveRecord::Base
belongs_to :item
belongs_to :transaction
end
class Transaction < ActiveRecord::Base #answer: rename Transaction
has_many :tran_items
has_many :items, :through => :tran_items
end
</code></pre>
<p>Schema:</p>
<pre><code>create_table :items do |t|
t.references :tran_items #answer: remove this line
t.string :name
end
create_table :tran_items do |t|
t.belongs_to :items, :transactions, :null => false #answer: unpluralize
t.integer :quantity
end
create_table :transactions do |t|
t.references :tran_items #answer: remove this line
t.decimal :profit
end
</code></pre>
<p>I lost a few hours trying to insert records, using the rails console to test things out.</p>
| [
{
"answer_id": 285471,
"author": "tamersalama",
"author_id": 7693,
"author_profile": "https://Stackoverflow.com/users/7693",
"pm_score": 1,
"selected": false,
"text": "item = Item.new(:name => \"item\")\nitem.transactions.build(:name => \"transaction\")\nitem.save!\n"
},
{
"answe... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25167/"
] |
285,465 | <p>Hi Guys I'm very new to regex, can you help me with this.</p>
<p>I have a string like this <code>"<input attribute='value' >"</code> where <code>attribute='value'</code> could be anything and I want to get do a <code>preg_replace</code> to get just <code><input /></code></p>
<p>How do I specify a wildcard to replace any number of any characters in a srting?</p>
<p>like this? <code>preg_replace("/<input.*>/",$replacement,$string);</code></p>
<p>Many thanks</p>
| [
{
"answer_id": 285479,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 3,
"selected": false,
"text": ".*\n"
},
{
"answer_id": 285483,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,474 | <p>If I have 2 DataTables (dtOne and dtTwo) and I want to merge them and put them in another DataTable (dtAll). How can I do this in C#? I tried the Merge statement on the datatable, but this returns void. Does Merge preserve the data? For example, if I do:</p>
<pre><code> dtOne.Merge(dtTwo);
</code></pre>
<p>Does dtOne change or does dtTwo change and if either one changes, do the changes preserve?</p>
<p>I know I can't do this because Merge returns void, but I want to be able to store the Merger of both dtOne and dtTwo in dtAll:</p>
<pre><code>//Will Not work, How do I do this
dtAll = dtOne.Merge(dtTwo);
</code></pre>
| [
{
"answer_id": 285500,
"author": "Jeromy Irvine",
"author_id": 8223,
"author_profile": "https://Stackoverflow.com/users/8223",
"pm_score": 8,
"selected": true,
"text": "Merge"
},
{
"answer_id": 454453,
"author": "Community",
"author_id": -1,
"author_profile": "https:/... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] |
285,477 | <p>This is something that comes up so often I almost stopped thinking about it but I'm almost certain that I'm not doing this the best way.</p>
<p>The question: Suppose you have the following table</p>
<pre><code>CREATE TABLE TEST_TABLE
(
ID INTEGER,
TEST_VALUE NUMBER,
UPDATED DATE,
FOREIGN_KEY INTEGER
);
</code></pre>
<p>What is the best way to select the TEST_VALUE associated with the most recently updated row where FOREIGN_KEY = 10?</p>
<p><strong>EDIT:</strong> Let's make this more interesting as the answers below simply go with my method of sorting and then selecting the top row. Not bad but for large returns the order by would kill performance. So bonus points: how to do it in a scalable manner (ie without the unnecessary order by).</p>
| [
{
"answer_id": 285485,
"author": "George Mauer",
"author_id": 5056,
"author_profile": "https://Stackoverflow.com/users/5056",
"pm_score": 1,
"selected": false,
"text": "SELECT TEST_VALUE\nFROM TEST_TABLE\nWHERE ID = (\n SELECT ID\n FROM (\n SELECT ID\n FROM TEST_TABLE\n WHERE ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] |
285,482 | <p>We've got an app with some legacy printer "setup" code that we are still using <code><a href="http://msdn.microsoft.com/en-us/library/ms646940(VS.85).aspx" rel="nofollow noreferrer">PrintDlg</a></code> for. We use a custom template to allow the user to select which printer to use for various types of printing tasks (such as reports or drawings) along with orientation and paper size/source.</p>
<p>It works on XP and 32-bit Vista, but on Vista x64 it gets a <code>CDERR_MEMLOCKFAILURE</code> via <code>CommDlgExtendedError()</code>. I've tried running it with just the bare-bones input in the <code>PRINTDLG</code> structure, but if the parameters include <code>PD_PRINTSETUP</code> or <code>PD_RETURNDEFAULT</code>, I get that error.</p>
<p>Since the printer selection / page setup has been split into <code><a href="http://msdn.microsoft.com/en-us/library/ms646937(VS.85).aspx" rel="nofollow noreferrer">PageSetupDlg</a></code> and <code><a href="http://msdn.microsoft.com/en-us/library/ms646942(VS.85).aspx" rel="nofollow noreferrer">PrintDlgEx</a></code>, there is no apparent easy transition without changing a fair amount of code and/or changing completely how we present printing and printer setup to the user.</p>
<p>Has anyone seen this problem on 64-bit Vista, and have you found any work-arounds?</p>
<p><b>Notes:</b><br>
Application runs as Administrator due to other constraints</p>
| [
{
"answer_id": 453486,
"author": "AZDean",
"author_id": 12058,
"author_profile": "https://Stackoverflow.com/users/12058",
"pm_score": 0,
"selected": false,
"text": "using System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.Drawing.Printing;\nusing System.Print... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1441/"
] |
285,495 | <p>I am binding an SPGridView to a SPList. As code samples suggest, I am using the following code to create a dataview based on the list. </p>
<pre><code>dim data as DataView = myList.Items.GetDataTable.DefaultView
grid.DataSource = data
etc...
</code></pre>
<p>What I am finding is that the column names in the resulting dataview do not always match the source fields defined in the SPList. For example I have columns named </p>
<ul>
<li>Description </li>
<li>ReportItem</li>
<li><p>ReportStatus</p>
<p>these show up in the resulting dataview with column names like </p></li>
<li>ReportType0</li>
<li>ReportStatus1</li>
</ul>
<p>This leads me to think that I have duplicate field names defined, but that does not seem to be the case.</p>
<p>Seems like I am missing something fundamental here?
Thanks.</p>
| [
{
"answer_id": 285590,
"author": "Abs",
"author_id": 1245,
"author_profile": "https://Stackoverflow.com/users/1245",
"pm_score": 3,
"selected": true,
"text": "GetDataTable"
},
{
"answer_id": 470181,
"author": "Community",
"author_id": -1,
"author_profile": "https://St... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10552/"
] |
285,502 | <p>This code works in Firefox, Internet Explorer, not in Safari/Chrome:</p>
<pre><code><head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<script>
function newDiv() {
var div = $('<div id="divNew" style="width: 50px; height: 50px; border: solid 1px; background: Red"></div>');
$('#divParent').append(div);
div.draggable(
{
containment: 'parent'
});
}
</script>
</head>
<body>
<a href="javascript:;" onclick="newDiv()">new div</a>
<div id="divParent" style="width: 500px; height: 500px; border: solid 1px;"></div>
</body>
</code></pre>
<p>In Safari/Chrome, the divNew can only be moved vertically. jQuery's this feature is currently incompatible? I am using 1.5.2 stable version.It can be found here <a href="http://jquery-ui.googlecode.com/files/jquery.ui-1.5.2.zip" rel="nofollow noreferrer">jQuery 1.5.2</a></p>
| [
{
"answer_id": 474619,
"author": "jacobangel",
"author_id": 31318,
"author_profile": "https://Stackoverflow.com/users/31318",
"pm_score": 2,
"selected": false,
"text": " <script>\n function newDiv() {\n var divs = \n $(unescape('%3Cdiv class=\"divNew\" s... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37122/"
] |
285,521 | <p>I am making a post from a .NET console app to a .NET web service. I know that the timeout on the server side is 20 min, but if my client takes more than 100 seconds to post my data to that service then I get a timeout exception. How would I tell my client to wait the available 20 min to timeout?</p>
| [
{
"answer_id": 285536,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 3,
"selected": false,
"text": "myServiceInstance.Timeout = 1200000\n"
},
{
"answer_id": 285547,
"author": "Vin",
"author_id": 1747,
"autho... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13593/"
] |
285,522 | <p>Let's say I have an html form. Each input/select/textarea will have a corresponding <code><label></code> with the <code>for</code> attribute set to the id of it's companion. In this case, I know that each input will only have a single label.</p>
<p>Given an input element in javascript — via an onkeyup event, for example — what's the best way to find it's associated label?</p>
| [
{
"answer_id": 285560,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 4,
"selected": false,
"text": "var labels = document.getElementsByTagName(\"LABEL\"),\n lookup = {},\n i, label;\n\nfor (i = 0; i < labels.length; ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3043/"
] |
285,523 | <p>Is there a way to determine if the loop is iterating for the last time. My code looks something like this:</p>
<pre><code>int[] array = {1, 2, 3...};
StringBuilder builder = new StringBuilder();
for(int i : array)
{
builder.append("" + i);
if(!lastiteration)
builder.append(",");
}
</code></pre>
<p>Now the thing is I don't want to append the comma in the last iteration. Now is there a way to determine if it is the last iteration or am I stuck with the for loop or using an external counter to keep track.</p>
| [
{
"answer_id": 285530,
"author": "Dinah",
"author_id": 356,
"author_profile": "https://Stackoverflow.com/users/356",
"pm_score": 5,
"selected": false,
"text": "StringBuilder"
},
{
"answer_id": 285534,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36858/"
] |
285,524 | <p>With the following code:</p>
<pre><code>Dim x As System.Xml.Linq.XElement = _
<div>
<%= message.ToString() %>
</div>
Dim m = x.ToString()
</code></pre>
<p>...if message is HTML, then the < and > characters get converted to <code>&lt;</code> and <code>&rt;</code>. </p>
<p>How can I force it to skip this encoding?</p>
| [
{
"answer_id": 805559,
"author": "CoderDennis",
"author_id": 69527,
"author_profile": "https://Stackoverflow.com/users/69527",
"pm_score": 4,
"selected": true,
"text": "message"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337/"
] |
285,551 | <p>I have a data acquisition program written in C++ (Visual Studio 6.0). Some clients would like to control the software from their own custom software or LabView. I would like to come up with a simple API with a dll I can distribute to them and would like some tips on how to get started. This is going to be VERY basic, maybe 4 or 5 commands. My DAQ program will still be running in its own window on the same machine, I would just like to set it up to be controlled from another program.</p>
| [
{
"answer_id": 286745,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 2,
"selected": false,
"text": "stdcall"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6320/"
] |
285,553 | <p>I need to be able to store a date (year/month/day) with no time component. It's an abstract concept of a date, such as a birthday - I need to represent a date in the year and not a particular instant in time.</p>
<p>I am using Java to parse the date from some input text, and need to store in a MySQL database. No matter what timezone the database, application, or any client is in, they should all see the same year/month/day.</p>
<p>My application will run on a machine with a different system timezone from the database server, and I don't have control over either. Does anyone have an elegant solution for ensuring I store the date correctly?</p>
<p>I can think of these solutions, neither of which seems very nice:</p>
<ul>
<li>Query my MySQL connection for its timezone and parse the input date in that timezone</li>
<li>Process the date entirely as a string yyyy-MM-dd</li>
</ul>
| [
{
"answer_id": 285656,
"author": "Ben Noland",
"author_id": 32899,
"author_profile": "https://Stackoverflow.com/users/32899",
"pm_score": 2,
"selected": false,
"text": "public static Date truncateDate(Date date)\n {\n GregorianCalendar cal = getGregorianCalendar();\n cal... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37134/"
] |
285,572 | <p>I've previously encountered the suggestion to call System.Threading.Thread.Sleep(0); in tights loops in C# to prevent CPU hogging and used it to good effect.</p>
<p>I have a PowerShell script that has a tight loop and I'm wondering whether I should be calling [Thread]::Sleep(0) or Start-Sleep 0 or whether the PS engine will yield for me occasionally.</p>
| [
{
"answer_id": 288453,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 4,
"selected": true,
"text": "[Thread]::CurrentThread.ThreadPriority = System.Threading.ThreadPriority.Lowest\n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20819/"
] |
285,573 | <p>I have googled quite a bit and I cannot find the answer. So how many characters can be stored in a Windows Installer property value. If you give an answer can you provide the source of the answer?</p>
| [
{
"answer_id": 286037,
"author": "saschabeaumont",
"author_id": 592,
"author_profile": "https://Stackoverflow.com/users/592",
"pm_score": 2,
"selected": false,
"text": "Property"
},
{
"answer_id": 286072,
"author": "Brody",
"author_id": 17131,
"author_profile": "https... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2768/"
] |
285,579 | <p>I'm fairly new to c# so that's why I'm asking this here.</p>
<p>I am consuming a web service that returns a long string of XML values. Because this is a string all the attributes have escaped double quotes</p>
<pre><code>string xmlSample = "<root><item att1=\"value\" att2=\"value2\" /></root>"
</code></pre>
<p>Here is my problem. I want to do a simple string.replace. If I was working in PHP I'd just run strip_slashes().</p>
<p>However, I'm in C# and I can't for the life of me figure it out. I can't write out my expression to replace the double quotes (") because it terminates the string. If I escape it then it has incorrect results. What am I doing wrong?</p>
<pre><code> string search = "\\\"";
string replace = "\"";
Regex rgx = new Regex(search);
string strip = rgx.Replace(xmlSample, replace);
//Actual Result <root><item att1=value att2=value2 /></root>
//Desired Result <root><item att1="value" att2="value2" /></root>
</code></pre>
<blockquote>
<p>MizardX: To include a quote in a raw string you need to double it. </p>
</blockquote>
<p>That's important information, trying that approach now...No luck there either
There is something going on here with the double quotes. The concepts you all are suggesting are solid, BUT the issue here is dealing with the double quotes and it looks like I'll need to do some additional research to solve this problem. If anyone comes up with something please post an answer.</p>
<pre><code>string newC = xmlSample.Replace("\\\"", "\"");
//Result <root><item att=\"value\" att2=\"value2\" /></root>
string newC = xmlSample.Replace("\"", "'");
//Result newC "<root><item att='value' att2='value2' /></root>"
</code></pre>
| [
{
"answer_id": 285603,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 2,
"selected": false,
"text": "\\"
},
{
"answer_id": 285624,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30408/"
] |
285,584 | <p>I am currently stuck on an ASP.NET error when trying to access a .aspx page through localhost. This is the error:</p>
<p><strong>OCIEnvCreate failed with return code -1 but error message text was not available.</strong></p>
<p><strong>Description</strong>: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.</p>
<p><strong>Exception Details</strong>: System.Exception: OCIEnvCreate failed with return code -1 but error message text was not available. </p>
<p><strong>Stack Trace:</strong></p>
<pre><code>[Exception: OCIEnvCreate failed with return code -1 but error message text was not available.]
System.Data.OracleClient.OciHandle..ctor(OciHandle parentHandle, HTYPE handleType, MODE ocimode, HANDLEFLAG handleflags) +363
System.Data.OracleClient.OciEnvironmentHandle..ctor(MODE environmentMode, Boolean unicode) +23
System.Data.OracleClient.OracleInternalConnection.OpenOnLocalTransaction(String userName, String password, String serverName, Boolean integratedSecurity, Boolean unicode, Boolean omitOracleConnectionName) +122
System.Data.OracleClient.OracleInternalConnection..ctor(OracleConnectionString connectionOptions) +135
System.Data.OracleClient.OracleConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +36
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +68
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +519
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +104
System.Data.OracleClient.OracleConnection.Open() +37
Wilson.ORMapper.Internals.Connection..ctor(String connectString, CustomProvider customProvider) +287
[ORMapperException: ObjectSpace: Connection String is Invalid - OCIEnvCreate failed with return code -1 but error message text was not available.]
Wilson.ORMapper.Internals.Connection..ctor(String connectString, CustomProvider customProvider) +357
Wilson.ORMapper.Internals.Context.Init(XmlDocument xmlMappings, String connectString, CustomProvider customProvider, Int32 sessionMinutes, Int32 cleanupMinutes) +92
Wilson.ORMapper.Internals.Context..ctor(Stream mappingStream, String connectString, CustomProvider customProvider, Int32 sessionMinutes, Int32 cleanupMinutes) +171
Wilson.ORMapper.ObjectSpace..ctor(Stream mappingStream, String connectString, Provider providerType, Int32 sessionMinutes, Int32 cleanupMinutes) +66
zedi.DataManager.GetDefaultInstance() in C:\projects\FINE Application Interface\Production\On-site Backlog\Source\Code\DataAccess\ORClasses\Data\DataManager.cs:155
zedi.DataManager.get_ObjectSpaceGlobal() in C:\projects\FINE Application Interface\Production\On-site Backlog\Source\Code\DataAccess\ORClasses\Data\DataManager.cs:105
zedi.DataManager.get_ObjectSpace() in C:\projects\FINE Application Interface\Production\On-site Backlog\Source\Code\DataAccess\ORClasses\Data\DataManager.cs:129
zedi.DataObjects.CompanyBase.RetrieveQuery(ObjectQuery query) in C:\projects\FINE Application Interface\Production\On-site Backlog\Source\Code\DataAccess\ORClasses\DataObjects\Base\CompanyBase.cs:279
zedi.DataObjects.CompanyBase.RetrieveAll(String sortClause) in C:\projects\FINE Application Interface\Production\On-site Backlog\Source\Code\DataAccess\ORClasses\DataObjects\Base\CompanyBase.cs:78
maint_inetpub.siteTemplates.updateDeviceTemplate.Page_Load(Object sender, EventArgs e) in c:\projects\FINE Application Interface\Production\On-site Backlog\Source\Code\Websites\maint-inetpub\siteTemplates\updateDeviceTemplate.aspx.cs:47
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
</code></pre>
<p>I notice it says the I have an invalid connection string but I have tested it and it works. I currently have Oracle 10g Express installed and before that I had Oracle 8i Client. It was working before I installed 10g Express. </p>
| [
{
"answer_id": 36290730,
"author": "AnisNoorAli",
"author_id": 5977038,
"author_profile": "https://Stackoverflow.com/users/5977038",
"pm_score": 0,
"selected": false,
"text": "\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.5"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37140/"
] |
285,586 | <p>I have a script that constantly segfaults - the problem that I can't solve as segfault is in python libxml bindings - didn't write those. Ok, so in Linux I used to run an inf.loop so that when script dies - it restarts, like so:</p>
<pre><code>#!/bin/bash
while [ 1 ]
do
nice -n 19 python server.py
sleep 1
done
</code></pre>
<p>Well, I can't seem to find /bin/bash in FreeBSD so that doesn't work. </p>
<p>Any ideas? Consider that cron is not an option - allowed downtime is a few seconds.</p>
| [
{
"answer_id": 285609,
"author": "David Thornley",
"author_id": 14148,
"author_profile": "https://Stackoverflow.com/users/14148",
"pm_score": 1,
"selected": false,
"text": "type bash"
},
{
"answer_id": 285610,
"author": "Evan Teran",
"author_id": 13430,
"author_profil... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37141/"
] |
285,591 | <p>Is it possible to use the __unused attribute macro on Objective-C object method parameters? I've tried placing it in various positions around the parameter declaration but it either causes a compilation error or seems to be ignored (i.e., the compiler still generates unused parameter warnings when compiling with -Wall -Wextra).</p>
<p>Has anyone been able to do use this? Is it just unsupported with Objective-C? For reference, I'm currently using Apple's build of GCC 4.0.1.</p>
| [
{
"answer_id": 285702,
"author": "Louis Gerbarg",
"author_id": 30506,
"author_profile": "https://Stackoverflow.com/users/30506",
"pm_score": 2,
"selected": false,
"text": "- (NSString *) test:(__unused NSString *)test {\n return nil;\n}\n"
},
{
"answer_id": 285750,
"author... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34218/"
] |
285,614 | <p>Every night I need to trim back a table to only contain the latest 20,000 records. I could use a subquery:</p>
<pre><code>delete from table WHERE id NOT IN (select TOP 20000 ID from table ORDER BY date_added DESC)
</code></pre>
<p>But that seems inefficient, especially if we later decide to keep 50,000 records. I'm using SQL 2005, and thought I could use ROW_NUMBER() OVER somehow to do it? Order them and delete all that have a ROW_NUMBER greater than 20,000? But I couldn't get it to work. Is the subquery my best bet or is there a better way?</p>
| [
{
"answer_id": 285851,
"author": "Borzio",
"author_id": 36215,
"author_profile": "https://Stackoverflow.com/users/36215",
"pm_score": 2,
"selected": false,
"text": "select top 20000 * into #myTempTable from MyTable ORDER BY DateAdded DESC\n"
},
{
"answer_id": 285914,
"author"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10876/"
] |
285,617 | <p>I'd like to call svn up from an asp.net page so people can hit the page to update a repository. (BTW: I'm using Beanstalk.com svn hosting which doesn't allow post-commit hooks, which is why I am doing it this way). </p>
<p>See what I've got below. The process starts (it shows up in Processes in Task Manager) and exits after several seconds with no output message (at least none is outputted to the page). The repository does not get updated. But it does do something with the repository because the next time I try to manually update it from the command line it says the repo is locked. I have to run svn cleanup to get it to update. </p>
<p>Ideas?</p>
<pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
startInfo = New System.Diagnostics.ProcessStartInfo("svn")
startInfo.RedirectStandardOutput = True
startInfo.UseShellExecute = False
startInfo.Arguments = "up " & Request.QueryString("path")
pStart.StartInfo = startInfo
pStart.Start()
pStart.WaitForExit()
Response.Write(pStart.StandardOutput.ReadToEnd())
End Sub
</code></pre>
| [
{
"answer_id": 286989,
"author": "Bert Huijben",
"author_id": 2094,
"author_profile": "https://Stackoverflow.com/users/2094",
"pm_score": 0,
"selected": false,
"text": "using(SvnClient client = new SvnClient())\n{\n client.Update(Request[\"path\"]);\n}\n"
},
{
"answer_id": 4943... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,618 | <p>Another angle:
how do I browse all the XUL for a given chrome path, e.g.</p>
<p><a href="http://kb.mozillazine.org/Dev_:_Firefox_Chrome_URLs" rel="nofollow noreferrer">http://kb.mozillazine.org/Dev_:_Firefox_Chrome_URLs</a> has a listing but seems to be out of date.</p>
| [
{
"answer_id": 476769,
"author": "Jason S",
"author_id": 44330,
"author_profile": "https://Stackoverflow.com/users/44330",
"pm_score": 1,
"selected": false,
"text": "chrome://"
},
{
"answer_id": 498352,
"author": "ephemient",
"author_id": 20713,
"author_profile": "htt... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34594/"
] |
285,619 | <p>I have an input String say <code>Please go to http://stackoverflow.com</code>. The url part of the String is detected and an anchor <code><a href=""></a></code> is automatically added by many browser/IDE/applications. So it becomes <code>Please go to <a href='http://stackoverflow.com'>http://stackoverflow.com</a></code>.</p>
<p>I need to do the same using Java.</p>
| [
{
"answer_id": 285667,
"author": "Jason Coco",
"author_id": 34218,
"author_profile": "https://Stackoverflow.com/users/34218",
"pm_score": 3,
"selected": false,
"text": "String originalString = \"Please go to http://www.stackoverflow.com\";\nString newString = originalString.replaceAll(\"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37144/"
] |
285,649 | <p>I have a web application that is using a data store that has it's own built in paging. The PagedResult class tells me the number of total pages. What I would like to do it (after binding my ASP.NET GridView) do this:</p>
<pre><code>MyGridView.PageCount = thePageCount;
</code></pre>
<p>And then have the GridView magically build the pagination links as it normally would if it was doing things itself.</p>
<p>The problem is that "PageCount" is a read-only property... so, how can I do this simply?</p>
| [
{
"answer_id": 1725048,
"author": "Randi",
"author_id": 209916,
"author_profile": "https://Stackoverflow.com/users/209916",
"pm_score": 0,
"selected": false,
"text": " Dim myCount as Integer = 1 'this sets the page count to 1 \n While (oreader.Read())\n myCount += ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11917/"
] |
285,658 | <p>Is there a way in FreeBSD to (being root) run a command as unprivileged user, like nobody? Kind of like reverse of sudo. Oh and considering that 'nobody' has /usr/sbin/nologin as shell - so <b>su</b> is not an option.</p>
| [
{
"answer_id": 285693,
"author": "DrStalker",
"author_id": 17007,
"author_profile": "https://Stackoverflow.com/users/17007",
"pm_score": 6,
"selected": true,
"text": "sudo -u nobody <command>\n"
},
{
"answer_id": 3234272,
"author": "Brad Ackerman",
"author_id": 113222,
... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37141/"
] |
285,660 | <p>In Vim I can <code>:set wrapscan</code> so that when I do an incremental search, the cursor jumps to the first match whether the first match is above or below the cursor.</p>
<p>In Emacs, if I start a search via <code>C-s</code>, the search fails saying <em>Failing I-search</em> if the first match is above the cursor. If I hit <code>C-s</code> again it then wraps the search, saying <em>Wrapped I-search</em>. How do I wrap and jump the cursor by default as in Vim, without having to <code>C-s</code> a second time?</p>
| [
{
"answer_id": 287067,
"author": "link0ff",
"author_id": 23952,
"author_profile": "https://Stackoverflow.com/users/23952",
"pm_score": 5,
"selected": true,
"text": "(defadvice isearch-repeat (after isearch-no-fail activate)\n (unless isearch-success\n (ad-disable-advice 'isearch-repe... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23070/"
] |
285,662 | <pre><code>some_var = foo()
another_var = bar()
</code></pre>
<p>or</p>
<pre><code>some_var = foo()
another_var = bar()
</code></pre>
<p>Including changing the whitespace as lines are added or removed to keep them lined up. Does this really look good? Is it worth the mucking up of the diff?</p>
| [
{
"answer_id": 285678,
"author": "Patrick Szalapski",
"author_id": 7453,
"author_profile": "https://Stackoverflow.com/users/7453",
"pm_score": 1,
"selected": false,
"text": "some_var[ 1] = \"foo\";\nsome_var[100] = \"bar\";\n"
},
{
"answer_id": 285681,
"author": "Paige Ruten... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19687/"
] |
285,666 | <p>I need to know how to return a default row if no rows exist in a table. What would be the best way to do this? I'm only returning a single column from this particular table to get its value. </p>
<p>Edit: This would be SQL Server. </p>
| [
{
"answer_id": 285699,
"author": "Jason Anderson",
"author_id": 1530166,
"author_profile": "https://Stackoverflow.com/users/1530166",
"pm_score": 1,
"selected": false,
"text": "select '' as columnA, '' as columnB, '' as columnC from #tempTable\n"
},
{
"answer_id": 285701,
"au... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26923/"
] |
285,674 | <p>In firefox, the error messages display as should. Just to the right of the element being validated. In IE. No matter what I do with the sizing of the labels/elements/errors, the error is always posted below the element, causing every other element to be pushed down.</p>
<pre><code><p>
<label for="handle"><strong>User Name</strong></label>
<INPUT NAME="handle" id="handle" VALUE="#attributes.getUser.handle#">
</p>
<p>
<label for="password"><strong>Password</strong></label>
<INPUT TYPE="TEXT" id="password" NAME="password"
MAXLENGTH=50 VALUE="#attributes.getUser.password#">
</p>
<p>
<label for="confirmPassword"><strong>Confirm Password</strong></label>
<INPUT TYPE="TEXT" id="confirmPassword" NAME="confirmPassword"
MAXLENGTH=50 VALUE="#attributes.getUser.password#">
</p>
</code></pre>
<p>If anyone else has had this issue, i'd be very grateful for any help.</p>
| [
{
"answer_id": 285699,
"author": "Jason Anderson",
"author_id": 1530166,
"author_profile": "https://Stackoverflow.com/users/1530166",
"pm_score": 1,
"selected": false,
"text": "select '' as columnA, '' as columnB, '' as columnC from #tempTable\n"
},
{
"answer_id": 285701,
"au... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26121/"
] |
285,680 | <p>I understand that BigDecimal is recommended best practice for representing monetary values in Java. What do you use? Is there a better library that you prefer to use instead?</p>
| [
{
"answer_id": 285707,
"author": "ninesided",
"author_id": 1030,
"author_profile": "https://Stackoverflow.com/users/1030",
"pm_score": 7,
"selected": true,
"text": "BigDecimal"
},
{
"answer_id": 285709,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "htt... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32595/"
] |
285,685 | <p>Here is a nice underhand lob pitch to you guys.</p>
<p>So basically I've got my content table with unique primary key IDs and I've got my tag table with unique primary key IDs. </p>
<p>I've got a table that has an identity column as a primary key but the two other columes are the contentID and tagID. What do I need to do to the table to make sure that I only have the same contentID and tagID combo only once.</p>
| [
{
"answer_id": 285697,
"author": "John Lemp",
"author_id": 12915,
"author_profile": "https://Stackoverflow.com/users/12915",
"pm_score": 2,
"selected": false,
"text": "ALTER TABLE ContentTag ADD CONSTRAINT\n IX_ContentID_TagID_Unique UNIQUE NONCLUSTERED ( contentID, tagID ) \nGO\n"
... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37154/"
] |
285,687 | <p>I would like to edit XHTML files using Emacs' <a href="http://www.emacswiki.org/emacs/NxmlMode" rel="nofollow noreferrer">nxml-mode</a> which can use <a href="http://infohost.nmt.edu/tcc/help/pubs/rnc/" rel="nofollow noreferrer">rnc</a> schemas for on the fly validation. This is all built in to newer Emacs versions.</p>
<p>However, my XHTML files contain elements from another schema. So <foo:foo> tags are valid, but only within the <xhtml:head> of the document.</p>
<p>Currently, nxml complains because the XHTML schema it is using does not describe the foo tag. How do I create a new schema which describes the foo tag in relation to the existing XHTML schema, and how do I apply that schema automatically using <a href="http://www.dpawson.co.uk/relaxng/nxml/schemaloc.html" rel="nofollow noreferrer">schema locating rules</a> in the schemas.xml file?</p>
<p>ie: I would like to validate a document using two schemas simultaneously: the built-in XHTML rules, and some custom rules which add certain namespaced tags.</p>
| [
{
"answer_id": 285697,
"author": "John Lemp",
"author_id": 12915,
"author_profile": "https://Stackoverflow.com/users/12915",
"pm_score": 2,
"selected": false,
"text": "ALTER TABLE ContentTag ADD CONSTRAINT\n IX_ContentID_TagID_Unique UNIQUE NONCLUSTERED ( contentID, tagID ) \nGO\n"
... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,700 | <p>i'm looking for a way to programatically convert word documents in docx format to doc format without using ole automation. i already have a windows service that does this but it means installing office on a server and it is a little unreliable and not supported. i am aware of the aspose.words product, and i will try it out, but has anyone any recommendations for how to do this as simply, reliably, and cheaply as possible?</p>
| [
{
"answer_id": 320854,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 4,
"selected": false,
"text": "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Shared Tools\\Text Converters\\Import\\Word12 \n"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3142/"
] |
285,710 | <p>Some of the platforms that I develop on, don't have profiling tools. I am looking for suggestions/techniques that you have personally used to help you identify hotspots, without the use of a profiler.</p>
<p>The target language is C++.</p>
<p>I am interested in what you have personally used.</p>
| [
{
"answer_id": 285926,
"author": "Andreas Magnusson",
"author_id": 5811,
"author_profile": "https://Stackoverflow.com/users/5811",
"pm_score": 4,
"selected": true,
"text": "#ifdef PROFILING\n# define PROFILE_CALL(x) do{ \\\n const DWORD t1 = timeGetTime(); \\\n x; \\\n const DWO... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] |
285,712 | <p>I have a file (called "number.txt") which I want to read to an array in Java. How exactly do I go ahead and do this? It is a straight-forward "1-dimensional" file, containing 100 numbers.</p>
<p>The problem is that I get an exception every time. Apparently it can't find it (I am sure its spelled correctly). When looking through code examples, it doesn't specify the file's entire file path, only the name of the file itself. How would I go about doing that if its necessary?</p>
<p>Also, when reading the file, will the array automatically contain all the lines of the file, or will I have to make a loop which which copies every line to corresponding subscript i?</p>
<p>I've heard of BufferedReader class, what it's purpose, and how does it corelate to reading input?</p>
| [
{
"answer_id": 285745,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 6,
"selected": false,
"text": "package com.acme;\n\nimport java.io.BufferedReader;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.ut... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37161/"
] |
285,715 | <h2>Background</h2>
<p>We are developing some in-house utilities using ASP.NET 2.0. One of which is extracting some information from databases and building an Excel workbook containing a number of spreadsheets with data based on queries into the database.</p>
<h2>Problem</h2>
<p>The proof-of-concept prototype (a simple ASP.NET page that queries a single item from the database and opens Excel to add data to a worksheet) is working well when run locally on the development machines, happily creating and displaying an Excel spreadsheet as requested. However, when run on our server, we get the following error upon trying to instantiate Excel .</p>
<p>Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).</p>
<h2>Solution?</h2>
<p>We are using the PIA for Excel 2003 and we have Excel 2003 and the PIA installed on the server. Can anyone explain why this isn't working or give us some tips on how we might track the problem down?</p>
<p>Thanks for any assistance you can provide.</p>
| [
{
"answer_id": 285745,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 6,
"selected": false,
"text": "package com.acme;\n\nimport java.io.BufferedReader;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.ut... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23234/"
] |
285,716 | <p>I have written a program that gets input from a usb second keyboard (actually a barcode scanner). The problem is that if another window is active the data is input there rather than in my program. Could someone give me advice on what I'm doing wrong?</p>
<pre><code>#include <stdio.h>
#include <string.h>
int main(int argc, char * argv[]){
FILE * fp_in;
char * data;
fp_in = fopen("/dev/input/by-id/usb-04d9_1400-event-kbd","r");
if(fp_in == NULL){
fprintf(stderr,"Failed to open input by id\n");
}
fp_in = fopen("/dev/input/by-path/pci-0000:00:1d.1-usb-0:2:1.0-event-kbd","r");
if(fp_in == NULL){
fprintf(stderr,"Failed to open input by path\n");
return 1;
}
while(1){
fscanf(fp_in,data,"%s");
fprintf(stderr,"%s",data);
}
return 0;
}
</code></pre>
<p>thanks
<hr>
If I may be so bold as to rephrase the question on Confuzzled's behalf:</p>
<p>How can I write a program under Linux that attaches itself to an input device, in this case a barcode scanner, so that the input does not go to the program that has the keyboard focus?</p>
| [
{
"answer_id": 21819422,
"author": "admiralswan",
"author_id": 3317403,
"author_profile": "https://Stackoverflow.com/users/3317403",
"pm_score": 2,
"selected": false,
"text": "xinput list"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37163/"
] |
285,717 | <p>What's the best way to run scheduled tasks in a Rails environment? Script/runner? Rake? I would like to run the task every few minutes.</p>
| [
{
"answer_id": 287107,
"author": "webmat",
"author_id": 6349,
"author_profile": "https://Stackoverflow.com/users/6349",
"pm_score": 4,
"selected": false,
"text": "# from ~\n/path/to/ruby /path/to/app/script/runner -e development \"MyClass.class_method\"\n/path/to/ruby /path/to/rake -f /p... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13195/"
] |
285,718 | <p>I'm using MediaTemple's (dv) hosting service. How do I determine what mail-server is installed? Should I use the shell? If so, what command would be used?</p>
| [
{
"answer_id": 285739,
"author": "Adam Pierce",
"author_id": 5324,
"author_profile": "https://Stackoverflow.com/users/5324",
"pm_score": 4,
"selected": false,
"text": "telnet <hostname> 25\n"
},
{
"answer_id": 285918,
"author": "Federico A. Ramponi",
"author_id": 18770,
... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,723 | <p>I'm a .NET developer, and worked with VB6 before that. I've become very familiar with those environments, and working in the context of garbage collected languages. However, I now wish to bolster my skillset with native C++ and find myself a bit overwhelmed. Ironically, it's not what I'd imagine is the usual stumbling blocks for beginners as I feel that I've got the grasp of pointers and memory management fairly well. The thing that's a bit confusing for me is more along the lines of:</p>
<ul>
<li>Referencing/using other libraries</li>
<li>Exposing <em>my</em> libraries for others to use</li>
<li>String handling</li>
<li>Data type conversions</li>
<li>Good project structure</li>
<li>Data structures to use (ie. in C#, I use <code>List<T></code> a lot, what do I use in C++ that works simiarly?)</li>
</ul>
<p>It almost feels like depending on the IDE you use, the guidelines are different, so I was really looking for something that's perhaps a bit more universal. Or at worst, focused on using Microsoft's compiler/IDE. Also, just to be clear, I'm not looking for anything about general programming practices (Design Patterns, Code Complete, etc.) as I feel I'm pretty well versed in those topics.</p>
| [
{
"answer_id": 285819,
"author": "jalf",
"author_id": 33213,
"author_profile": "https://Stackoverflow.com/users/33213",
"pm_score": 9,
"selected": true,
"text": "List<T>"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5416/"
] |
285,730 | <p>I'm attempting to bind a <code>DependancyProperty</code> in one of my usercontrols to the <code>Width</code> property of a <code>Column</code> in a <code>Grid</code>. </p>
<p>I have code similar to this:</p>
<pre><code><Grid x:Name="MyGridName">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="TitleSection" Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>...</Grid.RowDefinitions>
<GridSplitter x:Name="MyGridSplitter" Grid.Row="0" Grid.Column="0" ... />
</Grid>
</code></pre>
<p>In a separate Usercontrol I have the following<code>DependancyProperty</code> defined.</p>
<pre><code>public static readonly DependencyProperty TitleWidthProperty = DependencyProperty.Register("TitleWidth", typeof(int), typeof(MyUserControl));
public int TitleWidth
{
get { return (int)base.GetValue(TitleWidthProperty); }
set { base.SetValue(TitleWidthProperty, value); }
}
</code></pre>
<p>I am creating instances of the Usercontrol in code, hence I have a binding statement similar to this :</p>
<pre><code>MyUserControl Cntrl = new MyUserControl(/* Construction Params */);
BindingOperations.SetBinding(Cntrl , MyUserControl.AnotherProperty, new Binding { ElementName = "objZoomSlider", Path = new PropertyPath("Value"), Mode = BindingMode.OneWay });
BindingOperations.SetBinding(Cntrl , MyUserControl.TitleWidthProperty, new Binding { ElementName = "TitleSection", Path = new PropertyPath("ActualWidth"), Mode = BindingMode.OneWay });
/* Other operations on Cntrl */
</code></pre>
<p>The first binding defined works fantastically, although that is binding to an actual UIElement (in this case a Slider), but the Binding to "TitleSection" (which is the ColumnDefinition defined in the Grid) fails. Putting a breakpoint in the code and doing a watch on "TitleSection" returns the expected object. </p>
<p>I am beginning to suspect that a x:Name'd ColumnDefinition can't be bound to. <strong>Can anyone suggest how I might be able to bind to the changing width of the first column in my grid?</strong></p>
<p><strong>EDIT #1 - To answer comments</strong></p>
<p>The databinding 'fails' in the sense that with a breakpoint set on the setter for the <code>TitleWidth</code> property, and using the GridSplitter control to resize the first column, the breakpoint is never hit. Additionally, code I would expect to be fired when the DependancyProperty <code>TitleWidth</code> changes does not get executed.</p>
<p>The usercontrol is being created and added to a Stackpanel within the Grid in the <code>Window_Loaded</code> function. I would expect that the Grid has been rendered by the time the Usercontrols are being constructed. Certainly the x:Name'd Element <code>TitleSection</code> is watchable and has a value of <code>100</code> when they are being constructed / before the binding is happening.</p>
<p><strong>EDIT #2 - Possibly something to do with this?</strong></p>
<p>I've been having a sniff round the MSDN pages for the Grid ColumnDefinition documentation and have come across <a href="http://msdn.microsoft.com/en-us/library/system.windows.gridlength.aspx" rel="nofollow noreferrer">GridLength()</a> but I can't get my head around how I can use this in a binding expression. I cannot use the associated GridLengthConverter as a converter in the binding code as it does not derive from IValueConverter. </p>
<p>I am leaning towards somehow binding to the ActualWidth property of one of the cells in the Grid object. It doesn't seem as clean as binding to the column definition, but at the moment I cannot get that to work.</p>
| [
{
"answer_id": 286695,
"author": "Ian Oakes",
"author_id": 21606,
"author_profile": "https://Stackoverflow.com/users/21606",
"pm_score": 2,
"selected": false,
"text": "<ColumnDefinition \n x:Name=\"TitleSection\" \n Width=\"{Binding \n Path=TitleWidth, \n ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31128/"
] |
285,731 | <p>I have two C DLLs that I need to access in the same executable. I have header files and .LIB files for both libraries. Unfortunately a subset of the functions that I need to access have the exact same names. The best solution I have been able to come up with so far is to use LoadLibrary to load one of the DLLs and explicitly call its methods using GetProcAddress. Is there a way for me to implicitly load both libraries and somehow give the compiler a hint that in one case I want to call OpenApi in DLL A and in the other case I want to call OpenApi in DLL B?</p>
<p>I'm developing my executable in C++ using Visual Studio 2008 and the corresponding C runtime library (msvcr90.dll).</p>
<p>[Edit]</p>
<p>Commenter Ilya asks below what I don't like about the GetProcAddress solution. I don't like it for two reasons:</p>
<ol>
<li>It makes the code more complex. One line of code to call a function is replaced with three lines of code, one to define the function signature, one to call GetProcAddress, and one to actually call the function. </li>
<li>It's more prone to run-time errors. If I misspell the function name or mess up the signature I don't see the error until run-time. Say I decide to integrate a new version of the dll and one of the method names has changed, it will compile just fine and won't have a problem until the actual call to GetProcAddress, which could possibly even be missed in a test pass.</li>
</ol>
| [
{
"answer_id": 285758,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 3,
"selected": true,
"text": "LoadLibrary()/GetProcAddress()"
}
] | 2008/11/12 | [
"https://Stackoverflow.com/questions/285731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37155/"
] |
285,733 | <p>I've tried the following, but I was unsuccessful:</p>
<pre><code>ALTER TABLE person ALTER COLUMN dob POSITION 37;
</code></pre>
| [
{
"answer_id": 285740,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 8,
"selected": true,
"text": "attnum"
},
{
"answer_id": 27886259,
"author": "marcopolo",
"author_id": 4442083,
"author_profile": ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10040/"
] |
285,754 | <p>So, let's say I want to write a class that operates on different kinds of numbers, but I don't a priori know what kind of numbers (i.e. ints, doubles, etc.) I will be operating on.</p>
<p>I would like to use generics to create a general class for this scenario. Something like:</p>
<pre><code> Adder<Double> adder = new Adder<Double>();
adder.add(10.0d, 10.0d); // = 20.0d
</code></pre>
<p>But, I cannot instantiate the generic type I pass in to my Adder class! So -- what to do?</p>
| [
{
"answer_id": 285773,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 4,
"selected": true,
"text": "Double"
},
{
"answer_id": 285812,
"author": "Paul Brinkley",
"author_id": 18160,
"author_profile": "https... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10675/"
] |
285,760 | <p>I need to spawn a child process that is a console application, and capture its output.</p>
<p>I wrote up the following code for a method:</p>
<pre><code>string retMessage = String.Empty;
ProcessStartInfo startInfo = new ProcessStartInfo();
Process p = new Process();
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
startInfo.Arguments = command;
startInfo.FileName = exec;
p.StartInfo = startInfo;
p.Start();
p.OutputDataReceived += new DataReceivedEventHandler
(
delegate(object sender, DataReceivedEventArgs e)
{
using (StreamReader output = p.StandardOutput)
{
retMessage = output.ReadToEnd();
}
}
);
p.WaitForExit();
return retMessage;
</code></pre>
<p>However, this does not return anything. I don't believe the <code>OutputDataReceived</code> event is being called back, or the <code>WaitForExit()</code> command may be blocking the thread so it will never callback.</p>
<p>Any advice?</p>
<p><strong>EDIT:</strong> Looks like I was trying too hard with the callback. Doing:</p>
<pre><code>return p.StandardOutput.ReadToEnd();
</code></pre>
<p>Appears to work fine.</p>
| [
{
"answer_id": 285841,
"author": "Judah Gabriel Himango",
"author_id": 536,
"author_profile": "https://Stackoverflow.com/users/536",
"pm_score": 8,
"selected": false,
"text": "process.StartInfo.UseShellExecute = false;\nprocess.StartInfo.RedirectStandardOutput = true;\nprocess.OutputData... | 2008/11/12 | [
"https://Stackoverflow.com/questions/285760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.