qid int64 4 8.14M | question stringlengths 20 48.3k | answers list | date stringlengths 10 10 | metadata list | input stringlengths 12 45k | output stringlengths 2 31.8k |
|---|---|---|---|---|---|---|
498,142 | <p>I created a table in my SQL Server 2005 database and populated it with summary and calculated values. The purpose is to avoid extensive joins and groupings on every call to the database. I would like this table to refresh every hour, but I am not sure the best way to do this while the website is under load. If I ... | [
{
"answer_id": 498170,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 0,
"selected": false,
"text": "<p>It depends on the relationships in your database and the queries you run against it.</p>\n\n<p>If it's a summary ta... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2582/"
] | I created a table in my SQL Server 2005 database and populated it with summary and calculated values. The purpose is to avoid extensive joins and groupings on every call to the database. I would like this table to refresh every hour, but I am not sure the best way to do this while the website is under load. If I delete... | The way I have done this in a few projects is to use two copies of the table in different schemas. So something like:
```
CREATE SCHEMA fake WITH AUTHORIZATION dbo;
CREATE SCHEMA standby WITH AUTHORIZATION dbo;
GO
CREATE TABLE dbo.mySummary(<...columns...>);
CREATE TABLE fake.mySummary(<...columns...>);
GO
```
Now... |
498,186 | <p>How do you override the enter key in a datagridview so that it will set focus to the next column instead to the next row?</p>
| [
{
"answer_id": 498407,
"author": "Cerebrus",
"author_id": 53718,
"author_profile": "https://Stackoverflow.com/users/53718",
"pm_score": 3,
"selected": true,
"text": "<p>All you need to do is handle the KeyDown event of the DataGridView and in the handler, check if the current key pressed... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26087/"
] | How do you override the enter key in a datagridview so that it will set focus to the next column instead to the next row? | All you need to do is handle the KeyDown event of the DataGridView and in the handler, check if the current key pressed is an Enter key. If so, just set the CurrentCell of the DataGridView to the next cell (also check if this is the last cell in the row, in that case, move to the first cell of the next Row.)
```
Priva... |
498,197 | <p>I have two tables with <code>date</code> and <code>id</code> fields. I want to join on both fields. I tried </p>
<pre><code>JOIN t2 ON CONCAT(t1.id, t1.date)=CONCAT(t2.id, t2.date)
</code></pre>
<p>that works, but it is very slow. is there a better way to do this?</p>
| [
{
"answer_id": 498202,
"author": "Chad Birch",
"author_id": 41665,
"author_profile": "https://Stackoverflow.com/users/41665",
"pm_score": 6,
"selected": false,
"text": "<pre><code>JOIN t2 ON (t2.id = t1.id AND t2.date = t1.date)\n</code></pre>\n"
},
{
"answer_id": 498206,
"au... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48067/"
] | I have two tables with `date` and `id` fields. I want to join on both fields. I tried
```
JOIN t2 ON CONCAT(t1.id, t1.date)=CONCAT(t2.id, t2.date)
```
that works, but it is very slow. is there a better way to do this? | ```
JOIN t2 ON t1.id=t2.id AND t1.date=t2.date
``` |
498,200 | <p>What are the best way or method of best practise to ensure that a Winforms .NET application releases all the resources it consumed in the lifecycle of its execution?</p>
<p>In particular, the release of file handles and images.</p>
<p>Thanks.</p>
| [
{
"answer_id": 498208,
"author": "amazedsaint",
"author_id": 45956,
"author_profile": "https://Stackoverflow.com/users/45956",
"pm_score": 1,
"selected": false,
"text": "<p>Follow these thumb rules</p>\n\n<p>1 - Where ever possible, use using to ensure you properly dispose objects (espec... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60905/"
] | What are the best way or method of best practise to ensure that a Winforms .NET application releases all the resources it consumed in the lifecycle of its execution?
In particular, the release of file handles and images.
Thanks. | If your implementation is whiteboxed then calling Close on file stream should close it's memory stream.
If class implements IDisposable just use the using block if in C# so the resource will be disposed:
```
using (var foo = new Foo())
{
// Do some stuff to foo
}
```
If you are writing a wrapper that will consu... |
498,216 | <p>I have a very big problem solving this issue
I have 2 tables </p>
<p>first table is :
<a href="http://picasaweb.google.com/lh/photo/iDp4kgFFjk5d2h5dUZtbvg?feat=embedwebsite" rel="nofollow noreferrer">http://lh3.ggpht.com/_uMvfbnPHuko/SYPJQ1ZsBDI/AAAAAAAAAKs/eq49xquy3jM/s800/Untitled-2.jpg</a></p>
<p>which contain... | [
{
"answer_id": 498236,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 1,
"selected": false,
"text": "<p>How come you are using a comma-delimited list? The better approach would be to have a table in between which stores ... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459737/"
] | I have a very big problem solving this issue
I have 2 tables
first table is :
[http://lh3.ggpht.com/\_uMvfbnPHuko/SYPJQ1ZsBDI/AAAAAAAAAKs/eq49xquy3jM/s800/Untitled-2.jpg](http://picasaweb.google.com/lh/photo/iDp4kgFFjk5d2h5dUZtbvg?feat=embedwebsite)
which contains a modules (id and name)
second table is
[http://lh... | Your query doesn't works because LinqToSQL tries to translate everything to plain SQL.
If you cannot refactor your schema, and use an intermediate table since you clearly have a many-to-many relation ship, you can do something like this:
```
var userModules = db.userModules.SingleOrDefault(m => m.userId == myUserId).... |
498,217 | <p>Given: <code>Throwable</code> is <code>Exception</code>'s superclass.</p>
<p>When I read texts on writing your own 'exceptions', I see examples of <code>Throwable</code> being used in the <code>catch</code> block and other texts show <code>new Exception()</code> being used in the <code>catch</code> block. I have y... | [
{
"answer_id": 498226,
"author": "Ray Hidayat",
"author_id": 49643,
"author_profile": "https://Stackoverflow.com/users/49643",
"pm_score": 5,
"selected": false,
"text": "<p>Always throw an <code>Exception</code> (never a <code>Throwable</code>). You generally don't catch <code>Throwable<... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13491/"
] | Given: `Throwable` is `Exception`'s superclass.
When I read texts on writing your own 'exceptions', I see examples of `Throwable` being used in the `catch` block and other texts show `new Exception()` being used in the `catch` block. I have yet to see an explanation of when one should use each.
My question is this, w... | >
> (from comments) The issue that brought this up is that
> I need to pass an 'exception' to a
> piece of code a coworker is building
> if a collection does not get built.
>
>
>
In that case, you might want to throw a *checked exception*. You could throw an [`Exception`](http://java.sun.com/javase/6/docs/api/j... |
498,224 | <p>Suppose you have a list of acronym's that define a value (ex. AB1,DE2,CC3) and you need to check a string value (ex. "Happy:DE2|234") to see if an acronym is found in the string. For a short list of acronym's I would usually create a simple RegEx that used a separator (ex. (AB1|DE2|CC3) ) and just look for a match.... | [
{
"answer_id": 498263,
"author": "vava",
"author_id": 6258,
"author_profile": "https://Stackoverflow.com/users/6258",
"pm_score": 0,
"selected": false,
"text": "<p>If acronym's have fixed size (like in above example), you could calculate a hash for all of them (could be done once per app... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51949/"
] | Suppose you have a list of acronym's that define a value (ex. AB1,DE2,CC3) and you need to check a string value (ex. "Happy:DE2|234") to see if an acronym is found in the string. For a short list of acronym's I would usually create a simple RegEx that used a separator (ex. (AB1|DE2|CC3) ) and just look for a match.
B... | Personally I don't think 30 is particularly large for a regex so I wouldn't be too quick to rule it out. You can create the regex with a single line of code:
```
var acronyms = new[] { "AB", "BC", "CD", "ZZAB" };
var regex = new Regex(string.Join("|", acronyms), RegexOptions.Compiled);
for (var match = regex.Match("ZZ... |
498,232 | <p>some friends just finished the implementation of an app and they use Custom Exceptions. something that took my attention is that when a custom exception was raised they logged the exception in the code of the exception base class they implemented. so my question will be is this a good design approach?. my thinking i... | [
{
"answer_id": 498254,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 2,
"selected": false,
"text": "<p>No, this is a horrible approach IMO. The reason being is that the assumption is that every exception that is created... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14440/"
] | some friends just finished the implementation of an app and they use Custom Exceptions. something that took my attention is that when a custom exception was raised they logged the exception in the code of the exception base class they implemented. so my question will be is this a good design approach?. my thinking is t... | I understand their thinking in putting this into place so that they can assure that logging happens whenever an exception of CustomException is thrown; however, this is definitely smelly code.
An exception should be used just for exceptions and the code that executes the code that could cause a CustomException to be t... |
498,234 | <p>A few days ago, there were a couple questions on buffer overflow vulnerabilities (such as <a href="https://stackoverflow.com/questions/479701/does-java-have-buffer-overflows">Does Java have buffer overflows?</a>, <a href="https://stackoverflow.com/questions/483018/secure-c-and-the-universities-trained-for-buffer-ove... | [
{
"answer_id": 498270,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 1,
"selected": false,
"text": "<p>It may be possible to more easily cause unbounded recursion (and the resulting memory use) in a functional implementat... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17172/"
] | A few days ago, there were a couple questions on buffer overflow vulnerabilities (such as [Does Java have buffer overflows?](https://stackoverflow.com/questions/479701/does-java-have-buffer-overflows), [Secure C and the universities - trained for buffer overflow](https://stackoverflow.com/questions/483018/secure-c-and-... | If the programmer doesn't anticipate that *[some input]* could cause *[program]* to consume more-than-available resources, that's a vulnerability in the form of a possible DoS. This is a weakness of all Turing-complete languages I've seen, but Haskell's laziness makes it harder to reason about what a computation involv... |
498,235 | <p>Does anyone know the name of the CSS classes responsible for styling the dojo <code>promptMessage</code>s (or <code>invalidMessage</code>s) tooltip associated with <code>ValidationTextBox</code>es.</p>
<p>Normally Firebug does a great job of revealing all the inner workings of CSS, but in this case the tooltip prom... | [
{
"answer_id": 498256,
"author": "pierdeux",
"author_id": 53747,
"author_profile": "https://Stackoverflow.com/users/53747",
"pm_score": 0,
"selected": false,
"text": "<p>Actually, although my question remains for general purposes, in the specific case that interests me, it's probably as ... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53747/"
] | Does anyone know the name of the CSS classes responsible for styling the dojo `promptMessage`s (or `invalidMessage`s) tooltip associated with `ValidationTextBox`es.
Normally Firebug does a great job of revealing all the inner workings of CSS, but in this case the tooltip prompt disappears when I try to inspect it!
I ... | [Dijit Tooltip template](http://download.dojotoolkit.org/release-1.2.3/dojo-release-1.2.3/dijit/templates/Tooltip.html) reveals the structure:
```
<div class="dijitTooltip dijitTooltipLeft" id="dojoTooltip">
<div class="dijitTooltipContainer dijitTooltipContents" dojoAttachPoint="containerNode" waiRole='alert'></d... |
498,279 | <p>I have a link that goes to <a href="http://example.com/random.php" rel="nofollow noreferrer">http://example.com/random.php</a>, code for random.php below.</p>
<pre><code><?php
srand ((double) microtime( )*1000000);
$random_number = rand(1,100);
header( "Location: http://example.com/test?page=$random_number" ) ;
... | [
{
"answer_id": 498286,
"author": "Hexagon Theory",
"author_id": 59107,
"author_profile": "https://Stackoverflow.com/users/59107",
"pm_score": -1,
"selected": false,
"text": "<p>Um... your code works, bro; perhaps you've misunderstood the concept and think that reloading the page you've a... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a link that goes to <http://example.com/random.php>, code for random.php below.
```
<?php
srand ((double) microtime( )*1000000);
$random_number = rand(1,100);
header( "Location: http://example.com/test?page=$random_number" ) ;
?>
```
Basically what I want it to do is link to a random page. It works initially,... | Either your browser or server is probably caching the page. Try this in your php code:
```
header("cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0");
``` |
498,305 | <p>If I have a class that has a sharedInstance of itself (singleton pattern) or a shared instance of another class, how do I make sure that shared instance is released properly when my program exits? Better yet, can you point me to some documentation about this?</p>
<p>sample class (with all other methods removed for ... | [
{
"answer_id": 498389,
"author": "Barry Wark",
"author_id": 2140,
"author_profile": "https://Stackoverflow.com/users/2140",
"pm_score": 3,
"selected": false,
"text": "<p>Unless there are resources beyond the shared instance that need to be released (e.g. files, notifications at cleanup e... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45114/"
] | If I have a class that has a sharedInstance of itself (singleton pattern) or a shared instance of another class, how do I make sure that shared instance is released properly when my program exits? Better yet, can you point me to some documentation about this?
sample class (with all other methods removed for clarity):
... | Usually there is no need to clean up anything on exit as Barry pointed out, but what you can do is setting an NSApplication delegate that implements
```
- (void)applicationWillTerminate:(NSNotification *)aNotification
```
This method is then called right before your application is going to quit. In this method you c... |
498,315 | <p>Suppose that for some perverse reason you want to display the raw byte contents of a UTF8String.</p>
<pre><code>var
utf8Str : UTF8String;
begin
utf8Str := '€ąćęłńóśźż';
end;
</code></pre>
<p><strong>(1)</strong> This doesn't do, it displays the readable form:</p>
<pre><code>memo1.Lines.Add( RawByteString(... | [
{
"answer_id": 499160,
"author": "Barry Kelly",
"author_id": 3712,
"author_profile": "https://Stackoverflow.com/users/3712",
"pm_score": 4,
"selected": true,
"text": "<p><code>RawByteString</code> only exists to minimize the number of overloads required for functions that work with vario... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9226/"
] | Suppose that for some perverse reason you want to display the raw byte contents of a UTF8String.
```
var
utf8Str : UTF8String;
begin
utf8Str := '€ąćęłńóśźż';
end;
```
**(1)** This doesn't do, it displays the readable form:
```
memo1.Lines.Add( RawByteString( utf8Str ));
// output: '€ąćęłńóśźż'
```
**(2)**... | `RawByteString` only exists to minimize the number of overloads required for functions that work with various flavours of `AnsiString`s with different codepage affinities.
In general, don't declare variables of type `RawByteString`. Don't typecast values to that type. Don't do concatenations on variables of that type.... |
498,320 | <p>So I'm in Linux and I want to have a program accept arguments when you execute it from the command line.</p>
<p>For example, </p>
<p><code>./myprogram 42 -b -s</code></p>
<p>So then the program would store that number 42 as an int and execute certain parts of code depending on what arguments it gets like -b or -s... | [
{
"answer_id": 498322,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 5,
"selected": false,
"text": "<p>In C, this is done using arguments passed to your <code>main()</code> function:</p>\n\n<pre><code>int main(int argc, c... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60915/"
] | So I'm in Linux and I want to have a program accept arguments when you execute it from the command line.
For example,
`./myprogram 42 -b -s`
So then the program would store that number 42 as an int and execute certain parts of code depending on what arguments it gets like -b or -s. | You could use [getopt](http://www.gnu.org/software/libtool/manual/libc/Getopt.html).
```
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int
main (int argc, char **argv)
{
int bflag = 0;
int sflag = 0;
int index;
int c;
opterr = 0;
while ((c = getopt (argc, arg... |
498,323 | <p>How can I find which version of OSX is installed on my Mac by using AppleScript? I want to install an app programatically and run different pkg files based on the version.</p>
<p>Thanks</p>
| [
{
"answer_id": 498346,
"author": "Uri",
"author_id": 23072,
"author_profile": "https://Stackoverflow.com/users/23072",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not too familiar with AppleScript, but AFAIK you can get some info about versions from the shell with the sw_vers comma... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46297/"
] | How can I find which version of OSX is installed on my Mac by using AppleScript? I want to install an app programatically and run different pkg files based on the version.
Thanks | I'm not on a Mac, so there may be a better way to do this, but the first approach that comes to mind is just executing a shell command to query the OS version.
<http://developer.apple.com/technotes/tn2002/tn2065.html#TNTAG2>
<http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man1/sw_vers.1.html>
Bas... |
498,343 | <p>How do you change the password for the root user in phpMyAdmin on WAMP server? because I'm locked out of phpMyAdmin, after changing the password incorrectly.</p>
| [
{
"answer_id": 498365,
"author": "Tommy Hui",
"author_id": 60927,
"author_profile": "https://Stackoverflow.com/users/60927",
"pm_score": 2,
"selected": false,
"text": "<p>Search your installation of PhpMyAdmin for a file called Documentation.txt. This describes how to create a file calle... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44386/"
] | How do you change the password for the root user in phpMyAdmin on WAMP server? because I'm locked out of phpMyAdmin, after changing the password incorrectly. | my config.inc.php file in the phpmyadmin folder.
Change username and password to the one you have set for your database.
```
<?php
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = 'xampp'; /* YOU SHOULD CHANGE THIS FOR A MORE SECURE COOKIE AUTH! */... |
498,344 | <p>While debugging SQL statements, if I accidentally execute a query in using the mysql command line that outputs at lot of results (even if the query itself executes in reasonable time), the only way I know of to stop the endless stream of output is CTRL-C.</p>
<p>Unfortunately this puts me back in the shell, forcin... | [
{
"answer_id": 498355,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 4,
"selected": false,
"text": "<p>Not a keyboard shortcut.</p>\n\n<p>The only choice is to open another session, use <a href=\"http://dev.mysql.com/d... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17492/"
] | While debugging SQL statements, if I accidentally execute a query in using the mysql command line that outputs at lot of results (even if the query itself executes in reasonable time), the only way I know of to stop the endless stream of output is CTRL-C.
Unfortunately this puts me back in the shell, forcing me to log... | You can use `--pager` to have your output passed to a pager such as `less` which will give you control over the output. Not just killing it, but also paging, searching and even storing the output better than your terminal window gives you.
There's also the `--safe-updates` or `-U` switch aka `--i-am-a-dummy` which pro... |
498,345 | <p>I followed the example at <a href="http://wiki.class-dbi.com/wiki/Overriding_autogenerated_accessors" rel="nofollow noreferrer">http://wiki.class-dbi.com/wiki/Overriding_autogenerated_accessors</a></p>
<p>I want to modify the URL before it is inserted to the database:</p>
<pre><code>package Hosting::Company;
use b... | [
{
"answer_id": 498573,
"author": "innaM",
"author_id": 7498,
"author_profile": "https://Stackoverflow.com/users/7498",
"pm_score": 2,
"selected": false,
"text": "<p>In you URL accessor, you check whether a parameter was passed to that method. But you aren't passing anyhting in so the acc... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55111/"
] | I followed the example at <http://wiki.class-dbi.com/wiki/Overriding_autogenerated_accessors>
I want to modify the URL before it is inserted to the database:
```
package Hosting::Company;
use base 'Class::DBI';
my $class = __PACKAGE__;
$class->table('Companies');
$class->columns(Primary => 'CompanyId');
$class->co... | Overriding an accessor does not change `insert`. The best way to handle data normalization is to override [`normalize_column_values()`](http://search.cpan.org/perldoc?Class::DBI#DATA_NORMALIZATION). But Manni is right, your accessor is busted.
PS The [CDBI mailing list](http://lists.digitalcraftsmen.net/mailman/listin... |
498,350 | <p>Please could somebody point me out what is the error here? Using javascript i am validating the user input. When i click the login button without checking the javascript function, it goes to the welcome page. Here is my code:</p>
<pre><code><script type="text/javascript">
function validLogin()
{
if(... | [
{
"answer_id": 498356,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 1,
"selected": false,
"text": "<p>I see that you're using ASP .NET (the Page_Load event on your posted code).</p>\n\n<p>I think that will be e... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59637/"
] | Please could somebody point me out what is the error here? Using javascript i am validating the user input. When i click the login button without checking the javascript function, it goes to the welcome page. Here is my code:
```
<script type="text/javascript">
function validLogin()
{
if(document.getElementB... | I see that you're using ASP .NET (the Page\_Load event on your posted code).
I think that will be easier to handle validation through [ASP .NET Validation Controls](http://www.w3schools.com/aspnet/aspnet_refvalidationcontrols.asp), i.e. [RequiredFieldValidator](http://www.w3schools.com/ASPNET/control_reqfieldvalidator... |
498,358 | <p>I realize I could whip up a little C or Ruby program to do this, but I want my script to have as few dependencies as possible.</p>
<p>Given that <em>caveat</em>, how does one do date math in a bash script on OS X? I've seen a post (on another site) where someone did the following:</p>
<pre>date -d "-1 day"</pre>
... | [
{
"answer_id": 498398,
"author": "Matthew Schinckel",
"author_id": 188,
"author_profile": "https://Stackoverflow.com/users/188",
"pm_score": 7,
"selected": true,
"text": "<pre><code>$ date -v -1d\n</code></pre>\n\n<p>-d sets Daylight Savings time flag.</p>\n\n<p>Try man date for more inf... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27779/"
] | I realize I could whip up a little C or Ruby program to do this, but I want my script to have as few dependencies as possible.
Given that *caveat*, how does one do date math in a bash script on OS X? I've seen a post (on another site) where someone did the following:
```
date -d "-1 day"
```
But this does not seem t... | ```
$ date -v -1d
```
-d sets Daylight Savings time flag.
Try man date for more info. |
498,363 | <p>I was registering to an event in my class, and as per usual I was lazy and just use the autocomplete feature built into Visual Studio 2008 Pro which auto creates the delegate creation and it's associated method.</p>
<pre><code>public abstract class FooBase
{
protected event EventHandler<MyValueChangedArgs>... | [
{
"answer_id": 498367,
"author": "lubos hasko",
"author_id": 275,
"author_profile": "https://Stackoverflow.com/users/275",
"pm_score": 6,
"selected": true,
"text": "<p>General MS guidelines</p>\n\n<ol>\n<li>no</li>\n<li>no</li>\n<li>no</li>\n</ol>\n\n<p>GAC is really a repository for Mic... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27765/"
] | I was registering to an event in my class, and as per usual I was lazy and just use the autocomplete feature built into Visual Studio 2008 Pro which auto creates the delegate creation and it's associated method.
```
public abstract class FooBase
{
protected event EventHandler<MyValueChangedArgs> MyValueChanged;
... | General MS guidelines
1. no
2. no
3. no
GAC is really a repository for Microsoft common .NET libraries. Yes, they let developers use it too, but as a rule of thumb, if you don't need GAC, don't use it. keep things simple and local if it doesn't hurt.
* I would consider GAC only for performance reasons, for example i... |
498,371 | <p>How can I detect (.NET or Win32) if my application is running in a virtual machine?</p>
| [
{
"answer_id": 498394,
"author": "Jay Bazuzi",
"author_id": 5314,
"author_profile": "https://Stackoverflow.com/users/5314",
"pm_score": 5,
"selected": true,
"text": "<p>According to <a href=\"http://blogs.msdn.com/virtual_pc_guy/\" rel=\"noreferrer\">Virtual PC Guy</a>'s blog post \"<a h... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16794/"
] | How can I detect (.NET or Win32) if my application is running in a virtual machine? | According to [Virtual PC Guy](http://blogs.msdn.com/virtual_pc_guy/)'s blog post "[Detecting Microsoft virtual machines](http://blogs.msdn.com/virtual_pc_guy/archive/2005/10/27/484479.aspx)", you can use WMI to check the manufacturer of the motherboard. In PowerShell:
```
(gwmi Win32_BaseBoard).Manufacturer -eq "Micr... |
498,400 | <p>Consider:</p>
<pre><code>namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//int[] val = { 0, 0};
int val;
... | [
{
"answer_id": 498410,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 10,
"selected": true,
"text": "<p>It looks like you are calling a non static member (a property or method, specifically <code>setTextboxText</code>) from a s... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60930/"
] | Consider:
```
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//int[] val = { 0, 0};
int val;
if (textB... | It looks like you are calling a non static member (a property or method, specifically `setTextboxText`) from a static method (specifically `SumData`). You will need to either:
1. Make the called member static also:
```
static void setTextboxText(int result)
{
// Write static logic for setTextboxText.
// Thi... |
498,428 | <p>I'm building a blog engine to test some concepts such us TDD and using inversion of control... I came up with a setup where I'd have a generic IBlogRepository interface so I could support both SQL and XML.</p>
<pre><code>public interface IBlogRepository : IRepository
{
Post GetPostById(Guid postId);
Post Ge... | [
{
"answer_id": 498430,
"author": "Oscar Cabrero",
"author_id": 14440,
"author_profile": "https://Stackoverflow.com/users/14440",
"pm_score": 1,
"selected": false,
"text": "<p>i think a provider will fit your needs by implementing a provider you will wrap the resources in it</p>\n\n<p>her... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17176/"
] | I'm building a blog engine to test some concepts such us TDD and using inversion of control... I came up with a setup where I'd have a generic IBlogRepository interface so I could support both SQL and XML.
```
public interface IBlogRepository : IRepository
{
Post GetPostById(Guid postId);
Post GetPostByFriendl... | I don't understand why the fact that your two IBlogRepository implementations have different ctor signatures makes IoC "impossible"; on the contrary, this is a common scenario in IoC. The way it's addressed is that your IoC framework (and only your IoC framework) is responsible for calling the ctor of the desired IBlog... |
498,433 | <p>The following for creating a Global Object is resulting in compilation errors.</p>
<pre><code>#include "stdafx.h"
#include <iostream>
using namespace System;
using namespace std;
#pragma hdrstop
class Tester;
void input();
class Tester
{
static int number = 5;
public:
Tester(){};
~T... | [
{
"answer_id": 498442,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 5,
"selected": true,
"text": "<p>Just start addressing the errors one by one. A lot of the errors are just cascaded from the initial errors, so it l... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60615/"
] | The following for creating a Global Object is resulting in compilation errors.
```
#include "stdafx.h"
#include <iostream>
using namespace System;
using namespace std;
#pragma hdrstop
class Tester;
void input();
class Tester
{
static int number = 5;
public:
Tester(){};
~Tester(){};
void ... | Just start addressing the errors one by one. A lot of the errors are just cascaded from the initial errors, so it looks like there are a lot of problems when there's only a couple. Just start from the top:
```
1>.\test.cpp(15) : error C2864: 'Tester::number' : only static const integral data members can be initialized... |
498,448 | <p>When using windbg and running !dumpheap command to see the addresses of objects, how can you limit to a specific number of objects. The only way I found was using CTRL+BREAK
and a command line on a blog <a href="http://dotnetdebug.net/2005/07/04/dumpheap-parameters-and-some-general-information-on-sos-help-system/" r... | [
{
"answer_id": 498442,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 5,
"selected": true,
"text": "<p>Just start addressing the errors one by one. A lot of the errors are just cascaded from the initial errors, so it l... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49557/"
] | When using windbg and running !dumpheap command to see the addresses of objects, how can you limit to a specific number of objects. The only way I found was using CTRL+BREAK
and a command line on a blog <http://dotnetdebug.net/2005/07/04/dumpheap-parameters-and-some-general-information-on-sos-help-system/>
-l X - Prin... | Just start addressing the errors one by one. A lot of the errors are just cascaded from the initial errors, so it looks like there are a lot of problems when there's only a couple. Just start from the top:
```
1>.\test.cpp(15) : error C2864: 'Tester::number' : only static const integral data members can be initialized... |
498,455 | <p>What are the Advantages/Drawbacks of these two ways of iterating through a container / which one do you prefer and why:</p>
<pre><code>for (MyClass::iterator i = m.begin(), e = m.end() ; i != e ; i++)
{
// ...
}
</code></pre>
<p>or</p>
<pre><code>for (MyClass::iterator i = m.begin() ; i != m.end() ; i++)
{
... | [
{
"answer_id": 498459,
"author": "Tanveer Badar",
"author_id": 59081,
"author_profile": "https://Stackoverflow.com/users/59081",
"pm_score": 2,
"selected": false,
"text": "<p>Unless you have optimizations turned off, both are equivalent. As for i++ or ++i, ++i is more efficient because i... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54956/"
] | What are the Advantages/Drawbacks of these two ways of iterating through a container / which one do you prefer and why:
```
for (MyClass::iterator i = m.begin(), e = m.end() ; i != e ; i++)
{
// ...
}
```
or
```
for (MyClass::iterator i = m.begin() ; i != m.end() ; i++)
{
// ...
}
```
Subsidiary question:... | If the iterator is non-trivial (ie. not a pointer), ++i is definitely faster as it doesn't involves a copy to a temporary, which may or may not be optimized out.
The first form is a little faster but could be wrong if you erase or insert things in the loop.
For simple iteration over a container I use
```
#define for... |
498,461 | <p>How do I save user-entered line breaks from a <code><textarea></code> HTML element to a database?<br/>
It always removes the line breaks.</p>
| [
{
"answer_id": 498466,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 5,
"selected": false,
"text": "<p>When displaying the content you need to convert line breaks into <code><br /></code> tags, otherwise the web brow... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I save user-entered line breaks from a `<textarea>` HTML element to a database?
It always removes the line breaks. | `TextArea` HTML element is preserving the white space in the database.
The problem appears when trying to display the `\n` on the web browser, which will fail.
To display `\n` in the web browser use :
```
<p style="white-space: pre-line">multi-line text</p>
``` |
498,469 | <p>Is there any built in support in jQuery for basic assertion checking, primarily of things like 'expected number of returned elements'.</p>
<p>For instance I may have a simple statement like this :</p>
<pre><code> $("#btnSignup").click(function() {
return validateForm();
);
</code></pre>
<p>Now theres plenty... | [
{
"answer_id": 498509,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 5,
"selected": true,
"text": "<p>It doesn't look like there is anything built-in. But writing an extension isn't too hard:</p>\n\n<pre><code>$.fn.assertS... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | Is there any built in support in jQuery for basic assertion checking, primarily of things like 'expected number of returned elements'.
For instance I may have a simple statement like this :
```
$("#btnSignup").click(function() {
return validateForm();
);
```
Now theres plenty of reasons why `$("#btnSignup")`... | It doesn't look like there is anything built-in. But writing an extension isn't too hard:
```
$.fn.assertSize = function(size) {
if (this.length != size) {
alert("Expected " + size + " elements, but got " + this.length + ".");
// or whatever, maybe use console.log to be more unobtrusive
}
return this;
... |
498,474 | <p>I am using the <strong>AutoCompleteExtender</strong> from the <strong>Ajax Control Toolkit</strong> and it is behaving stragely.</p>
<p>My service method is shown here:</p>
<pre><code>[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] getEJMaps(string prefixText, int count)
{... | [
{
"answer_id": 509012,
"author": "colithium",
"author_id": 61332,
"author_profile": "https://Stackoverflow.com/users/61332",
"pm_score": 3,
"selected": true,
"text": "<p>You need to surround each string in the array with quotes. For example, getEJMaps should return an array that looks l... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14777/"
] | I am using the **AutoCompleteExtender** from the **Ajax Control Toolkit** and it is behaving stragely.
My service method is shown here:
```
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] getEJMaps(string prefixText, int count)
{ // method that returns the auto-suggest for ... | You need to surround each string in the array with quotes. For example, getEJMaps should return an array that looks like:
```
"00056399"
"00056717"
"00056721"
"00056722"
"00056900"
...
```
Don't forget you need to escape the quotes with a \
If this fixes the missing 0's but not the phantom values, let me know and I... |
498,482 | <pre><code>List<PageInfo> subPages = new List<PageInfo>();
// ...
// some code to populate subPages here...
// ...
List<Guid> subPageGuids = new List<Guid> {from x in subPages select x.Id}; //doesn't work
</code></pre>
<p>PageInfo has an Id field which is of type Guid. So x.Id is a System.Guid.... | [
{
"answer_id": 498489,
"author": "Stormenet",
"author_id": 2090,
"author_profile": "https://Stackoverflow.com/users/2090",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like the <code>Add()</code> is called and not <code>AddRange()</code>.</p>\n\n<p>You could use this syntax ins... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9484/"
] | ```
List<PageInfo> subPages = new List<PageInfo>();
// ...
// some code to populate subPages here...
// ...
List<Guid> subPageGuids = new List<Guid> {from x in subPages select x.Id}; //doesn't work
```
PageInfo has an Id field which is of type Guid. So x.Id is a System.Guid.
2nd line of code above does not work...I ... | I think you want:
```
List<Guid> subPageGuids = new List<Guid>(from x in subPages select x.Id);
```
(note the curly braces changed to regular braces)
That will call the constructor of List that takes an IEnumerable (which is what the linq query returns) as a parameter. Right now you're trying to use the syntax for ... |
498,495 | <p>I installed PHP in windows server 2003. All the files are working fine except the mail issue. There is no problem in SMTP. Because I run the JSP project in the same server.In that mail function working fine. So where is the problem? And how can i manage? I set the SMTP server in PHP as</p>
<pre><code>; For Win32 on... | [
{
"answer_id": 498489,
"author": "Stormenet",
"author_id": 2090,
"author_profile": "https://Stackoverflow.com/users/2090",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like the <code>Add()</code> is called and not <code>AddRange()</code>.</p>\n\n<p>You could use this syntax ins... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I installed PHP in windows server 2003. All the files are working fine except the mail issue. There is no problem in SMTP. Because I run the JSP project in the same server.In that mail function working fine. So where is the problem? And how can i manage? I set the SMTP server in PHP as
```
; For Win32 only.
SMTP = loc... | I think you want:
```
List<Guid> subPageGuids = new List<Guid>(from x in subPages select x.Id);
```
(note the curly braces changed to regular braces)
That will call the constructor of List that takes an IEnumerable (which is what the linq query returns) as a parameter. Right now you're trying to use the syntax for ... |
498,503 | <p>I am not into web (client/server)application development, but had this question for sometime -</p>
<p>If some web browser (IE/Firefox) makes a connection to some website, is it possible for the web server to find out the timezone of the client, or current local time of the client place, and display the same on the ... | [
{
"answer_id": 498506,
"author": "flesh",
"author_id": 27805,
"author_profile": "https://Stackoverflow.com/users/27805",
"pm_score": 2,
"selected": false,
"text": "<p>Yes. Use something like:</p>\n\n<pre><code><script type=\"text/javascript\" language=\"javascript\"> \nvar tz =(new... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2759376/"
] | I am not into web (client/server)application development, but had this question for sometime -
If some web browser (IE/Firefox) makes a connection to some website, is it possible for the web server to find out the timezone of the client, or current local time of the client place, and display the same on the page.
If ... | Yes. Use something like:
```
<script type="text/javascript" language="javascript">
var tz =(new Date).getTimezoneOffset()/-60;
</script>
```
See also:
<http://www.willmaster.com/library/javascript/determining-your-visitors-time-zone.php>
<http://www.tommylacroix.com/2008/02/25/detect-timezone-with-javascript/>
<h... |
498,577 | <p>I'm relatively new to MySql.</p>
<p>I have 2 tabled with the following structure</p>
<pre><code>products
{
pid-autoincrement,
pname
p_desc
}
services
{
sid-autoincrement
s_name
s_desc
}
</code></pre>
<p>Im trying to select the products or services which have the name <code>'%<somekeyword>%'</code></p>
<p>... | [
{
"answer_id": 498587,
"author": "karlis",
"author_id": 49034,
"author_profile": "https://Stackoverflow.com/users/49034",
"pm_score": 1,
"selected": false,
"text": "<p>you have to use the UNION operator</p>\n\n<p>therefore you can only select the same columns (as there is only one result... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm relatively new to MySql.
I have 2 tabled with the following structure
```
products
{
pid-autoincrement,
pname
p_desc
}
services
{
sid-autoincrement
s_name
s_desc
}
```
Im trying to select the products or services which have the name `'%<somekeyword>%'`
I'm using the query:
```
SELECT DISTINCT products.*,
... | You want to use UNION, like this:
```
SELECT DISTINCT products.pid-autoincrement AS id,
products.pname AS name,
products.p_desc AS desc
FROM products
WHERE products.pname
LIKE '%mob%'
UNION
SELECT DISTINCT services.sid-autoincrement AS id,
... |
498,581 | <p>I'm working on a site where a user could select certain dates that apply to them, e.g Date 1,Date 2, Date 3, etc.</p>
<p>Each date will have certain questions belonging to it, so if the customer checked off 'Date 1' to indicate that this date applies to him, he'll then see a bunch of textboxes asking him about Date... | [
{
"answer_id": 498591,
"author": "Kobi",
"author_id": 7586,
"author_profile": "https://Stackoverflow.com/users/7586",
"pm_score": 1,
"selected": false,
"text": "<p>Option 2 seems close to the good solution, but I'd replace <code>date_name</code> and <code>question_name</code> with <code>... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49153/"
] | I'm working on a site where a user could select certain dates that apply to them, e.g Date 1,Date 2, Date 3, etc.
Each date will have certain questions belonging to it, so if the customer checked off 'Date 1' to indicate that this date applies to him, he'll then see a bunch of textboxes asking him about Date 1 and how... | It sounds like you want something like the following (basic) table structure:
* **User** - `userId, userInfo`
* **Date** - `dateId, dateInfo`
* **Question** - `questionId, questionInfo`
* **UserDate** - `userId, dateId` - this stores all dates that apply for a given user and represents the many to many relationship be... |
498,582 | <p>I'm using C++ with the OpenCV library, which is a library image-processing although that's not relevant for this question. Currently I have a design decision to make. </p>
<p>OpenCV, being a C library, has its data structures (such as CvMat) declared as structs. To create them, you use functions like cvCreateMat, a... | [
{
"answer_id": 498605,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>If all you care about is exception safety, do this everytime you use matrixes:</p>\n\n<pre><code>void f() {\n try {\n ... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49643/"
] | I'm using C++ with the OpenCV library, which is a library image-processing although that's not relevant for this question. Currently I have a design decision to make.
OpenCV, being a C library, has its data structures (such as CvMat) declared as structs. To create them, you use functions like cvCreateMat, and to rele... | The auto\_ptr are really designed for RAII on C++ class with constructs/destructors you are pushing their uses here to things they probably should not be used for (but can).
Anyway don'y you want to be able to use your C++ object as if it was a normal stack variable without dynamically allocating each time?
The stan... |
498,597 | <p>I want to build dynamic linq.</p>
<p>But I want to dynamically set the table (from clause)</p>
<p>Is this possible?</p>
<p>Malcolm</p>
| [
{
"answer_id": 498640,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": true,
"text": "<p>As always, it depends ;-p</p>\n\n<p>If you want to use the LINQ extension methods or query syntax, then no: this is... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40568/"
] | I want to build dynamic linq.
But I want to dynamically set the table (from clause)
Is this possible?
Malcolm | As always, it depends ;-p
If you want to use the LINQ extension methods or query syntax, then no: this is tightly coupled to `IQueryable<T>`, where `T` is the source type. Generics might be an option, depending on the scenario:
```
public IQueryable<T> Get<T>(int id) where T : SomeBaseClass
{
return GetData<T>().... |
498,618 | <p>I am working on my phd in chemistry and for that reason I need to write a software application to help me with the imaging of samples under a microscope. This microscope is fitted with an x-y-z nanopositioning stage. The stage is controlled using an unmanaged DLL written in VC++ by the hardware vendor. I could provi... | [
{
"answer_id": 499689,
"author": "Ady Kemp",
"author_id": 60763,
"author_profile": "https://Stackoverflow.com/users/60763",
"pm_score": 1,
"selected": false,
"text": "<p>BOOL in C++ is actually an \"int\" so make sure you use System.Int32 and not System.Boolean.\nAlternatively it might b... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am working on my phd in chemistry and for that reason I need to write a software application to help me with the imaging of samples under a microscope. This microscope is fitted with an x-y-z nanopositioning stage. The stage is controlled using an unmanaged DLL written in VC++ by the hardware vendor. I could provide ... | BOOL in C++ is actually an "int" so make sure you use System.Int32 and not System.Boolean.
Alternatively it might be using COM data types i.e. VARIANT\_BOOL, in which case you need do need System.Boolean.
Have you tried running dependency viewer to confirm the function prototype? |
498,629 | <p>I'm useing MySQL and I have three tables, a table of tasks, a table of products and a table that describes the relation between the two: Each product is composed of several tasks, and each task may be found in multiple products.</p>
<p>The table that describes the relationship between the two has two primary keys, ... | [
{
"answer_id": 498635,
"author": "dkretz",
"author_id": 31641,
"author_profile": "https://Stackoverflow.com/users/31641",
"pm_score": 0,
"selected": false,
"text": "<p>The junction table has one primary key, but it's a multi-field key with two fields (the two FK's for the other tables). ... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54645/"
] | I'm useing MySQL and I have three tables, a table of tasks, a table of products and a table that describes the relation between the two: Each product is composed of several tasks, and each task may be found in multiple products.
The table that describes the relationship between the two has two primary keys, ProductID ... | You want a UNIQUE constraint:
```
create table ProductTasks
( ProductID ...
, TaskId ...
, TaskOrder ...
, primary key (ProductId, TaskId)
, unique (ProductId, TaskOrder)
);
``` |
498,636 | <p>I have a file which is encoded as iso-8859-1, and contains characters such as ô .</p>
<p>I am reading this file with java code, something like:</p>
<pre><code>File in = new File("myfile.csv");
InputStream fr = new FileInputStream(in);
byte[] buffer = new byte[4096];
while (true) {
int byteCount = fr.read(buff... | [
{
"answer_id": 498643,
"author": "Peter Štibraný",
"author_id": 47190,
"author_profile": "https://Stackoverflow.com/users/47190",
"pm_score": 2,
"selected": false,
"text": "<p>If you can, try to run your program in debugger to see what's inside your 's' string after it is created. It is ... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60956/"
] | I have a file which is encoded as iso-8859-1, and contains characters such as ô .
I am reading this file with java code, something like:
```
File in = new File("myfile.csv");
InputStream fr = new FileInputStream(in);
byte[] buffer = new byte[4096];
while (true) {
int byteCount = fr.read(buffer, 0, buffer.length);... | I suspect that either your file isn't *actually* encoded as ISO-8859-1, or System.out doesn't know how to print the character.
I recommend that to check for the first, you examine the relevant byte in the file. To check for the second, examine the relevant character in the string, printing it out with
```
System.out... |
498,686 | <p>I have a string buffer of about 2000 characters and need to check the buffer if it contains a specific string.<br/>
Will do the check in a ASP.NET 2.0 webapp for every webrequest.<br/></p>
<p>Does anyone know if the <a href="http://msdn.microsoft.com/en-us/library/dy85x1sa(VS.80).aspx" rel="noreferrer">String.Conta... | [
{
"answer_id": 498696,
"author": "David Schmitt",
"author_id": 4918,
"author_profile": "https://Stackoverflow.com/users/4918",
"pm_score": 2,
"selected": false,
"text": "<p>Use a benchmark library, like <a href=\"http://msmvps.com/blogs/jon_skeet/archive/2009/01/26/benchmarking-made-easy... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49544/"
] | I have a string buffer of about 2000 characters and need to check the buffer if it contains a specific string.
Will do the check in a ASP.NET 2.0 webapp for every webrequest.
Does anyone know if the [String.Contains method](http://msdn.microsoft.com/en-us/library/dy85x1sa(VS.80).aspx) performs better than [String... | `Contains` calls `IndexOf`:
```
public bool Contains(string value)
{
return (this.IndexOf(value, StringComparison.Ordinal) >= 0);
}
```
Which calls `CompareInfo.IndexOf`, which ultimately uses a CLR implementation.
If you want to see how strings are compared in the CLR [this will show you](https://github.com/gb... |
498,701 | <p>I know I should spend more time researching this and having a go before asking the question but I've got just 2 weeks to build a site with a portal style homepage (much like <a href="http://www.bc.co.uk" rel="nofollow noreferrer">http://www.bbc.co.uk</a>).</p>
<p>I'm fairly good with jQuery and have played with jQu... | [
{
"answer_id": 498721,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 4,
"selected": true,
"text": "<p>I've been thinking about something similar recently. The best method I could come up with was to have several 'zones' on the ... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56007/"
] | I know I should spend more time researching this and having a go before asking the question but I've got just 2 weeks to build a site with a portal style homepage (much like [http://www.bbc.co.uk](http://www.bc.co.uk)).
I'm fairly good with jQuery and have played with jQuery UI draggables in the past but I was wonderi... | I've been thinking about something similar recently. The best method I could come up with was to have several 'zones' on the page where items would be placed. In my case these were 3 columns. I gave each an identifier and used an Ajax call every time a block was moved to a different position to update the new position ... |
498,705 | <p>I am playing with the printf and the idea to
write a my_printf(...) that calls the normal printf
and a sprintf that sends the result to a special function.
(I was thinking about sprintf since that behaves just like printf on most platforms).</p>
<p>My idea was to write a small macro that did this:</p>
<pre>
#def... | [
{
"answer_id": 498717,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 4,
"selected": true,
"text": "<p>The best way to do this is with varargs. Create a function with the same prototype as printf() and use the varargs fun... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51425/"
] | I am playing with the printf and the idea to
write a my\_printf(...) that calls the normal printf
and a sprintf that sends the result to a special function.
(I was thinking about sprintf since that behaves just like printf on most platforms).
My idea was to write a small macro that did this:
```
#define my_printf(... | The best way to do this is with varargs. Create a function with the same prototype as printf() and use the varargs functions to pass data to sprintf to populate the desired buffer, the also pass that buffer to printf("%s") before returning.
A lot of the early implementations had a 4K limit on the lowest level printf()... |
498,747 | <p>I have a problem with understanding the "pass-by-value" action of Java in the following example:</p>
<pre><code>public class Numbers {
static int[] s_ccc = {7};
static int[] t_ccc = {7};
public static void calculate(int[] b, int[] c) {
System.out.println("s_ccc[0] = " + s_ccc[0]); // 7
... | [
{
"answer_id": 498753,
"author": "Zach Scrivena",
"author_id": 20029,
"author_profile": "https://Stackoverflow.com/users/20029",
"pm_score": 3,
"selected": false,
"text": "<p>There's an extended discussion of how Java passes variables at an earlier question \"<a href=\"https://stackoverf... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42155/"
] | I have a problem with understanding the "pass-by-value" action of Java in the following example:
```
public class Numbers {
static int[] s_ccc = {7};
static int[] t_ccc = {7};
public static void calculate(int[] b, int[] c) {
System.out.println("s_ccc[0] = " + s_ccc[0]); // 7
System.out.p... | There's an extended discussion of how Java passes variables at an earlier question "[Is Java pass by reference?](https://stackoverflow.com/questions/40480/is-java-pass-by-reference)". Java really passes object references **by value**.
In your code, the references for the arrays (which are objects) are passed into `cal... |
498,756 | <p>in the following example program in Java, I get infinite loop, and I cannot understand why:</p>
<pre><code>public class Time {
public static int next(int v) {
return v++;
}
public static void main(String[] args) {
int[] z = {3, 2, 1, 0};
int i = 1;
while(i < 4) {
... | [
{
"answer_id": 498759,
"author": "empi",
"author_id": 49048,
"author_profile": "https://Stackoverflow.com/users/49048",
"pm_score": 4,
"selected": false,
"text": "<p>You use post incrementation.\nThat should work:</p>\n\n<pre><code>public static int next(int v) {\n return v+1; //o... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42155/"
] | in the following example program in Java, I get infinite loop, and I cannot understand why:
```
public class Time {
public static int next(int v) {
return v++;
}
public static void main(String[] args) {
int[] z = {3, 2, 1, 0};
int i = 1;
while(i < 4) {
Syste... | You use post incrementation.
That should work:
```
public static int next(int v) {
return v+1; //or ++v
}
```
so basically, your next function in your example, returns the same number, not incremented one. |
498,757 | <p>I have a class</p>
<pre><code>template <unsigned int N>
class StaticVector {
// stuff
};
</code></pre>
<p>How can I declare and define in this class a static factory method returning a StaticVector<3> object, sth like </p>
<pre><code>StaticVector<3> create3dVec(double x1, double x2, double x2);
</... | [
{
"answer_id": 498797,
"author": "Klaim",
"author_id": 2368,
"author_profile": "https://Stackoverflow.com/users/2368",
"pm_score": 0,
"selected": false,
"text": "<p>Something like :</p>\n\n<pre><code>template< unsigned int SIZE >\nStaticVector< SIZE > createVec( const std::tr... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59557/"
] | I have a class
```
template <unsigned int N>
class StaticVector {
// stuff
};
```
How can I declare and define in this class a static factory method returning a StaticVector<3> object, sth like
```
StaticVector<3> create3dVec(double x1, double x2, double x2);
```
? | "How can I declare and define in this class"
In what class? You've defined a class template, not a class. You can't call a static function of a class template itself, you have to call a particular version of the static function that's part of a real class.
So, do you want the template (and hence all instantiations of... |
498,769 | <p>My appologies upfront for the lengthy question. I made quite an effort to make my question as clear as possible in one go. Please bear with me. ;o) any help will be greatly appreciated!</p>
<p>I have the classes Branch and Text:</p>
<pre><code>class Branch
int ID
Text WebDescription
and a bunch of other propert... | [
{
"answer_id": 498796,
"author": "E.J. Brennan",
"author_id": 53686,
"author_profile": "https://Stackoverflow.com/users/53686",
"pm_score": 0,
"selected": false,
"text": "<p>This would be very easy to do if you used a stored procedure. Are you opposed to using SP's as a solution?</p>\n"
... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58864/"
] | My appologies upfront for the lengthy question. I made quite an effort to make my question as clear as possible in one go. Please bear with me. ;o) any help will be greatly appreciated!
I have the classes Branch and Text:
```
class Branch
int ID
Text WebDescription
and a bunch of other properties
class Text
int ... | Without really answering the question, the cleanest approach would be to change the Text structure into a more normalized form like:
```
Text
ID
TextTranslation
ID
TextID
Lang
TextValue
```
where each text has a number of translations, one for each language.
The query would become something li... |
498,783 | <p>Suppose I need to have a class which wraps a priority queue of other objects (meaning the queue is a member of the class), and additionally gives it some extra functions.</p>
<p>I am not quite sure what the best way is to define that vector and, mainly, how to instantiate it.</p>
<p>Currently I have something like... | [
{
"answer_id": 498793,
"author": "Ray Hidayat",
"author_id": 49643,
"author_profile": "https://Stackoverflow.com/users/49643",
"pm_score": 3,
"selected": true,
"text": "<p>Just write:</p>\n\n<pre><code>SomeClass::SomeClass():\n queue() { }\n</code></pre>\n\n<p>C++ knows to call the co... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24545/"
] | Suppose I need to have a class which wraps a priority queue of other objects (meaning the queue is a member of the class), and additionally gives it some extra functions.
I am not quite sure what the best way is to define that vector and, mainly, how to instantiate it.
Currently I have something like this in the head... | Just write:
```
SomeClass::SomeClass():
queue() { }
```
C++ knows to call the constructor automatically from there with no arguments. |
498,805 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/5611724/a-riddle-in-c">A riddle (in C)</a> </p>
</blockquote>
<p>see this code</p>
<pre><code> #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
int array[] = {23,34,12,17,204,99,16};
int main... | [
{
"answer_id": 498830,
"author": "mouviciel",
"author_id": 45249,
"author_profile": "https://Stackoverflow.com/users/45249",
"pm_score": 0,
"selected": false,
"text": "<p>I suspect the unsigned type of <code>sizeof()</code> to propagate to the expression <code>TOTAL_ELEMENTS-2</code> and... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | >
> **Possible Duplicate:**
>
> [A riddle (in C)](https://stackoverflow.com/questions/5611724/a-riddle-in-c)
>
>
>
see this code
```
#define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
int array[] = {23,34,12,17,204,99,16};
int main()
{
int d;
for(d=-1;d <= TOTAL_ELEMENTS-2... | In your example **d** is converted to an *unsigned int* in the comparison. But -1 cannot be represented as an *unsigned int* value, so it is is converted to UINT\_ MAX. To avoid this behaviour you can convert the right side of the comparison to an signed *int* by prepending *(int)*.
See [Understand integer conversion ... |
498,835 | <pre><code>/* user-defined exception class derived from a standard class for exceptions*/
class MyProblem : public std::exception {
public:
...
MyProblem(...) { //special constructor
}
virtual const char* what() const throw() {
//what() function
...
}
};
...
void f() {
...
//create ... | [
{
"answer_id": 498842,
"author": "Alex B",
"author_id": 23643,
"author_profile": "https://Stackoverflow.com/users/23643",
"pm_score": 4,
"selected": true,
"text": "<p>Empty braces in <code>\"throw()\"</code> means the function does not throw.</p>\n"
},
{
"answer_id": 499134,
... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52913/"
] | ```
/* user-defined exception class derived from a standard class for exceptions*/
class MyProblem : public std::exception {
public:
...
MyProblem(...) { //special constructor
}
virtual const char* what() const throw() {
//what() function
...
}
};
...
void f() {
...
//create an exce... | Empty braces in `"throw()"` means the function does not throw. |
498,865 | <p>Consider this example schema:</p>
<pre><code>Customer ( int CustomerId pk, .... )
Employee ( int EmployeeId pk,
int CustomerId references Customer.CustomerId, .... )
WorkItem ( int WorkItemId pk,
int CustomerId references Customer.CustomerId,
null int EmployeeId references Employe... | [
{
"answer_id": 498877,
"author": "Kieron",
"author_id": 588,
"author_profile": "https://Stackoverflow.com/users/588",
"pm_score": 3,
"selected": true,
"text": "<p>Wouldn't a foreign key on a composite column (CustomerId, EmployeeId) work?</p>\n\n<pre><code>ALTER TABLE WorkItem\nADD CONST... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32809/"
] | Consider this example schema:
```
Customer ( int CustomerId pk, .... )
Employee ( int EmployeeId pk,
int CustomerId references Customer.CustomerId, .... )
WorkItem ( int WorkItemId pk,
int CustomerId references Customer.CustomerId,
null int EmployeeId references Employee.EmployeeId, ... | Wouldn't a foreign key on a composite column (CustomerId, EmployeeId) work?
```
ALTER TABLE WorkItem
ADD CONSTRAINT FK_Customer_Employee FOREIGN KEY (CustomerId, EmployeeId)
REFERENCES Employee (CustomerId, EmployeeId);
``` |
498,868 | <p>I would like to create a image uploading service (yes, i am aware of imageshack, photobucket, flickr...etc) :)</p>
<p>I have seen only imageshack show the directory names ("img294", "1646") of where the image is located, in the same way - i would like to do this. </p>
<p><a href="http://img294.imageshack.us/" rel=... | [
{
"answer_id": 498877,
"author": "Kieron",
"author_id": 588,
"author_profile": "https://Stackoverflow.com/users/588",
"pm_score": 3,
"selected": true,
"text": "<p>Wouldn't a foreign key on a composite column (CustomerId, EmployeeId) work?</p>\n\n<pre><code>ALTER TABLE WorkItem\nADD CONST... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51649/"
] | I would like to create a image uploading service (yes, i am aware of imageshack, photobucket, flickr...etc) :)
I have seen only imageshack show the directory names ("img294", "1646") of where the image is located, in the same way - i would like to do this.
<http://img294.imageshack.us/>**img294**/**1646/\*\*jquery**... | Wouldn't a foreign key on a composite column (CustomerId, EmployeeId) work?
```
ALTER TABLE WorkItem
ADD CONSTRAINT FK_Customer_Employee FOREIGN KEY (CustomerId, EmployeeId)
REFERENCES Employee (CustomerId, EmployeeId);
``` |
498,946 | <p>I'd like to use constants as config variables within my PHP applications, only when a constant doesn't exist (for whatever reason) it throws me a notice but I'd like that to be an error (or exception), just like when I try to echo a not existing variable.</p>
<p>Is that possible without using a separate function fo... | [
{
"answer_id": 498955,
"author": "Mark Davidson",
"author_id": 50866,
"author_profile": "https://Stackoverflow.com/users/50866",
"pm_score": 4,
"selected": false,
"text": "<p>I'd suggest using <a href=\"http://php.net/manual/en/function.defined.php\" rel=\"nofollow noreferrer\">defined</... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd like to use constants as config variables within my PHP applications, only when a constant doesn't exist (for whatever reason) it throws me a notice but I'd like that to be an error (or exception), just like when I try to echo a not existing variable.
Is that possible without using a separate function for getting ... | I'd suggest using [defined](http://php.net/manual/en/function.defined.php) with it you should be able to do something like
```
if (defined('CONSTANT')) {
echo CONSTANT;
} else {
throw new Exception('Undefined Constant.');
}
```
Edit:
The alternative to using this method as I stated in the comment below is t... |
498,965 | <p>i'm trying to get the return value of a javascript function(for example: <code>return "hello"</code>) with iPhone SDK.</p>
<p>On OS X the WebView method <code>-stringByEvaluatingJavaScriptFromString</code> returns a NSString containing the js function return value, but on the iPhone no value is returned.</p>
<p>Ho... | [
{
"answer_id": 505918,
"author": "squelart",
"author_id": 42690,
"author_profile": "https://Stackoverflow.com/users/42690",
"pm_score": 5,
"selected": false,
"text": "<p>The return string is the result of the last Javascript statement. Do <strong>not</strong> put <code>return</code> in f... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42240/"
] | i'm trying to get the return value of a javascript function(for example: `return "hello"`) with iPhone SDK.
On OS X the WebView method `-stringByEvaluatingJavaScriptFromString` returns a NSString containing the js function return value, but on the iPhone no value is returned.
How can I solve this?
---
I found a pri... | The return string is the result of the last Javascript statement. Do **not** put `return` in front of it!
The minimum code that worked for me:
```
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
[self.view addSubview:webView];
NSString *result = [webView stringByEvaluatingJavaScriptFromString:
... |
498,970 | <p>How do I remove all whitespace from the start and end of the string?</p>
| [
{
"answer_id": 498974,
"author": "Gumbo",
"author_id": 53114,
"author_profile": "https://Stackoverflow.com/users/53114",
"pm_score": 7,
"selected": false,
"text": "<p>There are <a href=\"http://blog.stevenlevithan.com/archives/faster-trim-javascript\" rel=\"noreferrer\">a lot of implemen... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20951/"
] | How do I remove all whitespace from the start and end of the string? | All browsers since IE9+ have [`trim()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim) method for strings:
```
" \n test \n ".trim(); // returns "test" here
```
For those browsers who does not support `trim()`, you can use this polyfill from [MDN](https://developer.mozi... |
498,988 | <p>We are currently using the log4net appender (web.config snippet):</p>
<pre><code><appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
</code></pre>
<p>Looking for experience using other appenders.</p>
| [
{
"answer_id": 499105,
"author": "devstuff",
"author_id": 41321,
"author_profile": "https://Stackoverflow.com/users/41321",
"pm_score": 3,
"selected": true,
"text": "<p>We use <code>SmtpAppender</code> for ERROR and FATAL levels to \"mail home\" exception reports. Also <code>ConsoleAppen... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49544/"
] | We are currently using the log4net appender (web.config snippet):
```
<appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
```
Looking for experience using other appenders. | We use `SmtpAppender` for ERROR and FATAL levels to "mail home" exception reports. Also `ConsoleAppender` when running a Windows Service in a console.
For `FileAppender` we set `<staticLogFileName value="false" />` to avoid an ever-increasing delay when rolling over to a new file and the folder contains lots of files. |
499,010 | <p>With reference to the following thread:
<a href="https://stackoverflow.com/questions/498636/java-app-unable-to-read-iso-8859-1-encoded-file-correctly">Java App : Unable to read iso-8859-1 encoded file correctly</a></p>
<p>What is the best way to programatically determine the correct charset encoding of an inputstre... | [
{
"answer_id": 499032,
"author": "Kevin",
"author_id": 26620,
"author_profile": "https://Stackoverflow.com/users/26620",
"pm_score": -1,
"selected": false,
"text": "<p>Can you pick the appropriate char set in the <a href=\"http://java.sun.com/javase/6/docs/api/java/io/InputStreamReader.h... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60956/"
] | With reference to the following thread:
[Java App : Unable to read iso-8859-1 encoded file correctly](https://stackoverflow.com/questions/498636/java-app-unable-to-read-iso-8859-1-encoded-file-correctly)
What is the best way to programatically determine the correct charset encoding of an inputstream/file ?
I have tri... | I have used this library, similar to jchardet for detecting encoding in Java:
<https://github.com/albfernandez/juniversalchardet> |
499,013 | <p>I need to run a batch file on a remote system from a local machine. Using the code below, I am getting the following error:</p>
<pre><code>Path not correct
</code></pre>
<p>I have the IP address of the machine, and I have given the batch file as public share and share name is <code>dsc</code>.</p>
<p>The IP addre... | [
{
"answer_id": 499029,
"author": "Mark",
"author_id": 37923,
"author_profile": "https://Stackoverflow.com/users/37923",
"pm_score": 0,
"selected": false,
"text": "<p>You're running on Windows but using Posix paths separators. Try <code>\"cmd /C \\\\\\\\16.181.37.28\\\\dsc\\\\StartVisTsD... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to run a batch file on a remote system from a local machine. Using the code below, I am getting the following error:
```
Path not correct
```
I have the IP address of the machine, and I have given the batch file as public share and share name is `dsc`.
The IP address of the machine is 16.181.37.28.
Here is ... | Are you trying to run the script ON THE REMOTE machine or ON YOUR LOCAL machine? Your approach will read the file from the remote machine but run it on your local.
The usual way to get something running on a remote machine is having a process on the remote machine to run permanently and listen for requests. If a reque... |
499,014 | <p>Hi I have looked at a question already posted about this and tried to adapt my code to do a simlar thing. Basicly I have a field in my mysql database that has the date in this format yyyy-dd-mm i need to the format to be dd-mm-yyyy. Currently my code is getting stuck on the line <code>echo "<td><strong> ... | [
{
"answer_id": 499021,
"author": "Rob",
"author_id": 3542,
"author_profile": "https://Stackoverflow.com/users/3542",
"pm_score": 3,
"selected": false,
"text": "<p>First things first</p>\n\n<pre><code> echo \"<td><strong> (\"d/m/y\",\". $row['date'] .\")</strong></td... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60163/"
] | Hi I have looked at a question already posted about this and tried to adapt my code to do a simlar thing. Basicly I have a field in my mysql database that has the date in this format yyyy-dd-mm i need to the format to be dd-mm-yyyy. Currently my code is getting stuck on the line `echo "<td><strong> ("d/m/y",". $row['da... | First things first
```
echo "<td><strong> ("d/m/y",". $row['date'] .")</strong></td>";
```
This line looks wrong; I suspect it ought to read something like
```
echo "<td><strong>" . date( "d/m/y", $row['date'] ) . "</strong></td>";
```
Note the missing function call and concatenation operators. Incidentally, ... |
499,016 | <p>Yesterday I read some code of a colleague and came across this:</p>
<pre><code>class a_class
{
public:
a_class() {...}
int some_method(int some_param) {...}
int value_1;
int value_2;
float value_3;
std::vector<some_other_class*> even_more_values;
/* and so on */
}
a_class a_ins... | [
{
"answer_id": 499019,
"author": "Fred A. Stair",
"author_id": 60991,
"author_profile": "https://Stackoverflow.com/users/60991",
"pm_score": 2,
"selected": false,
"text": "<p>I am not sure, but I think the memset would erase internal data of the vector.</p>\n"
},
{
"answer_id": 4... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8976/"
] | Yesterday I read some code of a colleague and came across this:
```
class a_class
{
public:
a_class() {...}
int some_method(int some_param) {...}
int value_1;
int value_2;
float value_3;
std::vector<some_other_class*> even_more_values;
/* and so on */
}
a_class a_instances[10];
void s... | This is a widely accepted method for initialization for C structs.
In C++ it doesn't work ofcourse because you can't assume anything about `vector`s internal structure. Zeroing it out is very likely to leave it in an illegal state which is why your program crashes. |
499,053 | <p>I have a C# application that scans a directory and gathers some information. I would like to display the account name for each file. I can do this on the local system by getting the SID for the FileInfo object, and then doing:</p>
<pre><code>string GetNameFromSID( SecurityIdentifier sid )
{
NTAccount ntAccoun... | [
{
"answer_id": 499355,
"author": "barneytron",
"author_id": 48988,
"author_profile": "https://Stackoverflow.com/users/48988",
"pm_score": 0,
"selected": false,
"text": "<p>This one is a stumper. You are in an Active Directory environment right? Just checking:)</p>\n\n<p>Anyhow, instead... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a C# application that scans a directory and gathers some information. I would like to display the account name for each file. I can do this on the local system by getting the SID for the FileInfo object, and then doing:
```
string GetNameFromSID( SecurityIdentifier sid )
{
NTAccount ntAccount = (NTAccount)s... | The SecurityReference object's Translate method does work on non-local SIDs but only for domain accounts. For accounts local to another machine or in a non-domain setup you would need to PInvoke the function LookupAccountSid specifying the specific machine name on which the look up needs to be performed. |
499,068 | <p>I'm trying to create clean URLs on my website. Now I succeeded in configuring apache so every request like <em>mysite.com/page</em> will work. But I also want that requests for <em>mysite.com/page.php</em> will be redirected to <em>mysite.com/page</em>. I've set environment variable in .htaccess to check if i alread... | [
{
"answer_id": 499088,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 5,
"selected": true,
"text": "<p>Add this rule above your existing rewrite rules to stop redirecting if the request has already been redirected once (<a ... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61020/"
] | I'm trying to create clean URLs on my website. Now I succeeded in configuring apache so every request like *mysite.com/page* will work. But I also want that requests for *mysite.com/page.php* will be redirected to *mysite.com/page*. I've set environment variable in .htaccess to check if i already been redirected to pre... | Add this rule above your existing rewrite rules to stop redirecting if the request has already been redirected once ([ref](http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html#fix-infinite-loop-redirects)):
```
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
``` |
499,070 | <p>I've got this nasty problem where sending multiple, large messages in quick succession from a Java (NIO) server (running Linux) to a client will lead to truncated packets. The messages have to be large and sent very rapidly for the problem to occur. Here's basically what my code is doing (not actual code, but more... | [
{
"answer_id": 499110,
"author": "Adrian Pronk",
"author_id": 41861,
"author_profile": "https://Stackoverflow.com/users/41861",
"pm_score": 2,
"selected": false,
"text": "<p>I haven't done any NIO programming, but according to the Javadocs, sc.write() will not write the entire ByteBuffer... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60006/"
] | I've got this nasty problem where sending multiple, large messages in quick succession from a Java (NIO) server (running Linux) to a client will lead to truncated packets. The messages have to be large and sent very rapidly for the problem to occur. Here's basically what my code is doing (not actual code, but more-or-l... | There are many reasons why sc.write() would not send some or all of the data. You have to check the return value and/or the number of bytes remaining in the buffer.
```
for (int n=0; n<20; n++){
ByteBuffer bb = encoder.encode(CharBuffer.wrap(msg+'\0'));
if(sc.write(bb) > 0 && bb.remaining() == 0) {
// all data... |
499,084 | <p>I've been writing a fair number of smaller wsgi apps lately and am looking to find a web server that can be distributed, preconfigured to run the specific app. I know there are things like twisted and cherrypy which can serve up wsgi apps, but they seem to be missing a key piece of functionality for me, which is th... | [
{
"answer_id": 499225,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 2,
"selected": false,
"text": "<p>What's wrong with Apache + mod_wsgi? Apache is already multiplatform; it's often already installed (except in Windows).... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61000/"
] | I've been writing a fair number of smaller wsgi apps lately and am looking to find a web server that can be distributed, preconfigured to run the specific app. I know there are things like twisted and cherrypy which can serve up wsgi apps, but they seem to be missing a key piece of functionality for me, which is the ab... | Lighttpd has a BSD license, so you should be able to bundle it if you wanted.
You say its for small apps, so I guess that means, small, local, single user web interfaces being served by a small http server? If thats is the case, then any python implementation should work. Just use something like py2exe to package it (... |
499,085 | <p>I'm placing content on my page through an ajax (post) request like so:</p>
<pre><code>$("input#ViewMore").click(function() {
var data = { before: oldestDate, threadId: 1 };
$.post("/Message/More", data,function(html) {
$('tbody#posts').prepend(html);
... | [
{
"answer_id": 499094,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 2,
"selected": false,
"text": "<p>When the new content is added to the page with Ajax you have to re-register all the events to those new elements.<... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50711/"
] | I'm placing content on my page through an ajax (post) request like so:
```
$("input#ViewMore").click(function() {
var data = { before: oldestDate, threadId: 1 };
$.post("/Message/More", data,function(html) {
$('tbody#posts').prepend(html);
return false;
... | You can use [Events/live](http://docs.jquery.com/Events/live) of jQuery 1.3, *live* will bind a handler to an event for all current - and future - matched elements. |
499,096 | <p>Code:</p>
<pre><code>for i in {0..3}; do ping http://www.pythonchallenge.com/pc/def/$i.html; done
</code></pre>
<p>A host should be found at www.pythonchallenge.com/pc/def/0.html. </p>
<p>I get this error for all pings:</p>
<blockquote>
<p>ping: cannot resolve www.pythonchallenge.com/pc/def/0.html:
Unknown h... | [
{
"answer_id": 499102,
"author": "wds",
"author_id": 10098,
"author_profile": "https://Stackoverflow.com/users/10098",
"pm_score": 4,
"selected": true,
"text": "<p>html pages != hosts. If you want to check if the three web pages actually exist, use wget. If you only want to check if the ... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54964/"
] | Code:
```
for i in {0..3}; do ping http://www.pythonchallenge.com/pc/def/$i.html; done
```
A host should be found at www.pythonchallenge.com/pc/def/0.html.
I get this error for all pings:
>
> ping: cannot resolve www.pythonchallenge.com/pc/def/0.html:
> Unknown host
>
>
> | html pages != hosts. If you want to check if the three web pages actually exist, use wget. If you only want to check if the host is up, ping www.pythonchallenge.com. |
499,106 | <p>When declaring a template, I am used to having this kind of code:</p>
<pre><code>template <class T>
</code></pre>
<p>But <a href="https://stackoverflow.com/questions/498757/factory-method-returning-an-concrete-instantiation-of-a-c-template-class">in this question</a>, they used:</p>
<pre><code>template <... | [
{
"answer_id": 499122,
"author": "maxaposteriori",
"author_id": 49046,
"author_profile": "https://Stackoverflow.com/users/49046",
"pm_score": 8,
"selected": true,
"text": "<p>It's perfectly possible to template a class on an integer rather than a type. We can assign the templated value ... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44673/"
] | When declaring a template, I am used to having this kind of code:
```
template <class T>
```
But [in this question](https://stackoverflow.com/questions/498757/factory-method-returning-an-concrete-instantiation-of-a-c-template-class), they used:
```
template <unsigned int N>
```
I checked that it compiles. But wha... | It's perfectly possible to template a class on an integer rather than a type. We can assign the templated value to a variable, or otherwise manipulate it in a way we might with any other integer literal:
```
unsigned int x = N;
```
In fact, we can create algorithms which evaluate at compile time (from [Wikipedia](ht... |
499,126 | <p>How do you set the cursor position in a text field using jQuery? I've got a text field with content, and I want the users cursor to be positioned at a certain offset when they focus on the field. The code should look kind of like this:</p>
<pre><code>$('#input').focus(function() {
$(this).setCursorPosition(4);
... | [
{
"answer_id": 499158,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 9,
"selected": true,
"text": "<p>I have two functions:</p>\n\n<pre><code>function setSelectionRange(input, selectionStart, selectionEnd) {\n ... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4767/"
] | How do you set the cursor position in a text field using jQuery? I've got a text field with content, and I want the users cursor to be positioned at a certain offset when they focus on the field. The code should look kind of like this:
```
$('#input').focus(function() {
$(this).setCursorPosition(4);
});
```
What w... | I have two functions:
```
function setSelectionRange(input, selectionStart, selectionEnd) {
if (input.setSelectionRange) {
input.focus();
input.setSelectionRange(selectionStart, selectionEnd);
}
else if (input.createTextRange) {
var range = input.createTextRange();
range.collapse(true);
range... |
499,137 | <p>I have a long string (a DNA sequence). It does not contain any whitespace character.</p>
<p>For example:</p>
<pre><code>ACTGATCGAGCTGAAGCGCAGTGCGATGCTTCGATGATGCTGACGATGCTACGATGCGAGCATCTACGATCAGTCGATGTAGCTAGTAGCATGTAGTGA
</code></pre>
<p>What would be the CSS selector to force this text to be wrapped in a <code>ht... | [
{
"answer_id": 499154,
"author": "heeen",
"author_id": 38893,
"author_profile": "https://Stackoverflow.com/users/38893",
"pm_score": 9,
"selected": true,
"text": "<p>for block elements:</p>\n\n<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58082/"
] | I have a long string (a DNA sequence). It does not contain any whitespace character.
For example:
```
ACTGATCGAGCTGAAGCGCAGTGCGATGCTTCGATGATGCTGACGATGCTACGATGCGAGCATCTACGATCAGTCGATGTAGCTAGTAGCATGTAGTGA
```
What would be the CSS selector to force this text to be wrapped in a `html:textarea` or in a `xul:textbox`? | for block elements:
```html
<textarea style="width:100px; word-wrap:break-word;">
ACTGATCGAGCTGAAGCGCAGTGCGATGCTTCGATGATGCTGACGATGCTACGATGCGAGCATCTACGATCAGTC
</textarea>
```
for inline elements:
```html
<span style="width:100px; word-wrap:break-word; display:inline-block;">
ACTGATCGAGCTGAAGCGCAGTGCGATGCTTCG... |
499,153 | <p>I have a function in an external library that I cannot change with the following signature:</p>
<pre><code>void registerResizeCallback(void (*)(int, int))
</code></pre>
<p>I want to pass in a member function as the callback, as my callback needs to modify instance variables.</p>
<p>Obviously this isn't possible w... | [
{
"answer_id": 499159,
"author": "Igor",
"author_id": 44673,
"author_profile": "https://Stackoverflow.com/users/44673",
"pm_score": 4,
"selected": true,
"text": "<p>Check <a href=\"http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.2\" rel=\"nofollow noreferrer\">"... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/214/"
] | I have a function in an external library that I cannot change with the following signature:
```
void registerResizeCallback(void (*)(int, int))
```
I want to pass in a member function as the callback, as my callback needs to modify instance variables.
Obviously this isn't possible with a simple:
```
registerResize... | Check ["[33.2] How do I pass a pointer-to-member-function to a signal handler, X event callback, system call that starts a thread/task, etc?"](http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.2) at the C++ FAQ Lite:
>
> Don't.
>
>
> Because a member function is meaningless without an object to ... |
499,166 | <p>I have a huge set of N-dimensional points (tens of millions; N is close to 100).</p>
<p>I need to map these points to a single dimension while preserving spatial locality. I want to use <a href="http://en.wikipedia.org/wiki/Hilbert_curve" rel="noreferrer">Hilbert space-filling curve</a> to do it.</p>
<p>For each p... | [
{
"answer_id": 499215,
"author": "Imran",
"author_id": 58866,
"author_profile": "https://Stackoverflow.com/users/58866",
"pm_score": 1,
"selected": false,
"text": "<p><del>I don't see how you can use a Hilbert curve in one dimension.</del></p>\n\n<p>If you are interested in mapping point... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6236/"
] | I have a huge set of N-dimensional points (tens of millions; N is close to 100).
I need to map these points to a single dimension while preserving spatial locality. I want to use [Hilbert space-filling curve](http://en.wikipedia.org/wiki/Hilbert_curve) to do it.
For each point I want to pick the closest point on the ... | I finally broke down and shelled out some money. The AIP (American Institute of Physics) has a nice, short article with source code in C. "Programming the Hilbert curve" by John Skilling (from the AIP Conf. Proc. 707, 381 (2004)) has an appendix with code for mappings in both directions. It works for any number of dime... |
499,173 | <p>How to build a simple recommendation system? I have seen some algorithms but it is so difficult to implement I wish their is practical description to implement the most simple algorithm?</p>
<p>i have these three tables</p>
<pre><code> Users
userid username
1 aaa
2 bbb
</c... | [
{
"answer_id": 499179,
"author": "peterchen",
"author_id": 31317,
"author_profile": "https://Stackoverflow.com/users/31317",
"pm_score": 0,
"selected": false,
"text": "<p>The table can be stored in three columns</p>\n\n<p><code>user_left</code>\n<code>user_top</code>\n<code>correlation</... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459737/"
] | How to build a simple recommendation system? I have seen some algorithms but it is so difficult to implement I wish their is practical description to implement the most simple algorithm?
i have these three tables
```
Users
userid username
1 aaa
2 bbb
```
and
```
p... | How you want to actually store the recommendations is as a question completely unrelated to how one would actually implement a recommendation engine. I leave that to your database architecture. On to the recommending.
You said "simple", so a Pearson correlation coefficient might be the thing you need to read up on.
C... |
499,183 | <p>I have a table that contains some blob fields that I don't want to load by default. </p>
<p>In a dbml file it is possible to set the delay loaded property for such fields. </p>
<p>Is there a similar option for external mapping files?</p>
| [
{
"answer_id": 499185,
"author": "Daniel Schaffer",
"author_id": 2596,
"author_profile": "https://Stackoverflow.com/users/2596",
"pm_score": 3,
"selected": true,
"text": "<p>I'm not familiar with \"external mapping files\", but this is basically how you do lazy loading with LINQ-to-SQL:<... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58864/"
] | I have a table that contains some blob fields that I don't want to load by default.
In a dbml file it is possible to set the delay loaded property for such fields.
Is there a similar option for external mapping files? | I'm not familiar with "external mapping files", but this is basically how you do lazy loading with LINQ-to-SQL:
```
private System.Data.Linq.Link<String> _content;
[Column(Name = "content", DbType = "NVarChar(MAX) NOT NULL", Storage = "_content")]
public String Content
{
get { return this._cont... |
499,200 | <p>I have two functions to add and remove table rows that contain a form input element. They both work fine, but I have a problem in that I need to show a Remove button input only on subsequently created table rows. My two function are as as follows:</p>
<pre><code>function addRow(table_id){
var clone;
var rows=docume... | [
{
"answer_id": 499197,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "<p>Vastly simplified, but what happens is an interrupt occurs when you try to access a reserved memory address. The in... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29538/"
] | I have two functions to add and remove table rows that contain a form input element. They both work fine, but I have a problem in that I need to show a Remove button input only on subsequently created table rows. My two function are as as follows:
```
function addRow(table_id){
var clone;
var rows=document.getElementB... | Have a look at [this](http://manugarg.googlepages.com/systemcallinlinux2_6.html).
>
> Starting with version 2.5, linux
> kernel introduced a new system call
> entry mechanism on Pentium II+
> processors. Due to performance issues
> on Pentium IV processors with existing
> software interrupt method, an
> alterna... |
499,206 | <p>What's the correct method for defining multi-line comments in an emacs mode
(like C's /* */)? The elisp examples I see are for comments that start with a single delimiter and end at the end of the line (like C++'s // or perl's #).</p>
| [
{
"answer_id": 499224,
"author": "Tom Dunham",
"author_id": 6402,
"author_profile": "https://Stackoverflow.com/users/6402",
"pm_score": 5,
"selected": true,
"text": "<p>It's like this:</p>\n\n<pre><code>(define-derived-mode my-mode\n awk-mode \"my\"\n \"My mode\"\n (setq comment-m... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14167/"
] | What's the correct method for defining multi-line comments in an emacs mode
(like C's /\* \*/)? The elisp examples I see are for comments that start with a single delimiter and end at the end of the line (like C++'s // or perl's #). | It's like this:
```
(define-derived-mode my-mode
awk-mode "my"
"My mode"
(setq comment-multi-line nil) ; maybe
(setq comment-start "/* ")
(setq comment-end "*/"))
```
But there are subtleties; maybe you want
```
/* line one */
/* line two */
/* line three */
```
or maybe you want
```
/*
... |
499,208 | <p>I have a set of Hilbert values (length from the start of the <a href="http://en.wikipedia.org/wiki/Hilbert_curve" rel="noreferrer">Hilbert curve</a> to the given point). </p>
<p>What is the best way to convert these values to 3D points? Original Hilbert curve was not in 3D, so I guess I have to pick by myself the H... | [
{
"answer_id": 499709,
"author": "Noah",
"author_id": 12113,
"author_profile": "https://Stackoverflow.com/users/12113",
"pm_score": 2,
"selected": false,
"text": "<p>Not an answer about 3D conversion, but there is a nice algorithm and discussion of Hilbert values here <a href=\"http://ww... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6236/"
] | I have a set of Hilbert values (length from the start of the [Hilbert curve](http://en.wikipedia.org/wiki/Hilbert_curve) to the given point).
What is the best way to convert these values to 3D points? Original Hilbert curve was not in 3D, so I guess I have to pick by myself the Hilbert curve rank I need. I do have to... | Not an answer about 3D conversion, but there is a nice algorithm and discussion of Hilbert values here [Two-dimensional spatial hashing with space-filling curves](http://www.serpentine.com/blog/2007/01/11/two-dimensional-spatial-hashing-with-space-filling-curves)
From [MIT](http://people.csail.mit.edu/jaffer/Geometry/... |
499,211 | <p>I'm using the data mapper pattern in a PHP app I'm developing and have a question. At present, you request a Site object with a specific ID and the mapper will lookup the row, create an object and return it. However, if you do this again for the same Site you end up with two different objects with identical data. eg... | [
{
"answer_id": 499268,
"author": "benlumley",
"author_id": 39161,
"author_profile": "https://Stackoverflow.com/users/39161",
"pm_score": 2,
"selected": true,
"text": "<p>I'd go with caching somehow - static mapper classes would be my first choice, and is what I've seen most of. Otherwise... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39428/"
] | I'm using the data mapper pattern in a PHP app I'm developing and have a question. At present, you request a Site object with a specific ID and the mapper will lookup the row, create an object and return it. However, if you do this again for the same Site you end up with two different objects with identical data. eg.:
... | I'd go with caching somehow - static mapper classes would be my first choice, and is what I've seen most of. Otherwise, your option 2 (which is the singleton pattern) is probably the best option.
Remember you need to clear this cache when an update is made to avoid returning stale data.
Having said that, unless you a... |
499,233 | <p>How can I create a link to the rest of the paragraph in an announcement in SharePoint, that displays the word: <strong>read more</strong></p>
<p>Cheers</p>
| [
{
"answer_id": 548562,
"author": "AboutDev",
"author_id": 64015,
"author_profile": "https://Stackoverflow.com/users/64015",
"pm_score": 0,
"selected": false,
"text": "<p>If you have a page and can edit it in SharePoint Designer, try <a href=\"http://randomdust.com/blogs/ryan/archive/2007... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I create a link to the rest of the paragraph in an announcement in SharePoint, that displays the word: **read more**
Cheers | I've found that the cleanest, easiest way to do this is to create a template in ItemStyle.xsl which selects a substring of the body content of the announcement and displays a link below to the article itself.
After adding the following code to your ItemStyle.xsl file (in SharePoint Designer navigate to the 'Style Lib... |
499,236 | <p>To specialize a class template, one has to redefine all of the member functions in the underlying base template (i.e. the unspecialized class template) even if they are expected to remain mostly unchanged. What are some of the accepted methods and "best practices" to avoid this code duplication?</p>
<p>Thanks.</p>
| [
{
"answer_id": 499249,
"author": "Nick",
"author_id": 26240,
"author_profile": "https://Stackoverflow.com/users/26240",
"pm_score": 2,
"selected": false,
"text": "<p>I've used base classes usually when this situation arises. Ie: put the common functionality in the base class, and derive ... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50251/"
] | To specialize a class template, one has to redefine all of the member functions in the underlying base template (i.e. the unspecialized class template) even if they are expected to remain mostly unchanged. What are some of the accepted methods and "best practices" to avoid this code duplication?
Thanks. | You can fully specialize a member selectively:
```
template<int N>
struct Vector {
int calculate() { return N; }
};
// put into the .cpp file, or make inline!
template<>
int Vector<3>::calculate() { return -1; }
```
You do a full specialization. Meaning you cannot partial specialize it:
```
template<int N, int... |
499,308 | <p>I have stored procedure:</p>
<pre><code>ALTER PROCEDURE [dbo].[k_ShoppingCart_DELETE]
@cartGUID nvarchar
AS
DELETE FROM
[dbo].[k_ShoppingCart]
WHERE
CartGUID = @cartGUID
</code></pre>
<p>When I execute this,</p>
<pre><code>exec dbo.k_ShoppingCart_DELETE '32390b5b-a35a-4e32-8393-67d5629192f0'
</code></pre>
... | [
{
"answer_id": 499312,
"author": "Noel Kennedy",
"author_id": 47207,
"author_profile": "https://Stackoverflow.com/users/47207",
"pm_score": 0,
"selected": false,
"text": "<p>Your stored proc SQL seems a bit strange, did you copy it properly?</p>\n\n<p>This doesn't look like it will compi... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51151/"
] | I have stored procedure:
```
ALTER PROCEDURE [dbo].[k_ShoppingCart_DELETE]
@cartGUID nvarchar
AS
DELETE FROM
[dbo].[k_ShoppingCart]
WHERE
CartGUID = @cartGUID
```
When I execute this,
```
exec dbo.k_ShoppingCart_DELETE '32390b5b-a35a-4e32-8393-67d5629192f0'
```
Result: 0 row (s) affected.
But, when I try ... | If you insist on using NVARCHAR instead of UNIQUEIDENTIFIER, you need to specify the size:
```
@cartGUID nvarchar(36)
```
Without it, your guids are being truncated ([to 30 characters](http://msdn.microsoft.com/en-us/library/aa276823.aspx)).
You can confirm this behavior by running this modified version of your wo... |
499,321 | <p>When the application is run, the <code>DataGridView</code> is bound to a <code>DataTable</code>. Later I add more columns to the <code>DataTable</code> programmatically and it is reflected in the underlying data - i.e. the column Ordinals are as they should be. However this is not reflected in the <code>DataGridView... | [
{
"answer_id": 499324,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "<p>That is just how <code>DataGridView</code> works; with auto-generate columns enabled, extra (unmapped) columns are ... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/199/"
] | When the application is run, the `DataGridView` is bound to a `DataTable`. Later I add more columns to the `DataTable` programmatically and it is reflected in the underlying data - i.e. the column Ordinals are as they should be. However this is not reflected in the `DataGridView`. Instead columns are appended onto the ... | That is just how `DataGridView` works; with auto-generate columns enabled, extra (unmapped) columns are appended to the end. You can unbind and re-bind to fix it; set the DataSource to null and back to the table:
```
this.dataGridView1.DataSource = null;
this.dataGridView1.Columns.Clear();
this.dataGridView1.DataSourc... |
499,345 | <p>I’m a newbie in Python. I’m learning regexes, but I need help here.</p>
<p>Here comes the HTML source:</p>
<pre><code><a href="http://www.ptop.se" target="_blank">http://www.ptop.se</a>
</code></pre>
<p>I’m trying to code a tool that only prints out <code>http://ptop.se</code>. Can you help me please?... | [
{
"answer_id": 499364,
"author": "JosefAssad",
"author_id": 53936,
"author_profile": "https://Stackoverflow.com/users/53936",
"pm_score": 4,
"selected": false,
"text": "<p>Don't use regexes, use <a href=\"http://www.crummy.com/software/BeautifulSoup/\" rel=\"noreferrer\">BeautifulSoup</a... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I’m a newbie in Python. I’m learning regexes, but I need help here.
Here comes the HTML source:
```
<a href="http://www.ptop.se" target="_blank">http://www.ptop.se</a>
```
I’m trying to code a tool that only prints out `http://ptop.se`. Can you help me please? | If you're only looking for one:
```
import re
match = re.search(r'href=[\'"]?([^\'" >]+)', s)
if match:
print(match.group(1))
```
If you have a long string, and want every instance of the pattern in it:
```
import re
urls = re.findall(r'href=[\'"]?([^\'" >]+)', s)
print(', '.join(urls))
```
Where `s` is the s... |
499,359 | <p>I want to install a driver for Ext2 partitions under Windows XP, the installation will be done with a self written Inno Setup script. Which API functions do I need to call for this? From what I googled so far I don't seem to be needing an inf file, and therefore no call to SetupCopyOEMInf. But I don't know what to d... | [
{
"answer_id": 511036,
"author": "Treb",
"author_id": 22114,
"author_profile": "https://Stackoverflow.com/users/22114",
"pm_score": 1,
"selected": false,
"text": "<p>All right, I found some more information:</p>\n\n<p>The <a href=\"http://msdn.microsoft.com/en-us/library/cc462995.aspx\" ... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22114/"
] | I want to install a driver for Ext2 partitions under Windows XP, the installation will be done with a self written Inno Setup script. Which API functions do I need to call for this? From what I googled so far I don't seem to be needing an inf file, and therefore no call to SetupCopyOEMInf. But I don't know what to do i... | As you asked which API functions are required to install a driver here is some code I use to load a driver in C:
```
bool LoadDriver( const char * cpDriverPath, const char * cpDriverName )
{
SC_HANDLE hSCService;
SC_HANDLE hSCManager;
hSCManager = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
if... |
499,381 | <p>What is the most optimal way to get a string or char* pointer into an istream.</p>
<p>I want to do the following</p>
<pre><code>std::string a = "abc..";
//I know this can be done, not sure if this is most efficient
// and not sure about char* pointers
std::istringstream istr (a);
...
foo (istr);
void foo(st... | [
{
"answer_id": 499415,
"author": "Fredrik Jansson",
"author_id": 58237,
"author_profile": "https://Stackoverflow.com/users/58237",
"pm_score": 5,
"selected": false,
"text": "<p>This will work:</p>\n\n<pre><code> std::istringstream is(\"abc...\");\n</code></pre>\n\n<p>And since istringstr... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43756/"
] | What is the most optimal way to get a string or char\* pointer into an istream.
I want to do the following
```
std::string a = "abc..";
//I know this can be done, not sure if this is most efficient
// and not sure about char* pointers
std::istringstream istr (a);
...
foo (istr);
void foo(std::istream& is) {
}
... | This will work:
```
std::istringstream is("abc...");
```
And since istringstream is a istream, you will be able to use your is object as an istream. |
499,385 | <p>How can I check component (move clip or button) <code>isInitilazed</code> before add event (release or click) for it in actionscript 3?</p>
| [
{
"answer_id": 501123,
"author": "hasseg",
"author_id": 4111,
"author_profile": "https://Stackoverflow.com/users/4111",
"pm_score": 1,
"selected": false,
"text": "<p>May I inquire what it is that you're trying to do, in more general terms?</p>\n\n<p>If you just want to avoid null referen... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36446/"
] | How can I check component (move clip or button) `isInitilazed` before add event (release or click) for it in actionscript 3? | May I inquire what it is that you're trying to do, in more general terms?
If you just want to avoid null reference errors, just check the reference (variable) you're using for `null`:
```
if (_myComponent != null)
{
// add listeners
}
```
If for some other reason you really need to know if the component has bee... |
499,393 | <p>I'm to get a custom DateTime format including the AM/PM designator, but I want the "AM" or "PM" to be lowercase <em>without</em> making the rest of of the characters lowercase.</p>
<p>Is this possible using a single format and without using a regex?</p>
<p>Here's what I've got right now:</p>
<pre><code>item.Poste... | [
{
"answer_id": 499396,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "<p><strong>EDIT</strong>: Jon's example is much better, though I think the extension method is still the way to go so y... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2596/"
] | I'm to get a custom DateTime format including the AM/PM designator, but I want the "AM" or "PM" to be lowercase *without* making the rest of of the characters lowercase.
Is this possible using a single format and without using a regex?
Here's what I've got right now:
```
item.PostedOn.ToString("dddd, MMMM d, yyyy a\... | I would personally format it in two parts: the non-am/pm part, and the am/pm part with ToLower:
```
string formatted = item.PostedOn.ToString("dddd, MMMM d, yyyy a\\t h:mm") +
item.PostedOn.ToString("tt").ToLower();
```
Another option (which I'll investigate in a sec) is to grab the current DateTi... |
499,401 | <p>I've got an app in development where you press a button to play a sound using System beep.</p>
<p>Instead of recording the output, I was thinking of recording the timing of when the buttons were pressed, so when the user presses a 'Play' button, the buttons are pressed in the same timing the user has pressed them, ... | [
{
"answer_id": 499396,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "<p><strong>EDIT</strong>: Jon's example is much better, though I think the extension method is still the way to go so y... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53677/"
] | I've got an app in development where you press a button to play a sound using System beep.
Instead of recording the output, I was thinking of recording the timing of when the buttons were pressed, so when the user presses a 'Play' button, the buttons are pressed in the same timing the user has pressed them, so it acts... | I would personally format it in two parts: the non-am/pm part, and the am/pm part with ToLower:
```
string formatted = item.PostedOn.ToString("dddd, MMMM d, yyyy a\\t h:mm") +
item.PostedOn.ToString("tt").ToLower();
```
Another option (which I'll investigate in a sec) is to grab the current DateTi... |
499,405 | <p>I have a drop-down list with known values. What I'm trying to do is set the drop down list to a particular value that I know exists using <strong>jQuery</strong>.
Using regular <strong>JavaScript</strong>, I would do something like:</p>
<pre><code>ddl = document.getElementById("ID of element goes here");
ddl.value... | [
{
"answer_id": 499413,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 11,
"selected": true,
"text": "<p><a href=\"http://docs.jquery.com/Attributes/val#val\" rel=\"noreferrer\">jQuery's documentation</a> states:</p>\n<block... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61029/"
] | I have a drop-down list with known values. What I'm trying to do is set the drop down list to a particular value that I know exists using **jQuery**.
Using regular **JavaScript**, I would do something like:
```
ddl = document.getElementById("ID of element goes here");
ddl.value = 2; // 2 being the value I want to set... | [jQuery's documentation](http://docs.jquery.com/Attributes/val#val) states:
>
> [jQuery.val] checks, or ***selects***, all the radio buttons, checkboxes, and select options that match the set of values.
>
>
>
This behavior is in `jQuery` versions `1.2` and above.
You most likely want this:
```
$("._statusDDL").... |
499,436 | <p>I have this code:</p>
<pre><code>using DC = MV6DataContext;
using MV6; // Business Logic Layer
// ...
public DC.MV6DataContext dc = new DC.MV6DataContext(ConnectionString);
IP ip = new IP(Request.UserHostAddress);
dc.IPs.InsertOnSubmit(ip);
dc.SubmitChanges();
// in Business Logic layer:
public class IP : DC.IP {... | [
{
"answer_id": 499449,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 2,
"selected": false,
"text": "<p>You can try to see what's happening, what changes will be done, if you place a breakpoint just before Submit... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11112/"
] | I have this code:
```
using DC = MV6DataContext;
using MV6; // Business Logic Layer
// ...
public DC.MV6DataContext dc = new DC.MV6DataContext(ConnectionString);
IP ip = new IP(Request.UserHostAddress);
dc.IPs.InsertOnSubmit(ip);
dc.SubmitChanges();
// in Business Logic layer:
public class IP : DC.IP {
public IP(s... | Got it.
Rather than creating a class that inherits from the DataContext's class, I extend the DC class itself with a partial class in the Business Logic layer. From there I can add whatever constructors and methods I wish.
In this case, it is neccessary to copy the code from the existing (auto-generated) constructor:... |
499,437 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/27578/when-to-choose-checked-and-unchecked-exceptions">When to choose checked and unchecked exceptions</a> </p>
</blockquote>
<p>When should I create a checked exception, and when should I make a runtime except... | [
{
"answer_id": 499444,
"author": "Henrik Paul",
"author_id": 2238,
"author_profile": "https://Stackoverflow.com/users/2238",
"pm_score": 3,
"selected": false,
"text": "<p>IMHO, it shouldn't be an exception at all. An exception, in my mind, should be used when exceptional things happen, a... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41283/"
] | >
> **Possible Duplicate:**
>
> [When to choose checked and unchecked exceptions](https://stackoverflow.com/questions/27578/when-to-choose-checked-and-unchecked-exceptions)
>
>
>
When should I create a checked exception, and when should I make a runtime exception?
For example, suppose I created the following ... | There's a LOT of disagreement on this topic. At my last job, we ran into some real issues with Runtime exceptions being forgotten until they showed up in production (on agedwards.com), so we resolved to use checked exceptions exclusively.
At my current job, I find that there are many who are for Runtime exceptions in ... |
499,456 | <p>im trying to run a cgi script (.cgi) with tomcat. I am getting the below error and cant find out whats wrong. I know i should really use apache and mod proxy but this really isnt my area of expertise so im taking the easy way out!</p>
<p>Thanks for any help.</p>
<pre>
java.io.IOException: Cannot run program "perl"... | [
{
"answer_id": 499489,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 2,
"selected": false,
"text": "<p>This is something of a guess, but you might need to add the following to your <code>web.xml</code> file so that T... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | im trying to run a cgi script (.cgi) with tomcat. I am getting the below error and cant find out whats wrong. I know i should really use apache and mod proxy but this really isnt my area of expertise so im taking the easy way out!
Thanks for any help.
```
java.io.IOException: Cannot run program "perl" (in directory ... | This is something of a guess, but you might need to add the following to your `web.xml` file so that Tomcat can find the perl executable. Tomcat doesn't look in your `PATH` to find executables, apparently:
```
executable
C:\perl\bin\perl
```
Use the actual path to perl on your system, of course. |
499,481 | <p>I have a php site about to go live (With Flex on the UI side) and was wondering what my options are for monitoring. I'm looking for some form of api which is the equivalent to .NET performance counters/ASP.NET health monitoring.</p>
<p>Ideally, I would like to get stuff like requests queued/responses served in ms, ... | [
{
"answer_id": 499497,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 2,
"selected": false,
"text": "<p>For monitoring my site, I use <a href=\"http://munin.projects.linpro.no/\" rel=\"nofollow noreferrer\">munin</a> whi... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] | I have a php site about to go live (With Flex on the UI side) and was wondering what my options are for monitoring. I'm looking for some form of api which is the equivalent to .NET performance counters/ASP.NET health monitoring.
Ideally, I would like to get stuff like requests queued/responses served in ms, and relate... | For monitoring my site, I use [munin](http://munin.projects.linpro.no/) which provides some nice graphs. As well, you can turn on some internal Apache statistics with mod\_status and mod\_info.
And for the real quick and dirty monitoring, on my home machine I poke my colo site ever 15 minutes with the following cron e... |
499,485 | <p>I would really appreciate help with this, I am seriously stuck. Basically I have a table that </p>
<p>looks like this:</p>
<pre><code>SSS_DOWID Name Mon Tue Wed Thu Fri Sat Sun Description
2 M Y N N N N N N Monday
3 MF Y N N N Y N N ... | [
{
"answer_id": 499530,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 2,
"selected": false,
"text": "<p>Sounds like you need an un-pivot.</p>\n\n<pre><code>DECLARE @Days TABLE\n(\n DayId int PRIMARY KEY,\n found int\n)\n\nINS... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would really appreciate help with this, I am seriously stuck. Basically I have a table that
looks like this:
```
SSS_DOWID Name Mon Tue Wed Thu Fri Sat Sun Description
2 M Y N N N N N N Monday
3 MF Y N N N Y N N Monday, Friday
....... | Sounds like you need an un-pivot.
```
DECLARE @Days TABLE
(
DayId int PRIMARY KEY,
found int
)
INSERT INTO @Days(DayId, found) SELECT 1, 0
INSERT INTO @Days(DayId, found) SELECT 2, 0
INSERT INTO @Days(DayId, found) SELECT 3, 0
INSERT INTO @Days(DayId, found) SELECT 4, 0
INSERT INTO @Days(DayId, found) SELECT 5, 0... |
499,504 | <p>I have this java string:</p>
<pre><code>String bla = "<my:string>invalid_content</my:string>";
</code></pre>
<p>How can I replace the "invalid_content" piece?</p>
<p>I know I should use something like this:</p>
<pre><code>bla.replaceAll(regex,"new_content");
</code></pre>
<p>in order to have:</p>
<... | [
{
"answer_id": 499514,
"author": "Mark Davidson",
"author_id": 50866,
"author_profile": "https://Stackoverflow.com/users/50866",
"pm_score": 4,
"selected": true,
"text": "<p>You could do something like</p>\n\n<pre><code>String ResultString = subjectString.replaceAll(\"(<my:string>)... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39339/"
] | I have this java string:
```
String bla = "<my:string>invalid_content</my:string>";
```
How can I replace the "invalid\_content" piece?
I know I should use something like this:
```
bla.replaceAll(regex,"new_content");
```
in order to have:
```
"<my:string>new_content</my:string>";
```
but I can't discover how... | You could do something like
```
String ResultString = subjectString.replaceAll("(<my:string>)(.*)(</my:string>)", "$1whatever$3");
``` |
499,507 | <p>I have some code like this:</p>
<pre><code>Function GetTypeFromTableName(ByVal _TableName As String, ByVal _DataContext As DataContext)
Dim Mytype As Type = (From t In _DataContext.Mapping.GetTables Where t.TableName = "dbo." + _TableName Select t.RowType.Type).SingleOrDefault
Return Mytype... | [
{
"answer_id": 499563,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like to me that you are selecting out a list of anonymous types, then changing the value in the list of ano... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have some code like this:
```
Function GetTypeFromTableName(ByVal _TableName As String, ByVal _DataContext As DataContext)
Dim Mytype As Type = (From t In _DataContext.Mapping.GetTables Where t.TableName = "dbo." + _TableName Select t.RowType.Type).SingleOrDefault
Return Mytype
End Func... | It looks like to me that you are selecting out a list of anonymous types, then changing the value in the list of anonymous types not in the matching object in the table. Since you haven't updated the table object itself, SubmitChanges has nothing to do.
Try changing it to the following
```
Dim matchingObj = Equery.... |
499,526 | <p>I have a number of tables in my DB that hold references to an key value pair:</p>
<p>types of phone numbers:</p>
<ul>
<li>1 - Home</li>
<li>2 - Work</li>
<li>3 - Mobile</li>
<li>4 - Fax</li>
</ul>
<p>etc</p>
<p>So I have a table for the types and when they are used in other tables they reference the int value a... | [
{
"answer_id": 499552,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 6,
"selected": true,
"text": "<p>Use a Dictionary<int, string> and set your DropDown DataValueField to <em>Key</em> and DataTextField to... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6486/"
] | I have a number of tables in my DB that hold references to an key value pair:
types of phone numbers:
* 1 - Home
* 2 - Work
* 3 - Mobile
* 4 - Fax
etc
So I have a table for the types and when they are used in other tables they reference the int value as a foreign key. When I have been pulling them out I have been s... | Use a Dictionary<int, string> and set your DropDown DataValueField to *Key* and DataTextField to *Value*.
```
// A sample dictionary:
var dictionary = new Dictionary<int, string>();
dictionary.Add(1, "Home");
dictionary.Add(2, "Work");
dictionary.Add(3, "Mobile");
dictionary.Add(4, "Fax");
... |
499,542 | <p>I am making a litte php-file to log some ip addresses. It is going to write the ips and date/time into a html-file. The html-file is going to be a table. So I want to mak it like this:</p>
<pre><code><table cellpadding="6" rules="groups" frame="no">
<thead>
<tr><th>IP</th><th>Da... | [
{
"answer_id": 499567,
"author": "MattBelanger",
"author_id": 655,
"author_profile": "https://Stackoverflow.com/users/655",
"pm_score": 3,
"selected": true,
"text": "<p>I'm going to assume that there's only a single table in the file. If there's more than one, this will add it to each.<... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39740/"
] | I am making a litte php-file to log some ip addresses. It is going to write the ips and date/time into a html-file. The html-file is going to be a table. So I want to mak it like this:
```
<table cellpadding="6" rules="groups" frame="no">
<thead>
<tr><th>IP</th><th>Date</th><th>Time</th></tr>
</thead>
<tbody>
<tr><t... | I'm going to assume that there's only a single table in the file. If there's more than one, this will add it to each.
```
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$date = date("j. F Y");
$time = date("H:i:s");
$text="<tr><td>{$ip}</td><td>{$date}</td><td>{$time}</td></tr> \n";
$originalfile = file_get_contents ('./ip... |
499,546 | <p>Using YUICompressor I get the following error from my javascript code:</p>
<pre>
[ERROR] 270:201:missing name after . operator
[ERROR] 292:6:missing ; before statement
</pre>
<p>Here's the javascript code at the following lines:</p>
<p>Line 270:</p>
<pre><code>new _ow.getScript(_ow.wwwurl+'/widget/save?t... | [
{
"answer_id": 499557,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 0,
"selected": false,
"text": "<p>You could make your own life a lot easier just by breaking it out onto multiple lines. You're compressing it anyway, so it'... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50394/"
] | Using YUICompressor I get the following error from my javascript code:
```
[ERROR] 270:201:missing name after . operator
[ERROR] 292:6:missing ; before statement
```
Here's the javascript code at the following lines:
Line 270:
```
new _ow.getScript(_ow.wwwurl+'/widget/save?title='+encodeURIComponent(this.... | [`private` is a reserved word.](http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Reserved_Words) |
499,550 | <p>I've got a class like this:</p>
<pre><code>[XmlRoot("channel")]
public class Channel
{
[XmlElement("title")]
public String Title { get; set; }
[WhatElseGoesHere]
[XmlArrayItem("item")]
public List<Item> Items { get; set; }
}
</code></pre>
<p>My desired output is this:</p>
<pre><code><chan... | [
{
"answer_id": 499677,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 3,
"selected": true,
"text": "<p>You can try using <a href=\"http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlelementattribute.... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2596/"
] | I've got a class like this:
```
[XmlRoot("channel")]
public class Channel
{
[XmlElement("title")]
public String Title { get; set; }
[WhatElseGoesHere]
[XmlArrayItem("item")]
public List<Item> Items { get; set; }
}
```
My desired output is this:
```
<channel>
<title>The title</title>
<item>{ite... | You can try using [XmlElementAttribute](http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlelementattribute.aspx) instead of [XmlArrayItemElementAttribute](http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlarrayitemattribute.aspx):
```
[XmlRoot("channel")]
public class Channel
{
... |
499,559 | <p>I don't know much about database optimization, but I'm trying to understand this case.</p>
<p>Say I have the following table:</p>
<pre><code>cities
===========
state_id integer
name varchar(32)
slug varchar(32)
</code></pre>
<p>Now, say I want to perform queries like this:</p>
<pre><code>SELECT * FROM cities WHE... | [
{
"answer_id": 499606,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>To do optimization use EXPLAIN <a href=\"http://www.postgresql.org/docs/7.4/static/sql-explain.html\" rel=\"nofollow norefe... | 2009/01/31 | [
"https://Stackoverflow.com/questions/499559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16957/"
] | I don't know much about database optimization, but I'm trying to understand this case.
Say I have the following table:
```
cities
===========
state_id integer
name varchar(32)
slug varchar(32)
```
Now, say I want to perform queries like this:
```
SELECT * FROM cities WHERE state_id = 123 AND slug = 'some_city'
SEL... | A single unique index on (state\_id, slug) should be sufficient. To be sure, of course, you'll need to run EXPLAIN and/or ANALYZE (perhaps with the help of something like <http://explain.depesz.com/>), but ultimately what indexes are appropriate depends very closely on what kind of queries you will be running. Remember... |