qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
355,318 | <ol>
<li><p><strong>How do i redirect a url to domain .</strong>
eg. <a href="http://www.mydomain.com/index.php=HairThing" rel="nofollow noreferrer">http://www.mydomain.com/index.php=HairThing</a> --> <a href="http://www.mydomain.com" rel="nofollow noreferrer">http://www.mydomain.com</a></p></li>
<li><p><strong>How do i redirect a non-www to www WITHOUT a slash at end ?</strong></p></li>
</ol>
<p>eg <a href="http://mydomain.com" rel="nofollow noreferrer">http://mydomain.com</a> ---> <a href="http://www.mydomain.com" rel="nofollow noreferrer">http://www.mydomain.com</a></p>
| [
{
"answer_id": 355339,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 2,
"selected": false,
"text": "#1\nRewriteRule /index.php=HairThing$ http://www.mydomain.com [R=301]\n\n#2\nRewriteCond %{HTTP_HOST} ^mydomain.com \... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
355,327 | <p>Does thread-safety of SQLite3 mean different threads can modify the same table of a database concurrently?</p>
| [
{
"answer_id": 2894848,
"author": "Jeremiah Rose",
"author_id": 234383,
"author_profile": "https://Stackoverflow.com/users/234383",
"pm_score": 2,
"selected": false,
"text": "check_same_thread"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/355327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26404/"
] |
355,333 | <p>I have a client that thought a highly dynamic ASP.NET application was a very simple sytem, yet to implement it in the manner in which they needed for future grown it has grown to well over 100 different code files.</p>
<p>I am looking for a way, most likely with some sort of static code analysis tool to put some numbers that might "make sense" to a non-technical person. I fully understand that Lines of Code and other metrics are not really "valid" items to evaluate, but in this case this is the type of thing I need, Lines of Code, Number of XML comments, Total Files, Total Folders. </p>
<p>I know I can look some of these up, but I'm looking for an easy way to get these values in bulk! I found a few old posts here, but nothing that specifically talked about .NET (Current versions) and/or C#.</p>
<p>Ideally I want something that can investigate a C# WAP project. SQL Server would be an AWESOME value add, but not a 100% needed item!</p>
| [
{
"answer_id": 2894848,
"author": "Jeremiah Rose",
"author_id": 234383,
"author_profile": "https://Stackoverflow.com/users/234383",
"pm_score": 2,
"selected": false,
"text": "check_same_thread"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/355333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13279/"
] |
355,343 | <p>Does anyone know how to acess a url from a windows application?.</p>
<p>I have an address <a href="http://serverport/Page.I" rel="nofollow noreferrer">http://serverport/Page.I</a> want to acess this page from my windows application.</p>
<p>Regards,
Harsh Suman</p>
| [
{
"answer_id": 355348,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 2,
"selected": false,
"text": "WebBrowser"
},
{
"answer_id": 355380,
"author": "Stein G. Strindhaug",
"author_id": 26115,
"author_profile... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
355,355 | <p>I am using <a href="http://www.svnkit.com" rel="nofollow noreferrer">SVNKit</a> in my application. I have a scenario wherein certain files should be ignored when doing svn operations. i.e. I need to set the svn:ignore property for certain patterns.</p>
<p>How do I do that using SVNKit?</p>
| [
{
"answer_id": 355363,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": true,
"text": "addIgnorePattern()"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/355355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35392/"
] |
355,358 | <p>I can't connect to the default web site in IIS 6.0 using localhost or 127.0.0.1 or by server name. When I telnet to port 80 with one of these names, there's no connection.</p>
<p>However other web sites are running and I can telnet using any of the ip addresses.
I can ping to localhost where 127.0.0.1 is responding.
The default web site is running. It's not stopped.</p>
| [
{
"answer_id": 356083,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": 0,
"selected": false,
"text": "*.(your site url)"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/355358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5232/"
] |
355,365 | <p>The Java AtomicInteger class has a method -</p>
<pre><code>boolean weakCompareAndSet(int expect,int update)
</code></pre>
<p>Its documnentation says:</p>
<blockquote>
<p>May fail spuriously.</p>
</blockquote>
<p>What does 'failing spuriously' here mean?</p>
| [
{
"answer_id": 355374,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 3,
"selected": false,
"text": "CompareAndSet()"
},
{
"answer_id": 355392,
"author": "VonC",
"author_id": 6309,
"author_profile":... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14316/"
] |
355,386 | <p>Please let me know why there is lot of white space below the page content and also why horizontal scroll bar is displayed. Attaching link to zip folder below. Unzip and open index.html.<br />
<a href="http://shivanand.in/tmp/Basic_Profile.zip" rel="nofollow noreferrer">link text</a></p>
| [
{
"answer_id": 355421,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": true,
"text": "div#content"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/355386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34642/"
] |
355,398 | <p>How do I segment a 2D image into blobs of similar values efficiently? The given input is a n array of integer, which includes hue for non-gray pixels and brightness of gray pixels.</p>
<p>I am writing a virtual mobile robot using Java, and I am using segmentation to analyze the map and also the image from the camera. This is a well-known problem in <a href="http://en.wikipedia.org/wiki/Computer_vision" rel="nofollow noreferrer">Computer Vision</a>, but when it's on a robot performance does matter so I wanted some inputs. Algorithm is what matters, so you can post code in any language.</p>
<ul>
<li>Wikipedia article: <a href="http://en.wikipedia.org/wiki/Segmentation_%28image_processing%29" rel="nofollow noreferrer">Segmentation (image processing)</a></li>
<li><a href="http://robots.stanford.edu/cs223b04/CS%20223-B%20L11%20Segmentation.ppt" rel="nofollow noreferrer">[PPT] Stanford CS-223-B Lecture 11 Segmentation and Grouping</a> (which says Mean Shift is perhaps the best technique to date)</li>
<li><a href="http://www.caip.rutgers.edu/~comanici/MSPAMI/msPamiResults.html" rel="nofollow noreferrer">Mean Shift Pictures</a> (paper is also available from <a href="http://www.caip.rutgers.edu/~comanici/" rel="nofollow noreferrer">Dorin Comaniciu</a>)</li>
</ul>
| [
{
"answer_id": 355417,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 0,
"selected": false,
"text": "UNSEGMENTED"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/355398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3827/"
] |
355,425 | <p>I need to write a script to change a filename from aDate.txt to bDate.txt where:</p>
<ul>
<li>aDate is the current system date in <em>yyyymmdd</em> format and </li>
<li>bDate is the current system date - 1 in <em>yyyymmdd</em> format.</li>
</ul>
<p>I currently have:</p>
<pre><code>set yy=%date:~6,2%
set mm=%date:~3,2%
set dd=%date:~0,2%
if "%date:~6,1%"==" " set yy=0%yy:~1,1%
if "%date:~3,1%"==" " set mm=0%mm:~1,1%
if "%date:~0,1%"==" " set dd=0%dd:~1,1%
SET sys_date=20%yy%%mm%%dd%
ECHO %sys_date%
REM still have to do this bit properly
SET sys_date_yesterday=%sys_date%a
move %sys_date%.txt %sys_date_yesterday%.txt
</code></pre>
<p>but I have no idea how to do the date -1 thing (other than the long winded) subtract 1 from the day and if that is = 0 then subtract one from the month and set the day = to the last day of the new month and so on for years.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 355561,
"author": "wimh",
"author_id": 33499,
"author_profile": "https://Stackoverflow.com/users/33499",
"pm_score": 3,
"selected": false,
"text": "@echo off\n\nset yyyy=\n\nset $tok=1-3\nfor /f \"tokens=1 delims=.:/-, \" %%u in ('date /t') do set $d1=%%u\nif \"%$d1:~0,1%\... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/939/"
] |
355,447 | <p>I have some documentation written in OpenOffice, and I would like to include some of it as PDF files in the final build deliveries. I would like to do this with the automated build script.</p>
<p>Is there a way to create a PDF file from OpenOffice with a command line command?</p>
| [
{
"answer_id": 355470,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 5,
"selected": true,
"text": " File inputFile = new File(\"C:\\\\oreyes\\\\hola.doc\"); \n File outputFile = new File(\"C:\\\\oreyes\\\\ho... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6482/"
] |
355,449 | <p>Hey folks - I'm writing a pretty simple iPhone application. The data comes from a plist file (NSDictionary basically), that I'm trying to load into a singleton class and use across my various view controllers to access the data.</p>
<p>Here's the implementation for my singleton (heavily modeled after <a href="https://stackoverflow.com/questions/145154/what-does-your-objective-c-singleton-look-like">this thread</a>)</p>
<pre><code>@implementation SearchData
@synthesize searchDict;
@synthesize searchArray;
- (id)init {
if (self = [super init]) {
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"searches.plist"];
searchDict = [NSDictionary dictionaryWithContentsOfFile:finalPath];
searchArray = [searchDict allKeys];
}
return self;
}
- (void)dealloc {
[searchDict release];
[searchArray release];
[super dealloc];
}
static SearchData *sharedSingleton = NULL;
+ (SearchData *)sharedSearchData {
@synchronized(self) {
if (sharedSingleton == NULL)
sharedSingleton = [[self alloc] init];
}
return(sharedSingleton);
}
@end
</code></pre>
<p>So whenever I try to access the searchDict or searchArray properties elsewhere in my application (like a TableView delegate) like so:</p>
<pre><code>[[[SearchData sharedSearchData] searchArray] objectAtIndex:indexPath.row]
</code></pre>
<p>I get an exception stating *** -[NSCFSet objectAtIndex:]: unrecognized selector sent to instance 0x5551f0</p>
<p>I'm not really sure why the objectAtIndex message is being sent to an NSCFSet object, I feel like my singleton is implemented wrong or something. I also tried a more complex singleton implementation like the one recommended by apple in the <a href="https://stackoverflow.com/questions/145154/what-does-your-objective-c-singleton-look-like">aforementioned thread</a> and had the same problem. Thanks for any insight you can provide.</p>
| [
{
"answer_id": 355461,
"author": "Ashley Clark",
"author_id": 4556,
"author_profile": "https://Stackoverflow.com/users/4556",
"pm_score": 5,
"selected": true,
"text": "-init"
},
{
"answer_id": 356125,
"author": "Chris Jefferson",
"author_id": 27074,
"author_profile": ... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44858/"
] |
355,456 | <p>Is it possible to get the current source line number in Perl?
The equivalent in C++ is <code>__LINE__</code>.</p>
| [
{
"answer_id": 355464,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 7,
"selected": true,
"text": "__LINE__"
},
{
"answer_id": 358293,
"author": "bigiain",
"author_id": 11590,
"author_profile": "htt... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/259/"
] |
355,459 | <p>I have a big red button and I'm trying to use javascript to perform the following: -</p>
<ol>
<li>OnMouseDown change image so the button looks depressed</li>
<li>OnMouseUp return to the initial image AND reveal a hidden div</li>
</ol>
<p>I can get the onMouse Down and onMouseUp image changes part to work.</p>
<p>I can also get the hidden div to reveal by using OnClick</p>
<p>The problem is I can't get it all to work together. </p>
<p>How do I do this?</p>
<p>BTW, I'm sure its obvious, but I'm fairly new to javascript, so I appreciate your help</p>
| [
{
"answer_id": 355484,
"author": "Jonathan Lonowski",
"author_id": 15031,
"author_profile": "https://Stackoverflow.com/users/15031",
"pm_score": 2,
"selected": true,
"text": "<img src=\"...\" alt=\"...\"\n onmousedown=\"depressed();\"\n onmouseup=\"undepressed(); revealDiv();\" />\n"
... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
355,473 | <p>I want to handle different types of docs the same way in my application
Therefore:
I have a generic interface like this.</p>
<pre><code>public interface IDocHandler<T>where T: class
{
T Document { get;set;}
void Load(T doc);
void Load(string PathToDoc);
void Execute();
void Execute(T doc);
}
</code></pre>
<p>And for different types of documents I implement this interface.</p>
<p>for example:</p>
<pre><code>public class FinanceDocumentProcessor:IDocumentHandler<ReportDocument>
{}
public class MarketingDocumentProcessor:IDocumentHandler<MediaDocument>
{}
</code></pre>
<p>Then I can do of course something like this:</p>
<pre><code>IDocumentHandler<ReportDocument> docProc= new FinanceDocumentProcessor();
</code></pre>
<p>It would be interessting to know how I could inject T at runtime to make the line above loosly coupled...</p>
<pre><code>IDocumentHandler<ReportDocument> docProc = container.resolve("FinanceDocumentProcessor());
</code></pre>
<p>but I want to decide per Configuration wether I want to have my FinanceDomcumentProcessor or my MarketingDocumentProcessor... therefore I would have to inject T on the left site, too ...
Since I have to use c# 2.0 I can not use the magic word "var" which would help a lot in this case... but how can I design this to be open and flexible...</p>
<hr>
<p>Sorry for the misunderstanding and thanks for all the comments but I have another example for my challenge (maybe I am using the wrong design for that) ...
But I give it a try: Same situation but different Explanation</p>
<p>Example Image I have:</p>
<p>ReportingService, Crystal, ListAndLabel
Three different Reporting Document types. I have a generic Handler <code>IReportHandler<T></code> (would be the same as above) this Handler provides all the functionality for handling a report Document.
for Example </p>
<pre><code>ChrystalReportHandler:IReportHandler<CrystalReportDocument>
</code></pre>
<p>Now I want to use a Framework like Unity (or some else framework) for dependency injection to decide via configuration whether I want to use Crystal, <code>Reportingservices</code> or List and Label.</p>
<p>When I specify my mapping I can inject my <code>ChrystalReportHandler</code> but how can I inject T on the left side or in better word The Type of <code>ReportDocument</code>.</p>
<pre><code>IReportHandler<T (this needs also to be injected)> = IOContainer.Resolve(MyMappedType here)
</code></pre>
<p>my Problem is the left Site of course because it is coupled to the type but I have my mapping ... would it be possible to generate a object based on Mapping and assign the mapped type ? or basically inject T on the left side, too?
Or is this approach not suitable for this situation.</p>
| [
{
"answer_id": 355525,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 1,
"selected": false,
"text": "public interface IDocumentHandler { }\npublic interface IDocumentHandler<T> : IDocumentHandler { }\n"
},
{
"a... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
355,477 | <p>In Silverlight (and I guess WPF) why are the properties x:name x:fieldmodifier x:uid the only ones with the prefix x. </p>
<p>I understand the x prefix is used to refer to the XML namespace but there are a number of other properties that do not use a prefix such as width. Identifying a control is such a common task it seems odd to require a prefix?</p>
| [
{
"answer_id": 355503,
"author": "DaniCE",
"author_id": 19046,
"author_profile": "https://Stackoverflow.com/users/19046",
"pm_score": 2,
"selected": false,
"text": "xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" \nxmlns:x=\"http://schemas.microsoft.com/winfx/2006/xam... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23066/"
] |
355,486 | <p>I've got a Core Data application that has an Event class, which has a start date and a finish date. It's trivial to bind these to a pair of NSDatePicker widgets, but I wanted to make it work with the NSRangeDateMode available in Leopard.</p>
<p>The NSDatePicker has a pair of methods that deal with timeInterval, but I don't seem to be able to bind to this.</p>
<p><strong>Update</strong>: I've used a manual call to do the binding, and it half works:</p>
<pre><code>[picker bind:@"timeInterval"
toObject:array
withKeyPath:@"selection.timeInterval"
options:options];
</code></pre>
<p>It sets the timeInterval in the NSDatePicker when the underlying object is changed, but does not set the underlying object when the NSDatePicker's timeInterval is changed.</p>
| [
{
"answer_id": 357758,
"author": "Ashley Clark",
"author_id": 4556,
"author_profile": "https://Stackoverflow.com/users/4556",
"pm_score": 1,
"selected": false,
"text": "timeInterval"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/355486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/188/"
] |
355,492 | <p>I have read the following properties from AD,</p>
<pre><code>TerminalServicesProfilePath
TerminalServicesHomeDirectory
TerminalServicesHomeDrive
</code></pre>
<p>I've tried DirectoryEntry and DirectorySearcher. But they does not include the properties.</p>
<p>I found some example in vbscript and VC to read them.
However I failed to make it working in C#. Am I missing some tricky thing?</p>
<p>EDIT: Am I have to run it on "Windows Server" to make it works? Can it be read from win XP?</p>
| [
{
"answer_id": 355513,
"author": "chriscena",
"author_id": 32671,
"author_profile": "https://Stackoverflow.com/users/32671",
"pm_score": 2,
"selected": true,
"text": "//user is a DirectoryEntry\nIADsTSUserEx adsiUser = (IADsTSUserEx)user.NativeObject; \n"
},
{
"answer_id": 355545... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40214/"
] |
355,508 | <p>Sorry about the vague subject but I couldn't think what to put.</p>
<p>Here's my problem, I'm doing a query on a table that returns me a count of items related to a day. I want to make sure that if I do a query on the DB, I always get a set number of rows. For example, imagine I have the following table that contains a log of when people log into a website:</p>
<pre><code>**WebsiteLogin**
id: Integer
login_date: Datetime
</code></pre>
<p>I can then get counts of the logins for each date by doing something like:</p>
<pre><code>SELECT DATE(login_date), COUNT(*) FROM WebsiteLogin GROUP BY DATE(login_date)
</code></pre>
<p>Which works great and will return me the data I want. But imagine my website was quite unpopular on the weekends. The data returned would look like:</p>
<pre><code>2008-12-10, 100
2008-12-11, 124
2008-12-12, 151
2008-12-15, 141
2008-12-16, 111
</code></pre>
<p>The 13th & 14th are missing because there was no data for those dates. Is there any way I can change my query so that I get data that includes all the dates I query on. E.g.</p>
<pre><code>2008-12-10, 100
2008-12-11, 124
2008-12-12, 151
2008-12-13, 0
2008-12-14, 0
2008-12-15, 141
2008-12-16, 111
</code></pre>
<p>I imagine I could do this if I set up a table containing all the dates in a year and then using a left/right join but that's really messy way of doing it.</p>
<p>So any clues on a nice way to do this in SQL? Or is programmatically my only choice? Cheers for any input.</p>
| [
{
"answer_id": 355625,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "select d login_date, count(login_date) count\nfrom\n websitelogin wsl\n right outer join (\n select start_date+l-... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1900/"
] |
355,516 | <p>When accessing my site, the user has to enter his credentials. They are basically plain directory access credentials.
At a certain point I check if a certain file they want to download exists by calling</p>
<pre><code>WebRequest req = HttpWebRequest.Create(checkUri.AbsoluteUri);
WebResponse res = req.GetResponse();
</code></pre>
<p>Although I can access the checkUri from the browser, I get a 401 when doing the above check. I think I have to set the</p>
<pre><code>req.Credentials
</code></pre>
<p>But I don't know where the current credentials are stored...</p>
<p>Any ideas?</p>
<p><strong>--Update--</strong> </p>
<ul>
<li>Integrated Windows Authentication: No</li>
<li>Allow Anonymous: Off</li>
<li>Caler: Link on page of same site (GET)</li>
<li>Impersonation: default is off (don't even know how to enable it in asp.net mvc)</li>
</ul>
| [
{
"answer_id": 355522,
"author": "mookid8000",
"author_id": 6560,
"author_profile": "https://Stackoverflow.com/users/6560",
"pm_score": 3,
"selected": false,
"text": "req.Credentials = CredentialCache.DefaultCredentials;\n"
},
{
"answer_id": 356308,
"author": "Dave Markle",
... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] |
355,526 | <p>HI,</p>
<p>I have a large table from which i can query to get the following table</p>
<pre><code>type no of times type occurs
101 450
102 562
103 245
</code></pre>
<p>also i can get another table</p>
<pre><code>code no of times code occurs
0 1222
1 750
2 355
</code></pre>
<p>but now i want to write a query which could get me the following table</p>
<pre><code>type no of timescode1occurs %of timescode1 occurs out of %of times code1 occurs out of
no of times type occurs no of times code occcurs
101 50 11% 6%
102 75 13% 10%
</code></pre>
<p>How can i write a query to get this?</p>
<p>Thanks</p>
| [
{
"answer_id": 355522,
"author": "mookid8000",
"author_id": 6560,
"author_profile": "https://Stackoverflow.com/users/6560",
"pm_score": 3,
"selected": false,
"text": "req.Credentials = CredentialCache.DefaultCredentials;\n"
},
{
"answer_id": 356308,
"author": "Dave Markle",
... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31132/"
] |
355,531 | <p>I am trying to understand if I really have any case for using git/mercurial.</p>
<p>The projects I work are java and c# projects, usually with 5-20 people working towards
a common goal (the "release"). Most of the developers are professional developers who
refactor code <em>all of the time</em>. So where the typical linux kernel has a large number of
relatively independent changes in separate files, we have a constant flux of refactoring changes -
often hitting a <em>lot</em> of files and a <em>lot</em> of code. No-one's scared of changing code here.</p>
<p>Now with subversion we solve this by staying extremely close to SVN HEAD. Some of us even have
automated svn up's that trigger on the build server's jabber broadcast. Most of us have also learned
(or learn really quickly) how to plan our work to stay close to SVN HEAD. If you're doing a major refactoring we
incrementally bend the source tree in a new direction instead of going away for too long. Sometimes you just plan the
refactoring operation and start off in the less contended areas. After some years
of working this way it becomes second nature. Most of us simply never leave the "comfort zone" of being less than
2 hours away from svn head. The automated build and svn head is the project "pulse" and we like it.</p>
<p>Of course we branch off each release, but the number of backmerges from the release-branch back to trunk dwindle
down quickly enough to be insignificant (we've got decent test coverage). Running off for days/weeks with private branches of the source sounds
like something we actively want to discourage, and it simply doesn't happen very frequently.</p>
<p>Both git and mercurial sound way cool, git slightly more so since I'm more a McGyver type than a James Bond type.
But when it comes to building a case for actually switching, it feels like Linus and I are living on two different planets.
Most of the time we <em>want</em> our teams to stay focused on HEAD. </p>
<p>How can GIT make my version control better ? How would GIT let me improve my process ? Am I a subversion dinosaur ?</p>
| [
{
"answer_id": 355686,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 5,
"selected": true,
"text": "a b center\n |\n |\n / Key: / - | \\ = Flow\n/----<---| < > = Fl... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23691/"
] |
355,533 | <p>I have two unix partitions under debian which I would like to merge (disk space problems :/). What would be the easiest way to do it? I think it would be best to tar or copy files from one partition to the other, delete one and resize the other. I will use parted to resize but how should I copy the files? There are links, permissions and devices which need to be moved without change.</p>
| [
{
"answer_id": 355591,
"author": "Anders Westrup",
"author_id": 36845,
"author_profile": "https://Stackoverflow.com/users/36845",
"pm_score": 3,
"selected": true,
"text": "cd /partition2\ntar cf - . | ( cd /partition1 && tar xf - )\n"
},
{
"answer_id": 440800,
"author": "Tedd... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26943/"
] |
355,538 | <p>The client has asked for a number of tables to be extracted into csv's, all done no problem. They've just asked we make sure the files are always in UTF 8 format.</p>
<p>How do I check this is actually the case. Or even better force it to be so, is it something i can set in a procedure before running a query perhaps?</p>
<p>The data is extracted from an Oracle 10g database.</p>
<p>What should I be checking?</p>
<p>Thanks</p>
| [
{
"answer_id": 355575,
"author": "rics",
"author_id": 21047,
"author_profile": "https://Stackoverflow.com/users/21047",
"pm_score": 4,
"selected": true,
"text": "select value from nls_database_parameters \nwhere parameter='NLS_CHARACTERSET'\n"
},
{
"answer_id": 356211,
"autho... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27412/"
] |
355,539 | <p>If I had a dictionary <code>dict</code> and I wanted to check for <code>dict['key']</code> I could either do so in a <code>try</code> block (bleh!) or use the <code>get()</code> method, with <code>False</code> as a default value.</p>
<p>I'd like to do the same thing for <code>object.attribute</code>. That is, I already have object to return <code>False</code> if it hasn't been set, but then that gives me errors like</p>
<blockquote>
<p>AttributeError: 'bool' object has no attribute 'attribute'</p>
</blockquote>
| [
{
"answer_id": 355562,
"author": "Zoomulator",
"author_id": 44563,
"author_profile": "https://Stackoverflow.com/users/44563",
"pm_score": 4,
"selected": false,
"text": "hasattr()"
},
{
"answer_id": 355571,
"author": "Community",
"author_id": -1,
"author_profile": "htt... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9106/"
] |
355,540 | <p>I have a special url which I would want only few people to have access to. I have a list of super users stored as an array in the app.yml. How can I use this array in :requirements section of a specific route in the routes.rb file to allow only those super users access to this route? Thanks a lot.</p>
| [
{
"answer_id": 355562,
"author": "Zoomulator",
"author_id": 44563,
"author_profile": "https://Stackoverflow.com/users/44563",
"pm_score": 4,
"selected": false,
"text": "hasattr()"
},
{
"answer_id": 355571,
"author": "Community",
"author_id": -1,
"author_profile": "htt... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44916/"
] |
355,550 | <p>I have two arrays in PHP. The first array ($author_array) is comprised of user_ids in a particular order, like so: (8, 1, 6)</p>
<p>The second array ($user_results) is comprised of an array of objects like so:</p>
<pre><code>Array
(
[0] => stdClass Object
(
[ID] => 1
[user_login] => user1
)
[1] => stdClass Object
(
[ID] => 6
[user_login] => user6
)
[2] => stdClass Object
(
[ID] => 8
[user_login] => user8
)
)
</code></pre>
<p>I'd like to "sort" the second array so it's in this order, which matches the order of the values in the first array of (8, 1, 6). So it'd look like this:</p>
<pre><code>Array
(
[0] => stdClass Object
(
[ID] => 8
[user_login] => user8
)
[1] => stdClass Object
(
[ID] => 1
[user_login] => user1
)
[2] => stdClass Object
(
[ID] => 6
[user_login] => user6
)
)
</code></pre>
<p>I'm weak on data structures. How could I do this? :-)</p>
<p>Thanks in advance for your help!</p>
<p>-Bob</p>
| [
{
"answer_id": 355583,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 6,
"selected": true,
"text": "function cmp($a, $b) \n{\n global $author_array;\n\n $pos1=array_search ($a->ID, $author_array);\n $pos2=array_searc... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44919/"
] |
355,560 | <p>I have these values: <code>d1, d45, d79, d33, d100</code></p>
<p>I want to sort these variables in ascending order from my table.</p>
<p>What is the query to get the output as:</p>
<pre><code>d1
d33
d45
d79
d100
</code></pre>
| [
{
"answer_id": 355611,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 0,
"selected": false,
"text": "select foo from bar order by cast(substring(foo from 2) as int)\n"
},
{
"answer_id": 356619,
"author": "Jonat... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
355,576 | <p>I would like to get Binding object from web.config or app.config.</p>
<p>So, this code works:</p>
<pre><code>wcfTestClient = new TestServiceClient("my_endpoint", Url + "/TestService.svc");
</code></pre>
<p>but I would like to do the following:</p>
<pre><code>Binding binding = DoSomething();
wcfTestClient = new TestServiceClient(binding, Url + "/TestService.svc");
</code></pre>
<p>I am interested in DoSomething() method, of course.</p>
| [
{
"answer_id": 355709,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": false,
"text": "Binding defaultBinding;\nusing(TestServiceClient client = new TestServiceClient()) {\n defaultBinding = client.End... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28912/"
] |
355,602 | <p>I've had to create a custom membership provider for my current ASP .Net project in order to fit in with our database schema, and am having problems configuring it to lockout a user if they get their password wrong three times, as is supported by the standard providers.</p>
<p>Is this something I need to implement myself, or should it be supported inherently?</p>
<p>I have no code that specifically deals with it (and none of the interface members seem to deal with it specifically), but if I need to implement it myself, how do I go about informing the user they are locked out? Do I need to raise some sort of exception in ValidateUser?</p>
<p><strong>Solution</strong></p>
<p>Shame I can't mark two answers, the links provided by Dave R give a great in depth look at how membership works, and what Zhaph pointed out was just what I ended up doing, handling the locked out logic in the custom membership provider.</p>
<p>I then handled the error condition by using the Login control's LoginError event and checked in there to see if the user was locked out in order to show the appropriate error message.</p>
| [
{
"answer_id": 356106,
"author": "Zhaph - Ben Duguid",
"author_id": 33051,
"author_profile": "https://Stackoverflow.com/users/33051",
"pm_score": 2,
"selected": false,
"text": "IsLockedOut\nFailedPasswordAttemptCount\nFailedPasswordAttemptWindowStart\n"
},
{
"answer_id": 2064058,... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40848/"
] |
355,619 | <p>The common sense tells that the Doxygen comment blocks have to be put in the header files where the classes, structs, enums, functions, declarations are. I agree that this is a sound argument for a libraries that are mean to be distributed without its source (only headers and libs with object code).</p>
<p>BUT...I've been thinking of the exact opposite approach when I'm developing an internal to the company (or as a side project for myself) library that will be used with its full source code. What I propose is to put the large comment blocks in the implementations files (HPP, INL, CPP, etc) in order NOT to clutter the inteface of the classes and functions declared in the header.</p>
<p><strong>Pros:</strong></p>
<ul>
<li>Less clutter in the header files, only categorizing of the functions can be added.</li>
<li>The comment blocks that are previewed when Intellisense for example is used doesn't clash - this is a defect that I have observed when I have a comment block for a function in the .H file and have its inline definition in the same .H file but included from .INL file.</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li>(The obvious one) The comment blocks are not in the header files where the declarations are.</li>
</ul>
<p>So, what do you think and possibly suggest?</p>
| [
{
"answer_id": 355646,
"author": "eaanon01",
"author_id": 36986,
"author_profile": "https://Stackoverflow.com/users/36986",
"pm_score": 4,
"selected": false,
"text": "/**\n * \\brief Short about function\n *\n * More about function\n */\nWORD my_fync1(BYTE*);\n"
},
{
"answer_id":... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34752/"
] |
355,632 | <p>On a website I'm working we have an onsite login and a private login, the problem I'm having is that Firefox doesn't seem to be able to differentiate between these login forms.</p>
<p>Does anybody know how I can make clear that these are different logins?</p>
<p>I already tried giving the form fields different names and ids, ex: onsite_login and login but without success.</p>
<p><strong>edit:</strong> my form-tags are not being mixed up, they aren't even on the same page</p>
<p>The two forms on the different pages</p>
<pre><code><form method="post" action="/en/login/1">
<fieldset>
<p>
<input type="hidden" value="login" name="form"/>
<input type="hidden" value="en" name="redirect"/>
<label for="onsite_username">Username<abbr title="Required ">*</abbr></label>
<input type="text" class="input-text" maxlength="255" value="" name="onsite_username" id="onsite_username"/>
<label for="onsite_password">Password<abbr title="Required ">*</abbr></label>
<input type="password" class="input-password" maxlength="255" value="" name="onsite_password" id="onsite_password"/>
<input type="submit" value="Log in" name="submit" class="input-submit"/>
</p>
</fieldset>
</form>
</code></pre>
<p>and</p>
<pre><code><form method="post" action="">
<fieldset>
<input type="hidden" value="login" name="form"/>
<div>
<label for="username">Username</label>
<input type="text" class="input-text" value="" name="username" id="username"/>
</div><div>
<label for="password">Password</label>
<input type="password" class="input-password" value="" name="password" id="password"/>
</div>
<input type="submit" value="Aanmelden" class="input-submit"/>
</fieldset>
</form>
</code></pre>
| [
{
"answer_id": 355734,
"author": "dragonlord21",
"author_id": 44931,
"author_profile": "https://Stackoverflow.com/users/44931",
"pm_score": 1,
"selected": false,
"text": "<p>"
},
{
"answer_id": 355856,
"author": "Polichism",
"author_id": 44544,
"author_profile": "http... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1074/"
] |
355,633 | <p>I was reading up on Ruby, and learned about its mixins pattern, but couldn't think of many useful mixin functionality (because I'm not used to thinking that way most likely). So I was wondering what would be good examples of useful Mixin functionality?</p>
<p>Thanks</p>
<p>Edit: A bit of background. I'm Coming from C++, and other Object languages, but my doubt here is that Ruby says it's not inheriting mixins, but I keep seeing mixins as Multiple inheritance, so I fear I'm trying to categorize them too soon into my comfort zone, and not really grok what a mixin is.</p>
| [
{
"answer_id": 355698,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 4,
"selected": true,
"text": "module Persistence\n def load sFileName\n puts \"load code to read #{sFileName} contents into my_data\"\n end\... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] |
355,636 | <p>I have a problem that I feel is best implimented in a stand alone windows application, but needs to pass data to a web page that is already open. </p>
<p>Is it possible to pass the data directly to the web page?</p>
<p>If so, what is the best way to go about it?</p>
<p>(Its my first question, so go easy on me!)</p>
| [
{
"answer_id": 355698,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 4,
"selected": true,
"text": "module Persistence\n def load sFileName\n puts \"load code to read #{sFileName} contents into my_data\"\n end\... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44914/"
] |
355,638 | <p>I'm using Jquery's toggle event to do some stuff when a user clicks a checkbox, like this:</p>
<pre><code>$('input#myId').toggle(
function(){
//do stuff
},
function(){
//do other stuff
}
);
</code></pre>
<p>The problem is that the checkbox isn't being ticked when I click on the checkbox. (All the stuff I've put into the toggle event is working properly.)</p>
<p>I've tried the following:</p>
<pre><code>$('input#myId').attr('checked', 'checked');
</code></pre>
<p>and</p>
<pre><code>$(this).attr('checked', 'checked');
</code></pre>
<p>and even simply</p>
<pre><code>return true;
</code></pre>
<p>But nothing is working. Can anyone tell me where I'm going wrong?</p>
<p>Edit - thanks to all who replied. Dreas' answer very nearly worked for me, except for the part that checked the attribute. This works perfectly (although it's a bit hacky)</p>
<pre><code>$('input#myInput').change(function ()
{
if(!$(this).hasClass("checked"))
{
//do stuff if the checkbox isn't checked
$(this).addClass("checked");
return;
}
//do stuff if the checkbox isn't checked
$(this).removeClass('checked');
});
</code></pre>
<p>Thanks again to all who replied.</p>
| [
{
"answer_id": 355664,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 7,
"selected": true,
"text": "change"
},
{
"answer_id": 355672,
"author": "adam",
"author_id": 33604,
"author_profile": "https:... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22946/"
] |
355,650 | <p>I am looking for template/generator libraries for C++ that are similar to eg. Ruby's Erb, Haml, PHP's Smarty, etc.</p>
<p>It would be great if I it would sport some basic features like loops, if/else, int conversion to strings, etc.</p>
<p>Parameter passing to template rendering engine is also important if I could pass all of them in a hash map instead of calling some function for each of parameters.</p>
<p>Do you have any recommendations?</p>
<p>I can see also the possibility of embedding languages like Lua, however I haven't found a templatizing library for that either.</p>
| [
{
"answer_id": 15592275,
"author": "kirill_igum",
"author_id": 390066,
"author_profile": "https://Stackoverflow.com/users/390066",
"pm_score": 2,
"selected": false,
"text": "std::cout << format(\"The answers are {} and {}\", 23, 42); \n// => \"The answers are 23 and 42\"\n\nstd::map<std:... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5731/"
] |
355,670 | <p>Myself and a colleague have a dispute about which of the following is more elegant. I won't say who's who, so it is impartial. Which is more elegant?</p>
<pre><code>public function set hitZone(target:DisplayObject):void
{
if(_hitZone != target)
{
_hitZone.removeEventListener(MouseEvent.ROLL_OVER, onBtOver);
_hitZone.removeEventListener(MouseEvent.ROLL_OUT, onBtOut);
_hitZone.removeEventListener(MouseEvent.MOUSE_DOWN, onBtDown);
_hitZone = target;
_hitZone.addEventListener(MouseEvent.ROLL_OVER, onBtOver, false, 0, true);
_hitZone.addEventListener(MouseEvent.ROLL_OUT, onBtOut, false, 0, true);
_hitZone.addEventListener(MouseEvent.MOUSE_DOWN, onBtDown, false, 0, true);
}
}
</code></pre>
<p>...or...</p>
<pre><code>public function set hitZone(target:DisplayObject):void
{
if(_hitZone == target)return;
_hitZone.removeEventListener(MouseEvent.ROLL_OVER, onBtOver);
_hitZone.removeEventListener(MouseEvent.ROLL_OUT, onBtOut);
_hitZone.removeEventListener(MouseEvent.MOUSE_DOWN, onBtDown);
_hitZone = target;
_hitZone.addEventListener(MouseEvent.ROLL_OVER, onBtOver, false, 0, true);
_hitZone.addEventListener(MouseEvent.ROLL_OUT, onBtOut, false, 0, true);
_hitZone.addEventListener(MouseEvent.MOUSE_DOWN, onBtDown, false, 0, true);
}
</code></pre>
| [
{
"answer_id": 355684,
"author": "xsl",
"author_id": 11387,
"author_profile": "https://Stackoverflow.com/users/11387",
"pm_score": 5,
"selected": false,
"text": "return"
},
{
"answer_id": 355812,
"author": "Zarkonnen",
"author_id": 15255,
"author_profile": "https://St... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11911/"
] |
355,673 | <p>This is probably a simple question but I am not an ASP.NET developer and I am quite stuck.</p>
<p>I have a simple search routine that returns between zero and several hundred results. Each of these must be added to the page as a button and I want to set the text of the button and the CommandArgument property so that when the button is clicked I can read the CommandArgument back and react accordingly.</p>
<p>However, when I click the button the event does not run at all. How can I get it to run?</p>
<p>The code for building the button list (simplified for readability) is as follows:</p>
<pre><code> foreach (SearchResult sr in searchResults)
{
Button result = new Button();
result.Text = sr.name;
result.CommandArgument = sr.ID.ToString();
AccountSearchResults.Controls.Add(result);
result.Click += new EventHandler(SearchResultClicked);
AccountSearchResults.Controls.Add(new LiteralControl("<br/>"));
}
</code></pre>
<p>At the minute to test, I have popped a label on the form to put the CommandArgument in. This code is never executed though.</p>
<pre><code> void SearchResultClicked(object sender, EventArgs e)
{
Label1.Text = ((Button)sender).CommandArgument;
}
</code></pre>
| [
{
"answer_id": 355683,
"author": "Ian Oxley",
"author_id": 1904,
"author_profile": "https://Stackoverflow.com/users/1904",
"pm_score": 0,
"selected": false,
"text": "result.Click += new EventHandler(SearchResultClicked);\n"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/355673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44938/"
] |
355,691 | <p>I've got an extremely long XML file, like</p>
<pre><code><Root>
<ele1>
<child1>context1</child1>
<child2>test1</child2>
<child1>context1</child1>
</ele1>
<ele2>
<child1>context2</child1>
<child2>test2</child2>
<child1>context2</child1>
</ele2>
<ele3>...........<elen>
</Root>
</code></pre>
<p>Now I want to remove all the second <code><child1></code> in each <code><ele></code> using xslt, is it possible?
The result would be like this:</p>
<pre><code><Root>
<ele1>
<child1>context1</child1>
<child2>test1</child2>
</ele1>
<ele2>
<child1>context2</child1>
<child2>test2</child2>
</ele2>
<ele3>...........<elen>
</Root>
</code></pre>
<p>Thank u, BR</p>
<p>Allen</p>
| [
{
"answer_id": 10670314,
"author": "ABach",
"author_id": 327179,
"author_profile": "https://Stackoverflow.com/users/327179",
"pm_score": 2,
"selected": false,
"text": "<child1>"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/355691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
355,700 | <p>I want to embed a link to a controller action in my page so I can use it from javascript. Something like</p>
<pre><code>var pollAction = '/Mycontroller/CheckStatus'
</code></pre>
<p>Now I am happy to hardcode it, but it would be really nice if there were a method I could use to create the URL. The AjaxHelper/HtmlExtensions contain methods to create hyperlinks (.ActionLink(...) and so on), but if you look into the guts of them, they rely on a method called UrlHelper.GenerateUrl() to resolve a controller and action into a url. This is internal so I can't really get at this.</p>
<p>Anyone found a good method in the framework to do this? Or must I roll my own?</p>
| [
{
"answer_id": 355736,
"author": "mapache",
"author_id": 41422,
"author_profile": "https://Stackoverflow.com/users/41422",
"pm_score": 5,
"selected": true,
"text": "var pollAction = '<%=Url.Action(\"CheckStatus\", \"MyController\") %>';\n"
},
{
"answer_id": 355824,
"author": ... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22360/"
] |
355,723 | <p>I'm trying in vain to write a regular expression to match valid ssh connection strings.</p>
<p>I really only need to recognise strings of the format:</p>
<ul>
<li>user@hostname:/some/path</li>
</ul>
<p>but it would be nice to also match an implicit home directory:</p>
<ul>
<li>user@hostname:</li>
</ul>
<p>I've so-far come up with this regex:</p>
<pre><code>/^[:alnum:]+\@\:(\/[:alnum:]+)*$/
</code></pre>
<p>which doesn't work as intended.</p>
<p>Any suggestions welcome before my brain explodes and I start speaking in line noise :)</p>
| [
{
"answer_id": 355750,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "/^[:alnum:]+\\@[:alnum:\\.]\\:(\\/[:alnum:]+)*$/\n"
},
{
"answer_id": 355753,
"author": "Kent Fredric",
... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
355,724 | <p>Is it possible to embed a DOS console in a Windows Form or User Control in C# 2.0?</p>
<p>We have a legacy DOS product that my Windows app has to interact with, and it's been requested that an instance of the legacy product should run within the Windows application.</p>
<p>At the moment, I'm using the user32.dll to locate the window that the DOS product is running in, minimising then maximising the window, and typing characters into the window. This isn't a very good solution to the problem, as it means my application has to store the window name in application settings, and requires that the user returns to the correct page of the DOS app before using the interaction function.</p>
<p>EDIT: Some more information</p>
<p>The legacy app needs to be visible to the user, but not in a separate window.</p>
<p>I've tried TimothyP's answer and it works very well, but is it possible to achieve the same functionality, but with the DOS window visually embedded in a windows form or user control instead of popping up in it's own window? Preferably in a ShowDialog() way so that the user cannot interact with the app wile they are in 'Legacy Mode', so to speak.</p>
| [
{
"answer_id": 355749,
"author": "TimothyP",
"author_id": 28149,
"author_profile": "https://Stackoverflow.com/users/28149",
"pm_score": 6,
"selected": true,
"text": "var processStartInfo = new ProcessStartInfo(\"someoldapp.exe\", \"-p someparameters\");\n\nprocessStartInfo.UseShellExecut... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18895/"
] |
355,730 | <p>What is the best way to store instances of a class to file/database?</p>
<p>We have a base class called Command and loads of derived classes.
Users create instances of these classes by adding commands to a graphical designer
where they can configure them. (Set the properties).</p>
<p>We then need a way to store these "commands" to a file without losing
any information.</p>
<p>One idea was to use db4o, but the GPL license is not acceptable for this project.</p>
<p>Any suggestions or code samples?</p>
<p>Update:</p>
<p>(In order to "de-blurryfie" my question :p)</p>
<p>The generated code might look something like:</p>
<pre><code> command[i++] = new DelayInSecondsCommand(2);
command[i++] = new DaliRequestCommand(1, false, 254);
command[i++] = new DaliRequestCommand(2, false, 254);
command[i++] = new DaliRequestCommand(3, false, 254);
command[i++] = new WaitInSecondsCommand(2);
command[i++] = new DaliRequestCommand(1, false, 0);
command[i++] = new DaliRequestCommand(2, false, 0);
command[i++] = new DaliRequestCommand(3, false, 0);
command[i++] = new JumpCommand(0);
</code></pre>
<p>But then with loads of different commands.</p>
<p>I know it's possible with .NET serialization, altough I've never used it before,
but I was wondering if there are better alternatives, like I said db4o seems nice but the license doesn't fit the project.</p>
<p>Update 2:</p>
<p>Thank you for the replies. I'll probably go with the serialization solution now,
but I'll look into the other options as well. F.Y.I. data is stored in a SQL Compact database.</p>
| [
{
"answer_id": 355838,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "DataContractSerializer"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/355730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28149/"
] |
355,732 | <p>For example, java.io.File is just a concrete class. My replacement for it supports resolving Windows shortcuts. I need to preprocess constructor parameters to resolve possible .lnk files because the FileSystem object that does normalizing/canonicalision/resolving on the abstract paths is not accessible. The need for preprocessing rules out pure subclassing - can't do preprocessing before calling super(...) and File is immutable. So I extend File and use a delegate, overriding all of File's constructors and methods (calling super("") in all constructors).</p>
<p>This works nicely, but is obviously not ideal - if File changes, I will not have overridden any new methods or constructors and this will expose the underlying empty abstract pathname. Am I missing something obvious? It seems like there should be a simpler/better way.</p>
| [
{
"answer_id": 355754,
"author": "Dan Vinton",
"author_id": 21849,
"author_profile": "https://Stackoverflow.com/users/21849",
"pm_score": 2,
"selected": false,
"text": "super()"
},
{
"answer_id": 355774,
"author": "bruno conde",
"author_id": 31136,
"author_profile": "... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2492/"
] |
355,737 | <p>How can I rotate the Apache Access and Error logs on a Window 2000 box?</p>
<p>I include my batch file below as an answer.</p>
<p>Is there a way of doing this directly via the Apache config file? I'm currently using the following customlog command to generate daily logs.</p>
<p>CustomLog '|" "*Apache-Path/bin/rotatelogs.exe" "*Apache-Path/logs/backup/internet_access_%d-%m-%y.log" 86400' combined</p>
| [
{
"answer_id": 355792,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 0,
"selected": false,
"text": "logrotate"
},
{
"answer_id": 355857,
"author": "alimack",
"author_id": 39447,
"author_profile": ... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39447/"
] |
355,775 | <p>I'm writing a JavaSCript class that has a method that recursively calls itself.</p>
<pre><code>Scheduler.prototype.updateTimer = function () {
document.write( this._currentTime );
this._currentTime -= 1000;
// recursively calls itself
this._updateUITimerHandler = window.setTimeout( arguments.callee , 1000 );
}
</code></pre>
<p>Property description:</p>
<pre><code>_currentTime: the currentTime of the timer in miliseconds.
_updateUITimerHandler: stores the reference so can be used later with clearTimeout().
</code></pre>
<p>my problem is where I'm using recursion with setTimeout(). I know setTimeout() will accept some string to execute, or a reference to a function. since this function is method of an object, I don't know how to call it from outside. so I used the second format of setTimeout() and passed in a reference to the method itself. but it does not work.</p>
| [
{
"answer_id": 355790,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 1,
"selected": false,
"text": "function f() \n{\n alert('foo');\n window.setTimeout(arguments.callee,5000);\n}\n\nf();\n"
},
{
"answer_id": 35... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9394/"
] |
355,787 | <p>This is something I'm not much consistent about and always curious about what other people do.</p>
<p>How do you access internal properties (private or public)? </p>
<p>For example you've got this property :</p>
<pre><code>Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
</code></pre>
<p>In the same class within another function which one do you prefer? and why?</p>
<pre><code>_Name = "Johnny"
</code></pre>
<p>or </p>
<pre><code>Name = "Johnny"
</code></pre>
<p><strong>Ignore the fact that I used Name instead of Me.Name.</strong></p>
| [
{
"answer_id": 355797,
"author": "bezmax",
"author_id": 43677,
"author_profile": "https://Stackoverflow.com/users/43677",
"pm_score": 1,
"selected": false,
"text": "Name = \"Johny\"\n"
},
{
"answer_id": 355806,
"author": "Jon Skeet",
"author_id": 22656,
"author_profil... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40322/"
] |
355,796 | <p>My relative is studying programming and has a hard time understanding classes. He has trouble understanding for example that you need to instantiate it, that methods cannot access variables in other methods and if you change a variable in one instance of a class it doesn't change for other instances.</p>
<p>I've tried to use analogies like a class definition is like a blueprint of a house. And instances are houses made from that blueprint.</p>
<p>How do you explain classes and OO in general?</p>
| [
{
"answer_id": 355810,
"author": "Robert Gould",
"author_id": 15124,
"author_profile": "https://Stackoverflow.com/users/15124",
"pm_score": 5,
"selected": true,
"text": " // Assembly: Common Classes\n // Namespace: CommonClasses\n\n public interface IAnimal\n {\n strin... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33468/"
] |
355,802 | <p>Is there some standard way or has anyone written something that allows you to log a message and have it be displayed either in a small scrolling section on the iphone screen or in a separate window in the iphone simulator?</p>
<p>Update:
For noobs like me and don't know, use the NSLog methods as decribed below and make sure you select Run->Console to display the console.</p>
<p>Would still like to know if anyone has written a simple logger that displays on the iphone itself....</p>
| [
{
"answer_id": 355861,
"author": "adam",
"author_id": 33604,
"author_profile": "https://Stackoverflow.com/users/33604",
"pm_score": 4,
"selected": true,
"text": "NSLog(@\"message\");\n"
},
{
"answer_id": 358233,
"author": "Rob",
"author_id": 386102,
"author_profile": ... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36510/"
] |
355,813 | <p>I've got some entities which have decimal properties on them. These entities' properties are displayed in multiple places throughout my UI.</p>
<p>Currently I'm finding myself doing:</p>
<pre><code>litWeight.Text = person.Weight.ToString("0.00");
</code></pre>
<p>all over the place.
Now I know for a fact that in several instances, and am suspicious of many others that the client is likely to want the values to 3d.p. in the future.</p>
<p>Is there some pattern I can employ to handle the formatting of this Weight property (and other properties; not just decimals, perhaps dates etc.) so that I can have this formatting in a single place?</p>
<p>I know could use a formatstring in the webconfig, or write some extension methods in the UI but these don't seem very elegant solutions.</p>
<p>It would be nice to have some formatting objects which are tied to my entities, so its inherently obvious which formatter to use.</p>
<p>Thanks,</p>
<p>Andrew</p>
| [
{
"answer_id": 355852,
"author": "Toni Ruža",
"author_id": 6267,
"author_profile": "https://Stackoverflow.com/users/6267",
"pm_score": 3,
"selected": true,
"text": "litWeight.Text = Utility.FormatWeight(person.Weight);\n"
},
{
"answer_id": 355854,
"author": "The Archetypal Pa... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28543/"
] |
355,816 | <p>I am using a global named mutex for file access synchronization between an ASP.NET application and a console application.</p>
<p>While running the ASP.NET application, the console application fails to acquire mutex - as expected. While running the console application, the ASP.NET application throws <code>UnauthorizedAccessException: Access to the path 'Global\TheNameOfTheMutex' is denied.</code> </p>
<p>I will try to catch the exception and treat it like it failed to acquire the mutex, but I want to know why is it behaving like this? The ASP.NET application runs as expected if it is accessed from two different browsers and the console applications also runs as expected when running multiple instances.</p>
<p><strong>Update:</strong> on Windows XP the exception is also thrown when the ASP.NET application is running and I try to start the console application.</p>
<p>The code used for synchronization is in a common assembly:</p>
<pre><code>using (Mutex m = new Mutex(false, "Global\\TheNameOfTheMutex")) // exception thrown
{
try
{
lock = m.WaitOne(0, false);
}
catch (AbandonedMutexException)
{
// ...
}
if(lock)
{
// ...
m.ReleaseMutex();
}
}
</code></pre>
<p>Environment: Windows Server 2008, IIS 7, ASP.NET 2.0</p>
| [
{
"answer_id": 355829,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "MutexSecurity and MutexAccessRule ?\n"
},
{
"answer_id": 3456066,
"author": "Vladislav",
"author_id": 155687,
... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19756/"
] |
355,818 | <pre><code>ScalarQuery<int> query = new ScalarQuery<int>(typeof(Role),
"select count(role.RoleId) from Role as role");
return query.Execute();
</code></pre>
<p>It fails with the invalidcast exception but succeeds when count is replaced with max. </p>
| [
{
"answer_id": 355837,
"author": "gcores",
"author_id": 40256,
"author_profile": "https://Stackoverflow.com/users/40256",
"pm_score": 2,
"selected": true,
"text": "ScalarQuery<long> query = new ScalarQuery<long>(typeof(Role), \n \"select count(r) from Role r\");\... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38807/"
] |
355,830 | <p>I would like to create a cache for my php pages on my site. I did find too many solutions but what I want is a script which can generate an HTML page from my database ex:</p>
<p>I have a page for categories which grabs all the categories from the DB, so the script should be able to generate an HTML page of the sort: my-categories.html. then if I choose a category I should get a my-x-category.html page and so on and so forth for other categories and sub categories.</p>
<p>I can see that some web sites have got URLs like: wwww.the-web-site.com/the-page-ex.html</p>
<p>even though they are dynamic.</p>
<p>thanks a lot for help</p>
| [
{
"answer_id": 355860,
"author": "Irmantas",
"author_id": 43182,
"author_profile": "https://Stackoverflow.com/users/43182",
"pm_score": 4,
"selected": false,
"text": "ob_start();\necho 'some_output';\n$content = ob_get_contents();\nob_end_clean();\n\necho 'Content generated :'.$content;\... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
355,833 | <p>I have been searching for a simple way to convert a dataset from a <a href="http://en.wikipedia.org/wiki/PostgreSQL" rel="nofollow noreferrer">PostgreSQL</a> database to JSON for use in a project that I am building.</p>
<p>This is my first time using JSON, and I have found it really tricky to find a simple way of doing this. I have been using a StringBuilder at the moment to create a JSON string from the information in the dataset, but I have heard that it is possible to do this very simply with <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="nofollow noreferrer">.NET</a> 3.5 using the <code>System.Runtime.Serialization</code> namespace, though I have yet to find a simple article or blog on how this is done! What is the easiest way to do this?</p>
| [
{
"answer_id": 5727183,
"author": "DineshHona",
"author_id": 404315,
"author_profile": "https://Stackoverflow.com/users/404315",
"pm_score": 0,
"selected": false,
"text": "public static string GetJSONString(DataTable Dt)\n{\n string[] StrDc = new string[Dt.Columns.Count];\n string ... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
355,842 | <p>I have the following HandleError filter on my controller:</p>
<pre>[HandleError(ExceptionType = typeof(ArgumentException), View = "DestinationError")]</pre>
<p>I've set-up the Web.Config so that customErrors are on. The problem I'm having is that the HandleError filter is working fine, when I run the app locally out of Visual Studio, but when I deploy it to the server all I get is a 500 Internal Server Error, indicating the Error view cannot be found.</p>
<p>Has anyone come across this before, I'm suspicious that routing may be the root cause of the problem (hoho). The site gets deployed into a directory in the web root, rather than into the wwwroot itself, so perhaps IIS cannot locate the error file.</p>
| [
{
"answer_id": 1230927,
"author": "labilbe",
"author_id": 1195872,
"author_profile": "https://Stackoverflow.com/users/1195872",
"pm_score": 0,
"selected": false,
"text": "Response.TrySkipIisCustomErrors = true;\n"
},
{
"answer_id": 1236497,
"author": "labilbe",
"author_id... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
355,848 | <p>How can I emulate classes (and namespaces) in JavaScript?</p>
<p>I need to create a JavaScript library and have limited experience with the language. I always thought that it had native support for classes, but it is less related to Java than I had assumed. It seems that everything in JavaScript is actually a function.</p>
<p>What I have found out so far makes a lot of sense with it being a dynamic weakly typed language, but this makes it a bit of a departure for people who are used to having a strongly typed language and using a compiler to spot our errors :)</p>
<p>I mainly work in C# and Java, and was hoping for something syntacticaly similar so the library would look familiar for our other C# developers that will have to maintain it.</p>
<p>I have the following sort of code which works, but I was wondering what other developer's takes would be on this. What are the alternatives? Is there a way that is better? Is there a way that is more readable?</p>
<p>I understand that what I want is something similar to C# or Java when I should just accept the fact that this <strong>is JavaScript</strong>, but my aim is to try to ease the learning curve for other developers by making it more familiar and intuitive for them.</p>
<pre><code>//Perform the namespace setup (this will actually be done with checking
//in real life so we don't overwrite definitions, but this is kept short
//for the code sample).
var DoctaJonez = new function();
DoctaJonez.Namespace1 = new function();
/**
* Class description.
*/
DoctaJonez.Namespace1.SomeClass = function()
{
/**
* Public functions listed at the top to act like a "header".
*/
this.publicFunction = privateFunction;
/**
* Private variables next.
*/
var privateVariable;
/**
* Finally private functions.
*/
function privateFunction()
{
}
}
//Create an instance of the class
var myClass = new DoctaJonez.SomeClass();
//Do some stuff with the instance
myClass.publicFunction();
</code></pre>
| [
{
"answer_id": 355889,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 1,
"selected": false,
"text": "DoctaJonez.Namespace1 = {};"
},
{
"answer_id": 356343,
"author": "Eugene Lazutkin",
"author_id": 26394,
... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39277/"
] |
355,865 | <p>I have the following code, which is the core part of my small AJAX application. I am not getting any errors, it is just that nothing happens. I am guessing there is a more efficient way to do what I am trying to do.</p>
<p>Here is the code:</p>
<pre><code>var xmlHttp
var layername
function update(layer, part, pk, query)
{
if (part=="1")
{
$url "get_auction.php?cmd=GetAuctionData&pk="+pk+"&sid="+Math.random()
}
else if (part=="2")
{
var url "get_records.php?cmd=GetRecordSet&query="+query+"&sid="+Math.random()
}
xmlHttp=GetXmlHttpObject()
if(xmlHttp==null)
{
alert("Your browser is not supported?")
}
xmlHttp.onreadystatechange = function() {
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
document.getElementById(layer).innerHTML=xmlHttp.responseText
} else if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading") {
document.getElementById(layer).innerHTML="loading"
}
};
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
xmlHttp=new XMLHttpRequest();
}catch (e)
{
try
{
xmlHttp =new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
return xmlHttp;
}
function makewindows(){
child1 = window.open ("about:blank");
child1.document.write(json_encode(<?php echo $row2["ARTICLE_DESC"]; ?>));
child1.document.close();
}
</code></pre>
<p>and an example of how I am calling the function from php</p>
<pre><code>onclick="update(\'Layer3\',\'2\','.$pk.'\',\'0\',)">'
</code></pre>
<p>pk or query will never be passed at the same time, only one of them will ever be passed.</p>
<p>edit: I am also wondering if it would make more sense for the makewindows function to take a parameter, or stay as it is. Are there advantages and disadvantages for each approach?</p>
| [
{
"answer_id": 355935,
"author": "Stoo",
"author_id": 27425,
"author_profile": "https://Stackoverflow.com/users/27425",
"pm_score": 1,
"selected": false,
"text": "onclick=\"update(\\'Layer3\\',\\'2\\',\\''.$pk.'\\',\\'0\\',)\">\n"
},
{
"answer_id": 356282,
"author": "Andreas ... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
355,875 | <p>I think I am having a mental block but can someone please enlighten me on how to combine these two LINQ statements into one? </p>
<pre><code>/// <summary>
/// Returns an array of Types that implement the supplied generic interface in the
/// current AppDomain.
/// </summary>
/// <param name="interfaceType">Type of generic interface implemented</param>
/// <param name="includeAbstractTypes">Include Abstract class types in the search</param>
/// <param name="includeInterfaceTypes">Include Interface class types in the search</param>
/// <returns>Array of Types that implement the supplied generic interface</returns>
/// <remarks>
/// History.<br/>
/// 10/12/2008 davide Method creation.<br/>
/// </remarks>
public static Type[] GetTypesImplementingGenericInterface(Type interfaceType, bool includeAbstractTypes, bool includeInterfaceTypes)
{
// Use linq to find types that implement the supplied interface.
var allTypes = AppDomain.CurrentDomain.GetAssemblies().ToList()
.SelectMany(s => s.GetTypes())
.Where(p => p.IsAbstract == includeAbstractTypes
&& p.IsInterface == includeInterfaceTypes);
var implementingTypes = from type in allTypes
from intf in type.GetInterfaces().ToList()
where intf.FullName != null && intf.FullName.Contains(interfaceType.FullName)
select type;
return implementingTypes.ToArray<Type>();
}
</code></pre>
<p>I am avoiding IsAssignableFrom as its seems to fail when not supplying the specific type of the generic interface therefore I believe using FullName caparison over IsAssignableFrom should suffice, for example:</p>
<pre><code>namespace Davide
{
interface IOutput<TOutputType> { }
class StringOutput : IOutput<string> { }
}
</code></pre>
<p>typeof(IOutput<>).FullName will return "Davide+IOutput`1"</p>
<p>typeof(StringOutput).GetInterfaces()[0].FullName will return "Davide+IOutput`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"</p>
<p>Therefore using FullName.Contains should suffice</p>
| [
{
"answer_id": 355936,
"author": "Hath",
"author_id": 5186,
"author_profile": "https://Stackoverflow.com/users/5186",
"pm_score": 1,
"selected": false,
"text": " public static Type[] GetTypesImplementingGenericInterface(Type interfaceType, bool includeAbstractTypes, bool includeInterf... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38041/"
] |
355,876 | <p>I'm working on an ASP .NET 2.0 site which uses a Web Application project file, and therefore compiles to a dll rather than deploying the source code as you do with the older style Web Site projects.</p>
<p>The site works fine on my test server (Windows Server 2003 R2, IIS6) when it runs in the root of a website. However I need to run it under a virtual directory instead. When I switch over to that, I get the following error on browsing to any of the pages in the site</p>
<p>CS1519: Invalid token ',' in class, struct, or interface member declaration</p>
<p>The error message goes onto tell me the line number and code file, however the code file is under the Temporary ASP .NET files folder and when I try to find it, it's not there.</p>
<p>As such I'm unable to work out which page is causing the issue although I suspect it could be the master page, if this error occurs on all pages. Has anyone else seen this before or found a solution?</p>
| [
{
"answer_id": 48753390,
"author": "noemi",
"author_id": 9351451,
"author_profile": "https://Stackoverflow.com/users/9351451",
"pm_score": -1,
"selected": false,
"text": "namespace Rectangle\n{\n class Name\n {\n int length1;\n int width1;\n int sum;\n\n ... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12277/"
] |
355,879 | <p>I have the following code:</p>
<p><a href="http://www.nomorepasting.com/getpaste.php?pasteid=22615" rel="nofollow noreferrer">http://www.nomorepasting.com/getpaste.php?pasteid=22615</a></p>
<p>Which is called by the javascript mentioned in <a href="https://stackoverflow.com/questions/355865/javascript-function-not-responsive">this question</a>:</p>
<p>My problem is that I do not seem to be able to pass $query, as in nothing seemingly happens when I call this file by itself.</p>
<p>I am unsure what the best way to control the flow of information is. Is my logic ok? Passing the query through javascript to the php file, and then returning it with the function? </p>
<p>I am also concerned about my use of $rows, as it does not seem to be required.</p>
| [
{
"answer_id": 356019,
"author": "spelley",
"author_id": 41654,
"author_profile": "https://Stackoverflow.com/users/41654",
"pm_score": 0,
"selected": false,
"text": "$query ='';\nif (isset($_GET[\"query\"]))\n$query = $_GET[\"query\"];\n"
},
{
"answer_id": 356085,
"author": "... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
355,899 | <pre><code> String fullName = PATH + "." + name;
Class cl= Class.forName(fullName);
if(name.equalsIgnoreCase("MobileSearch")){
if(msearchType==null){
msearchType=(SearchInterface)cl.newInstance();
}
return msearchType;
}
if(name.equalsIgnoreCase("BookSearch")){
if(bsearchType==null){
bsearchType=(SearchInterface)cl.newInstance();
}
return bsearchType;
}
</code></pre>
<p>How do I get rid of the <code>if</code> statements here.<br>
I am using reflection.<br>
Please help. Thanks in advance.</p>
| [
{
"answer_id": 355922,
"author": "Jacob Schoen",
"author_id": 3340,
"author_profile": "https://Stackoverflow.com/users/3340",
"pm_score": 0,
"selected": false,
"text": "String fullName = PATH + \".\" + name;\n\nClass cl= Class.forName(fullName); \nif(searchType==null){ ... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
355,903 | <p>I have a website setup in IIS 6, let's say it's called <strong><a href="http://www.this.com" rel="nofollow noreferrer">http://www.this.com</a></strong>.</p>
<p>I have setup a redirection for this website to <strong><a href="http://www.that.com" rel="nofollow noreferrer">http://www.that.com</a></strong> which maintains the directory structure and query parameters as follows:</p>
<p><strong><a href="http://www.that.com" rel="nofollow noreferrer">http://www.that.com</a>$S$Q - using the option "The exact URL entered above"</strong></p>
<p>This works great, whenever someone requests, for example:</p>
<p><strong><a href="http://www.this.com/subfolder/page.aspx?Id=1" rel="nofollow noreferrer">http://www.this.com/subfolder/page.aspx?Id=1</a></strong></p>
<p>then they end up at:</p>
<p><strong><a href="http://www.that.com/subfolder/page.aspx?Id=1" rel="nofollow noreferrer">http://www.that.com/subfolder/page.aspx?Id=1</a></strong></p>
<p>Now, I have one page, actually a handler, <strong><a href="http://www.this.com/image.axd" rel="nofollow noreferrer">http://www.this.com/image.axd</a></strong>, which I do not want to redirect.</p>
<p>What is the syntax for that? I've read the <strong>Redirection Using Wildcards</strong> section <a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/41c238b2-1188-488f-bf2d-464383b1bb08.mspx?mfr=true" rel="nofollow noreferrer">here</a>, but I can't work out how to do what seems to be something straight forward.</p>
<p>Note that <strong>image.axd</strong> is a handler so I can't just "right click" on it and set the redirection properties as it doesn't physically exist.</p>
<p>I also have a couple of other pages in subfolders which I do not want to redirect, for example:</p>
<p><strong><a href="http://www.this.com/subfolder/donotredirectthispage.aspx" rel="nofollow noreferrer">http://www.this.com/subfolder/donotredirectthispage.aspx</a></strong></p>
<p>Any help would be appreciated.</p>
<p><strong>Edit:</strong> A couple of people have mentioned using ISAPI_Rewrite, for which I'm grateful, but I really don't want to introduce another complexity into the website configuration. IIS seems to imply I can acheive what I want using the ! and 0 through 9 variables. </p>
<p>Is it really not possible to do this using IIS?</p>
<p>My current workaround is to set the redirection properties on ALL folders and pages that I want to redirect except those I do not, but this is a management nightmare.</p>
| [
{
"answer_id": 355912,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "page not found"
},
{
"answer_id": 355956,
"author": "Tomalak",
"author_id": 18771,
"author_profile"... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5449/"
] |
355,907 | <p>I'm aware that in Vim I can often repeat a command by simply adding a number in front of it. For example, one can delete 5 lines by:</p>
<pre><code>5dd
</code></pre>
<p>It's also often possible to specify a range of lines to apply a command to, for example</p>
<pre><code>:10,20s:hello:goodbye:gc
</code></pre>
<p>How can I perform a 'vertical edit'? I'd like to, for example, insert a particular symbol, say a comma, at the beggining (skipping whitespace, i.e. what you'd get if you type a comma after Shift-I in command mode) of every line in a given range. How can this be achieved (without resorting to down-period-down-period-down-period)?</p>
| [
{
"answer_id": 355921,
"author": "Svante",
"author_id": 31615,
"author_profile": "https://Stackoverflow.com/users/31615",
"pm_score": 8,
"selected": true,
"text": ":10,20s/^/,/"
},
{
"answer_id": 355923,
"author": "wimh",
"author_id": 33499,
"author_profile": "https:/... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37984/"
] |
355,908 | <p>For tasks that will take more than a few seconds, a good user interface, in my opinion, should provide a progress bar along with appropriate information on the progress of the operation. (Microsoft kindly provide <a href="http://msdn.microsoft.com/en-us/library/aa511486.aspx" rel="nofollow noreferrer">User Interface Guidelines</a> on this topic, but I want a status panel that is a bit more advanced.)</p>
<p>The "task" class I am using is able to log messages, and if the messages are important enough (warning or error), I would like to display them on the progress panel. It would also be nice with a graphical indication when warnings or errors have occured (a warning or error icon perhaps). If there are many such messages, a text box, a list view or perhaps some <a href="http://www.codejock.com/products/reportcontrol/" rel="nofollow noreferrer">report control</a> could be appropriate here.</p>
<p>There could be a cancel button while the task is running, and after the task has been completed, a "View log" button would also be nice.</p>
<p>To summarise, I have a good idea how to implement my status panel, but I would really like some input on this. Did I miss something important? Am I going overboard on this? Are there perhaps any components like this already available out there?</p>
| [
{
"answer_id": 357137,
"author": "Greg",
"author_id": 42882,
"author_profile": "https://Stackoverflow.com/users/42882",
"pm_score": 1,
"selected": false,
"text": "StartNewTask(Caption,NumberOfSubtasks)\nEndTask \nSetProgress(Caption,NumberOfSubtasksFinished)\n"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/355908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18651/"
] |
355,909 | <p>(All of the following is to be written in Java)</p>
<p>I have to build an application that will take as input XML documents that are, potentially, very large. The document is encrypted -- not with XMLsec, but with my client's preexisting encryption algorithm -- will be processed in three phases:</p>
<p>First, the stream will be decrypted according to the aforementioned algorithm.</p>
<p>Second, an extension class (written by a third party to an API I am providing) will read some portion of the file. The amount that is read is not predictable -- in particular it is not guaranteed to be in the header of the file, but might occur at any point in the XML.</p>
<p>Lastly, another extension class (same deal) will subdivide the input XML into 1..n subset documents. It is possible that these will in some part overlap the portion of the document dealt with by the second operation, ie: I believe I will need to rewind whatever mechanism I am using to deal with this object.</p>
<p>Here is my question:</p>
<p>Is there a way to do this without ever reading the entire piece of data into memory at one time? Obviously I can implement the decryption as an input stream filter, but I'm not sure if it's possible to parse XML in the way I'm describing; by walking over as much of the document is required to gather the second step's information, and then by rewinding the document and passing over it again to split it into jobs, ideally releasing all of the parts of the document that are no longer in use after they have been passed.</p>
| [
{
"answer_id": 355962,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 2,
"selected": false,
"text": "BufferedInputStream"
},
{
"answer_id": 356111,
"author": "Nick Holt",
"author_id": 41423,
"autho... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23309/"
] |
355,916 | <p>Please if you have used NHibernate and Entity Frameworks, please contrast your experiences.</p>
| [
{
"answer_id": 355962,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 2,
"selected": false,
"text": "BufferedInputStream"
},
{
"answer_id": 356111,
"author": "Nick Holt",
"author_id": 41423,
"autho... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799/"
] |
355,917 | <p>I have a web app that uses log4net to log errors to a log file.
It works well when I publish my website via xcopy but when I build a package installer, log4net does not appear to work when remote users access my site.</p>
<p>I use <em>impersonate=true</em> in my web.config and log4net only logs errors when I am the logged user.</p>
<p>I have another app that works fine in all cases but was not package deployed.</p>
<p>Does anyone have any thoughts?</p>
| [
{
"answer_id": 356205,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": " <!-- log4net -->\n <log4net debug=\"false\">\n <appender name=\"RollingFileAppender\" type=\"log4net.Appender.RollingFil... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
355,933 | <p>I have a ASP.NET project, in which I have a method with 10 local variables. This method calls about 10 other methods. 3 of the called methods need all the variables. Is it considered good practice to turn all those variables into global members, and then they don't have to passed as parameters?</p>
| [
{
"answer_id": 355954,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": false,
"text": "public class Foo {\n public string Key {get;set;}\n public decimal Quantity {get;set;}\n // etc\n}\n"
}... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/278/"
] |
355,937 | <p>I have Widget.title, Widget.publish_ at, and Widget.unpublish_ at. It's a rails app with thinking_sphinx running, indexing once a night. I want to find all Widgets that have 'foo' in the title, and are published (publish _at < Time.now, unpublish _at > Time.now). </p>
<p>To get pagination to work properly, I really want to do this in a sphinx query. I have
'has :publish_at, :unpublish_at' to get the attributes, but what's the syntax for 'Widget.search("foo @publish_ at > #{Time.now}",:match _mode=>:extended'? Is this even possible? </p>
| [
{
"answer_id": 356028,
"author": "Michael",
"author_id": 35500,
"author_profile": "https://Stackoverflow.com/users/35500",
"pm_score": 3,
"selected": false,
"text": "class Widget < ActiveRecord::Base\n define_index do\n indexes title\n has publish_at\n has unpublish_at\n ...... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18666/"
] |
355,942 | <p>I am getting an error while porting my application from VC6 to Visual Studio 2005.</p>
<p>Does anyone have any idea what this means?</p>
<blockquote>
<p>mfcs80.lib(dllmodul.obj) : error
LNK2005: _DllMain@12 already defined
in MSVCRT.lib(dllmain.obj)</p>
</blockquote>
| [
{
"answer_id": 2093094,
"author": "Ruddy",
"author_id": 229904,
"author_profile": "https://Stackoverflow.com/users/229904",
"pm_score": 2,
"selected": false,
"text": "#ifdef OMUTILITIES_LINK_STATIC\n #undef AfxGetStaticModuleState\n #define AfxGetStaticModuleState AfxGetModuleState... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43596/"
] |
355,945 | <p>Is there a quick and nice way using linq?</p>
| [
{
"answer_id": 355977,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 8,
"selected": true,
"text": "var most = list.GroupBy(i=>i).OrderByDescending(grp=>grp.Count())\n .Select(grp=>grp.Key).First();\n"
},
{
... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
355,958 | <p>i have little problem with boost::asio library. My app receive and process data asynchronously, it create threads and run io_service.run() on each of them.</p>
<pre><code>boost::asio::io_service io;
boost::thread_group thread_pool;
...
int cpu_cnt = get_cpu_count();
for (int i = 0; i < cpu_cnt; ++i)
{
thread_pool.create_thread( boost::bind(&run_service, &io) );
}
void run_service(boost::asio::io_service* io)
{
try
{
io->run();//make fun
}
catch(const std::exception& e)
{ //process error
}
catch(...)
{ //process error
}
}
</code></pre>
<p>Time after time, my application receives message(across windows messaging system) from some supervisor application that checks is my program alive or not. If my application wont reply, it will be restarted. The tricky part here is to check, that threads is running and not deadlocked. I can post handler to io_service like this:</p>
<pre><code>io.post( &reply_to_supervisor );
</code></pre>
<p>but this method affects only one thread.
How can i check that all threads is running and not deadlocked?</p>
| [
{
"answer_id": 416820,
"author": "Vlagged",
"author_id": 6727,
"author_profile": "https://Stackoverflow.com/users/6727",
"pm_score": 3,
"selected": true,
"text": "cpu_cnt"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/355958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42371/"
] |
355,967 | <p>The following code calls the builtin functions for clz/ctz in GCC and, on other systems, has C versions. Obviously, the C versions are a bit suboptimal if the system has a builtin clz/ctz instruction, like x86 and ARM.</p>
<pre><code>#ifdef __GNUC__
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#else
static uint32_t ALWAYS_INLINE popcnt( uint32_t x )
{
x -= ((x >> 1) & 0x55555555);
x = (((x >> 2) & 0x33333333) + (x & 0x33333333));
x = (((x >> 4) + x) & 0x0f0f0f0f);
x += (x >> 8);
x += (x >> 16);
return x & 0x0000003f;
}
static uint32_t ALWAYS_INLINE clz( uint32_t x )
{
x |= (x >> 1);
x |= (x >> 2);
x |= (x >> 4);
x |= (x >> 8);
x |= (x >> 16);
return 32 - popcnt(x);
}
static uint32_t ALWAYS_INLINE ctz( uint32_t x )
{
return popcnt((x & -x) - 1);
}
#endif
</code></pre>
<p>What functions do I need to call, which headers do I need to include, etc to add a proper ifdef for MSVC here? I've already looked at <a href="https://msdn.microsoft.com/en-us/library/wfd9z0bb.aspx" rel="noreferrer">this page</a>, but I'm not entirely sure what the #pragma is for (is it required?) and what restrictions it puts on MSVC version requirements for compilation. As someone who doesn't really use MSVC, I also don't know whether these intrinsics have C equivalents on other architectures, or whether I have to #ifdef x86/x86_64 as well when #defining them.</p>
| [
{
"answer_id": 5468852,
"author": "sh0dan",
"author_id": 681490,
"author_profile": "https://Stackoverflow.com/users/681490",
"pm_score": -1,
"selected": false,
"text": "#ifdef _MSC_VER\n#include <intrin.h>\n\nstatic uint32_t __inline ctz( uint32_t x )\n{\n int r = 0;\n _BitScanRevers... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11206/"
] |
355,986 | <p>How do we assign null value to int column in LINQ.
eg.</p>
<pre><code> SQLDBDataContext sqlD = new SQLDBDataContext();
var result = from p in sqlD.loadsRadius(Convert.ToInt32(Request["radius"]), .....
</code></pre>
<p>here if Request["radius"] is null gives an error.</p>
<p>I could pass 0 via this but I need to change in many already existing procedures.</p>
<p>Thanks in advance.<br>
<a href="http://www.ade-technologies.com" rel="nofollow noreferrer">Anil</a></p>
| [
{
"answer_id": 356158,
"author": "Pradeep Kumar Mishra",
"author_id": 22710,
"author_profile": "https://Stackoverflow.com/users/22710",
"pm_score": 0,
"selected": false,
"text": "int radius = -1;\nint.TryParse(Request[\"radius\"],out radius)\nif(radius > 0) // you can remove this clause ... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
355,988 | <p>I'm trying to do this:</p>
<pre><code>cmd.exe /C "C:\Program Files\Somewhere\SomeProgram.exe" > "C:\temp\Folder Containing Spaces\SomeProgram.out"
</code></pre>
<p>However, I have problems which are down to the way cmd.exe works. If you read the help for it, it handles " characters in a special way. See the help at the end of question. So, this doesn't execute correctly... I'm guessing cmd.exe strips some quotes which makes the statement ill-formed.</p>
<p>I can do this successfully:</p>
<pre><code>// quotes not required around folder with no spaces
cmd.exe /C "C:\Program Files\Somewhere\SomeProgram.exe" > C:\temp\FolderWithNoSpaces\SomeProgram.out
</code></pre>
<p>But, I really need the first one to work. Is there away around the strange quote processing that cmd.exe uses? I want it to preserve all of the quotes, but there doesn't appear to be an option to make it do that.</p>
<hr>
<p><strong>Help taken from output of: cmd /?</strong></p>
<p>If /C or /K is specified, then the remainder of the command line after
the switch is processed as a command line, where the following logic is
used to process quote (") characters:</p>
<pre><code>1. If all of the following conditions are met, then quote characters
on the command line are preserved:
- no /S switch
- exactly two quote characters
- no special characters between the two quote characters,
where special is one of: &<>()@^|
- there are one or more whitespace characters between the
the two quote characters
- the string between the two quote characters is the name
of an executable file.
2. Otherwise, old behavior is to see if the first character is
a quote character and if so, strip the leading character and
remove the last quote character on the command line, preserving
any text after the last quote character.
</code></pre>
| [
{
"answer_id": 356014,
"author": "Scott Langham",
"author_id": 11898,
"author_profile": "https://Stackoverflow.com/users/11898",
"pm_score": 8,
"selected": true,
"text": "cmd.exe /S /C \" do what you like here, quotes within the outermost quotes will be preserved \"\n"
},
{
"answ... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11898/"
] |
355,994 | <p>I have two medium-sized web applications that I'm merging into one. They are both localized with <code>GetText</code> and have large amout of common strings, so merging them manually would be extremely annoying. What is the fastest way to merge the two <code>PO</code> files?</p>
| [
{
"answer_id": 356001,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 3,
"selected": true,
"text": "msgmerge"
},
{
"answer_id": 7643286,
"author": "seanf",
"author_id": 14379,
"author_profile": "https://Stac... | 2008/12/10 | [
"https://Stackoverflow.com/questions/355994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38256/"
] |
356,000 | <p>I'd like to drop a user in a SQL Server script but I'll need to test for existence first or I'll get script errors. When dropping tables or stored procs, I check the sysobjects table like so:</p>
<pre><code>IF EXISTS (
SELECT *
FROM sysobjects
WHERE id = object_id(N'[dbo].[up_SetMedOptions]')
AND OBJECTPROPERTY(id, N'IsProcedure') = 1
)
Drop Procedure up_SetMedOptions;
GO
</code></pre>
<p>What is the corollary for checking for a user? Note that I am NOT asking about a database login to the server! The question pertains to a User in a specific database.</p>
| [
{
"answer_id": 356021,
"author": "edosoft",
"author_id": 6399,
"author_profile": "https://Stackoverflow.com/users/6399",
"pm_score": 2,
"selected": false,
"text": "select * from sys.sysusers\n"
},
{
"answer_id": 356030,
"author": "Ed Harper",
"author_id": 27825,
"auth... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15592/"
] |
356,002 | <p>So I'm trying to get rid of my std::vector's by using boost::ptr_vector. Now I'm trying to remove an element from one, and have the removed element deleted as well. The most obvious thing to me was to do:</p>
<pre><code>class A
{ int m; };
boost::ptr_vector<A> vec;
A* a = new A;
vec.push_back(a);
vec.erase(a);
</code></pre>
<p>But this won't even compile (see below for the full error message). I've tried the erase/remove idiom like I would on a std::vector but all the algorithms of boost::ptr_vector turn out to be slightly different from those in std::vector.</p>
<p>So my questions:</p>
<ul>
<li>How do I remove a pointer from a ptr_vector?</li>
<li>Do I still need to manually delete() that element that I removed?</li>
</ul>
<p>Compiler error:</p>
<pre><code>1>------ Build started: Project: ptr_vector_test, Configuration: Debug Win32 ------
1>Compiling...
1>ptr_vector_test.cpp
1>c:\users\rvanhout\svn\trunk\thirdparty\boost\range\const_iterator.hpp(37) : error C2825: 'C': must be a class or namespace when followed by '::'
1> c:\users\rvanhout\svn\trunk\thirdparty\boost\mpl\eval_if.hpp(63) : see reference to class template instantiation 'boost::range_const_iterator<C>' being compiled
1> with
1> [
1> C=A *
1> ]
1> c:\users\rvanhout\svn\trunk\thirdparty\boost\range\iterator.hpp(63) : see reference to class template instantiation 'boost::mpl::eval_if_c<C,F1,F2>' being compiled
1> with
1> [
1> C=true,
1> F1=boost::range_const_iterator<A *>,
1> F2=boost::range_mutable_iterator<A *const >
1> ]
1> c:\users\rvanhout\svn\trunk\thirdparty\boost\ptr_container\detail\reversible_ptr_container.hpp(506) : see reference to class template instantiation 'boost::range_iterator<C>' being compiled
1> with
1> [
1> C=A *const
1> ]
1> c:\tmp\ptr_vector_test\ptr_vector_test.cpp(21) : see reference to function template instantiation 'boost::void_ptr_iterator<VoidIter,T> boost::ptr_container_detail::reversible_ptr_container<Config,CloneAllocator>::erase<A*>(const Range &)' being compiled
1> with
1> [
1> VoidIter=std::_Vector_iterator<void *,std::allocator<void *>>,
1> T=A,
1> Config=boost::ptr_container_detail::sequence_config<A,std::vector<void *,std::allocator<void *>>>,
1> CloneAllocator=boost::heap_clone_allocator,
1> Range=A *
1> ]
1>c:\users\rvanhout\svn\trunk\thirdparty\boost\range\const_iterator.hpp(37) : error C2039: 'const_iterator' : is not a member of '`global namespace''
1>c:\users\rvanhout\svn\trunk\thirdparty\boost\range\const_iterator.hpp(37) : error C2146: syntax error : missing ';' before identifier 'type'
1>c:\users\rvanhout\svn\trunk\thirdparty\boost\range\const_iterator.hpp(37) : error C2208: 'boost::type' : no members defined using this type
1>c:\users\rvanhout\svn\trunk\thirdparty\boost\range\const_iterator.hpp(37) : fatal error C1903: unable to recover from previous error(s); stopping compilation
1>Build log was saved at "file://c:\tmp\ptr_vector_test\Debug\BuildLog.htm"
1>ptr_vector_test - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
</code></pre>
| [
{
"answer_id": 356016,
"author": "Evgeny Lazin",
"author_id": 42371,
"author_profile": "https://Stackoverflow.com/users/42371",
"pm_score": 1,
"selected": false,
"text": "vec.erase_if( predicate() );\n"
},
{
"answer_id": 356046,
"author": "Pieter",
"author_id": 5822,
... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11449/"
] |
356,004 | <p>Is it possible to have a singleton in a factory method? I have many domains using the factory method. How do I work around with this. Please help me with an example.</p>
| [
{
"answer_id": 356018,
"author": "mepcotterell",
"author_id": 43312,
"author_profile": "https://Stackoverflow.com/users/43312",
"pm_score": 2,
"selected": false,
"text": "/**\n * An interface defining objects that can create Singleton\n * instances.\n */\npublic interface SingletonFactor... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
356,010 | <p>I was wondering if there is some option to keep ReSharper from removing just the <code>using System;</code> directive? Perhaps this is configurable somewhere?</p>
<p>Also, is there a way to have ReSharper sort the remaining directives just as Visual Studio 2008 does it (alphabetically, I think)?</p>
<p>Thanks.</p>
| [
{
"answer_id": 356032,
"author": "Garry Shutler",
"author_id": 6369,
"author_profile": "https://Stackoverflow.com/users/6369",
"pm_score": 3,
"selected": false,
"text": "Resharper"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/356010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8205/"
] |
356,035 | <p>I have a 2D area with "dots" distributed on this area. I now am trying to detect "clusters" of dots, that is, areas with a certain high density of dots.</p>
<p>Any thoughts on (or links to articles with thoughts on) how to elegantly detect these areas?</p>
| [
{
"answer_id": 356069,
"author": "krusty.ar",
"author_id": 43981,
"author_profile": "https://Stackoverflow.com/users/43981",
"pm_score": 6,
"selected": true,
"text": "//load the image\nPImage sample;\nsample = loadImage(\"test.png\");\nsize(sample.width, sample.height);\nimage(sample, 0,... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6583/"
] |
356,039 | <p>For a stylesheet I'm writing (actually for a set of them, each generating a different output format), I have the need to evaluate whether a certain value is present in a list of values. In this case, the value being tested is taken from an element's attribute. The list it is to be tested against comes from the invocation of the stylesheet, and is taken as a top-level <code><xsl:param></code> (to be provided on the command-line when I call <code>xsltproc</code> or a Saxon equivalent invocation). For example, the input value may be:</p>
<pre><code>v0_01,v0_10,v0_99
</code></pre>
<p>while the attribute values will each look very much like <em>one</em> such value. (Whether a comma is used to separate values, or a space, is not important-- I chose a comma for now because I plan on passing the value via command-line switch to <code>xsltproc</code>, and using a space would require quoting the argument, and I'm lazy-enough to not want to type the extra two characters.)</p>
<p>What I am looking for is something akin to Perl's <code>grep</code>, wherein I can see if the value I currently have is contained in the list. It can be done with sub-string tests, but this would have to be clever so as not to get a false-positive (<code>v0_01</code> should not match a string that contains <code>v0_011</code>). It seems that the only non-scalar data-type that XSL/XSLT supports is a node-set. I suppose it's possible to convert the list into a set of text nodes, but that seems like over-kill, even compared to making a sub-string test with extra boundaries-checking to prevent false matches.</p>
| [
{
"answer_id": 356077,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 3,
"selected": false,
"text": "contains(concat(',' $list, ','), concat(',', $value, ','))\n"
},
{
"answer_id": 356777,
"author": "Dimitre Nov... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6421/"
] |
356,060 | <p>I have using the following code for developing tabs.</p>
<pre><code>$(document).ready(function() {
$('#container-1').tabs();
}
....
<div id="container-1">
<ul>
<li><a href="#fragment-1"><span>Home</span></a></li>
<li><a href="#fragment-2"><span>Contact</span></a></li>
</ul>
</div>
...
</code></pre>
<p>It works fine! I need the tab click event. If it is the <em>Home</em> tab click, I have to do <code>alert();</code>. How do I achieve this?</p>
| [
{
"answer_id": 356136,
"author": "adam",
"author_id": 33604,
"author_profile": "https://Stackoverflow.com/users/33604",
"pm_score": 0,
"selected": false,
"text": "$(\"#tabid\").click(function(e) {\n e.preventDefault();\n // Do tab click logic\n});\n"
},
{
"answer_id": 35615... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] |
356,090 | <p>I need a way to compute the nth root of a long integer in Python. </p>
<p>I tried <code>pow(m, 1.0/n)</code>, but it doesn't work:</p>
<blockquote>
<p>OverflowError: long int too large to convert to float</p>
</blockquote>
<p>Any ideas?</p>
<p>By long integer I mean REALLY long integers like:</p>
<blockquote>
<p>11968003966030964356885611480383408833172346450467339251
196093144141045683463085291115677488411620264826942334897996389
485046262847265769280883237649461122479734279424416861834396522
819159219215308460065265520143082728303864638821979329804885526
557893649662037092457130509980883789368448042961108430809620626
059287437887495827369474189818588006905358793385574832590121472
680866521970802708379837148646191567765584039175249171110593159
305029014037881475265618958103073425958633163441030267478942720
703134493880117805010891574606323700178176718412858948243785754
898788359757528163558061136758276299059029113119763557411729353
915848889261125855717014320045292143759177464380434854573300054
940683350937992500211758727939459249163046465047204851616590276
724564411037216844005877918224201569391107769029955591465502737
961776799311859881060956465198859727495735498887960494256488224
613682478900505821893815926193600121890632</p>
</blockquote>
| [
{
"answer_id": 356110,
"author": "Brian",
"author_id": 18192,
"author_profile": "https://Stackoverflow.com/users/18192",
"pm_score": 0,
"selected": false,
"text": "1/3"
},
{
"answer_id": 356187,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackove... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44988/"
] |
356,100 | <p>How to wait in a bash script for several subprocesses spawned from that script to finish, and then return exit code <code>!=0</code> when any of the subprocesses ends with code <code>!=0</code>?</p>
<p>Simple script:</p>
<pre><code>#!/bin/bash
for i in `seq 0 9`; do
doCalculations $i &
done
wait
</code></pre>
<p>The above script will wait for all 10 spawned subprocesses, but it will always give exit status <code>0</code> (see <code>help wait</code>). How can I modify this script so it will discover exit statuses of spawned subprocesses and return exit code <code>1</code> when any of subprocesses ends with code <code>!=0</code>?</p>
<p>Is there any better solution for that than collecting PIDs of the subprocesses, wait for them in order and sum exit statuses?</p>
| [
{
"answer_id": 356154,
"author": "Luca Tettamanti",
"author_id": 42448,
"author_profile": "https://Stackoverflow.com/users/42448",
"pm_score": 10,
"selected": true,
"text": "wait"
},
{
"answer_id": 356229,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "htt... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42201/"
] |
356,121 | <p>I want to refactor this mumbo jumbo of a method to make it more readible, it has way to many nested IF's for my liking.</p>
<p>How would you refactor this?</p>
<pre><code>public static void HandleUploadedFile(string filename)
{
try
{
if(IsValidFileFormat(filename)
{
int folderID = GetFolderIDFromFilename(filename);
if(folderID > 0)
{
if(HasNoViruses(filename)
{
if(VerifyFileSize(filename)
{
// file is OK
MoveToSafeFolder(filename);
}
else
{
DeleteFile(filename);
LogError("file size invalid");
}
}
else
{
DeleteFile(filename);
LogError("failed virus test");
}
}
else
{
DeleteFile(filename);
LogError("invalid folder ID");
}
}
else
{
DeleteFile(filename);
LogError("invalid file format");
}
}
catch (Exception ex)
{
LogError("unknown error", ex.Message);
}
finally
{
// do some things
}
}
</code></pre>
| [
{
"answer_id": 356148,
"author": "David Waters",
"author_id": 12148,
"author_profile": "https://Stackoverflow.com/users/12148",
"pm_score": 6,
"selected": true,
"text": "try{\n if(IsValidFileFormat(filename) == false){\n DeleteFile(filename);\n LogError(\"invalid file fo... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39677/"
] |
356,122 | <p>I am writing a .NET library that for various reasons cannot be registered in the GAC.
This dll (let's call it SDK.dll) depends on other DLLs in order to be loaded.</p>
<p>When writing a program that uses this SDK.dll, I noticed that my program failed loading the dll with a FileNotFoundException thrown. This happens because although I was able to find the referenced SDK.dll, the CLR failed to load its dependencies.</p>
<p>The only way I found to solve the problem is to "Copy Local" the SDK.dll and all its dependencies (something I can't do because of deployment problems), or compiling my program into the same directory as SDK.dll</p>
<p>Is there a way to tell SDK.dll where to look for it's dependencies regardless of its location? Maybe a SDK.dll.config file can help?</p>
| [
{
"answer_id": 356466,
"author": "Snooganz",
"author_id": 28224,
"author_profile": "https://Stackoverflow.com/users/28224",
"pm_score": 4,
"selected": true,
"text": "AppDomain.CurrentDomain.AssemblyResolve\n"
},
{
"answer_id": 1492843,
"author": "MauriceL",
"author_id": 1... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12818/"
] |
356,126 | <p>I am getting 'trailing whitespace' errors trying to commit some files in Git.</p>
<p>I want to remove these trailing whitespace characters automatically right before I save Python files.</p>
<p>Can you configure Vim to do this? If so, how?</p>
| [
{
"answer_id": 356130,
"author": "Paul D. Eden",
"author_id": 3045,
"author_profile": "https://Stackoverflow.com/users/3045",
"pm_score": 9,
"selected": true,
"text": "autocmd BufWritePre *.py :%s/\\s\\+$//e\n"
},
{
"answer_id": 356214,
"author": "mat",
"author_id": 42083... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3045/"
] |
356,128 | <p>If I have several classes with functions that I need but want to store separately for organisation, can I extend a class to have both?</p>
<p>i.e. <code>class a extends b extends c</code></p>
<p>edit: I know how to extend classes one at a time, but I'm looking for a method to instantly extend a class using multiple base classes - AFAIK you can't do this in PHP but there should be ways around it without resorting to <code>class c extends b</code>, <code>class b extends a</code></p>
| [
{
"answer_id": 356172,
"author": "adam",
"author_id": 33604,
"author_profile": "https://Stackoverflow.com/users/33604",
"pm_score": 7,
"selected": false,
"text": "// this is NOT allowed (for all you google speeders)\nMatron extends Nurse, HumanEntity\n"
},
{
"answer_id": 356431,
... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24416/"
] |
356,144 | <p>I want to use the GridView mode of a ListView to display a set of data that my program will be receiving from an external source. The data will consist of two arrays, one of column names and one of strings values to populate the control.</p>
<p>I don't see how to create a suitable class that I can use as the Item in a ListView. The only way I know to populate the Items is to set it to a class with properties that represent the columns, but I have no knowledge of the columns before run-time.</p>
<p>I could create an ItemTemplate dynamically as described in: <a href="https://stackoverflow.com/questions/125638/create-wpf-itemtemplate-dynamically-at-runtime">Create WPF ItemTemplate DYNAMICALLY at runtime</a> but it still leaves me at a loss as to how to describe the actual data.</p>
<p>Any help gratefully received.</p>
| [
{
"answer_id": 357306,
"author": "Robert Macnee",
"author_id": 19273,
"author_profile": "https://Stackoverflow.com/users/19273",
"pm_score": 5,
"selected": true,
"text": "private void AddColumns(GridView gv, string[] columnNames)\n{\n for (int i = 0; i < columnNames.Length; i++)\n ... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7989/"
] |
356,161 | <p>In python do you generally use <a href="http://www.python.org/dev/peps/pep-0008/" rel="noreferrer">PEP 8 -- Style Guide for Python Code</a> as your coding standards/guidelines? Are there any other formalized standards that you prefer?</p>
| [
{
"answer_id": 356426,
"author": "Ryan Cox",
"author_id": 620,
"author_profile": "https://Stackoverflow.com/users/620",
"pm_score": 3,
"selected": false,
"text": "# dict's setdefault method turns this:\nif key in dictobj:\n dictobj[key].append(val)\nelse:\n dictobj[key] = [val]\n# ... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52490/"
] |
356,164 | <p>Image i have a view that is cached with the OutputCache attribute but i still need to increment a counter that records that the page has been viewed, how could i do it?</p>
<p>I thought about creating my own Custom ActionFilterAttribute, and using Action Filter Order of Execution to record this .. but i'm not sure it will work.</p>
<p>eg.</p>
<pre><code>[IncrementViewCountFilter(Order=1)]
[OutputCache(Duration=60,Order=2)]
public ActionResult Index(int questionId)
{ ... }
</code></pre>
<p>Firstly, my assumption here is that if the OutputCache is called, and the page is cached, then the controller code will not be ran.</p>
<p>Next problem i'm guessing is that the IncrementViewCountFilter wouldn't know about the questionId, so how would it know what to increment (because it is executed before the main Index code is executed).</p>
<p>Secondly, if the IncrementViewCountFilter did know the questionId .. and it's getting lots of hits, you wouldn't want it to write all the time to the DB.. but only when it gets to a certain number .. and then u 'flush' the output.</p>
<p>Anyone have any thoughts?</p>
| [
{
"answer_id": 356363,
"author": "Dan Esparza",
"author_id": 19020,
"author_profile": "https://Stackoverflow.com/users/19020",
"pm_score": 4,
"selected": true,
"text": "<img src=\"/controller/action\"> \n"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/356164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] |
356,167 | <p>I could do this myself given time but does anyone have a nice asp.net implementation of an a-z list coming from a sql query. I would like it to come in the form:</p>
<p>A<br />
aardvark<br />
anagram<br />
apple</p>
<p>B<br />
barry<br />
brown....</p>
<p>That is with each entry being a link.</p>
| [
{
"answer_id": 356176,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": true,
"text": "Upper(Substring([myfield],1,1)) AS Letter"
},
{
"answer_id": 356195,
"author": "Shawn",
"author_id": 26... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16989/"
] |
356,174 | <p><strong>Dup of <a href="https://stackoverflow.com/questions/330709/some-basic-php-questions#330829">Some Basic PHP Questions</a></strong></p>
<p>Hello,</p>
<p>I have a heap of tinyint fields in a mysql database I need to show with PHP. At the moment I am doing something like this:</p>
<pre><code>if ($row['PAYPAL_ACCEPT'] == "1"){
$paypal = "Yes";
else
$paypal = "No";
}
</code></pre>
<p>For each field, which is tedious and seems like there should be a better way, than using an if clause for each field. If there is, what is it?</p>
| [
{
"answer_id": 356182,
"author": "lpfavreau",
"author_id": 35935,
"author_profile": "https://Stackoverflow.com/users/35935",
"pm_score": 2,
"selected": false,
"text": "$paypal = $row['PAYPAL_ACCEPT'] ? 'YES' : 'NO';\n"
},
{
"answer_id": 356184,
"author": "adam",
"author_i... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
356,180 | <p>Suppose to feed the filter standard input with these line:</p>
<pre><code>line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10
</code></pre>
<p>It would be nicer if someone tell me how to write a script that prints only every 4 lines, in the case of the example input above:</p>
<pre><code>line 1
line 5
line 9
</code></pre>
| [
{
"answer_id": 356198,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 5,
"selected": true,
"text": "$ yes | cat -n | head -10 | awk 'NR % 4 == 1'\n 1 y\n 5 y\n 9 y\n"
},
{
"answer_id": 356203,
"author... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36131/"
] |
356,194 | <p>I know that I can make a setter that checks to see if a value is NULL and do something. Example:</p>
<pre><code><TextBlock>
<TextBlock.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding SomeField}" Value="{x:Null}">
<Setter Property="TextBlock.Text" Value="It's NULL Baby!" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</code></pre>
<p>But how can I check for a "not" value... as in "NOT NULL", or "NOT = 3"? Is that possible in XAML?</p>
<p><strong>Results:</strong> Thanks for your answers... I knew I could do a value converter (which means I would have to go in code, and that would not be pure XAML as I hoped for). However, that does answer the question that effectively "no" you can't do it in pure XAML. The answer selected, however, shows probably the best way to <em>create</em> that kind of functionality. Good find.</p>
| [
{
"answer_id": 356690,
"author": "Robert Macnee",
"author_id": 19273,
"author_profile": "https://Stackoverflow.com/users/19273",
"pm_score": 7,
"selected": false,
"text": "<TextBlock>\n <TextBlock.Resources>\n <conv:IsNullConverter x:Key=\"isNullConverter\"/>\n </TextBlock.R... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11917/"
] |
356,217 | <p>I keep seeing code that does checks like this</p>
<pre><code>if (IsGood == false)
{
DoSomething();
}
</code></pre>
<p>or this</p>
<pre><code>if (IsGood == true)
{
DoSomething();
}
</code></pre>
<p>I hate this syntax, and always use the following syntax.</p>
<pre><code>if (IsGood)
{
DoSomething();
}
</code></pre>
<p>or</p>
<pre><code>if (!IsGood)
{
DoSomething();
}
</code></pre>
<p>Is there any reason to use '<code>== true</code>' or '<code>== false</code>'?</p>
<p>Is it a readability thing? Do people just not understand Boolean variables?</p>
<p>Also, is there any performance difference between the two?</p>
| [
{
"answer_id": 356223,
"author": "Bob",
"author_id": 45,
"author_profile": "https://Stackoverflow.com/users/45",
"pm_score": 2,
"selected": false,
"text": "!IsGood"
},
{
"answer_id": 356224,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https:... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23855/"
] |
356,219 | <p>Suppose you need to run a program on the world’s fastest supercomputer which will take 10 years to complete. You could:</p>
<ul>
<li>Spend $250M now</li>
<li>Program for 9 years, <a href="http://en.wikipedia.org/wiki/Moore%27s_Law" rel="nofollow noreferrer">Moore’s law</a> speedup (4,000x faster), spend $1M in 10years, complete in 2 weeks.</li>
</ul>
<p><strong>What is the optimum strategy?</strong></p>
<p><sub>Question from "<a href="https://research.microsoft.com/~Gray/talks/IO_talk_2006.ppt" rel="nofollow noreferrer">Long Term Storage Trends and You</a>"</sub></p>
| [
{
"answer_id": 356926,
"author": "Michael Myers",
"author_id": 13531,
"author_profile": "https://Stackoverflow.com/users/13531",
"pm_score": 4,
"selected": true,
"text": "endtime(startyear) = startyear + (calculations / speed(startyear))"
}
] | 2008/12/10 | [
"https://Stackoverflow.com/questions/356219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] |
356,243 | <p>What I want to do is basically this: on <strong>ONE</strong> page, my customers can click a <strong>VIEW CART</strong> link and the contents of their cart shows below on that same page. Here is my basic link form:</p>
<pre><code> <FORM METHOD=post ACTION="http://www.123websiteservices.com/cgi-bin/cybercart.pl">
<INPUT TYPE=hidden NAME=merchant VALUE="jessicas"/>
<INPUT TYPE=hidden NAME=action VALUE=order/>
<INPUT TYPE=hidden NAME=page_name VALUE="homepage.html"/>
<INPUT TYPE=image src="http://www.123websiteservices.com/~jessicas/images/viewcart.gif" border=0/></FORM>
</code></pre>
<p>I can't figure out how to wrap JavaScript around it to make it work. Any help is greatly appreciated!</p>
| [
{
"answer_id": 356272,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": 1,
"selected": false,
"text": "< script>\nfunction ShowScript() {\n // Do Your Show cart stuff here \n return false\n}\n< /script>\n\n...\n\n<... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45002/"
] |
356,248 | <p>I have a deceptively simple scenario, and I want a simple solution, but it's not obvious which is "most correct" or "most Java".</p>
<p>Let's say I have a small authenticate(Client client) method in some class. The authentication could fail for a number of reasons, and I want to return a simple boolean for control flow, but also return a String message for the user. These are the possibilities I can think of:</p>
<ul>
<li>Return a boolean, and pass in a StringBuilder to collect the message. This is the closest to a C-style way of doing it.</li>
<li>Throw an exception instead of returning false, and include the message. I don't like this since failure is not exceptional.</li>
<li>Create a new class called AuthenticationStatus with the boolean and the String. This seems like overkill for one small method.</li>
<li>Store the message in a member variable. This would introduce a potential race condition, and I don't like that it implies some state that isn't really there.</li>
</ul>
<p>Any other suggestions?</p>
<p><strong>Edit</strong> Missed this option off</p>
<ul>
<li>Return null for success - Is this unsafe?</li>
</ul>
<p><strong>Edit</strong> Solution:</p>
<p>I went for the most OO solution and created a small AuthenticationResult class. I wouldn't do this in any other language, but I like it in Java. I also liked the suggestion
of returning an String[] since it's like the null return but safer. One advantage of the Result class is that you can have a success message with further details if required.</p>
| [
{
"answer_id": 356287,
"author": "adam",
"author_id": 33604,
"author_profile": "https://Stackoverflow.com/users/33604",
"pm_score": 4,
"selected": false,
"text": "try {\n AuthenticateMethod();\n} catch (AuthenticateError ae) { \n // Display ae.getMessage() to user..\n Sy... | 2008/12/10 | [
"https://Stackoverflow.com/questions/356248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26334/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.