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 |
|---|---|---|---|---|---|---|
237,843 | <p>my shared hosting only allows me to create 2 virtual directories. and i want to host multiple webapps... say an asp.net mvc blog, a forum, a personal site etc... </p>
<p>isnt there any other way of doing this? cant i simply just ftp the blog folder to one of my virtual directories and then access it online??</p>
| [
{
"answer_id": 237913,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 0,
"selected": false,
"text": "<p>Can't you just put each app in a separate subdirectory in either of the virtual directories. e.g. if you had <a href=\"... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30007/"
] | my shared hosting only allows me to create 2 virtual directories. and i want to host multiple webapps... say an asp.net mvc blog, a forum, a personal site etc...
isnt there any other way of doing this? cant i simply just ftp the blog folder to one of my virtual directories and then access it online?? | For ASP.NET web applications, typically each would live in its own virtual directory which serves as the application starting point.
Technically you could "piggy-back" two applications on the same application starting point in one of two ways:
1. Put all the files for each application in the same directory (and appro... |
237,859 | <p>I have a text box in wxPython that takes the output of dictionary.items() and displays it to the user as items are added to the dictionary. However, the raw data is very ugly, looking like </p>
<pre><code>[(u'BC',45)
(u'CHM',25)
(u'CPM',30)]
</code></pre>
<p>I know dictionary.items() is a list of tuples, but I can... | [
{
"answer_id": 237872,
"author": "derfred",
"author_id": 10286,
"author_profile": "https://Stackoverflow.com/users/10286",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe the <a href=\"http://www.python.org/doc/2.5.2/lib/module-pprint.html\" rel=\"nofollow noreferrer\">pretty print</... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18676/"
] | I have a text box in wxPython that takes the output of dictionary.items() and displays it to the user as items are added to the dictionary. However, the raw data is very ugly, looking like
```
[(u'BC',45)
(u'CHM',25)
(u'CPM',30)]
```
I know dictionary.items() is a list of tuples, but I can't seem to figure out how ... | There is no built-in dictionary method that would return your desired result.
You can, however, achieve your goal by creating a helper function that will format the dictionary, e.g.:
```
def getNiceDictRepr(aDict):
return '\n'.join('%s %s' % t for t in aDict.iteritems())
```
This will produce your exact desired... |
237,876 | <p>I'm making a game and one of the methods calculates a character's base hit numbers based on skill values. The method currently calculates each value individually, since each skill can be used at short, medium, and long range.</p>
<p>I originally thought I could combine the skills into a tuple and iterate over it, d... | [
{
"answer_id": 237901,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>@Vinko: perhaps make calcBaseHitNumbers, do the \"if not self.calculatedBase:\" check internally, and just no-op if it's be... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18676/"
] | I'm making a game and one of the methods calculates a character's base hit numbers based on skill values. The method currently calculates each value individually, since each skill can be used at short, medium, and long range.
I originally thought I could combine the skills into a tuple and iterate over it, dynamically... | It feels like what you really want is a class representing the weapon, with attributes to handle the base values and calculate hit values with various modifiers. Here's a simple example:
```
SHORT_RANGE = 'S'
MEDIUM_RANGE = 'M'
LONG_RANGE = 'L'
SHORT_RANGE_MODIFIER = 0.6
MEDIUM_RANGE_MODIFIER = 0.3
LONG_RANGE_MODIFIER... |
237,899 | <p>I am using freeglut for opengl rendering...</p>
<p>I need to draw an envelop looking like a cone (2D) that has to be filled with some color and some transparency applied.</p>
<p>Is the freeglut toolkit equipped with such an inbuilt functionality to draw filled geometries(or some trick)?
or is there some other api ... | [
{
"answer_id": 237901,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>@Vinko: perhaps make calcBaseHitNumbers, do the \"if not self.calculatedBase:\" check internally, and just no-op if it's be... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30868/"
] | I am using freeglut for opengl rendering...
I need to draw an envelop looking like a cone (2D) that has to be filled with some color and some transparency applied.
Is the freeglut toolkit equipped with such an inbuilt functionality to draw filled geometries(or some trick)?
or is there some other api that has an inbui... | It feels like what you really want is a class representing the weapon, with attributes to handle the base values and calculate hit values with various modifiers. Here's a simple example:
```
SHORT_RANGE = 'S'
MEDIUM_RANGE = 'M'
LONG_RANGE = 'L'
SHORT_RANGE_MODIFIER = 0.6
MEDIUM_RANGE_MODIFIER = 0.3
LONG_RANGE_MODIFIER... |
237,914 | <p>Ok, I am trying to use Tail to monitor a log file, but I cannot get the same behavior programatically as when I manually run it through cmd prompt using the same parameters.</p>
<p>When run through cmd prompt it displays the new lines <strong>instantly</strong>. Programatically though, I have to wait for about <stro... | [
{
"answer_id": 237956,
"author": "tovare",
"author_id": 12677,
"author_profile": "https://Stackoverflow.com/users/12677",
"pm_score": 1,
"selected": false,
"text": "<p>In most languages and operating systems the standard stream is usually buffered, but the error stream is not.</p>\n\n<p>... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1147/"
] | Ok, I am trying to use Tail to monitor a log file, but I cannot get the same behavior programatically as when I manually run it through cmd prompt using the same parameters.
When run through cmd prompt it displays the new lines **instantly**. Programatically though, I have to wait for about **75+ new lines** in log fi... | Process.StandardOutput, when redirected, defaults to a StreamReader with a 4096-byte buffer, so the answer is yes. |
237,921 | <p>I have a tabview controller to which I added a UIViewController to each tab. I want to have multiple UIViews inside the UIViewController.</p>
<p>So in the implementation of the UIViewController class I added [self.view addSubView:uiview1] and [self.view addSubView:uiview2]. The problem is that when I run the app, i... | [
{
"answer_id": 237973,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 1,
"selected": false,
"text": "<p>There's no reason you can't have multiple views within your UIViewController's main view member variable. However, t... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23695/"
] | I have a tabview controller to which I added a UIViewController to each tab. I want to have multiple UIViews inside the UIViewController.
So in the implementation of the UIViewController class I added [self.view addSubView:uiview1] and [self.view addSubView:uiview2]. The problem is that when I run the app, it crahes o... | Assuming you are doing this programmatically, you're supposed to create the view in the view controller's loadView method. So you must do this:
```
self.view = [[[UIView alloc] initWithFrame:someFrame] autorelease];
```
before you do this:
```
[self.view addSubview:uiview1];
[self.view addSubview:uiview2];
```
Ot... |
237,966 | <p>The framework I am developing for my application relies very heavily on dynamically generated domain objects. I recently started using Spring WebFlow and now need to be able to serialize my domain objects that will be kept in flow scope. </p>
<p>I have done a bit of research and figured out that I can use <code>wri... | [
{
"answer_id": 238581,
"author": "Miguel Ping",
"author_id": 22992,
"author_profile": "https://Stackoverflow.com/users/22992",
"pm_score": 1,
"selected": false,
"text": "<p>Are you using spring's <code>ApplicationContext</code>, or <code>BeanFactory</code>? If you are using <code>Applica... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1969/"
] | The framework I am developing for my application relies very heavily on dynamically generated domain objects. I recently started using Spring WebFlow and now need to be able to serialize my domain objects that will be kept in flow scope.
I have done a bit of research and figured out that I can use `writeReplace()` an... | Are you using spring's `ApplicationContext`, or `BeanFactory`? If you are using `ApplicationContext`, you can implement ApplicationContextAware instead and spring will supply you with the application context. I've never used spring's `BeanFactory` before but I have used `ApplicationContext` and it works. |
237,977 | <p>This is probably one of those easy questions.. I'm trying to redirect the user after they've successfully authenticated, or return them back to the login page. But the Success page is on a different route and I can't get the redirection to work..</p>
<p>Here are my routes in Globals.asax:</p>
<pre><code>routes.Ma... | [
{
"answer_id": 237984,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 0,
"selected": false,
"text": "<p>I fail to see where you are setting the authentication cookie or marking the user as having been authenticated in an... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5662/"
] | This is probably one of those easy questions.. I'm trying to redirect the user after they've successfully authenticated, or return them back to the login page. But the Success page is on a different route and I can't get the redirection to work..
Here are my routes in Globals.asax:
```
routes.MapRoute( _
"Default... | Could it be that your Stuff route has exactly the same form as the default one, so when you call
```
Return RedirectToRoute("Stuff");
```
the resulting url has the form: {controller}/{action}/{id}, e.g. Login/Authenticate again, since you are inside Login-controller's Authenticate action.
Try to
```
RedirectToActi... |
237,978 | <p>An <a href="https://stackoverflow.com/questions/61278/quick-and-dirty-way-to-profile-your-code#231614">answer to one of my questions</a> included the following line of code:</p>
<pre><code>label = std::safe_string(name); // label is a std::string
</code></pre>
<p>The intent seems to be a wrapper around a string li... | [
{
"answer_id": 237996,
"author": "Nemanja Trifunovic",
"author_id": 8899,
"author_profile": "https://Stackoverflow.com/users/8899",
"pm_score": 2,
"selected": false,
"text": "<p>There is no such thing as <code>std::safe_string</code></p>\n"
},
{
"answer_id": 238017,
"author":... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3848/"
] | An [answer to one of my questions](https://stackoverflow.com/questions/61278/quick-and-dirty-way-to-profile-your-code#231614) included the following line of code:
```
label = std::safe_string(name); // label is a std::string
```
The intent seems to be a wrapper around a string literal (so presumably no allocation ta... | After searching [google code search](http://www.google.com/codesearch) (I should have thought of this first...) I found this:
```
//tools-cgi.cpp
string safe_string (const char * s)
{
return (s != NULL) ? s : "";
}
```
Which converts `NULL`s to zero length strings. Although this is not standard it's probably som... |
237,987 | <p>I'm a recent semi-convert to Eclipse after 20 years of using vi and gvim. One of the things I miss about gvim is that I could cut a bunch of different snippets of code into named buffers, and paste them at will when doing something like repeating a common idiom. For instance I'd have it so <code>"ap</code> would p... | [
{
"answer_id": 238042,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 7,
"selected": true,
"text": "<p>You might want to store those two snippets into a <a href=\"http://waynebeaton.wordpress.com/2006/02/27/code-template-expansi... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3333/"
] | I'm a recent semi-convert to Eclipse after 20 years of using vi and gvim. One of the things I miss about gvim is that I could cut a bunch of different snippets of code into named buffers, and paste them at will when doing something like repeating a common idiom. For instance I'd have it so `"ap` would paste
```
Databa... | You might want to store those two snippets into a [code template](http://waynebeaton.wordpress.com/2006/02/27/code-template-expansion-in-eclipse/), as explained in [this tutorial](http://web.archive.org/web/20140208040332/http://www.java-tips.org/other-api-tips/eclipse/how-to-add-your-own-code-template-in-eclipse.html)... |
238,002 | <p>How can I replace Line Breaks within a string in C#?</p>
| [
{
"answer_id": 238005,
"author": "The.Anti.9",
"author_id": 2128,
"author_profile": "https://Stackoverflow.com/users/2128",
"pm_score": 2,
"selected": false,
"text": "<p>Use the .Replace() method</p>\n\n<pre><code>Line.Replace(\"\\n\", \"whatever you want to replace with\");\n</code></pr... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3821/"
] | How can I replace Line Breaks within a string in C#? | Use replace with `Environment.NewLine`
```
myString = myString.Replace(System.Environment.NewLine, "replacement text"); //add a line terminating ;
```
As mentioned in other posts, if the string comes from another environment (OS) then you'd need to replace that particular environments implementation of [new line con... |
238,010 | <p>How is it done? What steps do I need to take and what pitfalls and gotchas are there to consider?</p>
| [
{
"answer_id": 238018,
"author": "Nils Pipenbrinck",
"author_id": 15955,
"author_profile": "https://Stackoverflow.com/users/15955",
"pm_score": 4,
"selected": false,
"text": "<p>I write quite a bit of ARM Cortex-A8 assembly-code. The CPU on the iPhone is an ARM11 (afaik) so the core inst... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8683/"
] | How is it done? What steps do I need to take and what pitfalls and gotchas are there to consider? | I've gotten this to work, thanks to some inside help over at the [Apple Devforums](https://devforums.apple.com/), you should sign up if you're a dedicated IPhone developer.
First thing's first, it's *\_\_asm\_\_()*, not plain *asm()*.
Secondly, by default, XCode generates a compilation target that compiles inline ass... |
238,013 | <p>I have an application running only on Windows and a batch file that launches it.
I want to invoke this batch file from Linux, meaning something like Linux batch will launch the windows batch with parameters and this in its turn run my application.</p>
<p>Can I do that? How?</p>
| [
{
"answer_id": 238021,
"author": "dsm",
"author_id": 7780,
"author_profile": "https://Stackoverflow.com/users/7780",
"pm_score": 5,
"selected": true,
"text": "<p>You could install an ssh server in the windows box (Cygwin has one), then from linux do something like:</p>\n\n<pre><code>ssh ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9855/"
] | I have an application running only on Windows and a batch file that launches it.
I want to invoke this batch file from Linux, meaning something like Linux batch will launch the windows batch with parameters and this in its turn run my application.
Can I do that? How? | You could install an ssh server in the windows box (Cygwin has one), then from linux do something like:
```
ssh user@windows-box c:/path/to/batch.cmd
```
and that should launch your application in the windows box. |
238,036 | <p>I'm working on an app which scrapes data from a website and I was wondering how I should go about getting the data. Specifically I need data contained in a number of div tags which use a specific CSS class - Currently (for testing purposes) I'm just checking for </p>
<pre><code>div class = "classname"
</code></pre... | [
{
"answer_id": 238040,
"author": "Yuval",
"author_id": 2819,
"author_profile": "https://Stackoverflow.com/users/2819",
"pm_score": 0,
"selected": false,
"text": "<p>If your HTML is well-formed, you can easily employ an XML parser to do the job for you... If you're only reading, <a href=\... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15075/"
] | I'm working on an app which scrapes data from a website and I was wondering how I should go about getting the data. Specifically I need data contained in a number of div tags which use a specific CSS class - Currently (for testing purposes) I'm just checking for
```
div class = "classname"
```
in each line of HTML ... | Several years ago I used JTidy for the same purpose:
<http://jtidy.sourceforge.net/>
"JTidy is a Java port of HTML Tidy, a HTML syntax checker and pretty printer. Like its non-Java cousin, JTidy can be used as a tool for cleaning up malformed and faulty HTML. In addition, JTidy provides a DOM interface to the documen... |
238,050 | <p>I am trying to issue a SQL update statement with nHibernate (2.0.1GA) like this:</p>
<pre><code>sqlstring = string.Format("set nocount on;update myusers set geo=geography::Point({0}, {1}, 4326) where userid={2};", mlat, mlong, userid);
_session.CreateSQLQuery(sqlstring).ExecuteUpdate();
</code></pre>
<p>However I ... | [
{
"answer_id": 645209,
"author": "tonyz",
"author_id": 58780,
"author_profile": "https://Stackoverflow.com/users/58780",
"pm_score": 0,
"selected": false,
"text": "<p>\"{whatever} is not a recognized built-in function name\" is a SQL Server error message, not sure what Hibernate is doing... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1975/"
] | I am trying to issue a SQL update statement with nHibernate (2.0.1GA) like this:
```
sqlstring = string.Format("set nocount on;update myusers set geo=geography::Point({0}, {1}, 4326) where userid={2};", mlat, mlong, userid);
_session.CreateSQLQuery(sqlstring).ExecuteUpdate();
```
However I receive the following erro... | I'm pretty sure I can tell you what is happening, but I don't know if there is a fix for it.
I think the problem is that the ':' character is used by NHibernate to create a named parameter. Your expression is getting changed to:
```
set nocount on;update myusers set geo=geography@p0({0}, {1}, 4326) where userid={2};
... |
238,071 | <p>What is the simplest, fastest way to complete the PHP code below such that the output is in a user-friendly format (for example, "October 27, 2006")?</p>
<pre><code>$result = mysql_query("SELECT my_timestamp FROM some_table WHERE id=42", $DB_CONN);
$row = mysql_fetch_array($result);
$formatted_date = ???($row['my_t... | [
{
"answer_id": 238074,
"author": "Richard Harrison",
"author_id": 19624,
"author_profile": "https://Stackoverflow.com/users/19624",
"pm_score": 0,
"selected": false,
"text": "<p>I use: </p>\n\n<p>date(\"F j, Y\", strtotime($row['my_timestamp']))</p>\n\n<p>or you can change the SELECT to... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2659/"
] | What is the simplest, fastest way to complete the PHP code below such that the output is in a user-friendly format (for example, "October 27, 2006")?
```
$result = mysql_query("SELECT my_timestamp FROM some_table WHERE id=42", $DB_CONN);
$row = mysql_fetch_array($result);
$formatted_date = ???($row['my_timestamp']);
e... | You could use MySQL to do this for you,
```
$result = mysql_query("SELECT DATE_FORMAT(my_timestamp, '%M %d, %Y) AS my_timestamp FROM some_table WHERE id=42", $DB_CONN);
$row = mysql_fetch_array($result);
$formatted_date = $row['my_timestamp'];
echo $formatted_date;
```
Or use PHP,
```
$result = mysql_query("SELECT ... |
238,073 | <p>When scripting in bash or any other shell in *NIX, while running a command that will take more than a few seconds, a progress bar is needed.</p>
<p>For example, copying a big file, opening a big tar file.</p>
<p>What ways do you recommend to add progress bars to shell scripts?</p>
| [
{
"answer_id": 238087,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 3,
"selected": false,
"text": "<p>Most unix commands will not give you the sort of direct feedback from which you can do this.\nSome wi... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13523/"
] | When scripting in bash or any other shell in \*NIX, while running a command that will take more than a few seconds, a progress bar is needed.
For example, copying a big file, opening a big tar file.
What ways do you recommend to add progress bars to shell scripts? | You can implement this by overwriting a line. Use `\r` to go back to the beginning of the line without writing `\n` to the terminal.
Write `\n` when you're done to advance the line.
Use `echo -ne` to:
1. not print `\n` and
2. to recognize escape sequences like `\r`.
Here's a demo:
```
echo -ne '##### ... |
238,102 | <p>I want to do some pattern matching on lists in Python. For example, in Haskell, I can do something like the following:</p>
<pre><code>fun (head : rest) = ...
</code></pre>
<p>So when I pass in a list, <code>head</code> will be the first element, and <code>rest</code> will be the trailing elements.</p>
<p>Likewise... | [
{
"answer_id": 238123,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 2,
"selected": false,
"text": "<p>That's a very much a 'pure functional' approach and as such is a sensible idiom in Haskell but it's p... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28804/"
] | I want to do some pattern matching on lists in Python. For example, in Haskell, I can do something like the following:
```
fun (head : rest) = ...
```
So when I pass in a list, `head` will be the first element, and `rest` will be the trailing elements.
Likewise, in Python, I can automatically unpack tuples:
```
(v... | So far as I know there's no way to make it a one-liner in current Python without introducing another function, e.g.:
```
split_list = lambda lst: (lst[0], lst[1:])
head, rest = split_list(my_func())
```
However, in Python 3.0 the specialized syntax used for variadic argument signatures and argument unpacking will be... |
238,110 | <p>I am trying to get the signature on the method below to work. As this is an Anonymous Type I have some trouble, any help would be great.</p>
<p>When I looked at sortedGameList.ToList() in a QuickWatch window I get the signature </p>
<pre><code>System.Collections.Generic.List<<>f__AnonymousType0<System.... | [
{
"answer_id": 238127,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 3,
"selected": false,
"text": "<p>The simple answer is: don't use an anonymous type.</p>\n\n<p>The closest you're going get with that anonymous type is... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17584/"
] | I am trying to get the signature on the method below to work. As this is an Anonymous Type I have some trouble, any help would be great.
When I looked at sortedGameList.ToList() in a QuickWatch window I get the signature
```
System.Collections.Generic.List<<>f__AnonymousType0<System.DateTime,System.Linq.IGrouping<Sy... | select new { Date = s.Key, Games = s.ToList() };
Edit: thats wrong! I think this will do.
```
public List<IGrouping<DateTime, Game>> getGamesList(int leagueID)
{
var sortedGameList =
from g in Games
group g by g.Date;
return sortedGameList.ToList();
}
```
And no, you do not need the select... |
238,173 | <p>Similar to <a href="https://stackoverflow.com/questions/233030/worst-php-practice-found-in-your-experience">this question</a>...</p>
<p>What are the worst practices you actually found in Java code?</p>
<p>Mine are:</p>
<ul>
<li>using instance variables in servlets (it's not just bad practice but bug, actually)</l... | [
{
"answer_id": 238181,
"author": "Inisheer",
"author_id": 2982,
"author_profile": "https://Stackoverflow.com/users/2982",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"https://stackoverflow.com/questions/237719#237728\">Overkill abstraction of object oriented design (Deleted so... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/686/"
] | Similar to [this question](https://stackoverflow.com/questions/233030/worst-php-practice-found-in-your-experience)...
What are the worst practices you actually found in Java code?
Mine are:
* using instance variables in servlets (it's not just bad practice but bug, actually)
* using Collection implementations like H... | I had to maintain java code, where most of the Exception handling was like:
```
catch( Exception e ) {}
``` |
238,183 | <p>Every time I do an <code>hg diff file.ext</code> I end up using a console diff application. I would like to use Kdiff3 or WinMerge (I'm using Windows).</p>
<p>Is there a way to change that? I can't find a reference in Mercurial documentation (<strong>I'm not talking about merge!</strong>). </p>
| [
{
"answer_id": 241018,
"author": "Tute",
"author_id": 4386,
"author_profile": "https://Stackoverflow.com/users/4386",
"pm_score": 7,
"selected": true,
"text": "<p>I've solved this using a Mercurial built-in extension... I just have to add the following lines to Mercurial.ini (on Mercuria... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4386/"
] | Every time I do an `hg diff file.ext` I end up using a console diff application. I would like to use Kdiff3 or WinMerge (I'm using Windows).
Is there a way to change that? I can't find a reference in Mercurial documentation (**I'm not talking about merge!**). | I've solved this using a Mercurial built-in extension... I just have to add the following lines to Mercurial.ini (on Mercurial folder):
```
[extensions]
hgext.extdiff=
[extdiff]
cmd.vdiff = kdiff3
```
When I want to use kdiff3 instead of diff I only have to use:
```
hg vdiff file.ext
``` |
238,184 | <p>My application uses measurement instruments that are connected to the PC. I want to make it possible to use similar instruments from different vendors. </p>
<p>So I defined an interface: </p>
<pre><code>interface IMeasurementInterface
{
void Initialize();
void Close();
}
</code></pre>
<p>S... | [
{
"answer_id": 238199,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 0,
"selected": false,
"text": "<p>That would probably work. Another option is to pass the parameters in a dictionary.</p>\n"
},
{
"answer_id"... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30507/"
] | My application uses measurement instruments that are connected to the PC. I want to make it possible to use similar instruments from different vendors.
So I defined an interface:
```
interface IMeasurementInterface
{
void Initialize();
void Close();
}
```
So far so good. Before a measureme... | You might be better off coming up with an abstract "Parameters" class that is extended by each different instruments parameters... e.g. and then using Generics to ensure that the correct parameters are passed to the correct classes...
```
public interface IMeasurement<PARAMTYPE> where PARAMTYPE : Parameters
{
void... |
238,194 | <p>I use <a href="http://www.crockford.com/javascript/jsmin.html" rel="nofollow noreferrer">jsmin</a> to compress my javascript files before uploading them to production.</p>
<p>Since I tend to have one "code-behind" javascript file per page, I wind up doing this a lot.</p>
<p>I installed a Windows Powertoy that adds... | [
{
"answer_id": 238204,
"author": "Andrew Cox",
"author_id": 27907,
"author_profile": "https://Stackoverflow.com/users/27907",
"pm_score": 0,
"selected": false,
"text": "<p>you could drop a link to a batch script into the user sendto directory. Something like</p>\n\n<pre><code>jsmin %1 s... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28118/"
] | I use [jsmin](http://www.crockford.com/javascript/jsmin.html) to compress my javascript files before uploading them to production.
Since I tend to have one "code-behind" javascript file per page, I wind up doing this a lot.
I installed a Windows Powertoy that adds a context menu item in Windows Explorer, so I can "Op... | Here is how to add an entry to your context menu for .js files:
```
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JSFile\shell\JSMinify]
@="JSMinify"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JSFile\shell\JSMinify\Command]
@="cmd.exe /c \"implement whatever cmd-friendly functions you want here (can use %1 and %%f) "
``` |
238,196 | <p>I have an XML that needs to be databound to a <strong>WPF TreeView</strong>. Here the XML can have different structure. The TreeView should be databound generic enough to load any permutation of hierarchy. However an <strong>XAttribute</strong> on the nodes (called <strong>Title</strong>) should be databound to the ... | [
{
"answer_id": 238253,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>I think all you need to do is create a <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.hierarchicaldatatem... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1747/"
] | I have an XML that needs to be databound to a **WPF TreeView**. Here the XML can have different structure. The TreeView should be databound generic enough to load any permutation of hierarchy. However an **XAttribute** on the nodes (called **Title**) should be databound to the TreeViewItem's **header text** and **not t... | Hurrah !!! I figured out how to bind XAttribute. It is not intuitive and it's not easily imaginable. But here is how it can be done.
```
<TreeViewItem Header="{Binding Path=Attribute[Title].Value}"/>
```
It is hard to imagine that Title can directly be used in square braces.
[More @ this MSDN link](http://msdn.micr... |
238,223 | <p>I'm matching identifiers, but now I have a problem: my identifiers are allowed to contain unicode characters. Therefore the old way to do things is not enough:</p>
<pre><code>t_IDENTIFIER = r"[A-Za-z](\\.|[A-Za-z_0-9])*"
</code></pre>
<p>In <a href="http://freehg.org/u/cheery/aml/" rel="nofollow noreferrer">my mar... | [
{
"answer_id": 238227,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 0,
"selected": false,
"text": "<p>Probably <a href=\"http://www.regular-expressions.info/posixbrackets.html\" rel=\"nofollow noreferrer\">POSIX character... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21711/"
] | I'm matching identifiers, but now I have a problem: my identifiers are allowed to contain unicode characters. Therefore the old way to do things is not enough:
```
t_IDENTIFIER = r"[A-Za-z](\\.|[A-Za-z_0-9])*"
```
In [my markup language](http://freehg.org/u/cheery/aml/) parser I match unicode characters by allowing ... | the [re](http://docs.python.org/library/re#regular-expression-syntax) module supports the \w syntax which:
>
> If UNICODE is set, this will match the
> characters [0-9\_] plus whatever is
> classified as alphanumeric in the
> Unicode character properties database.
>
>
>
therefore the following examples shows h... |
238,260 | <p>I have given a location defined by latitude and longitude.
Now i want to calculate a bounding box within e.g. 10 kilometers of that point.</p>
<p>The bounding box should be defined as latmin, lngmin and latmax, lngmax.</p>
<p>I need this stuff in order to use the <a href="http://www.panoramio.com/api/" rel="norefe... | [
{
"answer_id": 238278,
"author": "jcoby",
"author_id": 2884,
"author_profile": "https://Stackoverflow.com/users/2884",
"pm_score": 3,
"selected": false,
"text": "<p>You're looking for an ellipsoid formula. </p>\n\n<p>The best place I've found to start coding is based on the Geo::Ellipso... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21672/"
] | I have given a location defined by latitude and longitude.
Now i want to calculate a bounding box within e.g. 10 kilometers of that point.
The bounding box should be defined as latmin, lngmin and latmax, lngmax.
I need this stuff in order to use the [panoramio API](http://www.panoramio.com/api/).
Does someone know t... | I suggest to approximate locally the Earth surface as a sphere with radius given by the WGS84 ellipsoid at the given latitude. I suspect that the exact computation of latMin and latMax would require elliptic functions and would not yield an appreciable increase in accuracy (WGS84 is itself an approximation).
My implem... |
238,267 | <p>I have seen various rules for naming stored procedures. </p>
<p>Some people prefix the sproc name with usp_, others with an abbreviation for the app name, and still others with an owner name. You shouldn't use sp_ in SQL Server unless you really mean it.</p>
<p>Some start the proc name with a verb (Get, Add, Save,... | [
{
"answer_id": 238275,
"author": "friol",
"author_id": 23034,
"author_profile": "https://Stackoverflow.com/users/23034",
"pm_score": 2,
"selected": false,
"text": "<p>I always encapsulate the stored procedures in <strong>packages</strong> (I'm using Oracle, at work). That will reduce the... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27637/"
] | I have seen various rules for naming stored procedures.
Some people prefix the sproc name with usp\_, others with an abbreviation for the app name, and still others with an owner name. You shouldn't use sp\_ in SQL Server unless you really mean it.
Some start the proc name with a verb (Get, Add, Save, Remove). Other... | For my last project i used usp\_[Action][Object][Process] so for example, usp\_AddProduct or usp\_GetProductList, usp\_GetProductDetail. However now the database is at 700 procedures plus, it becomes a lot harder to find all procedures on a specific object. For example i now have to search 50 odd Add procedures for the... |
238,284 | <p>I'm building an Android app and I want to copy the text value of an EditText widget. It's possible for the user to press <code>Menu+A</code> then <code>Menu+C</code> to copy the value, but how would I do this programmatically?</p>
| [
{
"answer_id": 238297,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 10,
"selected": true,
"text": "<p>Use <a href=\"https://developer.android.com/reference/android/content/ClipboardManager#setPrimaryClip(android.content.Cli... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9128/"
] | I'm building an Android app and I want to copy the text value of an EditText widget. It's possible for the user to press `Menu+A` then `Menu+C` to copy the value, but how would I do this programmatically? | Use [`ClipboardManager#setPrimaryClip`](https://developer.android.com/reference/android/content/ClipboardManager#setPrimaryClip(android.content.ClipData)) method:
```
import android.content.ClipboardManager;
// ...
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ... |
238,314 | <p>Let's say I have the following ruby code :</p>
<pre><code>
def use_object(object)
puts object.some_method
end
</code></pre>
<p>and , this will work on any object that responds to <strong>some_method</strong>,right?</p>
<p>Assuming that the following java interface exists :</p>
<pre><code>
interface TestInterfa... | [
{
"answer_id": 238318,
"author": "Fernando Miguélez",
"author_id": 34880,
"author_profile": "https://Stackoverflow.com/users/34880",
"pm_score": 2,
"selected": true,
"text": "<p>You are right except that you can not define the body of a function in Java Interfaces, only prototypes. </p>\... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31610/"
] | Let's say I have the following ruby code :
```
def use_object(object)
puts object.some_method
end
```
and , this will work on any object that responds to **some\_method**,right?
Assuming that the following java interface exists :
```
interface TestInterface {
public String some_method();
}
```
Am I right ... | You are right except that you can not define the body of a function in Java Interfaces, only prototypes.
Interfaces are the only way to implemente a pseudo multi-derivation in Java, since normal class derivation is only simple (just one parent). |
238,317 | <p>I have a route</p>
<pre><code>// Sample URL: /Fixtures/Team/id
routes.MapRoute(
"Fixtures-by-TeamID",
"Fixtures/Team/{teamId}",
new { controller = "Fixtures", action = "GetByTeamID", },
new { teamId = @"\d{1,3}" }
);
</code></pre>
<p>and I am trying to use ActionLink in ASP.net MVC p5. </p>
<p... | [
{
"answer_id": 238339,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 1,
"selected": false,
"text": "<p>In my experience, the only time action routes really work properly is when you only have the single default route. As... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17584/"
] | I have a route
```
// Sample URL: /Fixtures/Team/id
routes.MapRoute(
"Fixtures-by-TeamID",
"Fixtures/Team/{teamId}",
new { controller = "Fixtures", action = "GetByTeamID", },
new { teamId = @"\d{1,3}" }
);
```
and I am trying to use ActionLink in ASP.net MVC p5.
```
<%= Html.ActionLink(g.HomeTe... | In my experience, the only time action routes really work properly is when you only have the single default route. As soon as you start adding custom routes like yours above, action routes become... I guess "finicky" is the right word. The matching system doesn't work exactly how you'd expect it to.
In this case, you ... |
238,328 | <p>I am trying to figure out the best way to model a spreadsheet (from the database point of view), taking into account :</p>
<ul>
<li>The spreadsheet can contain a variable number of rows.</li>
<li>The spreadsheet can contain a variable number of columns.</li>
<li>Each column can contain one single value, but its typ... | [
{
"answer_id": 238396,
"author": "Turnkey",
"author_id": 13144,
"author_profile": "https://Stackoverflow.com/users/13144",
"pm_score": 3,
"selected": true,
"text": "<p>You may want to study EAV (Entity-attribute-value) data models, as they are trying to solve a similar problem.</p>\n\n<p... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12388/"
] | I am trying to figure out the best way to model a spreadsheet (from the database point of view), taking into account :
* The spreadsheet can contain a variable number of rows.
* The spreadsheet can contain a variable number of columns.
* Each column can contain one single value, but its type is unknown (integer, date,... | You may want to study EAV (Entity-attribute-value) data models, as they are trying to solve a similar problem.
[Entity-Attribute-Value - Wikipedia](http://en.wikipedia.org/wiki/Entity-Attribute-Value_model) |
238,340 | <p>I have a C# collection of strings. Each string is a sentence that can appear on a page. I also have a collection of page breaks which is a collection of int's. representing the index where the collection of strings are split to a new page.</p>
<p>Example: Each 10 items in the string collection is a page so the coll... | [
{
"answer_id": 238369,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "<p>Not sure what the list of page breaks is for. I would think of it this way. A collection of strings, a page number... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | I have a C# collection of strings. Each string is a sentence that can appear on a page. I also have a collection of page breaks which is a collection of int's. representing the index where the collection of strings are split to a new page.
Example: Each 10 items in the string collection is a page so the collection of ... | "Pure" Linq isn't a good fit for this problem. The best fit is to rely on the methods and properties of List(T). There aren't -that- many special cases.
```
//pageNum is zero-based.
List<string> GetPage(List<string> docList, List<int> pageBreaks, int pageNum)
{
// 0 page case
if (pageBreaks.Count != 0)
{
re... |
238,343 | <p>I am trying to place a big number in a C++ variable. The number is 600851475143</p>
<p>I tried unsigned long long int but got an error saying it the constant was too big.
I then tried a bigInt library called BigInt -> <a href="http://mattmccutchen.net/bigint/" rel="nofollow noreferrer">http://mattmccutchen.net/big... | [
{
"answer_id": 238345,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 6,
"selected": true,
"text": "<p>You can specify an integer literal as long by the suffix L.<br>\nYou can specify an integer literal as long long by ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8715/"
] | I am trying to place a big number in a C++ variable. The number is 600851475143
I tried unsigned long long int but got an error saying it the constant was too big.
I then tried a bigInt library called BigInt -> <http://mattmccutchen.net/bigint/>
The problem is I can't compile the code as I get many errors regarding ... | You can specify an integer literal as long by the suffix L.
You can specify an integer literal as long long by the suffix LL.
```
#include <iostream>
int main()
{
long long num = 600851475143LL;
std::cout << num;
}
``` |
238,349 | <p>Below is the code that i cannot get to work. I know i have established a connection to the database but this returns nothing. What am i doing wrong?</p>
<pre><code>$result = "SELECT * FROM images WHERE path = ?";
$params = array("blah");
$row = sqlsrv_query($conn, $result, $params);
$finished = sqlsrv_fetch_array(... | [
{
"answer_id": 238495,
"author": "user29149",
"author_id": 29149,
"author_profile": "https://Stackoverflow.com/users/29149",
"pm_score": 1,
"selected": false,
"text": "<p>You may need to replace your ntwdblib.dll as explanied on the <a href=\"http://www.php.net/manual/en/function.mssql-c... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Below is the code that i cannot get to work. I know i have established a connection to the database but this returns nothing. What am i doing wrong?
```
$result = "SELECT * FROM images WHERE path = ?";
$params = array("blah");
$row = sqlsrv_query($conn, $result, $params);
$finished = sqlsrv_fetch_array($row);
if($fi... | You may need to replace your ntwdblib.dll as explanied on the [mssql\_connect() page of the php.net manual](http://www.php.net/manual/en/function.mssql-connect.php). |
238,358 | <p>I'm trying to get authentication working to my liking in a CakePHP app and running into a snag. </p>
<p>I want to let the user login from either the home page or from a dedicated login page. I'm using the Auth component to manage login and right now the login itself works. I am submitting the form on the home page ... | [
{
"answer_id": 239319,
"author": "Alexander Morland",
"author_id": 4013,
"author_profile": "https://Stackoverflow.com/users/4013",
"pm_score": 0,
"selected": false,
"text": "<p>Yes auth has a feature where it will redirect you to the page you tried to access before logging in. If setting... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7018/"
] | I'm trying to get authentication working to my liking in a CakePHP app and running into a snag.
I want to let the user login from either the home page or from a dedicated login page. I'm using the Auth component to manage login and right now the login itself works. I am submitting the form on the home page to /Users/... | in the AppController
```
public function beforeFilter( )
{
$this->Auth->autoRedirect = false;
}
```
in UsersController
```
public function login( )
{
if( $this->Auth->user( ) )
{
$this->redirect( array(
'controller' => 'users' ,
'action' => 'index' ,
)... |
238,359 | <p>I'm hosting my first WCF service in IIS. I have two methods, 1 to set a string variable on the WCF Service, and the other to retrieve it. The interface used is:</p>
<pre><code>[OperationContract]
string ReturnText();
[OperationContract]
void SetText(string s);
</code></pre>
<p>BasicHttpBinding is used. Stepping t... | [
{
"answer_id": 238434,
"author": "Brian",
"author_id": 19299,
"author_profile": "https://Stackoverflow.com/users/19299",
"pm_score": 4,
"selected": true,
"text": "<p>By default things are session-less and instances are per-call. See</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/li... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445/"
] | I'm hosting my first WCF service in IIS. I have two methods, 1 to set a string variable on the WCF Service, and the other to retrieve it. The interface used is:
```
[OperationContract]
string ReturnText();
[OperationContract]
void SetText(string s);
```
BasicHttpBinding is used. Stepping through the service with th... | By default things are session-less and instances are per-call. See
<http://msdn.microsoft.com/en-us/library/ms731193.aspx>
for some starter information, but in order to have state across the calls, you'll either need a PerSession or Single instancing mode on the server, and in the former case, configure the binding t... |
238,376 | <p>I am writing my own Joomla component (MVC), its based heavily on the newsflash module, because I want to display the latest 5 content items in a sliding tabbed interface, all the hard work is done, but I am having real difficult getting content out of the for loop.</p>
<p>Here is the code I have so far
default.php<... | [
{
"answer_id": 238389,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 3,
"selected": true,
"text": "<p>You said, you tried <code>if $i = 0</code>, the <a href=\"http://www.php.net/operators.comparison\" rel=\"nof... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28241/"
] | I am writing my own Joomla component (MVC), its based heavily on the newsflash module, because I want to display the latest 5 content items in a sliding tabbed interface, all the hard work is done, but I am having real difficult getting content out of the for loop.
Here is the code I have so far
default.php
```
<ul i... | You said, you tried `if $i = 0`, the [comparison operator](http://www.php.net/operators.comparison) in PHP is `==`, with your if you have an endless loop, because in each iteration you assign 0 to $i, and it never reaches $n, you should do inside your loop:
```
if ($i == 0){
// First Item here...
}else{
// Other ... |
238,380 | <p>When there are one of more columns that reference another, I'm struggling for the best way to update that column while maintaining referential integrity. For example, if I have a table of labels and descriptions and two entries:</p>
<pre><code>Label | Description
------------------------------------
read | This it... | [
{
"answer_id": 238390,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 2,
"selected": true,
"text": "<p>If you have many rows referencing READ, you could alter the foreign key to be on cascade update, update that table... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19687/"
] | When there are one of more columns that reference another, I'm struggling for the best way to update that column while maintaining referential integrity. For example, if I have a table of labels and descriptions and two entries:
```
Label | Description
------------------------------------
read | This item has been re... | If you have many rows referencing READ, you could alter the foreign key to be on cascade update, update that table set Label = 'read' where Label = 'READ' and everything will get automagically fixed. After that you can alter the constraint again to be as it was before.
To find all the tables referencing the column, yo... |
238,384 | <p>It's not quite a "programming" question, but I hope its related closely enough.</p>
<p>Do you know if it is possible to configure the browser in Linux (e.g. Firefox) to use Wine to create ActiveX objects? I would like to handle web pages that use:</p>
<pre><code>var xmlDocument = new ActiveXObject( Msxml2.DOMDocum... | [
{
"answer_id": 238407,
"author": "dsm",
"author_id": 7780,
"author_profile": "https://Stackoverflow.com/users/7780",
"pm_score": 0,
"selected": false,
"text": "<p>ActiveXObject is part of the Windows Script host, and not available in Linux unless you can use Wine to install it.</p>\n\n<p... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5363/"
] | It's not quite a "programming" question, but I hope its related closely enough.
Do you know if it is possible to configure the browser in Linux (e.g. Firefox) to use Wine to create ActiveX objects? I would like to handle web pages that use:
```
var xmlDocument = new ActiveXObject( Msxml2.DOMDocument.4.0 )
```
etc. ... | I think you can only do that in [Internet Explorer on Wine](http://www.gagme.com/greg/linux/activex-linux.php) |
238,413 | <p>I am trying to use Lambda Expressions in a project to map to a third party query API. So, I'm parsing the Expression tree by hand.</p>
<p>If I pass in a lambda expression like:</p>
<pre><code>p => p.Title == "title"
</code></pre>
<p>everything works.</p>
<p>However, if my lambda expression looks like:</p>
<p... | [
{
"answer_id": 238425,
"author": "Grank",
"author_id": 12975,
"author_profile": "https://Stackoverflow.com/users/12975",
"pm_score": -1,
"selected": false,
"text": "<p>I'm not sure I understand. Where are you \"seeing\" that? Is that at design-time or run-time? Lambda expressions can ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49611/"
] | I am trying to use Lambda Expressions in a project to map to a third party query API. So, I'm parsing the Expression tree by hand.
If I pass in a lambda expression like:
```
p => p.Title == "title"
```
everything works.
However, if my lambda expression looks like:
```
p => p.Title == myaspdropdown.SelectedValue
... | Remember that when you're dealing with the lambda expression as an expression tree, you don't have executable code. Rather you have a tree of expression elements, that make up the expression you wrote.
Charlie Calvert has [a good post](https://learn.microsoft.com/en-us/archive/blogs/charlie/expression-tree-basics) tha... |
238,430 | <p>I think I know the answer, but I would like to bounce around some ideas.</p>
<p>I would like to pass several (in this instance 2) somewhat different pieces of data to a View. My initial thought is simply to wrap-up the various objects into a containing object and pass them along that way. Then from the View, I'd h... | [
{
"answer_id": 238447,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>I've got the same dealie going on. Here's my solution (may not be the best practice, but it works for me).</p>\n\n<p>I cre... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017/"
] | I think I know the answer, but I would like to bounce around some ideas.
I would like to pass several (in this instance 2) somewhat different pieces of data to a View. My initial thought is simply to wrap-up the various objects into a containing object and pass them along that way. Then from the View, I'd have somethi... | I find it useful to create additional classes dedicated that are to be presented to the Views. I keep them in a separate namespace called 'Core.Presentation' to keep things organized. Here is an example:
```
namespace Core.Presentation
{
public class SearchPresentation
{
public IList<StateProvince> Sta... |
238,437 | <p>In ASP.NET MVC, you can mark up a controller method with <code>AuthorizeAttribute</code>, like this:</p>
<pre><code>[Authorize(Roles = "CanDeleteTags")]
public void Delete(string tagName)
{
// ...
}
</code></pre>
<p>This means that, if the currently logged-in user is not in the "CanDeleteTags" role, the contro... | [
{
"answer_id": 238700,
"author": "Keltex",
"author_id": 28260,
"author_profile": "https://Stackoverflow.com/users/28260",
"pm_score": 2,
"selected": false,
"text": "<p>Unfortunately, you're dealing with the default behavior of ASP.NET forms authentication. There is a workaround (I haven'... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8446/"
] | In ASP.NET MVC, you can mark up a controller method with `AuthorizeAttribute`, like this:
```
[Authorize(Roles = "CanDeleteTags")]
public void Delete(string tagName)
{
// ...
}
```
This means that, if the currently logged-in user is not in the "CanDeleteTags" role, the controller method will never be called.
Un... | When it was first developed, System.Web.Mvc.AuthorizeAttribute was doing the right thing -
older revisions of the HTTP specification used status code 401 for both "unauthorized" and "unauthenticated".
From the original specification:
>
> If the request already included Authorization credentials, then the 401 respo... |
238,441 | <p>I have worked on projects for embedded systems in the past where we have rearranged the order of declaration of stack variables to decrease the size of the resulting executable. For instance, if we had:</p>
<pre><code>void func()
{
char c;
int i;
short s;
...
}
</code></pre>
<p>We would reorder th... | [
{
"answer_id": 238450,
"author": "CiNN",
"author_id": 2566,
"author_profile": "https://Stackoverflow.com/users/2566",
"pm_score": 0,
"selected": false,
"text": "<p>it is compiler specifics, one can make his own compiler that would do the inverse if he wanted it that way.</p>\n"
},
{
... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13728/"
] | I have worked on projects for embedded systems in the past where we have rearranged the order of declaration of stack variables to decrease the size of the resulting executable. For instance, if we had:
```
void func()
{
char c;
int i;
short s;
...
}
```
We would reorder this to be:
```
void func()
... | As there is nothing in the standard prohibiting that for C or C++ compilers, yes, the compiler can do that.
It is different for aggregates (i.e. structs), where the relative order must be maintained, but still the compiler may insert pad bytes to achieve preferable alignment.
IIRC newer MSVC compilers use that free... |
238,452 | <p>I am familiar with C++ RTTI, and find the concept interesting.</p>
<p>Still there exist a lot of more ways to abuse it than to use it correctly (the RTTI-switch dread comes to mind). As a developer, I found (and used) only two viable uses for it (more exactly, one and a half).</p>
<p><strong>Could you share some o... | [
{
"answer_id": 238499,
"author": "fizzer",
"author_id": 18167,
"author_profile": "https://Stackoverflow.com/users/18167",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://www.objectmentor.com/resources/articles/acv.pdf\" rel=\"nofollow noreferrer\">Acyclic Visitor</a> (pdf)... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14089/"
] | I am familiar with C++ RTTI, and find the concept interesting.
Still there exist a lot of more ways to abuse it than to use it correctly (the RTTI-switch dread comes to mind). As a developer, I found (and used) only two viable uses for it (more exactly, one and a half).
**Could you share some of the ways RTTI is a vi... | [Acyclic Visitor](http://www.objectmentor.com/resources/articles/acv.pdf) (pdf) is a great use of it. |
238,460 | <p>When I use the default model binding to bind form parameters to a complex object which is a parameter to an action, the framework remembers the values passed to the first request, meaning that any subsequent request to that action gets the same data as the first. The parameter values and validation state are persist... | [
{
"answer_id": 240829,
"author": "Eilon",
"author_id": 31668,
"author_profile": "https://Stackoverflow.com/users/31668",
"pm_score": 2,
"selected": false,
"text": "<p>I tried to reproduce this problem but I'm not seeing that same behavior. I created almost exactly the same controller and... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12006/"
] | When I use the default model binding to bind form parameters to a complex object which is a parameter to an action, the framework remembers the values passed to the first request, meaning that any subsequent request to that action gets the same data as the first. The parameter values and validation state are persisted ... | It turns out that the problem was that my controllers were being reused between calls. One of the details I chose to omit from my original post is that I am using the Castle.Windsor container to create my controllers. I had failed to mark my controller with the Transient lifestyle, so I was getting the same instance ba... |
238,466 | <p>How do you access the items collection of a combo box in a specific row in a DataGridView?</p>
<p>I'm populating the combo as follows:</p>
<pre><code> Dim VATCombo As New DataGridViewComboBoxColumn
With VATCombo
.HeaderText = "VAT Rate"
.Name = .HeaderText
... | [
{
"answer_id": 240458,
"author": "thismat",
"author_id": 14045,
"author_profile": "https://Stackoverflow.com/users/14045",
"pm_score": 0,
"selected": false,
"text": "<p>Could you not directly cast the control within the cell using the row index to access the current row?</p>\n"
},
{
... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20048/"
] | How do you access the items collection of a combo box in a specific row in a DataGridView?
I'm populating the combo as follows:
```
Dim VATCombo As New DataGridViewComboBoxColumn
With VATCombo
.HeaderText = "VAT Rate"
.Name = .HeaderText
Dim VATCol... | The problem with the basic combobox in EditGridView is that all rows share the same combobox, so you cannot change it.
You to create a new class (ComboEditingControl) inherited from the ComboBox and implementing IDataGridViewEditingControl:
(e.g. customdropdown.vb:)
```
Imports System.Collections.Generic
Imports Sys... |
238,473 | <p>I want to make a really simple iphone app: one screen with a single button... when the button is tapped a new screen appears. That's it. No animations, nothing,</p>
<p>I've tried endlessly to make the NavBar sample project do this... and it works but only if I use a UINavigationController with a table that I can... | [
{
"answer_id": 238477,
"author": "kdbdallas",
"author_id": 26728,
"author_profile": "https://Stackoverflow.com/users/26728",
"pm_score": 4,
"selected": true,
"text": "<p>One way you could do this is to create a new UIView and then when the button is pressed add that new UIVIew as a subvi... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22471/"
] | I want to make a really simple iphone app: one screen with a single button... when the button is tapped a new screen appears. That's it. No animations, nothing,
I've tried endlessly to make the NavBar sample project do this... and it works but only if I use a UINavigationController with a table that I can tap etc. I'v... | One way you could do this is to create a new UIView and then when the button is pressed add that new UIVIew as a subview, therefore making it what you see.
If you make the new view its own subclass of UIView you would do something like this.
```
LoginView *login = [[LoginView alloc] initWithFrame: rect];
[mainView ad... |
238,490 | <p><strong>edit #2:</strong> Question solved halfways. Look below</p>
<p>As a follow-up question, does anyone know of a non-intrusive way to solve what i'm trying to do below (namely, linking objects to each other without triggering infinite loops)?</p>
<hr>
<p>I try to create a asp.net-mvc web application, and get ... | [
{
"answer_id": 238507,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>Hai! I think your models are recursively calling a method unintentionally, which results in the stack overflow. Like, for... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13466/"
] | **edit #2:** Question solved halfways. Look below
As a follow-up question, does anyone know of a non-intrusive way to solve what i'm trying to do below (namely, linking objects to each other without triggering infinite loops)?
---
I try to create a asp.net-mvc web application, and get a StackOverFlowException. A con... | The problem might be this: countries have subregions and subregions have countries. I don't know how you implement the lazy list, but that might keep calling GetCountries and then GetSubRegions and so on. To find that out, I would launch the debugger en set breakpoints on the GetCountries and GetSubRegions method heade... |
238,517 | <p>I have intermittent crashes occurring in my ActiveMQ libraries due to the way I'm using the activemq-cpp API. It'd be much easier to debug the issue if I could observe every function being called leading up to the crash. Are there any quick ways to trace the entry and exit of functions in a Visual Studio 2005 c++ ... | [
{
"answer_id": 238522,
"author": "Dima",
"author_id": 13313,
"author_profile": "https://Stackoverflow.com/users/13313",
"pm_score": 3,
"selected": true,
"text": "<p>Use a Tracer object. Something like this:</p>\n\n<pre><code>\nclass Tracer\n{\npublic:\n Tracer(const char *functionName)... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238517",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191808/"
] | I have intermittent crashes occurring in my ActiveMQ libraries due to the way I'm using the activemq-cpp API. It'd be much easier to debug the issue if I could observe every function being called leading up to the crash. Are there any quick ways to trace the entry and exit of functions in a Visual Studio 2005 c++ multi... | Use a Tracer object. Something like this:
```
class Tracer
{
public:
Tracer(const char *functionName) : functionName_(functionName)
{
cout << "Entering function " << functionName_ << endl;
}
~Tracer()
{
cout << "Exiting function " << functionName_ << endl;
}
const char *functionName_;
};
```
... |
238,525 | <p>I've been running the built-in <a href="http://ant.apache.org/" rel="nofollow noreferrer">Ant</a> from the command line on a Macintosh (10.5.5) and have run into some trouble with the <strong>Mail</strong> task. Running the Mail task produces the following message:</p>
<pre><code>[mail] Failed to initialise MIME ma... | [
{
"answer_id": 239516,
"author": "npellow",
"author_id": 2767300,
"author_profile": "https://Stackoverflow.com/users/2767300",
"pm_score": 1,
"selected": false,
"text": "<p>Download the Java Mail libraries from: <a href=\"http://java.sun.com/products/javamail/\" rel=\"nofollow noreferrer... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31629/"
] | I've been running the built-in [Ant](http://ant.apache.org/) from the command line on a Macintosh (10.5.5) and have run into some trouble with the **Mail** task. Running the Mail task produces the following message:
```
[mail] Failed to initialise MIME mail: org.apache.tools.ant.taskdefs.email.MimeMailer
```
This is... | Here's what I ended up doing to resolve the problem:
1. Downloaded the latest version of Ant from <http://ant.apache.org/>
2. The "built-in" Ant is installed in /usr/share/ant; I didn't want to overwrite that version so I extracted the new, full version into /usr/***local***/share/apache-ant-1.7.1/
3. As [npellow](htt... |
238,535 | <p>Is it more efficient for a class to access member variables or local variables? For example, suppose you have a (callback) method whose sole responsibility is to receive data, perform calculations on it, then pass it off to other classes. Performance-wise, would it make more sense to have a list of member variables ... | [
{
"answer_id": 238543,
"author": "Daren Thomas",
"author_id": 2260,
"author_profile": "https://Stackoverflow.com/users/2260",
"pm_score": 2,
"selected": false,
"text": "<p>This should be your compilers problem. Instead, optimize for maintainability: If the information is only ever used l... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it more efficient for a class to access member variables or local variables? For example, suppose you have a (callback) method whose sole responsibility is to receive data, perform calculations on it, then pass it off to other classes. Performance-wise, would it make more sense to have a list of member variables tha... | Executive summary: In virtually all scenarios, it doesn't matter, but there is a slight advantage for local variables.
Warning: You are micro-optimizing. You will end up spending hours trying to understand code that is supposed to win a nanosecond.
Warning: In your scenario, performance shouldn't be the question, but... |
238,536 | <p>I tried to override the settings in the default stlyesheet that comes with the simplemodal jquery plugin with containerCSS which is working fine in IE7 but not Firefox or Chrome. Not sure if this is a bug or I am doing something wrong.</p>
<p><strong>jQuery code:</strong></p>
<pre><code>$(document).ready(function(... | [
{
"answer_id": 238561,
"author": "Craig",
"author_id": 27294,
"author_profile": "https://Stackoverflow.com/users/27294",
"pm_score": 0,
"selected": false,
"text": "<p>I would have a look at jqModal instead. </p>\n"
},
{
"answer_id": 238804,
"author": "beckelmw",
"author_i... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25335/"
] | I tried to override the settings in the default stlyesheet that comes with the simplemodal jquery plugin with containerCSS which is working fine in IE7 but not Firefox or Chrome. Not sure if this is a bug or I am doing something wrong.
**jQuery code:**
```
$(document).ready(function() {
$("#ButtonPopup").click(fu... | Gecko and WebKit based browsers really like their units. Make sure you always tell it how to measure your values.
Also as a note, if you want to override inline styles from a css file, you can do so by adding !important to the end of the value.
height: 300px !important;
will override the inline styles.
Cheers! |
238,537 | <p>I am new to Access. I have a table full of records. I want to write a function to check if any id is null or empty. If so, I want to update it with xxxxx.
The check for id must be run through all tables in a database.
Can anyone provide some sample code?</p>
| [
{
"answer_id": 238551,
"author": "Daren Thomas",
"author_id": 2260,
"author_profile": "https://Stackoverflow.com/users/2260",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure if you are going to be able to find all tables in the database with Access SQL. Instead, you might want... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am new to Access. I have a table full of records. I want to write a function to check if any id is null or empty. If so, I want to update it with xxxxx.
The check for id must be run through all tables in a database.
Can anyone provide some sample code? | I'm not sure if you are going to be able to find all tables in the database with Access SQL. Instead, you might want to write up some VBA to loop through the tables and generate some SQL for each table. Something along the lines of:
```
update TABLE set FIELD = 'xxxxxx' where ID is null
``` |
238,547 | <p>I would like to be able to fetch a web page's html and save it to a <code>String</code>, so I can do some processing on it. Also, how could I handle various types of compression.</p>
<p>How would I go about doing that using Java?</p>
| [
{
"answer_id": 238556,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": false,
"text": "<p>Well, you could go with the built-in libraries such as <a href=\"http://java.sun.com/javase/6/docs/api/java/net/URL.h... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2598/"
] | I would like to be able to fetch a web page's html and save it to a `String`, so I can do some processing on it. Also, how could I handle various types of compression.
How would I go about doing that using Java? | Here's some tested code using Java's [URL](http://java.sun.com/javase/6/docs/api/java/net/URL.html) class. I'd recommend do a better job than I do here of handling the exceptions or passing them up the call stack, though.
```
public static void main(String[] args) {
URL url;
InputStream is = null;
Buffered... |
238,555 | <p>How do I get the value of a <code>MemberInfo</code> object? <code>.Name</code> returns the name of the variable, but I need the value. </p>
<p>I think you can do this with <code>FieldInfo</code> but I don't have a snippet, if you know how to do this can you provide a snippet??</p>
<p>Thanks!</p>
| [
{
"answer_id": 238562,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": false,
"text": "<p>Here's an example for fields, using <a href=\"http://msdn.microsoft.com/en-us/library/system.reflection.fieldinfo.get... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49611/"
] | How do I get the value of a `MemberInfo` object? `.Name` returns the name of the variable, but I need the value.
I think you can do this with `FieldInfo` but I don't have a snippet, if you know how to do this can you provide a snippet??
Thanks! | Although I generally agree with Marc's point about not reflecting fields, there are times when it is needed. If you want to reflect a member and you don't care whether it is a field or a property, you can use this extension method to get the value (if you want the type instead of the value, see nawful's answer to [this... |
238,603 | <p>How can I find out the size of a file I opened with an application written in C ?
I would like to know the size, because I want to put the content of the loaded file into a string, which I allocate using <code>malloc()</code>. Just writing <code>malloc(10000*sizeof(char));</code> is IMHO a bad idea. </p>
| [
{
"answer_id": 238607,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 10,
"selected": true,
"text": "<p>You need to seek to the end of the file and then ask for the position:</p>\n\n<pre><code>fseek(fp, 0L, SEEK_END);\nsz ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25017/"
] | How can I find out the size of a file I opened with an application written in C ?
I would like to know the size, because I want to put the content of the loaded file into a string, which I allocate using `malloc()`. Just writing `malloc(10000*sizeof(char));` is IMHO a bad idea. | You need to seek to the end of the file and then ask for the position:
```
fseek(fp, 0L, SEEK_END);
sz = ftell(fp);
```
You can then seek back, e.g.:
```
fseek(fp, 0L, SEEK_SET);
```
or (if seeking to go to the beginning)
```
rewind(fp);
``` |
238,606 | <p>I'm trying to make a simple C# web server that, at this stage, you can access via your browser and will just do a "Hello World". </p>
<p>The problem I'm having is that the server can receive data fine - I get the browser's header information - but the browser doesn't receive anything I send. Furthermore, I can only... | [
{
"answer_id": 238616,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>One thing which isn't a problem at the moment but might be later on is that your content length is based on the <em>U... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19696/"
] | I'm trying to make a simple C# web server that, at this stage, you can access via your browser and will just do a "Hello World".
The problem I'm having is that the server can receive data fine - I get the browser's header information - but the browser doesn't receive anything I send. Furthermore, I can only connect t... | You might like to know that you can use [`HttpListener`](http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx) to write a basic web-server very easily - this deals with most of the painful bits, letting you concentrate on writing the actual code. The MSDN page gives an example.
Note that this uses HTTP... |
238,608 | <p>I'm using TortoiseHg 0.5 (which includes Mercurial 1.0.2) on Vista64. My understanding from the <a href="http://hgbook.red-bean.com/hgbookch7.html#x11-1530007.7" rel="noreferrer">Mercurial Book</a> is that Mercurial should handle filenames in a case-insensitive manner on a case-insensitive filesystem (such as NTFS, ... | [
{
"answer_id": 245867,
"author": "Ry4an Brase",
"author_id": 8992,
"author_profile": "https://Stackoverflow.com/users/8992",
"pm_score": 3,
"selected": false,
"text": "<p>I think you misread the hgbook. The intro to section 7.7 is just describing the three different types of case sensit... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30198/"
] | I'm using TortoiseHg 0.5 (which includes Mercurial 1.0.2) on Vista64. My understanding from the [Mercurial Book](http://hgbook.red-bean.com/hgbookch7.html#x11-1530007.7) is that Mercurial should handle filenames in a case-insensitive manner on a case-insensitive filesystem (such as NTFS, which is what I'm on). However ... | This issue has been resolved in Mercurial 1.1! From the [release notes](http://www.selenic.com/mercurial/wiki/index.cgi/WhatsNew#head-b1d1f9a535adb686d6e0a490e049261313f10d7d): "Improved correctness in the face of casefolding filesystems".
On Windows, Mercurial now ignores case in its command line arguments:
```
>hg ... |
238,615 | <p>I have a quite old templating system written on top of ERB. It relies on ERB templates stored in database. Those are read and rendered. When I want to pass data from one template to another I use the :locals parameter to Rails render method. For setting default variables of those variables in some templates I use th... | [
{
"answer_id": 238715,
"author": "Rômulo Ceccon",
"author_id": 23193,
"author_profile": "https://Stackoverflow.com/users/23193",
"pm_score": 6,
"selected": true,
"text": "<p>First: actually, <a href=\"http://ruby-doc.com/docs/ProgrammingRuby/html/tut_expressions.html#UG\" rel=\"noreferre... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8621/"
] | I have a quite old templating system written on top of ERB. It relies on ERB templates stored in database. Those are read and rendered. When I want to pass data from one template to another I use the :locals parameter to Rails render method. For setting default variables of those variables in some templates I use the d... | First: actually, [`defined?` is an operator](http://ruby-doc.com/docs/ProgrammingRuby/html/tut_expressions.html#UG).
Second: if I understand your question correctly, the way to do it is with this Ruby idiom:
```
perex ||= true
```
That'll assign true to `perex` if it's undefined or `nil`. It's not exactly what your... |
238,625 | <p>I have a Visual Studio 2008 solution with two projects (a Word-Template project and a VB.Net console application for testing). Both projects reference a database project which opens a connection to an MS-Access 2007 database file and have references to System.Data.OleDb. In the database project I have a function w... | [
{
"answer_id": 238708,
"author": "Joel Lucsy",
"author_id": 645,
"author_profile": "https://Stackoverflow.com/users/645",
"pm_score": 3,
"selected": false,
"text": "<p>Are you running a 64 bit system with the database running 32 bit but the console running 64 bit? There are no MS Access ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4612/"
] | I have a Visual Studio 2008 solution with two projects (a Word-Template project and a VB.Net console application for testing). Both projects reference a database project which opens a connection to an MS-Access 2007 database file and have references to System.Data.OleDb. In the database project I have a function which ... | I have a visual Basic program with Visual Studio 2008 that uses an Access 2007 database and was receiving the same error. I found some threads that advised changing the advanced compile configuration to x86 found in the programs properties if you're running a 64 bit system. So far I haven't had any problems with my pro... |
238,654 | <p>I have animation code in a class that extends the UIView:</p>
<pre><code>// Start Animation Block
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:[self superview] cache:YES];
[UIView set... | [
{
"answer_id": 238670,
"author": "Nick Stinemates",
"author_id": 4960,
"author_profile": "https://Stackoverflow.com/users/4960",
"pm_score": 0,
"selected": false,
"text": "<p>I think a Linked List of views might be what you should think about implementing.</p>\n"
},
{
"answer_id"... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23695/"
] | I have animation code in a class that extends the UIView:
```
// Start Animation Block
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:[self superview] cache:YES];
[UIView setAnimationCurve... | Apple have a pretty good tutorial on view transitions [here](https://developer.apple.com/iphone/library/samplecode/ViewTransitions/index.html). Other than the way they implement them you can also look at using a UINavigationController which manages a bunch of views and transitioning between them.
Essentially you need ... |
238,660 | <p>When you attempt to declare an unsigned variable in C#.NET with a value outside its value range it is flagged as a compiler error, but if you produce a negative value at runtime and assign it to that variable at runtime the value wraps.</p>
<pre><code>uint z = -1; // Will not compile
uint a = 5;
uint b = 6;
uint c... | [
{
"answer_id": 238669,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 6,
"selected": true,
"text": "<p>Declaring an unassigned variable in C# isn't flagged with an error - trying to assign an invalid value to a variable i... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27765/"
] | When you attempt to declare an unsigned variable in C#.NET with a value outside its value range it is flagged as a compiler error, but if you produce a negative value at runtime and assign it to that variable at runtime the value wraps.
```
uint z = -1; // Will not compile
uint a = 5;
uint b = 6;
uint c = a - b; // W... | Declaring an unassigned variable in C# isn't flagged with an error - trying to assign an invalid value to a variable is. For instance, here's a variable which isn't definitely assigned (assuming it's local) after declaration:
```
uint z;
```
-1 isn't a valid value for a uint any more than 0.5 is, which is why your e... |
238,662 | <pre><code>string[] filesOfType1 = GetFileList1();
string[] filesOfType2 = GetFileList2();
var cookieMap = new Dictionary<string, CookieContainer>();
Action<string, Func<string, KeyValuePair<string, CookieContainer>>> addToMap = (filename, pairGetter) =>
{
KeyValuePair<string,... | [
{
"answer_id": 238729,
"author": "Omer van Kloeten",
"author_id": 4979,
"author_profile": "https://Stackoverflow.com/users/4979",
"pm_score": 1,
"selected": false,
"text": "<p>Excuse my not actually going ahead and compiling this, but this is the way I'd go around to doing it:</p>\n\n<pr... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3191/"
] | ```
string[] filesOfType1 = GetFileList1();
string[] filesOfType2 = GetFileList2();
var cookieMap = new Dictionary<string, CookieContainer>();
Action<string, Func<string, KeyValuePair<string, CookieContainer>>> addToMap = (filename, pairGetter) =>
{
KeyValuePair<string, CookieContainer> cookiePair;
... | Here's my attempt - seemed simplest to split the task into three distinct statements.
I'm using a helper function that returns null if the action throws an exception - for consistency with the answer from Omer van Kloeten, I've called this Swallow()
Also, I'm not using the LINQ syntax, just the extension methods prov... |
238,684 | <p>I have a Ruby DateTime which gets filled from a form. Additionally I have n hours from the form as well. I'd like to subtract those n hours from the previous DateTime. (To get a time range).</p>
<p>DateTime has two methods "-" and "<<" to subtract day and month, but not hour. (<a href="https://ruby-doc.org/st... | [
{
"answer_id": 238690,
"author": "Matthias Winkelmann",
"author_id": 4494,
"author_profile": "https://Stackoverflow.com/users/4494",
"pm_score": 3,
"selected": false,
"text": "<p>If you are working in <em>Rails</em>, the following super-intutive possibility exists:</p>\n\n<pre><code>>... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31644/"
] | I have a Ruby DateTime which gets filled from a form. Additionally I have n hours from the form as well. I'd like to subtract those n hours from the previous DateTime. (To get a time range).
DateTime has two methods "-" and "<<" to subtract day and month, but not hour. ([API](https://ruby-doc.org/stdlib-2.5.1/libdoc/d... | You could do this.
```
adjusted_datetime = (datetime_from_form.to_time - n.hours).to_datetime
``` |
238,697 | <p>New to xml. Looking for XPath to search a xml file with python ElementTree format</p>
<pre><code><root>
<child>One</child>
<child>Two</child>
<child>Three</child>
</root>
</code></pre>
<p>to do search for child with "Two" and return true/false</p>
<p>if it was star... | [
{
"answer_id": 238691,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>I would check out the System.Diagnostic namespace. It has a lot of stuff on tracking memory and cpu usage.</p>\n"
},
{
... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | New to xml. Looking for XPath to search a xml file with python ElementTree format
```
<root>
<child>One</child>
<child>Two</child>
<child>Three</child>
</root>
```
to do search for child with "Two" and return true/false
if it was started off like
```
from elementtree import ElementTree
root = ElementTree.parse(op... | You could use a sampling profiler like Intel's Vtune to obtain a measure of how many CPU cycles are being consumed with a minimum amount of disturbance on the system being measured.
When using threads however the goal is to avoid needless spawning new threads. Look into using the [thread pool](http://msdn.microsoft.co... |
238,702 | <p>In my database, Concessions have a many-to-one relationship with Firms (each Concession has a FirmID). SqlMetal has captured this relationship and generated the appropriate classes, so that each Concession has a Firm element. I'm binding against a query (simplified here) that returns a list of Concessions along with... | [
{
"answer_id": 238706,
"author": "Keltex",
"author_id": 28260,
"author_profile": "https://Stackoverflow.com/users/28260",
"pm_score": 2,
"selected": false,
"text": "<p>Your 2nd example is doing an inner join. It won't return Concessions which have null FirmID. You want to do an outer joi... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/239663/"
] | In my database, Concessions have a many-to-one relationship with Firms (each Concession has a FirmID). SqlMetal has captured this relationship and generated the appropriate classes, so that each Concession has a Firm element. I'm binding against a query (simplified here) that returns a list of Concessions along with in... | @James Curran: I'm getting the error any time the query is actually executed - e.g. if I databind a grid to it, or if I apply `.ToList` to it.
VB.NET has a new true ternary syntax (still more verbose than C#). This actually works:
```
From c As Concession In db.Concessions _
Select _
c.ConcessionID, _
c.Tit... |
238,733 | <p>I want to "remove" a UIView from a superview and add it again at the end... but at the "bottom" of the rest of the UIviews that belong to the superview. </p>
<p>Is this possible?</p>
<p>Any help is very appreciated!</p>
| [
{
"answer_id": 238758,
"author": "Max Stewart",
"author_id": 18338,
"author_profile": "https://Stackoverflow.com/users/18338",
"pm_score": 5,
"selected": true,
"text": "<p>Hmmm...</p>\n\n<pre><code>- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;\n</code></pre>\n\n<p>Might ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23695/"
] | I want to "remove" a UIView from a superview and add it again at the end... but at the "bottom" of the rest of the UIviews that belong to the superview.
Is this possible?
Any help is very appreciated! | Hmmm...
```
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
```
Might be what you're after? Alternatively -
```
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;
```
Though you could avoid removing the view all together (if you don't need to for any other reason) by callin... |
238,738 | <p>I'm not sure how to look for this online... I think they might be called something different in C++</p>
<p>I want to have a simple event system, somthing like</p>
<pre><code>event myCustomEvent;
myCustomEvent.subscribe( void myHandler(string) );
myCustomEvent.fire("a custom argument");
// myHandler prints out the ... | [
{
"answer_id": 238742,
"author": "Keith Nicholas",
"author_id": 10431,
"author_profile": "https://Stackoverflow.com/users/10431",
"pm_score": 3,
"selected": false,
"text": "<p>The observer pattern from the GOF is pretty much what you want.</p>\n\n<p>In the book, it has C++ code for this.... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1825034/"
] | I'm not sure how to look for this online... I think they might be called something different in C++
I want to have a simple event system, somthing like
```
event myCustomEvent;
myCustomEvent.subscribe( void myHandler(string) );
myCustomEvent.fire("a custom argument");
// myHandler prints out the string passed in the ... | I use [sigslot](http://sigslot.sourceforge.net/) for exactly this purpose. |
238,765 | <p>I am parsing an Expression Tree. Given a NodeType of ExpressionType.MemberAccess, how do I get the value of that Field? </p>
<p>From C# MSDN docs:
MemberAccess is A node that represents reading from a field or property. </p>
<p>A code snippet would be incredibly, incredibly helpful. Thanks in advance!!!</p>
<p>M... | [
{
"answer_id": 238798,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 7,
"selected": true,
"text": "<p>[updated for clarity]</p>\n\n<p>First; cast the <code>Expression</code> to a <code>MemberExpression</code>.</p>\n\n... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49611/"
] | I am parsing an Expression Tree. Given a NodeType of ExpressionType.MemberAccess, how do I get the value of that Field?
From C# MSDN docs:
MemberAccess is A node that represents reading from a field or property.
A code snippet would be incredibly, incredibly helpful. Thanks in advance!!!
My code looks something l... | [updated for clarity]
First; cast the `Expression` to a `MemberExpression`.
A `MemberExpression` has two things of interest:
* .Member - the `PropertyInfo` / `FieldInfo` to the member
* .Expression - the expression to evaluate to get the "obj" for the .Member
i.e. if you can evaluate the `.Expression` to "obj", and... |
238,784 | <p>I wrote a class/function to send xml over https via PHP4/cURL, just wondering if this is the correct approach, or if there's a better one.</p>
<p>Note that PHP5 is not an option at present.</p>
<pre><code>/**
* Send XML via http(s) post
*
* curl --header "Content-Type: text/xml" --data "<?xml version="1.0"?&... | [
{
"answer_id": 238790,
"author": "Nick Stinemates",
"author_id": 4960,
"author_profile": "https://Stackoverflow.com/users/4960",
"pm_score": -1,
"selected": false,
"text": "<p>Use the <a href=\"http://us2.php.net/manual/en/function.soap-soapclient-construct.php\" rel=\"nofollow noreferre... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29854/"
] | I wrote a class/function to send xml over https via PHP4/cURL, just wondering if this is the correct approach, or if there's a better one.
Note that PHP5 is not an option at present.
```
/**
* Send XML via http(s) post
*
* curl --header "Content-Type: text/xml" --data "<?xml version="1.0"?>...." http://www.foo.com... | If the protocol you are using is XML-RPC (looks like it based on what you said) and you are using at least PHP 4.2, have a look at <http://phpxmlrpc.sourceforge.net/> for libraries and resources. |
238,792 | <p>I cannot seem to programmatcally scroll in WPF
in a normal Windows Form I would use the code below
but that property does not exist in WPF.</p>
<pre><code>HtmlDocument doc = this.webBrowser1.Document;
doc.Body.ScrollTop = 800;
return;
</code></pre>
<p>Is there an alternative to doing this? </p>
| [
{
"answer_id": 238826,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Not exaclty sure what to look for in that code, but I basically have a WebControl that shows a Webpage that has several art... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I cannot seem to programmatcally scroll in WPF
in a normal Windows Form I would use the code below
but that property does not exist in WPF.
```
HtmlDocument doc = this.webBrowser1.Document;
doc.Body.ScrollTop = 800;
return;
```
Is there an alternative to doing this? | Not exaclty sure what to look for in that code, but I basically have a WebControl that shows a Webpage that has several articles.
I would like to jump to an article by it's title. I know I can get the index of the article name, but jumping to it is the issue. |
238,800 | <p>I have a query:</p>
<p>UPDATE choices SET votes = votes + 1 WHERE choice_id = '$user_choice'</p>
<p>But when I execute it in my script, the votes field is updated twice, so the votes will go from 4 to 6 instead to 5. It doesn't seem that it is getting called twice because I echo out stuff to test this and only get... | [
{
"answer_id": 238808,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 2,
"selected": false,
"text": "<p>There are several SQL interfaces for many different brands of database in PHP. You haven't shown the PHP code you ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a query:
UPDATE choices SET votes = votes + 1 WHERE choice\_id = '$user\_choice'
But when I execute it in my script, the votes field is updated twice, so the votes will go from 4 to 6 instead to 5. It doesn't seem that it is getting called twice because I echo out stuff to test this and only get one echo. Is t... | There are several SQL interfaces for many different brands of database in PHP. You haven't shown the PHP code you use to execute the query, nor have you identified which brand of database you use.
In some SQL interfaces in PHP, creating the statement implicitly executes the SQL. Then you have the opportunity to fetch ... |
238,812 | <p>I have a server dropdownlist in an <a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="noreferrer">Ajax</a> updatepanel. When I use the mouse to click on an item it fires the postback but when I click the up/down arrow to change entries, this is not firing. What could be reason?</p>
| [
{
"answer_id": 238816,
"author": "YonahW",
"author_id": 3821,
"author_profile": "https://Stackoverflow.com/users/3821",
"pm_score": 0,
"selected": false,
"text": "<p>I think you have to leave the control if you are using the keyboard in order to fire the event.</p>\n"
},
{
"answe... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | I have a server dropdownlist in an [Ajax](http://en.wikipedia.org/wiki/Ajax_%28programming%29) updatepanel. When I use the mouse to click on an item it fires the postback but when I click the up/down arrow to change entries, this is not firing. What could be reason? | Try this:
```
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" onKeyUp="this.blur();">
```
With **onKeyUp="this.blur();"** the control will lose focus when a key is unpressed, and that will trigger the onChange event. |
238,814 | <p>I'm trying to build an in-game Tell A Friend form like in AppStore. Does anybody know if it can be found anywhere in the SDK? I wouldn't like to reinvent the sliced bread.</p>
<p>Thanks!</p>
| [
{
"answer_id": 238905,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 1,
"selected": false,
"text": "<p>There's nothing like this in the SDK, sorry.</p>\n"
},
{
"answer_id": 239375,
"author": "Chris Samuels",... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31515/"
] | I'm trying to build an in-game Tell A Friend form like in AppStore. Does anybody know if it can be found anywhere in the SDK? I wouldn't like to reinvent the sliced bread.
Thanks! | Short of writing your own SMTP client, you can create a message then exit your app by sending a URL to the mail app with openURL.
```
NSURL *url = [[NSURL alloc] initWithString: @"mailto:gilm@myopenid.com?subject=subject&body=body"];
[[UIApplication sharedApplication] openURL:url];
```
The user then checks the conte... |
238,824 | <p>How do I call a url in order to process the results?</p>
<p>I have a stand-alone reporting servlet which I link to for reports. I want to email these reports now, if I were doing this in the browser, I could just use an xhttprequest, and process the results - I basically want to do the same thing in Java, but I'm n... | [
{
"answer_id": 238831,
"author": "Moishe Lettvin",
"author_id": 23786,
"author_profile": "https://Stackoverflow.com/users/23786",
"pm_score": 1,
"selected": false,
"text": "<p>Check out the URL and URLConnection classes. Here's some documentation: <a href=\"http://www.exampledepot.com/eg... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/943/"
] | How do I call a url in order to process the results?
I have a stand-alone reporting servlet which I link to for reports. I want to email these reports now, if I were doing this in the browser, I could just use an xhttprequest, and process the results - I basically want to do the same thing in Java, but I'm not sure ho... | ```
public byte[] download(URL url) throws IOException {
URLConnection uc = url.openConnection();
int len = uc.getContentLength();
InputStream is = new BufferedInputStream(uc.getInputStream());
try {
byte[] data = new byte[len];
int offset = 0;
while (offset < len) {
... |
238,829 | <p>Here is the story. I was doing a program, every time the program is closed all the data(File links) created by the user is lost, so whenever the user reopen the program, he does have to do all the work again.</p>
<p>So I decided to use an xml file to store the data, because a dbms would take too long to load and co... | [
{
"answer_id": 238859,
"author": "Paul Prewett",
"author_id": 15751,
"author_profile": "https://Stackoverflow.com/users/15751",
"pm_score": 3,
"selected": true,
"text": "<p>If LINQ is in your toolbox, I would highly recommend using that to read/write xml as opposed to a DataTable. It's ... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2605/"
] | Here is the story. I was doing a program, every time the program is closed all the data(File links) created by the user is lost, so whenever the user reopen the program, he does have to do all the work again.
So I decided to use an xml file to store the data, because a dbms would take too long to load and code to hand... | If LINQ is in your toolbox, I would highly recommend using that to read/write xml as opposed to a DataTable. It's much more fluent and intuitive and you can control where the nodes go... wherever you add them to the collection is where they appear in the resulting XML.
Here's a quick intro and there's a metric ton of ... |
238,878 | <p>I am still very new to Ruby (reading through the Pickaxe and spending most of my time in <code>irb</code>), and now that I know it's possible to patch classes in Ruby, I'm wondering when it's acceptable to do so, specifically whether it's acceptable to patch Ruby's base classes. For example: I answered another Ruby ... | [
{
"answer_id": 238888,
"author": "Dónal",
"author_id": 2648,
"author_profile": "https://Stackoverflow.com/users/2648",
"pm_score": 3,
"selected": false,
"text": "<p>Personally, I think it's acceptable to add methods to the base classes, but unacceptable to modify the implementation of ex... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17862/"
] | I am still very new to Ruby (reading through the Pickaxe and spending most of my time in `irb`), and now that I know it's possible to patch classes in Ruby, I'm wondering when it's acceptable to do so, specifically whether it's acceptable to patch Ruby's base classes. For example: I answered another Ruby question [here... | My personal answer, in a nutshell: [the core-class patching hammer should be at the bottom of your toolbox](http://avdi.org/devblog/2008/02/25/full-disclosure/). There are a lot of other techniques available to you, and in almost all cases they are sufficient, cleaner, and more [sustainable](http://avdi.org/devblog/200... |
238,894 | <p>I am trying to design a 4-bit adder subtracter in verilog. This is only the second thing I have ever written in verilog, and I don't know all the correct syntax yet. This is the module I have so far:</p>
<pre><code>module Question3(carryin, X, Y, Z, S, carryout, overflow);
parameter n = 4;
input carryin, Z;... | [
{
"answer_id": 238916,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 1,
"selected": false,
"text": "<p>You are using a lower case \"y\" in \"Y = not(y) + 4'b0001;\"</p>\n\n<p>Also, you're using more additions than you n... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23323/"
] | I am trying to design a 4-bit adder subtracter in verilog. This is only the second thing I have ever written in verilog, and I don't know all the correct syntax yet. This is the module I have so far:
```
module Question3(carryin, X, Y, Z, S, carryout, overflow);
parameter n = 4;
input carryin, Z;
input [n-... | ```
reg [n-1:0] Y_compl;
always @( Z, Y, X, carryin ) begin
Y_ = ( ~Y + 4'b0001 );
if ( Z == 1'b0 ) begin
{carryout, S} = X + Y_compl + carryin;
overflow = carryout ^ X[n-1] ^ Y_compl[n-1] ^ S[n-1];
end
else begin
{carryout, S} = X + Y + carryin;
overflow = carryout ^ X[n-1] ^ Y[n-1] ^ S[n-1];
... |
238,898 | <p>Has anyone noticed that if you retrieve HTML from the clipboard, it gets the encoding wrong and injects weird characters?</p>
<p>For example, executing a command like this:</p>
<pre><code>string s = (string) Clipboard.GetData(DataFormats.Html)
</code></pre>
<p>Results in stuff like:</p>
<pre><code><FONT size=... | [
{
"answer_id": 239161,
"author": "Ken Paul",
"author_id": 26671,
"author_profile": "https://Stackoverflow.com/users/26671",
"pm_score": 1,
"selected": false,
"text": "<p>You have to interpret the data as UTF-8. See <a href=\"https://stackoverflow.com/questions/189640/ms-office-hyperlink... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31015/"
] | Has anyone noticed that if you retrieve HTML from the clipboard, it gets the encoding wrong and injects weird characters?
For example, executing a command like this:
```
string s = (string) Clipboard.GetData(DataFormats.Html)
```
Results in stuff like:
```
<FONT size=-2>Â Â <A href="/advanced_search?hl=en">Advance... | In this case it is not so visible as it was in my case. Today I tried to copy data from clipboard but there were a few unicode characters. The data I got were as if I would read a UTF-8 encoded file in Windows-1250 encoding *(local encoding in my Windows)*.
It seems you case is the same. If you save the html data *(re... |
238,918 | <p>I have been having some problems trying to get my PHP running. When I try and run any scripts they appear in the source and do not run properly. This is the htaccess file:</p>
<pre><code># Use PHP5 as default
AddHandler application/x-httpd-php5 .php
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
</code></pre>... | [
{
"answer_id": 238922,
"author": "Gabriel Ross",
"author_id": 10751,
"author_profile": "https://Stackoverflow.com/users/10751",
"pm_score": 0,
"selected": false,
"text": "<p>is libphp5.so loaded?</p>\n\n<p>That AddHandler directive, I believe, should be:</p>\n\n<p>AddType application/x-h... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31677/"
] | I have been having some problems trying to get my PHP running. When I try and run any scripts they appear in the source and do not run properly. This is the htaccess file:
```
# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
```
Could this be the err... | Change `AddHandler application/x-httpd-php5 .php` to `AddHandler application/x-httpd-php .php` and ensure the file you're hitting has the .php extension. Also comment out those other two `AddType`/`AddHandler` lines (the `x-mapp-*` ones). What someone else said about making sure the module is loaded or compiled in is w... |
238,931 | <p>I am developing some client side Javascript that is using some JSON web services on a different domain. I have read that some browsers do not allow cross-domain scripting and that I should create a proxy on my local server to serve the data.</p>
<p>Can someone please point me to a simple example of how to do this ... | [
{
"answer_id": 238940,
"author": "roenving",
"author_id": 23142,
"author_profile": "https://Stackoverflow.com/users/23142",
"pm_score": 0,
"selected": false,
"text": "<p><strong>No</strong> browsers allow cross-domain scripting, and although w3c has left space for this in its recommendat... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10589/"
] | I am developing some client side Javascript that is using some JSON web services on a different domain. I have read that some browsers do not allow cross-domain scripting and that I should create a proxy on my local server to serve the data.
Can someone please point me to a simple example of how to do this in ASP.Net? | You may be able to avoid a proxy by using a technique like [JSONP](http://remysharp.com/2007/10/08/what-is-jsonp/). Assuming the web service you're talking to supports JSONP (for example, Flickr or Twitter both offer a JSONP API) or you have control over the data the web service sends back, you can send JSON data betwe... |
238,941 | <p><strong>UPDATE:</strong> Thanks to everyone for the responses. I didn't realize document.write() was deprecated. Add a another notch to the learning column. I'll be taking the advice posted here, but leave the original question so that the answers given make sense in context of the original question.</p>
<hr>
<p>I... | [
{
"answer_id": 238957,
"author": "eyelidlessness",
"author_id": 17964,
"author_profile": "https://Stackoverflow.com/users/17964",
"pm_score": 3,
"selected": true,
"text": "<p>My gut reaction is: <strong>don't do that</strong>. (Your example is poor, you should not be writing big chunks o... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | **UPDATE:** Thanks to everyone for the responses. I didn't realize document.write() was deprecated. Add a another notch to the learning column. I'll be taking the advice posted here, but leave the original question so that the answers given make sense in context of the original question.
---
I'm in the process of cod... | My gut reaction is: **don't do that**. (Your example is poor, you should not be writing big chunks of content in your behavior layer.)
Whenever you *have to* do this, either concat:
```
var longVar = 'asdfasdf asdf asdf asdfasdf asdfasdf asdf asdfasdf' +
' fasdf s9d0af asdf asdf0s,dv z-xcfva-sdfmwaert ' +
'qe... |
238,949 | <p>If this is possible, please provide a sample query or two so I can see how it would work. Both tables will be in the same database.</p>
<p>Thanks!</p>
| [
{
"answer_id": 238952,
"author": "Andrew",
"author_id": 826,
"author_profile": "https://Stackoverflow.com/users/826",
"pm_score": 5,
"selected": true,
"text": "<p>Pseudo code:</p>\n\n<pre><code>insert into <target-table>\n( <column-list> )\nselect <columns>\n from <... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1572436/"
] | If this is possible, please provide a sample query or two so I can see how it would work. Both tables will be in the same database.
Thanks! | Pseudo code:
```
insert into <target-table>
( <column-list> )
select <columns>
from <source-table>
``` |
238,956 | <p>On the latest Ubuntu, I have a functioning PHP 5.2.4 installation. I want to use a remote Oracle server from PHP using OCI.</p>
<p>I've downloaded the <em>"Instant Client Package - Basic Lite"</em> (<a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html" rel="nofollow noref... | [
{
"answer_id": 238979,
"author": "Till",
"author_id": 2859,
"author_profile": "https://Stackoverflow.com/users/2859",
"pm_score": 2,
"selected": false,
"text": "<p>You need the PHP extension, try the following on your Ubuntu:</p>\n\n<pre><code>(sudo) pecl install oci8\n</code></pre>\n\n<... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3401/"
] | On the latest Ubuntu, I have a functioning PHP 5.2.4 installation. I want to use a remote Oracle server from PHP using OCI.
I've downloaded the *"Instant Client Package - Basic Lite"* ([Link](http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html)). I've unzipped the package containing ... | You need the PHP extension, try the following on your Ubuntu:
```
(sudo) pecl install oci8
```
Make sure your php.ini's (there should be one for your Apache and one for cli php) contain `extension=oci8.so` afterwards. Finally, you have to restart Apache and can confirm via `<?php phpinfo(); ?>` that the extension is... |
238,996 | <p>I've never had a reason to put a label element inside of a legend element (never really thought about it or seen it done). But with the design I'm implementing, it's tempting to do so.</p>
<p>Here's what I'm tempted to do:</p>
<pre><code><fieldset>
<legend><label for="formInfo">I would like infor... | [
{
"answer_id": 239011,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 0,
"selected": false,
"text": "<p>well, the label element itself seems fine - it's the description of the \"formInfo\" element, so that's no worries. Semanti... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17252/"
] | I've never had a reason to put a label element inside of a legend element (never really thought about it or seen it done). But with the design I'm implementing, it's tempting to do so.
Here's what I'm tempted to do:
```
<fieldset>
<legend><label for="formInfo">I would like information on</label></legend>
<select id="... | Where is your `</fieldset>`?
Semantically, [`legend` describes a `fieldset`](http://www.w3.org/TR/html401/interact/forms.html#h-17.10), just as `label` describes a single field.
Fieldsets are supposed to be used to group together semantically related fields (for instance, an "address" fieldset might have input fields... |
239,002 | <p>Is there a simple way to duplicate all child components under parent component, including their published properties?</p>
<p>For example:</p>
<ul>
<li>TPanel
<ul>
<li>TLabel</li>
<li>TEdit</li>
<li>TListView</li>
<li>TSpecialClassX</li>
</ul></li>
</ul>
<p>Of course the most important factor, it should duplicate... | [
{
"answer_id": 239056,
"author": "Kluge",
"author_id": 8752,
"author_profile": "https://Stackoverflow.com/users/8752",
"pm_score": 0,
"selected": false,
"text": "<p>It's actually fairly easy to duplicate existing components at runtime. The difficult part is to copy all of their publishe... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30787/"
] | Is there a simple way to duplicate all child components under parent component, including their published properties?
For example:
* TPanel
+ TLabel
+ TEdit
+ TListView
+ TSpecialClassX
Of course the most important factor, it should duplicate any new component which I drop on the TPanel without modifying the cod... | have a read of this page
[**Run-Time Type Information In Delphi - Can It Do Anything For You?**](http://www.blong.com/Conferences/BorConUK98/DelphiRTTI/CB140.htm)
Noting the section [Copying Properties From A Component To Another](http://www.blong.com/Conferences/BorConUK98/DelphiRTTI/CB140.htm#CopyingPropertiesFromA... |
239,020 | <p>I have a third-party product, a terminal emulator, which provides a DLL that can be linked to a C program to basically automate the driving of this product (send keystrokes, detect what's on the screen and so forth).</p>
<p>I want to drive it from a scripting language (I'm comfortable with Python and slightly less ... | [
{
"answer_id": 239041,
"author": "albertb",
"author_id": 26715,
"author_profile": "https://Stackoverflow.com/users/26715",
"pm_score": 5,
"selected": true,
"text": "<p>One way to call C libraries from Python is to use <a href=\"https://docs.python.org/library/ctypes.html\" rel=\"nofollow... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14860/"
] | I have a third-party product, a terminal emulator, which provides a DLL that can be linked to a C program to basically automate the driving of this product (send keystrokes, detect what's on the screen and so forth).
I want to drive it from a scripting language (I'm comfortable with Python and slightly less so with Pe... | One way to call C libraries from Python is to use [ctypes](https://docs.python.org/library/ctypes.html):
```
>>> from ctypes import *
>>> windll.user32.MessageBoxA(None, "Hello world", "ctypes", 0);
``` |
239,023 | <p>I have a dependency that I need to inject into one of my classes. This dependency will be lifestyle of <code>Transient</code>. It in-turn has a dependency of type <code>Type</code>. This type should be the type of the original class. I was just wondering if anyone has any idea how I might go about conducting this re... | [
{
"answer_id": 239033,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not entirely sure it is that you're trying to achieve, but instead you might want to rewrite your code so you're doing... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30572/"
] | I have a dependency that I need to inject into one of my classes. This dependency will be lifestyle of `Transient`. It in-turn has a dependency of type `Type`. This type should be the type of the original class. I was just wondering if anyone has any idea how I might go about conducting this registration.
See example:... | The simplest solution I can see is to change it to
```
public interface IRegister<TParent> { ... }
public class Register<TParent> : IRegister<TParent>
{
public Register() { ... }
}
public class Customer : ICustomer
{
public Customer(IRegister<Customer> register) { .... }
}
```
And register IRegister as an o... |
239,059 | <p>I am trying to mock out HttpContext so that I can unit test my controller's Request.IsAuthenicated call. I am using the <a href="http://www.hanselman.com/blog/ASPNETMVCSessionAtMix08TDDAndMvcMockHelpers.aspx" rel="noreferrer">code that I found at Scott Hanselman's</a> blog to simulate HttpContext using rhino.mocks. ... | [
{
"answer_id": 239418,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 0,
"selected": false,
"text": "<p>Now, for disclosure, I have yet to get my hands dirty with most of the stuff you are working with, however:</p>\n\n<p>If... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31699/"
] | I am trying to mock out HttpContext so that I can unit test my controller's Request.IsAuthenicated call. I am using the [code that I found at Scott Hanselman's](http://www.hanselman.com/blog/ASPNETMVCSessionAtMix08TDDAndMvcMockHelpers.aspx) blog to simulate HttpContext using rhino.mocks.
so i have this unit test piece... | This should work:
```
PostsController postsController = new PostsController(postDL);
var context = mocks.Stub<HttpContextBase>();
var request = mocks.Stub<HttpRequestBase>();
SetupResult.For(request.IsAuthenticated).Return(true);
SetupResult.For(context.Request).Return(request);
postsController.ControllerContext =... |
239,063 | <p>I came across an article about Car remote entry system at <a href="http://auto.howstuffworks.com/remote-entry2.htm" rel="nofollow noreferrer">http://auto.howstuffworks.com/remote-entry2.htm</a> In the third bullet, author says,</p>
<blockquote>
<p>Both the transmitter and the receiver use the same pseudo-random n... | [
{
"answer_id": 239066,
"author": "Erik Forbes",
"author_id": 16942,
"author_profile": "https://Stackoverflow.com/users/16942",
"pm_score": 5,
"selected": true,
"text": "<p>In PRNG functions, the output of the function is dependent on a 'seed' value, such that the same output will be prov... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15474/"
] | I came across an article about Car remote entry system at <http://auto.howstuffworks.com/remote-entry2.htm> In the third bullet, author says,
>
> Both the transmitter and the receiver use the same pseudo-random number generator. When the transmitter sends a 40-bit code, it uses the pseudo-random number generator to p... | In PRNG functions, the output of the function is dependent on a 'seed' value, such that the same output will be provided from successive calls given the same seed value. So, yes.
An example (using C#) would be something like:
```
// Provide the same seed value for both generators:
System.Random r1 = new System.Random... |
239,082 | <p>I'm working on a simple javascript login for a site, and have come up with this:</p>
<pre><code><form id="loginwindow">
<strong>Login to view!</strong>
<p><strong>User ID:</strong>
<input type="text" name="text2">
</p>
<p><strong>Password:</strong>... | [
{
"answer_id": 239085,
"author": "Ady",
"author_id": 31395,
"author_profile": "https://Stackoverflow.com/users/31395",
"pm_score": 0,
"selected": false,
"text": "<p>My Thought = Massive security hole. Anyone can view the username and password.</p>\n\n<p>More relevant to your question: - ... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27171/"
] | I'm working on a simple javascript login for a site, and have come up with this:
```
<form id="loginwindow">
<strong>Login to view!</strong>
<p><strong>User ID:</strong>
<input type="text" name="text2">
</p>
<p><strong>Password:</strong>
<input type="password" name="text1"><br>
<input type="button" value="Check In... | There are several topics being discussed at once here. Let's try to clarify.
**1. Your Immediate Concern:**
(*Why won't the input button work when ENTER is pressed?*)
Use the **submit** button type.
```
<input type="submit".../>
```
..instead of
```
<input type="button".../>
```
Your problem doesn't really h... |
239,103 | <p>I have a char in c#:</p>
<pre><code>char foo = '2';
</code></pre>
<p>Now I want to get the 2 into an int. I find that Convert.ToInt32 returns the actual decimal value of the char and not the number 2. The following will work:</p>
<pre><code>int bar = Convert.ToInt32(new string(foo, 1));
</code></pre>
<p>int.pa... | [
{
"answer_id": 239107,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 8,
"selected": false,
"text": "<p>This will convert it to an <code>int</code>:</p>\n<pre><code>char foo = '2';\nint bar = foo - '0';\n</code></pre>\n<p>T... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26854/"
] | I have a char in c#:
```
char foo = '2';
```
Now I want to get the 2 into an int. I find that Convert.ToInt32 returns the actual decimal value of the char and not the number 2. The following will work:
```
int bar = Convert.ToInt32(new string(foo, 1));
```
int.parse only works on strings as well.
Is there no na... | Interesting answers but the docs say differently:
>
> Use the `GetNumericValue` methods to
> convert a `Char` object that represents
> a number to a numeric value type. Use
> `Parse` and `TryParse` to convert a
> character in a string into a `Char`
> object. Use `ToString` to convert a `Char`
> object to a `Str... |
239,122 | <p>Just to clarify, I'm running Sybase 12.5.3, but I am lead to believe that this holds true for SQL Server 2005 too. Basically, I'm trying to write a query that looks a little like this, I've simplified it as much as possible to highlight the problem:</p>
<pre><code>DECLARE @a int, @b int, @c int
SELECT
@a = h... | [
{
"answer_id": 239407,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>I've just ran your code against 12.5.3 and it parses fine...doesn't return anything but it does run. Have you maybe simplif... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1030/"
] | Just to clarify, I'm running Sybase 12.5.3, but I am lead to believe that this holds true for SQL Server 2005 too. Basically, I'm trying to write a query that looks a little like this, I've simplified it as much as possible to highlight the problem:
```
DECLARE @a int, @b int, @c int
SELECT
@a = huzzah.a
,@... | The error does appear as described in 12.5.3 esd 4 & 7, it runs fine in 12.5.4 esd 4 & 6.
Looks like a bug that's been patched, your only options seem to be workaround or patch.
Have found what appears to be the [bug 377625](http://search.sybase.com/kbx/changerequests?bug_id=377625) |
239,136 | <p>Using PHP, what's the fastest way to convert a string like this: <code>"123"</code> to an integer?</p>
<p>Why is that particular method the fastest? What happens if it gets unexpected input, such as <code>"hello"</code> or an array?</p>
| [
{
"answer_id": 239173,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 10,
"selected": true,
"text": "<p>I've just set up a quick benchmarking exercise:</p>\n\n<pre><code>Function time to run 1 million iterations\n--... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | Using PHP, what's the fastest way to convert a string like this: `"123"` to an integer?
Why is that particular method the fastest? What happens if it gets unexpected input, such as `"hello"` or an array? | I've just set up a quick benchmarking exercise:
```
Function time to run 1 million iterations
--------------------------------------------
(int) "123": 0.55029
intval("123"): 1.0115 (183%)
(int) "0": 0.42461
intval("0"): 0.95683 (225%)
(int) in... |
239,147 | <p>I am a complete JSP beginner. I am trying to use a <code>java.util.List</code> in a JSP page. What do I need to do to use classes other than ones in <code>java.lang</code>?</p>
| [
{
"answer_id": 239199,
"author": "Axeman",
"author_id": 11289,
"author_profile": "https://Stackoverflow.com/users/11289",
"pm_score": 4,
"selected": false,
"text": "<p>In the page tag:</p>\n\n<pre><code><%@ page import=\"java.util.List\" %>\n</code></pre>\n"
},
{
"answer_id... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2598/"
] | I am a complete JSP beginner. I am trying to use a `java.util.List` in a JSP page. What do I need to do to use classes other than ones in `java.lang`? | Use the following import statement to import `java.util.List`:
```
<%@ page import="java.util.List" %>
```
BTW, to import more than one class, use the following format:
```
<%@ page import="package1.myClass1,package2.myClass2,....,packageN.myClassN" %>
``` |
239,171 | <p>I have sets of 5, 6 and 7 digit numbers. I need them to be displayed in the 000/000/000 format. So for example: </p>
<p>12345 would be displayed as 000/012/345 </p>
<p>and </p>
<p>9876543 would be displayed as 009/876/543</p>
<p>I know how to do this in a messy way, involving a series of if/else statements, and ... | [
{
"answer_id": 239176,
"author": "Adam Pierce",
"author_id": 5324,
"author_profile": "https://Stackoverflow.com/users/5324",
"pm_score": 5,
"selected": true,
"text": "<p>sprintf and modulo is one option</p>\n\n<pre><code>function formatMyNumber($num)\n{\n return sprintf('%03d/%03d/%03... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have sets of 5, 6 and 7 digit numbers. I need them to be displayed in the 000/000/000 format. So for example:
12345 would be displayed as 000/012/345
and
9876543 would be displayed as 009/876/543
I know how to do this in a messy way, involving a series of if/else statements, and strlen functions, but there has... | sprintf and modulo is one option
```
function formatMyNumber($num)
{
return sprintf('%03d/%03d/%03d',
$num / 1000000,
($num / 1000) % 1000,
$num % 1000);
}
``` |
239,194 | <p>Can someone explain how XSS works in plain english? Maybe with an example. Googling didn't help much.</p>
| [
{
"answer_id": 239212,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 5,
"selected": false,
"text": "<p>Cross Site Scripting basically is a security vulnerability of dynamic web pages where an attacker can create... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Can someone explain how XSS works in plain english? Maybe with an example. Googling didn't help much. | Cross Site Scripting basically is a security vulnerability of dynamic web pages where an attacker can create a malicious link to inject unwanted executable JavaScript into a Web site. The most usual case of this vulnerabilities occurs when GET variables are printed or echoed without filtering or checking their content.... |
239,232 | <p>In our application we enable users to print pages. We do this by supplying a button which when click calls the window.print() function.<br>
Some of the pages would look better if they were printed in landscape mode rather than portrait. Is there a way to control the page layout from JavaScript? </p>
<p>Update: Fol... | [
{
"answer_id": 239234,
"author": "da5id",
"author_id": 14979,
"author_profile": "https://Stackoverflow.com/users/14979",
"pm_score": 2,
"selected": false,
"text": "<p>Do it with CSS by including a print stylesheet thusly:</p>\n\n<pre><code><style type=\"text/css\" media=\"print\">@... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/278/"
] | In our application we enable users to print pages. We do this by supplying a button which when click calls the window.print() function.
Some of the pages would look better if they were printed in landscape mode rather than portrait. Is there a way to control the page layout from JavaScript?
Update: Following the a... | You should use a print stylesheet.
```
<link rel="stylesheet" href="print.css" type="text/css" media="print" />
```
More info...
[How to print only parts of a page?](https://stackoverflow.com/questions/224078/how-to-print-only-parts-of-a-page)
Edit: to coerce landscape orientation, apparently the standard is `size... |
239,258 | <p>Imagine you got an entity in the Google App Engine datastore, storing links for anonymous users.
You would like to perform the following SQL query, which is not supported:</p>
<pre><code>SELECT DISTINCT user_hash FROM links
</code></pre>
<p>Instead you could use:</p>
<pre><code>user = db.GqlQuery("SELECT user_ha... | [
{
"answer_id": 239305,
"author": "James Bennett",
"author_id": 28070,
"author_profile": "https://Stackoverflow.com/users/28070",
"pm_score": 1,
"selected": false,
"text": "<p>One option would be to put the results into a set object:</p>\n\n<p><a href=\"http://www.python.org/doc/2.6/libra... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26763/"
] | Imagine you got an entity in the Google App Engine datastore, storing links for anonymous users.
You would like to perform the following SQL query, which is not supported:
```
SELECT DISTINCT user_hash FROM links
```
Instead you could use:
```
user = db.GqlQuery("SELECT user_hash FROM links")
```
How to use Pyth... | A set is good way to deal with that:
```
>>> a = ['google.com', 'livejournal.com', 'livejournal.com', 'google.com', 'stackoverflow.com']
>>> b = set(a)
>>> b
set(['livejournal.com', 'google.com', 'stackoverflow.com'])
>>>
```
One suggestion w/r/t the first answer, is that sets and dicts are better at retrieving uni... |
239,264 | <p>Does anyone have a copy of MSIINV.EXE (The MSI Inventory tool)? The site where it used to be available is down(<a href="http://www.huydao.net/" rel="nofollow noreferrer">http://www.huydao.net/</a>). I'm trying to uninstall some components in order to force the Visual Studio Setup to reinstall them. I apologize as th... | [
{
"answer_id": 239456,
"author": "Roger Lipscombe",
"author_id": 8446,
"author_profile": "https://Stackoverflow.com/users/8446",
"pm_score": 1,
"selected": false,
"text": "<p>What does that tool do? Does it list the component GUIDs from an MSI? If so, I've found the DARK tool from <a hre... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3927/"
] | Does anyone have a copy of MSIINV.EXE (The MSI Inventory tool)? The site where it used to be available is down(<http://www.huydao.net/>). I'm trying to uninstall some components in order to force the Visual Studio Setup to reinstall them. I apologize as this is not strictly a programming question but I figured anyone t... | I've created a GitHub repository with both the original source and a copy of the .exe for MsiInv.exe. I am the original author.
<https://github.com/ZisBoom/MsiInv.exe>
My most common usage is `msiinv.exe -p` to list all installed products,
or `msiinv.exe -p | findstr /i <pattern>` to find a specific product.
`msiinv... |