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 |
|---|---|---|---|---|---|---|
351,484 | <p>I have an application the will load usercontrols dynamically depending on the user. You will see in the example below that I am casting each user control via switch/case statements. Is there a better way to do this? Reflection? (I must be able to add an event handler Bind in each control.)</p>
<pre><code>override... | [
{
"answer_id": 351497,
"author": "Brody",
"author_id": 17131,
"author_profile": "https://Stackoverflow.com/users/17131",
"pm_score": 0,
"selected": false,
"text": "<p>You could try TypeOf (in c#) Or would uc.GetType() work.</p>\n"
},
{
"answer_id": 351505,
"author": "Jeroen L... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4888/"
] | I have an application the will load usercontrols dynamically depending on the user. You will see in the example below that I am casting each user control via switch/case statements. Is there a better way to do this? Reflection? (I must be able to add an event handler Bind in each control.)
```
override protected void ... | I do not see anything control-class-specific in your code. You perform exactly the same operations, and looks like all user controls inherit from Control.
If the only specific thing is the event binding (i.e. Control class does not have Bind event), then better think about refactoring your code, so you make all your u... |
351,487 | <p>I am a Delphi novice, but I'm trying to understand the relationship between TApplication and TfrmMain windows using Spy++. It seems that the TfrmMain window is the real window that has proper screen coordinates, but the TApplication window is the one that appears in the Windows taskbar. Also, they don't seem to be r... | [
{
"answer_id": 351504,
"author": "JamesSugrue",
"author_id": 1075,
"author_profile": "https://Stackoverflow.com/users/1075",
"pm_score": 4,
"selected": true,
"text": "<p>TApplication is the class that encapsulates your application and handles things like the Windows Messaging. TfrmMain w... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343/"
] | I am a Delphi novice, but I'm trying to understand the relationship between TApplication and TfrmMain windows using Spy++. It seems that the TfrmMain window is the real window that has proper screen coordinates, but the TApplication window is the one that appears in the Windows taskbar. Also, they don't seem to be rela... | TApplication is the class that encapsulates your application and handles things like the Windows Messaging. TfrmMain will be a subclass of TForm which will be your Applications "Main Form".
So basically, TApplication is the controller so to speak and it owns and creates TfrmMain, and forwards messages to it, or any of... |
351,489 | <p>How can I get a PL/SQL block to output the results of a <code>SELECT</code> statement the same way as if I had done a plain <code>SELECT</code>?</p>
<p>For example how to do a <code>SELECT</code> like:</p>
<pre><code>SELECT foo, bar FROM foobar;
</code></pre>
<p>Hint :</p>
<pre><code>BEGIN
SELECT foo, bar FROM f... | [
{
"answer_id": 351752,
"author": "Sergey Stadnik",
"author_id": 10557,
"author_profile": "https://Stackoverflow.com/users/10557",
"pm_score": 6,
"selected": false,
"text": "<p>It depends on what you need the result for.</p>\n\n<p>If you are sure that there's going to be only 1 row, use i... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26659/"
] | How can I get a PL/SQL block to output the results of a `SELECT` statement the same way as if I had done a plain `SELECT`?
For example how to do a `SELECT` like:
```
SELECT foo, bar FROM foobar;
```
Hint :
```
BEGIN
SELECT foo, bar FROM foobar;
END;
```
doesn't work. | It depends on what you need the result for.
If you are sure that there's going to be only 1 row, use implicit cursor:
```
DECLARE
v_foo foobar.foo%TYPE;
v_bar foobar.bar%TYPE;
BEGIN
SELECT foo,bar FROM foobar INTO v_foo, v_bar;
-- Print the foo and bar values
dbms_output.put_line('foo=' || v_foo || ', ... |
351,495 | <p>All the documentation I've found so far is to update keys that are already created:</p>
<pre><code> arr['key'] = val;
</code></pre>
<p>I have a string like this: <code>" name = oscar " </code></p>
<p>And I want to end up with something like this:</p>
<pre><code>{ name: 'whatever' }
</code></pre>
<p>That i... | [
{
"answer_id": 351507,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 8,
"selected": true,
"text": "<p>Use the first example. If the key doesn't exist it will be added.</p>\n\n<pre><code>var a = new Array();\na['name'] ... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20654/"
] | All the documentation I've found so far is to update keys that are already created:
```
arr['key'] = val;
```
I have a string like this: `" name = oscar "`
And I want to end up with something like this:
```
{ name: 'whatever' }
```
That is, split the string and get the first element, and then put that in a dic... | Use the first example. If the key doesn't exist it will be added.
```
var a = new Array();
a['name'] = 'oscar';
alert(a['name']);
```
Will pop up a message box containing 'oscar'.
Try:
```
var text = 'name = oscar'
var dict = new Array()
var keyValuePair = text.replace(/ /g,'').split('=');
dict[ keyValuePair[0] ] ... |
351,496 | <p>Does anyone know of a <code>SQL</code> library in <code>ASP.NET</code> that can be used to manage tables?</p>
<p>E.g.</p>
<pre><code>SQLTable table = new SQLTable();
table.AddColumn(“First name”, varchar, 100);
table.AddColumn(“Last name”, varchar, 100);
if(table.ColumnExists(“Company”))
table.RemoveColumn(“Comp... | [
{
"answer_id": 351524,
"author": "Dave Neeley",
"author_id": 9660,
"author_profile": "https://Stackoverflow.com/users/9660",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://subsonicproject.com/\" rel=\"nofollow noreferrer\">Subsonic</a> has a <a href=\"http://subsonicproje... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24696/"
] | Does anyone know of a `SQL` library in `ASP.NET` that can be used to manage tables?
E.g.
```
SQLTable table = new SQLTable();
table.AddColumn(“First name”, varchar, 100);
table.AddColumn(“Last name”, varchar, 100);
if(table.ColumnExists(“Company”))
table.RemoveColumn(“Company”);
```
The operations I am looking fo... | Use Microsoft.SqlServer.Management.Smo
Other option would be to install the Microsoft Sql Server Web Data Administrator
[Sql Server Web Data Administrator](http://www.microsoft.com/downloads/details.aspx?FamilyID=C039A798-C57A-419E-ACBC-2A332CB7F959&displaylang=en)
Some references for Smo:
[Create Table in SQL Serv... |
351,499 | <p>I need to make a pop-up window for users to log-in to my website from other websites.</p>
<p>I need to use a pop-up window to show the user the address bar so that they know it is a secure login, and not a spoof. For example, if I used a floating iframe, websites could spoof my login window and record the user's l... | [
{
"answer_id": 351506,
"author": "Jon DellOro",
"author_id": 36456,
"author_profile": "https://Stackoverflow.com/users/36456",
"pm_score": -1,
"selected": false,
"text": "<p>If your users are using IE, and your site is in the trusted sites, the popup blocker will be deactivated.</p>\n\n<... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43005/"
] | I need to make a pop-up window for users to log-in to my website from other websites.
I need to use a pop-up window to show the user the address bar so that they know it is a secure login, and not a spoof. For example, if I used a floating iframe, websites could spoof my login window and record the user's login inform... | Take a look at [this site.](http://www.quirksmode.org/js/popup.html)
Some code copied from it:
```
<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
newwindow=window.open(url,'name','height=200,width=150');
if(!newindow){
alert('We have detected that you are using po... |
351,519 | <pre><code>typedef union
{
uint ui[4];
} md5hash;
void main(void)
{
int opt;
while ((opt = getopt(argc, argv, "c:t:s:h:")) != -1) {
switch (opt) {
case 'h':
hash = optarg;
break;
default: /* '?' */
exit(EXIT_FAILURE);
}
}
md5hash... | [
{
"answer_id": 351566,
"author": "dreamlax",
"author_id": 10320,
"author_profile": "https://Stackoverflow.com/users/10320",
"pm_score": 3,
"selected": false,
"text": "<ol start=\"2\">\n<li>You seem to have two variables called hash, except one is implicit in your code.</li>\n<li>The <cod... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
typedef union
{
uint ui[4];
} md5hash;
void main(void)
{
int opt;
while ((opt = getopt(argc, argv, "c:t:s:h:")) != -1) {
switch (opt) {
case 'h':
hash = optarg;
break;
default: /* '?' */
exit(EXIT_FAILURE);
}
}
md5hash hash;
... | 2. You seem to have two variables called hash, except one is implicit in your code.
3. The `sscanf` statement attempts to read `hash` back into itself, but obviously it will not find any hexadecimal digits.
4. `%x` may load a different sized integer in hexadecimal on different platforms because you have not specified a... |
351,520 | <p>Greetings!</p>
<p>I have an XML value that I'd like to use as a boolean value to toggle the visibility of a Panel. I have something like this:</p>
<pre><code><asp:FormView id="MyFormView" runat="server" DataSourceID="MyXmlDataSource">
<ItemTemplate>
<!-- some stuff -->
<as... | [
{
"answer_id": 351529,
"author": "Andrew Rollings",
"author_id": 40410,
"author_profile": "https://Stackoverflow.com/users/40410",
"pm_score": 1,
"selected": false,
"text": "<p>Try <code><%#(Convert.ToBoolean(XPath(\"Menu/Show\"))) %></code></p>\n"
},
{
"answer_id": 351530,... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27870/"
] | Greetings!
I have an XML value that I'd like to use as a boolean value to toggle the visibility of a Panel. I have something like this:
```
<asp:FormView id="MyFormView" runat="server" DataSourceID="MyXmlDataSource">
<ItemTemplate>
<!-- some stuff -->
<asp:Panel id="MyPanel" runat="server" Visible... | if the xpath returns a string, don't you want to use [Boolean.Parse](http://msdn.microsoft.com/en-us/library/system.boolean.parse.aspx)(XPath("Menu/Show")) |
351,522 | <p>basically, I've got my Huffman table as </p>
<pre><code>std::map<std::string, char> ciMap;
</code></pre>
<p>Where string is the bit pattern and char is the value represented by said pattern.
The problem is how do I store that as a header of my compressed file so I can build again the same map when I want to ... | [
{
"answer_id": 351535,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 2,
"selected": false,
"text": "<p>Great question. Problem here is that the default containers don't support serialization - you have to write it yourse... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15345/"
] | basically, I've got my Huffman table as
```
std::map<std::string, char> ciMap;
```
Where string is the bit pattern and char is the value represented by said pattern.
The problem is how do I store that as a header of my compressed file so I can build again the same map when I want to decode it?
Trying to store it a... | You can do it yourself, or you can do it with boost: <http://www.boost.org/doc/libs/1_37_0/libs/serialization/doc/index.html>. What you currently try is just view the map as a plain old datatype, which essentially means it's a C datatype. But it isn't, so it fails to save/load. boost serialization does it correctly. Ha... |
351,546 | <p>I'm trying to show in the screen a table...</p>
<p>Basically I create a custom UITableViewController with the methods needed for the UITableView delegate and data source which is self since UITableViewController does it for you.</p>
<p>When I put it in the <code>-initWithRootView:</code> controller, and add the na... | [
{
"answer_id": 351535,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 2,
"selected": false,
"text": "<p>Great question. Problem here is that the default containers don't support serialization - you have to write it yourse... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to show in the screen a table...
Basically I create a custom UITableViewController with the methods needed for the UITableView delegate and data source which is self since UITableViewController does it for you.
When I put it in the `-initWithRootView:` controller, and add the nav's bar view to the window i... | You can do it yourself, or you can do it with boost: <http://www.boost.org/doc/libs/1_37_0/libs/serialization/doc/index.html>. What you currently try is just view the map as a plain old datatype, which essentially means it's a C datatype. But it isn't, so it fails to save/load. boost serialization does it correctly. Ha... |
351,547 | <p>I've used the Views Theming Wizard to output a template and it gave me the following chunk of code to go in template.php.</p>
<p>I'd prefer to just maintain the one template, so all my functions will be calling the same one, and rather than writing numerous versions of the same function, I'm wondering if there's a ... | [
{
"answer_id": 353285,
"author": "pdemarest",
"author_id": 40332,
"author_profile": "https://Stackoverflow.com/users/40332",
"pm_score": 3,
"selected": true,
"text": "<p>You could just have the templates you need call one version of the actual function.</p>\n\n<p>Something like:</p>\n\n<... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16124/"
] | I've used the Views Theming Wizard to output a template and it gave me the following chunk of code to go in template.php.
I'd prefer to just maintain the one template, so all my functions will be calling the same one, and rather than writing numerous versions of the same function, I'm wondering if there's a way to str... | You could just have the templates you need call one version of the actual function.
Something like:
```
function phptemplate_views_view_list_recent_articles($view, $nodes, $type){
actual_template_function($view, $nodes, $type);
}
function phptemplate_views_view_list_popular_articles($view, $nodes, $type){
... |
351,557 | <p>I'm trying to insert a column into an existing DataSet using C#.</p>
<p>As an example I have a DataSet defined as follows:</p>
<pre><code>DataSet ds = new DataSet();
ds.Tables.Add(new DataTable());
ds.Tables[0].Columns.Add("column_1", typeof(string));
ds.Tables[0].Columns.Add("column_2", typeof(int));
ds.Tables[0]... | [
{
"answer_id": 351564,
"author": "Paul Morel",
"author_id": 1311247,
"author_profile": "https://Stackoverflow.com/users/1311247",
"pm_score": -1,
"selected": false,
"text": "<p>Copy the first two columns into a new dataset, then add the third column, and add the remaining columns.</p>\n\... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39532/"
] | I'm trying to insert a column into an existing DataSet using C#.
As an example I have a DataSet defined as follows:
```
DataSet ds = new DataSet();
ds.Tables.Add(new DataTable());
ds.Tables[0].Columns.Add("column_1", typeof(string));
ds.Tables[0].Columns.Add("column_2", typeof(int));
ds.Tables[0].Columns.Add("column_... | You can use the [DataColumn.SetOrdinal()](http://msdn.microsoft.com/en-us/library/system.data.datacolumn.setordinal.aspx) method for this purpose.
```
DataSet ds = new DataSet();
ds.Tables.Add(new DataTable());
ds.Tables[0].Columns.Add("column_1", typeof(string));
ds.Tables[0].Columns.Add("column_2", typeof(int));
ds.... |
351,565 | <h2><strong>Accuracy Vs. Precision</strong></h2>
<p>What I would like to know is whether I should use <strong>System.currentTimeMillis()</strong> or <strong>System.nanoTime()</strong> when updating my object's positions in my game? Their change in movement is directly proportional to the elapsed time since the last c... | [
{
"answer_id": 351571,
"author": "dancavallaro",
"author_id": 42891,
"author_profile": "https://Stackoverflow.com/users/42891",
"pm_score": 9,
"selected": true,
"text": "<p>If you're just looking for extremely precise measurements of <strong>elapsed time</strong>, use <code>System.nanoTi... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2635/"
] | **Accuracy Vs. Precision**
--------------------------
What I would like to know is whether I should use **System.currentTimeMillis()** or **System.nanoTime()** when updating my object's positions in my game? Their change in movement is directly proportional to the elapsed time since the last call and I want to be as p... | If you're just looking for extremely precise measurements of **elapsed time**, use `System.nanoTime()`. `System.currentTimeMillis()` will give you the most accurate possible elapsed time in milliseconds since the epoch, but `System.nanoTime()` gives you a nanosecond-precise time, relative to some arbitrary point.
From... |
351,578 | <p>I need to make OK and Cancel buttons in my HTML, and I'd like them to be a fixed width so the two buttons are the same size. For example, like this:</p>
<pre><code><style>
button.ok_cancel {
width: 50px;
background-color: #4274af;
font-size: 9px;
line-height: 12px;
color: #fff;
cursor... | [
{
"answer_id": 351584,
"author": "twodayslate",
"author_id": 27570,
"author_profile": "https://Stackoverflow.com/users/27570",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure but:</p>\n\n<blockquote>\n <p>button { min-width: 50px; width: auto;\n }</p>\n</blockquote>\n\n<p>LMK if... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14343/"
] | I need to make OK and Cancel buttons in my HTML, and I'd like them to be a fixed width so the two buttons are the same size. For example, like this:
```
<style>
button.ok_cancel {
width: 50px;
background-color: #4274af;
font-size: 9px;
line-height: 12px;
color: #fff;
cursor: pointer;
text-t... | I worked from twodayslate's answer and ended up with this:
```
/* Browser hack! This is for everyone: */
button {
display: inline;
cursor: pointer;
padding: 6px 6px;
width: 50px;
overflow: visible;
}
/* and this is for non-IE browsers: */
html>body button {
min-width: 50px;
width: auto;
}
... |
351,602 | <p>Just curious, did I overlook somewhere in the API to display a chat bubble type image as found in the iPhone's SMS application? There's a few applications out there that use bubbles that look verbatim to the iPhone's and I'm wondering if they're using a native widget or their own image.</p>
<p>This is also seen in ... | [
{
"answer_id": 351642,
"author": "kdbdallas",
"author_id": 26728,
"author_profile": "https://Stackoverflow.com/users/26728",
"pm_score": 3,
"selected": false,
"text": "<p>You need to use your own images, and Apple recommends using 9 UIImageViews (3 rows of 3) (Top Left Corner, Top Middle... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | Just curious, did I overlook somewhere in the API to display a chat bubble type image as found in the iPhone's SMS application? There's a few applications out there that use bubbles that look verbatim to the iPhone's and I'm wondering if they're using a native widget or their own image.
This is also seen in the Tweeti... | I suggest using the stretch method they recommend for button images.
```
[UIImage stretchableImageWithLeftCapWidth:15 topCapHeight:13]
```
You can see a working example by downloading [Twitterfon](http://twitterfon.net/)'s source(it's on the FAQ page). You can see how they code a reusable control for it as well as e... |
351,633 | <p>I currently have issues in Webkit(Safari and Chrome) were I try to load dynamically (innerHTML) some html into a div, the html contains css rules (...), after the html gets rendered the style definitions are not loaded (so visually I can tell the styles are not there and also if I search with javascript for them no ... | [
{
"answer_id": 352060,
"author": "I.devries",
"author_id": 6388,
"author_profile": "https://Stackoverflow.com/users/6388",
"pm_score": 4,
"selected": true,
"text": "<p>I think it's a better practice to append a \"link\" tag to the head of your document. If that isn't possible, try to app... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I currently have issues in Webkit(Safari and Chrome) were I try to load dynamically (innerHTML) some html into a div, the html contains css rules (...), after the html gets rendered the style definitions are not loaded (so visually I can tell the styles are not there and also if I search with javascript for them no sty... | I think it's a better practice to append a "link" tag to the head of your document. If that isn't possible, try to append a "style" tag to the head. Style tags shouldn't be in the body (Doesn't even validate).
Append link tag:
```
var link = document.createElement('link');
link.setAttribute('rel', 'stylesheet');
li... |
351,644 | <p>I'm using ADO.NET dataservices in a Silverlight application and since the silverlight libraries don't support the ToList() call on the IQueryable I thought it might be possible to create an extension method around this called SilverlightToList(). So in this method I'm calling the BeginExecute method on my context as... | [
{
"answer_id": 351649,
"author": "dkretz",
"author_id": 31641,
"author_profile": "https://Stackoverflow.com/users/31641",
"pm_score": 1,
"selected": false,
"text": "<p>Silverlight probably isn't going to like synchronous anything, because it's intended to run in the browser, and it only ... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36086/"
] | I'm using ADO.NET dataservices in a Silverlight application and since the silverlight libraries don't support the ToList() call on the IQueryable I thought it might be possible to create an extension method around this called SilverlightToList(). So in this method I'm calling the BeginExecute method on my context as sh... | I've since found [this post](http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3981405&SiteID=1) on the MSDN forum which says that any managed->UnManaged->Managed marshalling happens on the UI thread which explains why the WaitOne method call is hanging... |
351,657 | <p>By default sqlplus truncates column names to the length of the underlying data type. Many of the column names in our database are prefixed by the table name, and therefore look identical when truncated.</p>
<p>I need to specify select * queries to remote DBAs in a locked down production environment, and drag back s... | [
{
"answer_id": 353335,
"author": "m0j0",
"author_id": 31319,
"author_profile": "https://Stackoverflow.com/users/31319",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think sqlplus offers the functionality you are requesting. You might be able to automate the formatting, using so... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14749/"
] | By default sqlplus truncates column names to the length of the underlying data type. Many of the column names in our database are prefixed by the table name, and therefore look identical when truncated.
I need to specify select \* queries to remote DBAs in a locked down production environment, and drag back spooled re... | One thing you can try is to dynamically generate "column x format a20" commands. Something like the following:
```
set termout off
set feedback off
spool t1.sql
select 'column ' || column_name || ' format a' || data_length
from all_tab_cols
where table_name='YOUR_TABLE'
/
spool off
@t1.sql
set pagesize 24
set headin... |
351,665 | <p>Having installed Hibernate Tools in Eclipse, how can I view the would-be generated SQL query of from the JPA query language? (I'm using Hibernate as my JPA implementation)</p>
<p>My Java DAO class looks something like:</p>
<pre><code>public List<Person> findById(int id)
{
return entityManager.find(Person... | [
{
"answer_id": 352007,
"author": "Gennady Shumakher",
"author_id": 42512,
"author_profile": "https://Stackoverflow.com/users/42512",
"pm_score": 2,
"selected": false,
"text": "<p>In order to see the SQL query you can just configure hibernate.show_sql=true in your hibernate.cfg.xml file. ... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24396/"
] | Having installed Hibernate Tools in Eclipse, how can I view the would-be generated SQL query of from the JPA query language? (I'm using Hibernate as my JPA implementation)
My Java DAO class looks something like:
```
public List<Person> findById(int id)
{
return entityManager.find(Person.class, id);
}
public List<... | In order to see the SQL query you can just configure hibernate.show\_sql=true in your hibernate.cfg.xml file. Then you should see the queries in the console window during application execution.
That's the feature of the hibernate runtime, when Tools provide you with HQL editor, so you can test the queries before you p... |
351,732 | <p>How do you usually convert line breaks in a form textbox or input=text element to html line breaks?</p>
<p>Thanks</p>
<p>Edit: Is it always \r\n with all browsers?</p>
| [
{
"answer_id": 351735,
"author": "Shawn",
"author_id": 26,
"author_profile": "https://Stackoverflow.com/users/26",
"pm_score": 2,
"selected": false,
"text": "<pre><code>Replace(vbcrlf, \"<br />\")\n</code></pre>\n"
},
{
"answer_id": 351747,
"author": "ine",
"author_... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/676066/"
] | How do you usually convert line breaks in a form textbox or input=text element to html line breaks?
Thanks
Edit: Is it always \r\n with all browsers? | Or in C#:
```
myString.Replace("\r\n", "<br />");
```
If you're worried about it being different on different platforms, you could also do:
```
myString.Replace("\r\n", "<br />");
myString.Replace("\n", "<br />");
myString.Replace("\r", "<br />");
``` |
351,754 | <p>I have several blocks of the following code that each use there own matrix. Is there a way to run each block in it's own thread rather then run all of them sequentially?</p>
<pre>
for i=1:length(DJI)
DJI2(:,1) = reshape(datenum(strvcat(DJI(:,2)(:)), length(DJI(:,2)),'yyyy-mm-dd'));
DJI2(:,2:6) = reshape(str2num(str... | [
{
"answer_id": 351960,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 0,
"selected": false,
"text": "<p>We do not have <em>exactly</em> a common eclipse configuration but rather a common eclipse <strong>distribution</strong>.</p... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14744/"
] | I have several blocks of the following code that each use there own matrix. Is there a way to run each block in it's own thread rather then run all of them sequentially?
```
for i=1:length(DJI)
DJI2(:,1) = reshape(datenum(strvcat(DJI(:,2)(:)), length(DJI(:,2)),'yyyy-mm-dd'));
DJI2(:,2:6) = reshape(str2num(strvcat(DJI... | If you want to go with the preconfigured distribution, but still want to let your developers choose, which plugins from a restricted set of plugins to install additionally, then its worth to create a company internal update site, which **mirrors selected features** and plugins, so your developers can install them (and ... |
351,760 | <p>I would like to create a simple file format/DSL which would allow my users to input data. My system is in python and using python's parser is appealing.
Syntax like this for defining a data element seems quite convenient.</p>
<pre><code>Allocation(Param1 = Val1, Param2 = Val2 )
</code></pre>
<p>However, it does ... | [
{
"answer_id": 351776,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 1,
"selected": false,
"text": "<p>You can do this:</p>\n\n<pre><code>def Allocation(**kwargs):\n print kwargs\n\nmyargs = {\"Param 1\":Val1, \"P... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52490/"
] | I would like to create a simple file format/DSL which would allow my users to input data. My system is in python and using python's parser is appealing.
Syntax like this for defining a data element seems quite convenient.
```
Allocation(Param1 = Val1, Param2 = Val2 )
```
However, it does not support param names wit... | Here's my preference.
```
AllocationSet(
Alloc( name="some name", value=1.23 ),
Alloc( name="another name", value=2.34 ),
Alloc( name="yet another name", value=4.56 ),
)
```
These are relatively easy class declarations to create. The resulting structure is pleasant to process, too. |
351,769 | <p>I'm trying to connect to a remote database (hosted on Netfirms <a href="http://www.netfirms.ca" rel="nofollow noreferrer">www.netfirms.ca</a> if anyone is curious) using hibernate. My mapping file is as follows:</p>
<pre><code><hibernate-configuration>
<session-factory>
<property name="hi... | [
{
"answer_id": 351816,
"author": "Strelok",
"author_id": 2788,
"author_profile": "https://Stackoverflow.com/users/2788",
"pm_score": 1,
"selected": false,
"text": "<p>I guess the first step will be to check (since you didn't say that you already tried), if you can connect to the database... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23249/"
] | I'm trying to connect to a remote database (hosted on Netfirms [www.netfirms.ca](http://www.netfirms.ca) if anyone is curious) using hibernate. My mapping file is as follows:
```
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
... | It turns out that there were several issues with the connection:
1. Although the site said to use mysql.netfirms.ca on the Control Panel, their generic instructions were correct and I was supposed to use mysql.netfirms.com as someone else mentioned earlier.
2. Netfirms was having some issues with their site, and appar... |
351,784 | <p>My requirement is to replace a set of words in a given text file with a second set of words, which might be given from the command line or another file. Wanting to use Perl to do this, as the rest of my code is also in Perl.</p>
<p>So, if I have the following:</p>
<pre><code>server name="${server1}" host="abc.com"... | [
{
"answer_id": 351831,
"author": "George Stocker",
"author_id": 16587,
"author_profile": "https://Stackoverflow.com/users/16587",
"pm_score": 0,
"selected": false,
"text": "<p>Change your Regex to the following:</p>\n\n<pre><code>perl -pie 's/\\{server/myword/g' loginOut.txt > loginOu... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35416/"
] | My requirement is to replace a set of words in a given text file with a second set of words, which might be given from the command line or another file. Wanting to use Perl to do this, as the rest of my code is also in Perl.
So, if I have the following:
```
server name="${server1}" host="abc.com"
server name="${serve... | You may want to try out [Template Toolkit](http://template-toolkit.org/).
*Here's an excerpt from the Template Toolkit [Intro, Manual page](http://template-toolkit.org/docs/manual/Intro.html)*:
The Template Toolkit is a collection of Perl modules which implement a fast, flexible, powerful and extensible template proc... |
351,793 | <p>So here's what I'm looking to achieve. I would like to give my users a single google-like textbox where they can type their queries. And I would like them to be able to express semi-natural language such as</p>
<pre><code>"view all between 1/1/2008 and 1/2/2008"
</code></pre>
<p>it's ok if the syntax has to be f... | [
{
"answer_id": 351839,
"author": "BFree",
"author_id": 15861,
"author_profile": "https://Stackoverflow.com/users/15861",
"pm_score": -1,
"selected": false,
"text": "<p>Trying to parse that stuff would be a disaster, and ultimatley very limiting to the user, thus frustrating them more the... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5416/"
] | So here's what I'm looking to achieve. I would like to give my users a single google-like textbox where they can type their queries. And I would like them to be able to express semi-natural language such as
```
"view all between 1/1/2008 and 1/2/2008"
```
it's ok if the syntax has to be fairly structured and limited... | You are describing a programming language. Granted it's a small language (often called a little language, or Domain Specific Language (DSL)). If you've never heard the term recursive descent parser, you are probably better off following Paul's advice and using drop down boxes of some description.
However, again, I wou... |
351,797 | <p>I know this maybe a very basic question but I'm having a bit of a mind blank at the moment. Should I be unit testing this class.</p>
<pre><code>public class MapinfoWindowHandle : IWin32Window
{
IntPtr handle;
public MapinfoWindowHandle(IntPtr mapinfoHandle)
{
this.handle = ... | [
{
"answer_id": 351805,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": "<p>The only thing that I can see is making sure you get out the handle that you put in via your constructor. I know tha... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6335/"
] | I know this maybe a very basic question but I'm having a bit of a mind blank at the moment. Should I be unit testing this class.
```
public class MapinfoWindowHandle : IWin32Window
{
IntPtr handle;
public MapinfoWindowHandle(IntPtr mapinfoHandle)
{
this.handle = mapinfoHandle; ... | The only thing that I can see is making sure you get out the handle that you put in via your constructor. I know that it's obvious that you implemented it this way, but a test would assure you that it stays this way. I would test this only because you are injecting it via the constructor. If it was just { get; set; } I... |
351,800 | <p>Is it possible to create an inline delegate in vb.net like you can in c#?</p>
<p>For example, I would like to be able to do something inline like this:</p>
<pre><code>myObjects.RemoveAll(delegate (MyObject m) { return m.X >= 10; });
</code></pre>
<p>only in VB and without having to do something like this</p>
... | [
{
"answer_id": 351820,
"author": "Shawn",
"author_id": 26,
"author_profile": "https://Stackoverflow.com/users/26",
"pm_score": 3,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code>myObjects.RemoveAll(Function(m) m.X >= 10)\n</code></pre>\n\n<p>This works in 3.5, not sure about the... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1632/"
] | Is it possible to create an inline delegate in vb.net like you can in c#?
For example, I would like to be able to do something inline like this:
```
myObjects.RemoveAll(delegate (MyObject m) { return m.X >= 10; });
```
only in VB and without having to do something like this
```
myObjects.RemoveAll(AddressOf Greate... | ```
myObjects.RemoveAll(Function(m As MyObject) m.X >= 10)
```
See [Lambda Expressions on MSDN](http://msdn.microsoft.com/en-us/library/bb531253.aspx) |
351,823 | <p>The following is a simplified version of what I'm trying to do, because I'm sure you don't want to wade through an entire set of structs and function prototypes for a particle system.</p>
<pre><code>float const materials[24][4][4] = {{{...}}};
typedef struct EmitterStruct { float *material[4][4]; } Emitter;
typede... | [
{
"answer_id": 351843,
"author": "AlfaZulu",
"author_id": 44060,
"author_profile": "https://Stackoverflow.com/users/44060",
"pm_score": 1,
"selected": false,
"text": "<p>In regard to the first snippet, you get that error because arrays in C are not assignable. You have to perform a <code... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The following is a simplified version of what I'm trying to do, because I'm sure you don't want to wade through an entire set of structs and function prototypes for a particle system.
```
float const materials[24][4][4] = {{{...}}};
typedef struct EmitterStruct { float *material[4][4]; } Emitter;
typedef struct Parti... | I'm answering to your updated question (which appeared in your own answer). First your code:
```
float const materials[24][4][4] = {{{...}}};
typedef struct EmitterStruct { float *material; } Emitter; /*Use just a plain pointer*/
typedef struct ParticleStruct { float material[4][4]; } Particle;
Emitter *myEmitter;
E... |
351,840 | <p>I have the following Transact-Sql that I am trying to convert to LINQ ... and struggling. </p>
<pre><code>SELECT * FROM Project
WHERE Project.ProjectId IN (SELECT ProjectId FROM ProjectMember Where MemberId = 'a45bd16d-9be0-421b-b5bf-143d334c8155')
</code></pre>
<p>Any help would be greatly appreciated ... I woul... | [
{
"answer_id": 351859,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 3,
"selected": false,
"text": "<p>In this context, you can just use .Contains(), something like this:</p>\n\n<pre><code>var projects = \nfrom p in db... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] | I have the following Transact-Sql that I am trying to convert to LINQ ... and struggling.
```
SELECT * FROM Project
WHERE Project.ProjectId IN (SELECT ProjectId FROM ProjectMember Where MemberId = 'a45bd16d-9be0-421b-b5bf-143d334c8155')
```
Any help would be greatly appreciated ... I would like to do it with Lambda... | GFrizzle beat me to it. But here is a C# version
```
var projectsMemberWorkedOn = from p in Projects
join projectMember in ProjectMembers on
p.ProjectId equals projectMember.ProjectId
where projectMember.MemberId == "a45bd16d-9be0-421b-b5bf-143d334c8155"
... |
351,845 | <p>I have a class A and another class that inherits from it, B. I am overriding a function that accepts an object of type A as a parameter, so I have to accept an A. However, I later call functions that only B has, so I want to return false and not proceed if the object passed is not of type B.</p>
<p>What is the best... | [
{
"answer_id": 351850,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 5,
"selected": false,
"text": "<p>This is called <a href=\"https://en.wikipedia.org/wiki/Run-time_type_information\" rel=\"noreferrer\">RTTI</a>, but you... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43463/"
] | I have a class A and another class that inherits from it, B. I am overriding a function that accepts an object of type A as a parameter, so I have to accept an A. However, I later call functions that only B has, so I want to return false and not proceed if the object passed is not of type B.
What is the best way to fi... | dynamic\_cast should do the trick
```
TYPE& dynamic_cast<TYPE&> (object);
TYPE* dynamic_cast<TYPE*> (object);
```
The [`dynamic_cast`](http://en.cppreference.com/w/cpp/language/dynamic_cast) keyword casts a datum from one pointer or reference type to another, performing a runtime check to ensure the validity of the ... |
351,848 | <p>Ok another WPF question, well I guess this is just general .NET. I have an xml document retreived from a URL.</p>
<p>I want to get multiple values out of the document (weather data, location, some other strings).</p>
<p>When I use the XmlTextReader I can call my method to pull the values out. The first time I pass... | [
{
"answer_id": 351855,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 0,
"selected": false,
"text": "<p>Isn't XMLTextReader a SAX reader? Don't you have to rewind the stream to read the file in again?</p>\n"
},
{
"a... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22451/"
] | Ok another WPF question, well I guess this is just general .NET. I have an xml document retreived from a URL.
I want to get multiple values out of the document (weather data, location, some other strings).
When I use the XmlTextReader I can call my method to pull the values out. The first time I pass the method to se... | XmlTextReader cannot be reset to the beginning.
Download you content first and then use multiple XmlTextReaders (if you have to).
If the document you are downloading is small, I would just use an XmlDocument (or XDocument if you are using .NET 3.5) |
351,903 | <p>I have a GridView that has columns such as:</p>
<pre><code>| A | B C | D E / F |
</code></pre>
<p>I want these to be wrapped in a particular way - that is, I do not want to leave it up to the browser to work out whether to wrap or not depending on the column width. So in the above example I may wa... | [
{
"answer_id": 352986,
"author": "HectorMac",
"author_id": 1400,
"author_profile": "https://Stackoverflow.com/users/1400",
"pm_score": 3,
"selected": false,
"text": "<p>If you use a template field, you can have fine grain control the header content in the header template:</p>\n\n<pre><co... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a GridView that has columns such as:
```
| A | B C | D E / F |
```
I want these to be wrapped in a particular way - that is, I do not want to leave it up to the browser to work out whether to wrap or not depending on the column width. So in the above example I may want the following:
```
| ... | You can do it without templates. Just set HtmlEncode="False" on the headers with `<br />` tags in them.
Example:
```
<asp:GridView ID="GridView1" runat="server" DataSourceID="Data">
<Columns>
<asp:BoundField HeaderText="First Line<br />Second Line" DataField="ContactID"
HtmlEncode="False" />
<... |
351,911 | <p>Example:</p>
<pre><code>public class Name {
public string FirstName { get; private set; }
public string LastName { get; private set; }
private Name() { }
public Name(string firstName, string lastName) {
FirstName = firstName;
LastName = lastName;
}
}
</code></pre>
<p>When... | [
{
"answer_id": 351920,
"author": "BFree",
"author_id": 15861,
"author_profile": "https://Stackoverflow.com/users/15861",
"pm_score": 1,
"selected": false,
"text": "<p>Wow, that's strange. I just tried it myself on my copy of VS2008 (I'm also running SP1) and had the exact same results. W... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23217/"
] | Example:
```
public class Name {
public string FirstName { get; private set; }
public string LastName { get; private set; }
private Name() { }
public Name(string firstName, string lastName) {
FirstName = firstName;
LastName = lastName;
}
}
```
When trying to instantiate thi... | Wow, that's strange. I just tried it myself on my copy of VS2008 (I'm also running SP1) and had the exact same results. When there was more than one parameter, the private constructor showed up in Intellisense, but not when there was only one. My guess is, it's a bug. |
351,915 | <p>I have written a function that gets a given number of random records from a list. Currently I can do something like:</p>
<pre><code>IEnumerable<City> cities = db.Cites.GetRandom(5);
</code></pre>
<p>(where db is my DataContext connecting to a SQL Server DB)</p>
<p>Currently, I have a function like this in ... | [
{
"answer_id": 351922,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 0,
"selected": false,
"text": "<p>Try this</p>\n\n<pre><code>public static IEnumerable<T> GetRandom<T>( this Table<T> table, int count... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30529/"
] | I have written a function that gets a given number of random records from a list. Currently I can do something like:
```
IEnumerable<City> cities = db.Cites.GetRandom(5);
```
(where db is my DataContext connecting to a SQL Server DB)
Currently, I have a function like this in every entity I need random records from:... | JaredPar, I don't think you can do that with the :class inside the generic definition.
I think this is the proper way to define type constraints:
```
public static IEnumerable<T> GetRandom<T>( this Table<T> table, int count) where T : class {
...
}
```
More info on type constraints [here](http://msdn.microsoft.co... |
351,919 | <p>I've had a lot of users complain that the little "i" info button is difficult to touch on the iPhone. Ok, simple enough -- I just stuck a big-fat invisible button behind it that you can't miss even with the sloppiest of finger touches and, when you touch it, it does the infoButtonAction.</p>
<p>Thing is, I'd like ... | [
{
"answer_id": 351951,
"author": "Matt Ball",
"author_id": 43120,
"author_profile": "https://Stackoverflow.com/users/43120",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know exactly what happens in your <code>infotap</code> method, but there doesn't appear to be anything there ... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34820/"
] | I've had a lot of users complain that the little "i" info button is difficult to touch on the iPhone. Ok, simple enough -- I just stuck a big-fat invisible button behind it that you can't miss even with the sloppiest of finger touches and, when you touch it, it does the infoButtonAction.
Thing is, I'd like to flash th... | The problem is that you are marking your button as needing display (calling `-setNeedsDisplay` is unecessary; the button calls that internally), but then never allowing the run loop a chance to display the new image.
In Cocoa, you could use something like `-performClick:` but that is not available on the iPhone.
Inst... |
351,927 | <p>I just ran into an issue with Python's imaplib and Gmail's authentication mechanism:</p>
<pre><code>>>> import imaplib
>>> imap = imaplib.IMAP4_SSL('imap.gmail.com', 993)
>>> imap.authenticate('bobdole@gmail.com', 'Bob Dole likes your style!')
Traceback (most recent call last):
...
imap... | [
{
"answer_id": 351930,
"author": "cdleary",
"author_id": 3594,
"author_profile": "https://Stackoverflow.com/users/3594",
"pm_score": 0,
"selected": false,
"text": "<p>I found the solution on <a href=\"http://codeclimber.blogspot.com/2008/06/using-ruby-for-imap-with-gmail.html\" rel=\"nof... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] | I just ran into an issue with Python's imaplib and Gmail's authentication mechanism:
```
>>> import imaplib
>>> imap = imaplib.IMAP4_SSL('imap.gmail.com', 993)
>>> imap.authenticate('bobdole@gmail.com', 'Bob Dole likes your style!')
Traceback (most recent call last):
...
imaplib.error: AUTHENTICATE command error: BA... | Instead of
```
>>> imap.authenticate('bobdole@gmail.com', 'Bob Dole likes your style!')
```
use
```
>>> imap.login('bobdole@gmail.com', 'Bob Dole likes your style!')
``` |
351,932 | <p>How do you associate a <code>-mouseUp:</code> event with the <code>-add:</code> method of a NSArrayController? The <code>-mouseUp:</code> event lives in a different object but is <code>#import</code>'ed and instantiated in the object that holds the array being controlled.</p>
<p>Usually, with an NSButton you comma... | [
{
"answer_id": 351930,
"author": "cdleary",
"author_id": 3594,
"author_profile": "https://Stackoverflow.com/users/3594",
"pm_score": 0,
"selected": false,
"text": "<p>I found the solution on <a href=\"http://codeclimber.blogspot.com/2008/06/using-ruby-for-imap-with-gmail.html\" rel=\"nof... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41880/"
] | How do you associate a `-mouseUp:` event with the `-add:` method of a NSArrayController? The `-mouseUp:` event lives in a different object but is `#import`'ed and instantiated in the object that holds the array being controlled.
Usually, with an NSButton you command-drag from the button to the NSArrayController's `-ad... | Instead of
```
>>> imap.authenticate('bobdole@gmail.com', 'Bob Dole likes your style!')
```
use
```
>>> imap.login('bobdole@gmail.com', 'Bob Dole likes your style!')
``` |
351,937 | <p>I'm trying to write a html helper extension that outputs an image tag.
I need to access (within C# code) something like Razor's @Url.Content() helper to get the proper URL for the current context.
How does one do this?</p>
| [
{
"answer_id": 351955,
"author": "Dave K",
"author_id": 19864,
"author_profile": "https://Stackoverflow.com/users/19864",
"pm_score": -1,
"selected": false,
"text": "<p>You can get to the Request object and thus the URL like this:</p>\n\n<pre><code>string fullUrl = HttpContext.Current.Re... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4541/"
] | I'm trying to write a html helper extension that outputs an image tag.
I need to access (within C# code) something like Razor's @Url.Content() helper to get the proper URL for the current context.
How does one do this? | Use the following to mimic Url.Content in code.
```
VirtualPathUtility.ToAbsolute("~/url/");
``` |
351,971 | <p>Hi I'm trying to use mono-service2 to run a stock Windows Service Project from visual studio. I'm running this on debian with mono 2.0 and compiling with.</p>
<pre><code>gmcs *.cs -pkg:dotnet
</code></pre>
<p>I try and start with this (I've tried with -d set to the dir with the app and -n,-m set)</p>
<pre><code>m... | [
{
"answer_id": 352051,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 4,
"selected": true,
"text": "<p>Where is your LD_LIBRARY_PATH pointing to? Is <code>libMonoPosixHelper.so</code> in there?</p>\n"
},
{
"answer_i... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/253/"
] | Hi I'm trying to use mono-service2 to run a stock Windows Service Project from visual studio. I'm running this on debian with mono 2.0 and compiling with.
```
gmcs *.cs -pkg:dotnet
```
I try and start with this (I've tried with -d set to the dir with the app and -n,-m set)
```
mono-service2 -l:service.lock --debug ... | Where is your LD\_LIBRARY\_PATH pointing to? Is `libMonoPosixHelper.so` in there? |
351,987 | <p>I'm trying to grab an image from a web site using simpleXML and am getting a PHP error saying that I'm trying to call to a member function <code>xpath()</code> on a non-object.</p>
<p>Below are the lines I'm trying to use to get the image's source tag: </p>
<pre><code>$xpath = '/html/body/div/div/div[5]/div/div/di... | [
{
"answer_id": 352022,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>Problem solved. Was funning xpath on an empty string.</p>\n"
},
{
"answer_id": 352023,
"author": "dancavallaro... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to grab an image from a web site using simpleXML and am getting a PHP error saying that I'm trying to call to a member function `xpath()` on a non-object.
Below are the lines I'm trying to use to get the image's source tag:
```
$xpath = '/html/body/div/div/div[5]/div/div/div[2]/div/div[2]/img';
... | Try this code to first make sure that the document is being parsed correctly.
```
$xpath = '/html/body/div/div/div[5]/div/div/div[2]/div/div[2]/img';
$html = new DOMDocument();
@$html->loadHTMLFile($target_URL);
$xml = simplexml_import_dom($html);
if (!$xml) {
echo 'Error while parsing the document';
... |
352,032 | <p>I'm just trying to do simple scripting with F#, and Math.PI seems to have 'disappeared'. I've referenced FSharp.PowerPack.dll, but still can't find it.</p>
| [
{
"answer_id": 352037,
"author": "Milan",
"author_id": 44000,
"author_profile": "https://Stackoverflow.com/users/44000",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure and can't test it now but have a look at Microsoft.FSharp.Math.</p>\n"
},
{
"answer_id": 352040,
... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] | I'm just trying to do simple scripting with F#, and Math.PI seems to have 'disappeared'. I've referenced FSharp.PowerPack.dll, but still can't find it. | The constant pi is System.Math.PI, if you want to use, Math.PI just open System, in your fsharp file:
```
open System
Math.PI
``` |
352,055 | <p>What is the best approach in stripping leading and trailing spaces in C?</p>
| [
{
"answer_id": 352069,
"author": "Norman Ramsey",
"author_id": 41661,
"author_profile": "https://Stackoverflow.com/users/41661",
"pm_score": 3,
"selected": false,
"text": "<p>This question looks as if it might be a homework question, so I'll answer obliquely: look up the man pages for is... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16139/"
] | What is the best approach in stripping leading and trailing spaces in C? | You can do this entirely in place.
```
void stripLeadingAndTrailingSpaces(char* string){
assert(string);
/* First remove leading spaces */
const char* firstNonSpace = string;
while(*firstNonSpace != '\0' && isspace(*firstNonSpace))
{
++firstNonSpace;
}
size_t len = s... |
352,076 | <p>This is something that has bugged me for some time. I learnt Haskell before I learnt Python, so I've always been fond of thinking of many computations as a mapping onto a list. This is beautifully expressed by a list comprehension (I'm giving the pythonic version here):</p>
<pre><code>result = [ f(x) for x in list ... | [
{
"answer_id": 352105,
"author": "Darius Bacon",
"author_id": 27024,
"author_profile": "https://Stackoverflow.com/users/27024",
"pm_score": 0,
"selected": false,
"text": "<p>There are cases where it's best to go back to the for-loop, yes, but more often I prefer one of these approaches:<... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37984/"
] | This is something that has bugged me for some time. I learnt Haskell before I learnt Python, so I've always been fond of thinking of many computations as a mapping onto a list. This is beautifully expressed by a list comprehension (I'm giving the pythonic version here):
```
result = [ f(x) for x in list ]
```
In man... | You can easily do function composition in Python.
Here's a demonstrates of a way to create a new function which is a composition of existing functions.
```
>>> def comp( a, b ):
def compose( args ):
return a( b( args ) )
return compose
>>> def times2(x): return x*2
>>> def plus1(x): return x+1
>>>... |
352,089 | <p>Why isn't there a bit structure in C#?</p>
| [
{
"answer_id": 352093,
"author": "Ed S.",
"author_id": 1053,
"author_profile": "https://Stackoverflow.com/users/1053",
"pm_score": 4,
"selected": false,
"text": "<p>It is called a boolean. At least, it would serve the basic function, right? You don't twiddle bits that often in C# (at l... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44527/"
] | Why isn't there a bit structure in C#? | For what's worth, here is a full-fledged bit structure, complete with `int` and `bool` casting and arithmetic operations. Probably not perfect, but works fine for me. Enjoy!
```
/// <summary>
/// Represents a single bit that can be implicitly cast to/from and compared
/// with booleans and integers.
/// </summary>
///... |
352,098 | <p>Is there a (Unix) shell script to format JSON in human-readable form?</p>
<p>Basically, I want it to transform the following:</p>
<pre class="lang-json prettyprint-override"><code>{ "foo": "lorem", "bar": "ipsum" }
</code></pre>
<p>... into something like this:</p>
<pre class=... | [
{
"answer_id": 352115,
"author": "Robert Gould",
"author_id": 15124,
"author_profile": "https://Stackoverflow.com/users/15124",
"pm_score": 3,
"selected": false,
"text": "<p>There is <a href=\"http://www.raboof.com/Projects/TidyJson/\" rel=\"nofollow noreferrer\">TidyJSON</a>.</p>\n\n<p>... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there a (Unix) shell script to format JSON in human-readable form?
Basically, I want it to transform the following:
```json
{ "foo": "lorem", "bar": "ipsum" }
```
... into something like this:
```json
{
"foo": "lorem",
"bar": "ipsum"
}
``` | With Python 2.6+ you can do:
```sh
echo '{"foo": "lorem", "bar": "ipsum"}' | python -m json.tool
```
or, if the JSON is in a file, you can do:
```sh
python -m json.tool my_json.json
```
if the JSON is from an internet source such as an API, you can use
```sh
curl http://my_url/ | python -m json.tool
```
For co... |
352,103 | <p>On this page (<a href="http://www.bonniesphere.com/blog/elsewhere/" rel="nofollow noreferrer">http://www.bonniesphere.com/blog/elsewhere/</a>) the "li" items have an image instead of a bullet. But the image is centered vertically, and in multi-line entries it doesn't look good. Can anyone tell me if there is somethi... | [
{
"answer_id": 352106,
"author": "Kablam",
"author_id": 42389,
"author_profile": "https://Stackoverflow.com/users/42389",
"pm_score": 0,
"selected": false,
"text": "<pre><code>.entry ul {list-style-type:none;} \n.entry ul li{padding: 0 0 0 15px;\nbackground: url(img/ol.gif) no-repeat lef... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | On this page (<http://www.bonniesphere.com/blog/elsewhere/>) the "li" items have an image instead of a bullet. But the image is centered vertically, and in multi-line entries it doesn't look good. Can anyone tell me if there is something in the CSS that should be changed?
Here's the relative code:
.entry ul {list-sty... | replace **center** with **top**:
```
background: transparent url(img/ol.gif) no-repeat scroll left top;
``` |
352,117 | <p>I've been lately trying to learn more and generally test Java's serialization for both work and personal projects and I must say that the more I know about it, the less I like it. This may be caused by misinformation though so that's why I'm asking these two things from you all:</p>
<p><strong>1:</strong> On byte l... | [
{
"answer_id": 352133,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": true,
"text": "<p>I would personally try to avoid Java's \"built-in\" serialization:</p>\n\n<ul>\n<li>It's not portable to other platfor... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44523/"
] | I've been lately trying to learn more and generally test Java's serialization for both work and personal projects and I must say that the more I know about it, the less I like it. This may be caused by misinformation though so that's why I'm asking these two things from you all:
**1:** On byte level, how does serializ... | I would personally try to avoid Java's "built-in" serialization:
* It's not portable to other platforms
* It's not hugely efficient
* It's fragile - getting it to cope with multiple versions of a class is somewhat tricky. Even changing compilers can break serialization unless you're careful.
For details of what the a... |
352,118 | <p>I place using namespace in a view code behind but i can't call any class of this name space in aspx.</p>
<p>In codebehind:</p>
<pre><code>using MVCTest.Controller;
</code></pre>
| [
{
"answer_id": 352138,
"author": "mookid8000",
"author_id": 6560,
"author_profile": "https://Stackoverflow.com/users/6560",
"pm_score": 2,
"selected": false,
"text": "<p>Did you remember to include the assembly as well? E.g. like this:</p>\n\n<pre><code>// system.web / compilation / asse... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44533/"
] | I place using namespace in a view code behind but i can't call any class of this name space in aspx.
In codebehind:
```
using MVCTest.Controller;
``` | try to use in your aspx / ascx file
```
<%@ import namespace='your namespace' %>
```
you could also try to import your namespace in the web.config
```
<system.web>
<pages>
<namespaces>
<add namespace='you namespace' />
</namespaces>
</pages>
</system.web>
``` |
352,152 | <p>I was wondering if there is an iterator in the STL that dereferences the object pointed before returning it. This could be very useful when manipulating containers aggregating pointers. Here's an example of what I would like to be able to do:</p>
<pre><code>#include <vector>
#include <iterator>
#include... | [
{
"answer_id": 352162,
"author": "Luc Touraille",
"author_id": 20984,
"author_profile": "https://Stackoverflow.com/users/20984",
"pm_score": 2,
"selected": false,
"text": "<p>If it is impossible using Boost, writing a custom iterator is not that hard. Here is an example of a \"dereferenc... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20984/"
] | I was wondering if there is an iterator in the STL that dereferences the object pointed before returning it. This could be very useful when manipulating containers aggregating pointers. Here's an example of what I would like to be able to do:
```
#include <vector>
#include <iterator>
#include <algorithm>
using namesp... | Try Boost's [`indirect_iterator`](http://www.boost.org/doc/libs/1_37_0/libs/iterator/doc/indirect_iterator.html).
An `indirect_iterator` has the same category as the iterator it is wrapping. For example, an `indirect_iterator<int**>` is a random access iterator. |
352,174 | <pre><code> [SoapRpcMethod(Action = "http://cyberindigo/TempWebService/InsertXML",
RequestNamespace = "http://cyberindigo/TempWebService/Request",
RequestElementName = "InsertXMLRequest",
ResponseNamespace = "http://cyberindigo/TempWebService/Response",
ResponseElementName = "InsertXMLResponse",
U... | [
{
"answer_id": 352244,
"author": "ya23",
"author_id": 29430,
"author_profile": "https://Stackoverflow.com/users/29430",
"pm_score": 2,
"selected": false,
"text": "<p>I had similar issue. To debug the problem, I've run <a href=\"http://www.wireshark.org/\" rel=\"nofollow noreferrer\">Wire... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42070/"
] | ```
[SoapRpcMethod(Action = "http://cyberindigo/TempWebService/InsertXML",
RequestNamespace = "http://cyberindigo/TempWebService/Request",
RequestElementName = "InsertXMLRequest",
ResponseNamespace = "http://cyberindigo/TempWebService/Response",
ResponseElementName = "InsertXMLResponse",
Use = Sy... | The source of the next part of this post is:
>
> <http://bluebones.net/2003/07/server-did-not-recognize-http-header-soapaction/>
>
>
>
(since the OP didn't want to give attribution, and thanks to Peter)
Please note that bakert is the original author of the text, not the OP.
---
Seeing as nowhere on the inter... |
352,176 | <p>The following SQL separates tables according to their relationship. The problem is with the tables that sort under the 3000 series. Tables that are part of foreign keys and that use foreign keys. Anyone got some clever recursive CTE preferably or a stored procedure to do the necessary sorting?? Programs connectiong ... | [
{
"answer_id": 352294,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 2,
"selected": false,
"text": "<p>You can use an iterative algorithm, which is probably less convoluted than a CTE. Here's an example ... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13219/"
] | The following SQL separates tables according to their relationship. The problem is with the tables that sort under the 3000 series. Tables that are part of foreign keys and that use foreign keys. Anyone got some clever recursive CTE preferably or a stored procedure to do the necessary sorting?? Programs connectiong to ... | Thank you for a working solution NXC. You put me on the right track to solve the problem using a recursive CTE.
```
WITH
TablesCTE(TableName, TableID, Ordinal) AS
(
SELECT
OBJECT_SCHEMA_NAME(so.id) +'.'+ OBJECT_NAME(so.id) AS TableName,
so.id AS TableID,
0 AS Ordinal
FROM dbo.sysobjects so INNER ... |
352,177 | <p>Fun with enums in C#. Take one generic list that is created to store some Enum that you had defined previously and add few items in it. Iterate with foreach or <code>GetEnumerator<T>()</code> but specify some other enum then the original and see what happens. I was expecting InvalidCastException or something l... | [
{
"answer_id": 352196,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 2,
"selected": false,
"text": "<p>Conceptually, an Enum is a statically-typed value with a string representation and a number. When you call <code>ToSt... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29511/"
] | Fun with enums in C#. Take one generic list that is created to store some Enum that you had defined previously and add few items in it. Iterate with foreach or `GetEnumerator<T>()` but specify some other enum then the original and see what happens. I was expecting InvalidCastException or something like that but it perf... | Enum types are distinct, but you're being confused by an implicit cast which is in foreach.
Let's rewrite your loop a bit:
```
public static void Main()
{
List<Cars> cars = new List<Cars>();
List<Animals> animals = new List<Animals>();
cars.Add(Cars.Chevrolet);
cars.Add(Cars.Honda);
cars.Add(Cars.... |
352,203 | <p>I'm looking for an algorithm to generate permutations of a set in such a way that I could make a lazy list of them in Clojure. i.e. I'd like to iterate over a list of permutations where each permutation is not calculated until I request it, and all of the permutations don't have to be stored in memory at once.</p>
... | [
{
"answer_id": 352226,
"author": "Bogdan Maxim",
"author_id": 23795,
"author_profile": "https://Stackoverflow.com/users/23795",
"pm_score": 2,
"selected": false,
"text": "<p>You should check the <a href=\"http://en.wikipedia.org/wiki/Permutation#Numbering_permutations\" rel=\"nofollow no... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23070/"
] | I'm looking for an algorithm to generate permutations of a set in such a way that I could make a lazy list of them in Clojure. i.e. I'd like to iterate over a list of permutations where each permutation is not calculated until I request it, and all of the permutations don't have to be stored in memory at once.
Alterna... | Yes, there *is* a "next permutation" algorithm, and it's quite simple too. The C++ standard template library (STL) even has a function called `next_permutation`.
The algorithm actually finds the *next* permutation -- the lexicographically next one. The idea is this: suppose you are given a sequence, say "32541". What ... |
352,236 | <p>Is there a way for a Windows application to access another applications data, more specifically a text input field in the GUI, and grab the text there for processing in our own application?</p>
<p>If it is possible, is there a way to "shield" your application to prevent it?</p>
<hr />
<p><strong>EDIT:</str... | [
{
"answer_id": 352242,
"author": "MZywitza",
"author_id": 44243,
"author_profile": "https://Stackoverflow.com/users/44243",
"pm_score": 1,
"selected": false,
"text": "<p>Look at <a href=\"http://www.autohotkey.com\" rel=\"nofollow noreferrer\">AutoHotkey</a>. If you need an API for your ... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40657/"
] | Is there a way for a Windows application to access another applications data, more specifically a text input field in the GUI, and grab the text there for processing in our own application?
If it is possible, is there a way to "shield" your application to prevent it?
---
**EDIT:** The three first answers seem to be ... | For reading text content from another application's text box you will need to get that text box control's window handle somehow. Depending on how your application UI is designed (if it has a UI that is) there are a couple of different ways that you can use to get this handle. You might use "FindWindow"/"FindWindowEx" t... |
352,259 | <p>I want to use the standard ADO connection string dialog box in MS Access.
How can I do that?</p>
| [
{
"answer_id": 352272,
"author": "Galwegian",
"author_id": 3201,
"author_profile": "https://Stackoverflow.com/users/3201",
"pm_score": -1,
"selected": false,
"text": "<p>See <a href=\"http://support.microsoft.com/kb/281998\" rel=\"nofollow noreferrer\">How to bind Microsoft Access forms ... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to use the standard ADO connection string dialog box in MS Access.
How can I do that? | If not already selected, check the following references in the References dialog:
Microsoft OLE DB Service Component 1.0 Type Library
Microsoft ActiveX Data Objects 2.7 Library
The following code will open the dialog box and set a connection object to the parameters provided in the Data Link Properties dialog box:
... |
352,311 | <p>I'm using this database where the date colomn is a numeric value instead of a Date value. </p>
<p>Yes, I know I can change that with a mouseclick, but all the applications using that database were made by one of my predecessors (and everyone after him just ignored it and built on). So if I'd change it to Date a lot... | [
{
"answer_id": 352329,
"author": "Simon",
"author_id": 20048,
"author_profile": "https://Stackoverflow.com/users/20048",
"pm_score": 0,
"selected": false,
"text": "<p>Access stores date internally as a floating point number (number of days since 31.12.1899 or something), have you tried u... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42389/"
] | I'm using this database where the date colomn is a numeric value instead of a Date value.
Yes, I know I can change that with a mouseclick, but all the applications using that database were made by one of my predecessors (and everyone after him just ignored it and built on). So if I'd change it to Date a lot af applic... | Access will convert to a number for you, as was mentioned, the dates are stored as numbers.
```
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("TestTable")
rs.AddNew
rs!NumberDate = Now() 'Value stored, eg, 39791.4749074074 '
rs.Update
rs.MoveLast
'To show that it converts back to the correct date / time... |
352,321 | <p>I am testing the application in the debug mode under several conditions. Now I'm doing it by writing some of the states and executed functions on the piece of paper and then comparing the scenarios.</p>
<p>Does anyone know if there is any built-in functionality in VS2008 or any additional tool that could record the... | [
{
"answer_id": 352329,
"author": "Simon",
"author_id": 20048,
"author_profile": "https://Stackoverflow.com/users/20048",
"pm_score": 0,
"selected": false,
"text": "<p>Access stores date internally as a floating point number (number of days since 31.12.1899 or something), have you tried u... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22996/"
] | I am testing the application in the debug mode under several conditions. Now I'm doing it by writing some of the states and executed functions on the piece of paper and then comparing the scenarios.
Does anyone know if there is any built-in functionality in VS2008 or any additional tool that could record the selected ... | Access will convert to a number for you, as was mentioned, the dates are stored as numbers.
```
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("TestTable")
rs.AddNew
rs!NumberDate = Now() 'Value stored, eg, 39791.4749074074 '
rs.Update
rs.MoveLast
'To show that it converts back to the correct date / time... |
352,334 | <p>I'm using GDOME.pm and in my script I have this line:</p>
<pre><code>my $doc = XML::GDOME->createDocument("","","");
</code></pre>
<p>I can't for the life of me figure out why it's coming out with this error:</p>
<pre><code>NAMESPACE_ERR at /usr/lib/perl5/site_perl/5.6.1/i586-linux/XML/GDOME.pm line 103.
</cod... | [
{
"answer_id": 352567,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 2,
"selected": true,
"text": "<p>The documentation says: </p>\n\n<pre><code>$doc = XML::GDOME->createDocument( $nsURI, $name, $dtd );\n</code></... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38124/"
] | I'm using GDOME.pm and in my script I have this line:
```
my $doc = XML::GDOME->createDocument("","","");
```
I can't for the life of me figure out why it's coming out with this error:
```
NAMESPACE_ERR at /usr/lib/perl5/site_perl/5.6.1/i586-linux/XML/GDOME.pm line 103.
```
which basically points to:
```
sub cre... | The documentation says:
```
$doc = XML::GDOME->createDocument( $nsURI, $name, $dtd );
```
>
> Creates a new xml document. It will be
> in the $nsURI namespace, if $nsURI is
> defined, and its document element will
> have the name $name.
>
>
>
Now, your example uses `""` for the namespace. That's not the sam... |
352,340 | <p>Edit: How to return/serve a file from a python controller (back end) over a web server, with the file_name? as suggested by @JV</p>
| [
{
"answer_id": 352385,
"author": "James Anderson",
"author_id": 38207,
"author_profile": "https://Stackoverflow.com/users/38207",
"pm_score": 2,
"selected": false,
"text": "<p>You can either pass back a reference to the file itself i.e. the full path to the file. Then you can open the fi... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2220518/"
] | Edit: How to return/serve a file from a python controller (back end) over a web server, with the file\_name? as suggested by @JV | Fully supported in CherryPy using
```
from cherrypy.lib.static import serve_file
```
As documented in the [CherryPy docs - FileDownload](http://www.cherrypy.org/wiki/FileDownload):
```
import glob
import os.path
import cherrypy
from cherrypy.lib.static import serve_file
class Root:
def index(self, directory="... |
352,341 | <p>I often find myself using Integers to represent values in different "spaces". For example...</p>
<pre><code>int arrayIndex;
int usersAge;
int daysToChristmas;
</code></pre>
<p>Ideally, I'd like to have separate classes for each of these types "Index","Years" and "Days", which should prevent me accidentally mixing ... | [
{
"answer_id": 352363,
"author": "Joris Timmermans",
"author_id": 33987,
"author_profile": "https://Stackoverflow.com/users/33987",
"pm_score": 3,
"selected": false,
"text": "<p>One funky \"hack\" you could use is a template non-type parameter to create wrapper types. This doesn't add a... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1737/"
] | I often find myself using Integers to represent values in different "spaces". For example...
```
int arrayIndex;
int usersAge;
int daysToChristmas;
```
Ideally, I'd like to have separate classes for each of these types "Index","Years" and "Days", which should prevent me accidentally mixing them up. Typedefs are a he... | You could try BOOST\_STRONG\_TYPEDEF. From `boost/strong_typedef.hpp`:
```
// macro used to implement a strong typedef. strong typedef
// guarentees that two types are distinguised even though the
// share the same underlying implementation. typedef does not create
// a new type. BOOST_STRONG_TYPEDEF(T, D) creates ... |
352,343 | <p>I'm developing a web app. In it I have a section called categories that every time a user clicks one of the categories an update panel loads the appropriate content. </p>
<p>After the user clicked the category I want to change the browser's address bar url from</p>
<pre><code>www.mysite.com/products
</code></pre>... | [
{
"answer_id": 352353,
"author": "Galwegian",
"author_id": 3201,
"author_profile": "https://Stackoverflow.com/users/3201",
"pm_score": 2,
"selected": false,
"text": "<p>I don't think this is possible (at least changing to a totally different address), as it would be an unintuitive misuse... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm developing a web app. In it I have a section called categories that every time a user clicks one of the categories an update panel loads the appropriate content.
After the user clicked the category I want to change the browser's address bar url from
```
www.mysite.com/products
```
to something like
```
www.... | With HTML5 you can modify the url without reloading:
If you want to make a new post in the browser's history (i.e. back button will work)
```
window.history.pushState('Object', 'Title', '/new-url');
```
If you just want to change the url without being able to go back
```
window.history.replaceState('Object', 'Titl... |
352,350 | <p>This is a question for a WSS/SharePoint guru. </p>
<p>Consider this scenario: I have an ASP.Net web service which links our corporate CRM system and WSS-based intranet together. What I am trying to do is provision a new WSS site collection whenever a new client is added to the CRM system. In order to make this work... | [
{
"answer_id": 354261,
"author": "Nat",
"author_id": 13813,
"author_profile": "https://Stackoverflow.com/users/13813",
"pm_score": 2,
"selected": true,
"text": "<p><strong>Update</strong>\nI think you have proved that the issue is not with the code.</p>\n\n<p>SPSecurity.RunWithElevatedPr... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1052/"
] | This is a question for a WSS/SharePoint guru.
Consider this scenario: I have an ASP.Net web service which links our corporate CRM system and WSS-based intranet together. What I am trying to do is provision a new WSS site collection whenever a new client is added to the CRM system. In order to make this work, I need t... | **Update**
I think you have proved that the issue is not with the code.
SPSecurity.RunWithElevatedPrivileges: Normally the code in the SharePoint web application executes with the privileges of the user taking the action. The RunWithElevatedPrivileges runs the code in the context of the SharePoint web application pool... |
352,354 | <p>I need to match a string holiding html using a regex to pull out all the nested spans, I assume I assume there is a way to do this using a regex but have had no success all morning. </p>
<p>So for a sample input string of </p>
<pre><code><DIV id=c445c9c2-a02e-4cec-b254-c134adfa4192 style="BORDER-RIGHT: #000000 ... | [
{
"answer_id": 352396,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 3,
"selected": false,
"text": "<p>Once again <a href=\"http://www.developer.com/net/csharp/article.php/2230091\" rel=\"nofollow noreferrer\">use an HTML... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/87783/"
] | I need to match a string holiding html using a regex to pull out all the nested spans, I assume I assume there is a way to do this using a regex but have had no success all morning.
So for a sample input string of
```
<DIV id=c445c9c2-a02e-4cec-b254-c134adfa4192 style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #... | Try this:
```
@"(?is)<SPAN\b[^>]*>\s*(<SPAN\b[^>]*>.*?</SPAN>)\s*</SPAN>"
```
This is basically the same as PhiLho's regex, except it permits whitespace between the tags at either end. I also had to add the SingleLine/DOTALL modifier to accomodate line separators within the matched text. I don't know if either of th... |
352,389 | <p>We have this set of data that we need to get the average of a column. a <code>select avg(x) from y</code> does the trick. However we need a more accurate figure.</p>
<p>I figured that there must be a way of filtering records that has either too high or too low values(spikes) so that we can exclude them in calculati... | [
{
"answer_id": 352402,
"author": "Mladen Prajdic",
"author_id": 31345,
"author_profile": "https://Stackoverflow.com/users/31345",
"pm_score": 1,
"selected": false,
"text": "<p>in sql server there's also the STDEV function so maybe that can be of some help...</p>\n"
},
{
"answer_i... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20300/"
] | We have this set of data that we need to get the average of a column. a `select avg(x) from y` does the trick. However we need a more accurate figure.
I figured that there must be a way of filtering records that has either too high or too low values(spikes) so that we can exclude them in calculating the average. | There are three types of average, and what you are originally using is the mean - the sum of all the values divided by the number of values.
You might find it more useful to get the mode - the most frequently occuring value:
```
select name,
(select top 1 h.run_duration
from sysjobhistory h
... |
352,408 | <p>A colleague of mine and I have been discussing how to declare variables in a function.</p>
<p>Let's say you have a class called TStrings (using Delphi for the sake of explanation) that has at least one abstract method and a descendant class called TStringList which obviously implements the abstract method, but it i... | [
{
"answer_id": 352416,
"author": "Chris Kimpton",
"author_id": 48310,
"author_profile": "https://Stackoverflow.com/users/48310",
"pm_score": 0,
"selected": false,
"text": "<p>My vote is the second form - the idea being that TStrings defines a contract/interface and its better to code to ... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1264322/"
] | A colleague of mine and I have been discussing how to declare variables in a function.
Let's say you have a class called TStrings (using Delphi for the sake of explanation) that has at least one abstract method and a descendant class called TStringList which obviously implements the abstract method, but it introduces ... | It is a TStringList, so you should also declare it as TStringList (first example). Everything else could confuse you or others that read the code later. |
352,415 | <p>I am reorganizing my source files into a single solution with a single project, due to various reasons:</p>
<ul>
<li>a paranoic configured antivirus software;</li>
<li><a href="http://codebetter.com/blogs/patricksmacchia/archive/2008/12/08/advices-on-partitioning-code-through-net-assemblies.aspx" rel="nofollow nore... | [
{
"answer_id": 352421,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "<p>Yes - use folders.</p>\n\n<p>If you create a folder within a project, new classes within that folder will automaticall... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19756/"
] | I am reorganizing my source files into a single solution with a single project, due to various reasons:
* a paranoic configured antivirus software;
* [Advices on partitioning code through .NET assemblies](http://codebetter.com/blogs/patricksmacchia/archive/2008/12/08/advices-on-partitioning-code-through-net-assemblies... | Yes - use folders.
If you create a folder within a project, new classes within that folder will automatically use the folder name as the basis for the namespace.
For instance, if you have a project with a default namespace of "Company.Project" and a folder "Foo" containing "Bar.cs" you'll end up with:
```
using Syst... |
352,420 | <p>I just wanted to know what's the difference between clear() and str("");</p>
<p>For example:</p>
<pre><code>stringstream ss("Stack Overflow");
ss.clear();
ss.str("");
</code></pre>
<p>I wanted to know the underlying technical difference.</p>
| [
{
"answer_id": 352426,
"author": "AlfaZulu",
"author_id": 44060,
"author_profile": "https://Stackoverflow.com/users/44060",
"pm_score": 5,
"selected": true,
"text": "<p><code>clear()</code> clears the error state flags in the <code>stringstream</code>. That is to say it sets the error st... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38038/"
] | I just wanted to know what's the difference between clear() and str("");
For example:
```
stringstream ss("Stack Overflow");
ss.clear();
ss.str("");
```
I wanted to know the underlying technical difference. | `clear()` clears the error state flags in the `stringstream`. That is to say it sets the error state to `goodbit`(which is equal to zero).
`str("")` sets the associated string object to the empty string.
They actually do completely different things. The peculiar choice of names only make it *sound* as though they per... |
352,434 | <p>I have a long "binary string" like the output of PHPs pack function.</p>
<p>How can I convert this value to base62 (0-9a-zA-Z)?
The built in maths functions overflow with such long inputs, and BCmath doesn't have a base_convert function, or anything that specific. I would also need a matching "pack base62" function... | [
{
"answer_id": 364626,
"author": "david",
"author_id": 27600,
"author_profile": "https://Stackoverflow.com/users/27600",
"pm_score": 1,
"selected": false,
"text": "<p>Unless you really, really have to have base62, why not go for:</p>\n\n<pre><code>base64_encode()\nbase64_decode()\n</code... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a long "binary string" like the output of PHPs pack function.
How can I convert this value to base62 (0-9a-zA-Z)?
The built in maths functions overflow with such long inputs, and BCmath doesn't have a base\_convert function, or anything that specific. I would also need a matching "pack base62" function. | I think there is a misunderstanding behind this question. Base conversion and encoding/decoding are **different**. The output of `base64_encode(...)` is ***not*** a large base64-number. It's a series of discrete base64 values, corresponding to the compression function. That is why BC Math does not work, because BC Math... |
352,452 | <p>I have this code </p>
<p><a href="http://www.nomorepasting.com/getpaste.php?pasteid=22580" rel="nofollow noreferrer">http://www.nomorepasting.com/getpaste.php?pasteid=22580</a> </p>
<p>which is part of a small ajax application. I would like to know a better, more efficient way to assign $query, instead of copying ... | [
{
"answer_id": 352483,
"author": "markus",
"author_id": 11995,
"author_profile": "https://Stackoverflow.com/users/11995",
"pm_score": 3,
"selected": true,
"text": "<p><strong>UPDATE</strong>: I integrated Eran's function into the refactored code. NOTE: I corrected it by passing the $tabl... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | I have this code
<http://www.nomorepasting.com/getpaste.php?pasteid=22580>
which is part of a small ajax application. I would like to know a better, more efficient way to assign $query, instead of copying the sql each time with a different query or a bunch of if clauses. Basically the query will be dependant on the... | **UPDATE**: I integrated Eran's function into the refactored code. NOTE: I corrected it by passing the $table variable into it and renamed it since it doesn't search the query text only but mainly returns the needed rows!
**MAIN MISTAKES**:
* mistake 1: you overwrite query with query2 in all cases which breaks the co... |
352,463 | <p>I have a JSON as follows</p>
<pre><code>{
columns : [RULE_ID,COUNTRY_CODE],
RULE_ID : [1,2,3,7,9,101,102,103,104,105,106,4,5,100,30],
COUNTRY_CODE : [US,US,CA,US,FR,GB,GB,UM,AF,AF,AL,CA,US,US,US]
}
</code></pre>
<p>I need to retrive the column names from the columns entry and then use it to search... | [
{
"answer_id": 352533,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 4,
"selected": true,
"text": "<pre><code>jQuery.each(data.columns, function(i,column) {\n jQuery.each(data[column], function(i, row) {\n .... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16488/"
] | I have a JSON as follows
```
{
columns : [RULE_ID,COUNTRY_CODE],
RULE_ID : [1,2,3,7,9,101,102,103,104,105,106,4,5,100,30],
COUNTRY_CODE : [US,US,CA,US,FR,GB,GB,UM,AF,AF,AL,CA,US,US,US]
}
```
I need to retrive the column names from the columns entry and then use it to search the rest of the entries u... | ```
jQuery.each(data.columns, function(i,column) {
jQuery.each(data[column], function(i, row) {
....
});
});
``` |
352,467 | <p>I am currently doing the front end for a site with looooads of forms, all styled up and looking pretty in IE, but I've just noticed that in Firefox the file input fields aren't responding to any of my styles, all the other types of input fields are fine. I've checked it in Firebug and its associating the correct sty... | [
{
"answer_id": 352512,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": -1,
"selected": false,
"text": "<p>Use cheat code ( # ) infront of the attribute of css class\nsay:</p>\n\n<pre><code>form.CollateralForm input,\nform.C... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31109/"
] | I am currently doing the front end for a site with looooads of forms, all styled up and looking pretty in IE, but I've just noticed that in Firefox the file input fields aren't responding to any of my styles, all the other types of input fields are fine. I've checked it in Firebug and its associating the correct styles... | Many of the answers above are quite old. **In 2013 a much simpler solution exists**: nearly all current browsers...
* Chrome
* IE
* Safari
* Firefox with a few-line fix
pass through click events from labels. Try it here: <http://jsfiddle.net/rvCBX/7/>
* Style the `<label>` however you you would like your file upload... |
352,472 | <p>I was curiious to know what type of structures you use for your project references?</p>
<p>Where I work the developers have a shared folder called AssemblyCache (\\MACHINENAME\AssemblyCache) which is mapped to an R:\ via GPO in Windows 2008 AD (tied to the Developers AD group).</p>
<p>Our shared components have po... | [
{
"answer_id": 352489,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<ul>\n<li>Store all the reference assemblies in source control.</li>\n<li>Always fetch such that the code has the same <... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5791/"
] | I was curiious to know what type of structures you use for your project references?
Where I work the developers have a shared folder called AssemblyCache (\\MACHINENAME\AssemblyCache) which is mapped to an R:\ via GPO in Windows 2008 AD (tied to the Developers AD group).
Our shared components have post-build events t... | You dont need to create a network share. I think you can get away with creating a virtual drive letter for a local folder using the windows subst command for example...
```
subst R: "C:\.Net %VERSION%\Project\%SOMETHING%"
```
The advantage here is that an arbitrary path can be routed to a standard well defined path ... |
352,474 | <p>I have an interface A, for which I have to supply a few different
implementations. However, those implementations share some helper methods, so
I moved those methods to an abstract base class.</p>
<pre><code>Interface A {
void doX();
}
abstract Class B implements A {
protected void commonY() {
// .... | [
{
"answer_id": 352484,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<ul>\n<li>Should I declare the abstract Method doX() in Class B? Why (not)?</li>\n</ul>\n\n<p>No. It's an abstract class - def... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29549/"
] | I have an interface A, for which I have to supply a few different
implementations. However, those implementations share some helper methods, so
I moved those methods to an abstract base class.
```
Interface A {
void doX();
}
abstract Class B implements A {
protected void commonY() {
// ...
}
... | I think it would be better to do it as follows:
```
Interface A {
void doX();
}
abstract Class B {
protected void commonY() {
// ...
}
}
Class C extends B implements A{
public void doX() {
// ...
}
}
Class D extends B implements A{
pu... |
352,478 | <p>Does anyone know of a really simple way of capitalizing just the first letter of a string, regardless of the capitalization of the rest of the string?</p>
<p>For example:</p>
<pre><code>asimpletest -> Asimpletest
aSimpleTest -> ASimpleTest
</code></pre>
<p>I would like to be able to do all string lengths as... | [
{
"answer_id": 352494,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 3,
"selected": false,
"text": "<pre><code>s = s[0].upper() + s[1:]\n</code></pre>\n\n<p>This should work with every string, except for the empty st... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18909/"
] | Does anyone know of a really simple way of capitalizing just the first letter of a string, regardless of the capitalization of the rest of the string?
For example:
```
asimpletest -> Asimpletest
aSimpleTest -> ASimpleTest
```
I would like to be able to do all string lengths as well. | @[saua](https://stackoverflow.com/a/352494/2285236) is right, and
```
s = s[:1].upper() + s[1:]
```
will work for any string. |
352,479 | <p>When I compile my application under Delphi 2006 I get the following warning
[Pascal Warning]- W1002 Symbol 'FileSetDate' is specific to a platform</p>
<p>What must I do to suppress this warning?</p>
<p>The code </p>
<pre><code>MyLastError:= FileSetDate( Files[ i ].Handle, DateTimeToFileDate( arcDate ) );
</code>... | [
{
"answer_id": 352498,
"author": "Daniel Rikowski",
"author_id": 23368,
"author_profile": "https://Stackoverflow.com/users/23368",
"pm_score": 5,
"selected": false,
"text": "<p>1) In the project options you can choose the compiler messages you want to see.\nIf you don't care about platfo... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17560/"
] | When I compile my application under Delphi 2006 I get the following warning
[Pascal Warning]- W1002 Symbol 'FileSetDate' is specific to a platform
What must I do to suppress this warning?
The code
```
MyLastError:= FileSetDate( Files[ i ].Handle, DateTimeToFileDate( arcDate ) );
``` | Although the answer of DR solves the warning, it is not the correct solution.
You should use the platform independent version of FileSetDate:
```
function FileSetDate(const FileName: string; Age: Integer): Integer; overload;
```
Also in SysUtils. |
352,503 | <p>Master table contains ID and PersonName.<br>
Course table contains ID, CourseName.<br>
Detail table contains ID, MasterID, CourseID, StartDate,EndDate</p>
<p>I want to create report that shows list of persons (PersonName) and the only last course they took (so every person is listed only once):</p>
<p>PersonName -... | [
{
"answer_id": 352526,
"author": "Tony Andrews",
"author_id": 18747,
"author_profile": "https://Stackoverflow.com/users/18747",
"pm_score": 3,
"selected": true,
"text": "<pre><code>select m.PersonName, c.CourseName\nfrom Master m\njoin Detail d on d.MasterID = m.ID\njoin Course c o... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11744/"
] | Master table contains ID and PersonName.
Course table contains ID, CourseName.
Detail table contains ID, MasterID, CourseID, StartDate,EndDate
I want to create report that shows list of persons (PersonName) and the only last course they took (so every person is listed only once):
PersonName - CourseName - Start... | ```
select m.PersonName, c.CourseName
from Master m
join Detail d on d.MasterID = m.ID
join Course c on c.ID = d.CourseID
where d.StartDate = (select max(d2.StartDate)
from Detail d2
where d2.MasterID = m.ID
)
``` |
352,527 | <p>I am adventuring into some AOP and it seems with .NET PostSharp is the way to go. </p>
<p>I want to do some simple logging to the db when an exception occurs. However I am finding it difficult to find any real solid examples of using PostSharp beyond the basics. I tried the following:</p>
<pre><code>[Serializable]... | [
{
"answer_id": 353886,
"author": "Joel Lucsy",
"author_id": 645,
"author_profile": "https://Stackoverflow.com/users/645",
"pm_score": 0,
"selected": false,
"text": "<p>I've used OnMethodBoundaryAspect instead of ExceptionHandlerAspect without problems. And I've not made mine sealed eithe... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3193/"
] | I am adventuring into some AOP and it seems with .NET PostSharp is the way to go.
I want to do some simple logging to the db when an exception occurs. However I am finding it difficult to find any real solid examples of using PostSharp beyond the basics. I tried the following:
```
[Serializable]
public sealed class ... | I got it to work by extending the `OnExceptionAspect`:
```
[Serializable]
public sealed class LogExceptionAttribute : OnExceptionAspect
{
public override void OnException(MethodExecutionEventArgs eventArgs)
{
//do some logging here
}
}
```
---
**Original Post:**
It wants you to add the Multicas... |
352,532 | <p><strong>Questions</strong>:</p>
<ul>
<li>What does the kernel do if you stick a shell-script into the shebang line? </li>
<li>How does the Kernel know which interpreter to launch?</li>
</ul>
<p><strong>Explanation</strong>:</p>
<p>I recently wanted to write a wrapper around <em>/usr/bin/env</em> because my CGI En... | [
{
"answer_id": 352830,
"author": "Piotr Lesnicki",
"author_id": 38796,
"author_profile": "https://Stackoverflow.com/users/38796",
"pm_score": 2,
"selected": false,
"text": "<p>You should carefully read the wikipedia article about <a href=\"http://en.wikipedia.org/wiki/Shebang_(Unix)\" re... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15274/"
] | **Questions**:
* What does the kernel do if you stick a shell-script into the shebang line?
* How does the Kernel know which interpreter to launch?
**Explanation**:
I recently wanted to write a wrapper around */usr/bin/env* because my CGI Environment does not allow me to set the *PATH* variable, except globally (whi... | First of all, you should very seldom use `$*` and you should almost always use `"$@"` instead. There are a number of questions here on SO which explain the ins and outs of why.
Second - the `env` command has two main uses. One is to print the current environment; the other is to completely control the environment of a... |
352,535 | <p>Aloha</p>
<p>I have a VS2008 solution to which I want to add a webservice reference. I enter an url like '<a href="http://192.168.100.87:7001/wsdl/IMySOAPWebService" rel="nofollow noreferrer">http://192.168.100.87:7001/wsdl/IMySOAPWebService</a>'. The Add Web Reference dialog starts looking then throws me this erro... | [
{
"answer_id": 352830,
"author": "Piotr Lesnicki",
"author_id": 38796,
"author_profile": "https://Stackoverflow.com/users/38796",
"pm_score": 2,
"selected": false,
"text": "<p>You should carefully read the wikipedia article about <a href=\"http://en.wikipedia.org/wiki/Shebang_(Unix)\" re... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6399/"
] | Aloha
I have a VS2008 solution to which I want to add a webservice reference. I enter an url like '<http://192.168.100.87:7001/wsdl/IMySOAPWebService>'. The Add Web Reference dialog starts looking then throws me this error:
>
> There was an error downloading
> '<http://192.168.100.87:7001/wsdl/IMySOAPWebService/>$... | First of all, you should very seldom use `$*` and you should almost always use `"$@"` instead. There are a number of questions here on SO which explain the ins and outs of why.
Second - the `env` command has two main uses. One is to print the current environment; the other is to completely control the environment of a... |
352,537 | <p>How can I extend a builtin class in python?
I would like to add a method to the str class.<br />
I've done some searching but all I'm finding is older posts, I'm hoping someone knows of something newer.</p>
| [
{
"answer_id": 352546,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 6,
"selected": true,
"text": "<p>Just subclass the type</p>\n\n<pre><code>>>> class X(str):\n... def my_method(self):\n... return int... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] | How can I extend a builtin class in python?
I would like to add a method to the str class.
I've done some searching but all I'm finding is older posts, I'm hoping someone knows of something newer. | Just subclass the type
```
>>> class X(str):
... def my_method(self):
... return int(self)
...
>>> s = X("Hi Mom")
>>> s.lower()
'hi mom'
>>> s.my_method()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in my_method
ValueError: invalid literal for int() w... |
352,538 | <p>I want the IIS server to return <code>HTTP 304 (Not Modified)</code> when a particular file is accessed. </p>
<p>How can I set this up? </p>
| [
{
"answer_id": 352546,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 6,
"selected": true,
"text": "<p>Just subclass the type</p>\n\n<pre><code>>>> class X(str):\n... def my_method(self):\n... return int... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38212/"
] | I want the IIS server to return `HTTP 304 (Not Modified)` when a particular file is accessed.
How can I set this up? | Just subclass the type
```
>>> class X(str):
... def my_method(self):
... return int(self)
...
>>> s = X("Hi Mom")
>>> s.lower()
'hi mom'
>>> s.my_method()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in my_method
ValueError: invalid literal for int() w... |
352,540 | <p>I'd like to create an XPS document for storing and printing.</p>
<p>What is the easiest way to create an XPS document (for example with a simple grid with some data inside) in my program, and to pass it around?</p>
| [
{
"answer_id": 352550,
"author": "BFree",
"author_id": 15861,
"author_profile": "https://Stackoverflow.com/users/15861",
"pm_score": 0,
"selected": false,
"text": "<p>All it is, is really XML. If you're comfortable working with XML files, you should have no problem working with XPS docum... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7021/"
] | I'd like to create an XPS document for storing and printing.
What is the easiest way to create an XPS document (for example with a simple grid with some data inside) in my program, and to pass it around? | Nothing easy about it. But it can be done. I've got some (sadly, still buggy) sample code and information on my blog for creating the document in memory.
Here's some code I whipped up for testing that encapsulates everything (it writes a collection of FixedPages to an XPS document in memory). It includes code for seri... |
352,543 | <p>This is a bit of a long question, but here we go. There is a version of FormatDateTime that is said to be thread safe in that you use </p>
<pre><code>GetLocaleFormatSettings(3081, FormatSettings);
</code></pre>
<p>to get a value and then you can use it like so; </p>
<pre><code>FormatDateTime('yyyy', 0, FormatSet... | [
{
"answer_id": 353173,
"author": "PetriW",
"author_id": 1604,
"author_profile": "https://Stackoverflow.com/users/1604",
"pm_score": 1,
"selected": false,
"text": "<p>As DateTimeToString which FormatDateTime calls uses GetThreadLocale, you may wish to try having a local FormatSettings var... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44574/"
] | This is a bit of a long question, but here we go. There is a version of FormatDateTime that is said to be thread safe in that you use
```
GetLocaleFormatSettings(3081, FormatSettings);
```
to get a value and then you can use it like so;
```
FormatDateTime('yyyy', 0, FormatSettings);
```
Now imagine two timers... | I am not sure if it is good form to post an "Answer" to my own question but it seemed logical, let me know if that is uncool.
I think I have found the problem, the thread local storage idea lead me to follow a bunch of leads and I found this magical line;
IsMultiThread := True;
From the help;
"IsMultiThread is set... |
352,544 | <p>I need a thread to wait until a file is exist or created.
I have the following code so far:</p>
<pre><code>while(!receivedDataFile.isFileExists("receiveddata.txt"))
{
try {
Thead.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
return null;
}
}
</code></pre>
... | [
{
"answer_id": 352548,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 2,
"selected": false,
"text": "<p>You should find out which thread interrupts that thread. Threads don’t do that on their own.</p>\n"
},
{
"answer_... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need a thread to wait until a file is exist or created.
I have the following code so far:
```
while(!receivedDataFile.isFileExists("receiveddata.txt"))
{
try {
Thead.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
return null;
}
}
```
When I run it, the foll... | You should find out which thread interrupts that thread. Threads don’t do that on their own. |
352,552 | <p>My table has a large number of columns. I have a command to copy some data - think of it as cloning a product - but as the columns may change in the future, I would like to only select everything from the table and only change the value of one column without having to refer to the rest.</p>
<p>Eg instead of:</p>
<... | [
{
"answer_id": 352558,
"author": "berlindev",
"author_id": 44276,
"author_profile": "https://Stackoverflow.com/users/44276",
"pm_score": 1,
"selected": false,
"text": "<p>Your example should almost work.\nJust add the column names of the new table to it.</p>\n\n<pre><code>\nINSERT INTO M... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23447/"
] | My table has a large number of columns. I have a command to copy some data - think of it as cloning a product - but as the columns may change in the future, I would like to only select everything from the table and only change the value of one column without having to refer to the rest.
Eg instead of:
```
INSERT INTO... | You could do this:
```
create table mytable_copy as select * from mytable;
update mytable_copy set id=new_id;
insert into mytable select * from mytable_copy;
drop table mytable_copy;
``` |
352,569 | <p>I have four tables containing exactly the same columns, and want to create a view over all four so I can query them together.</p>
<p>Is this possible?</p>
<p>(for tedious reasons I cannot/am not permitted to combine them, which would make this irrelevant!)</p>
| [
{
"answer_id": 352573,
"author": "rix",
"author_id": 11744,
"author_profile": "https://Stackoverflow.com/users/11744",
"pm_score": 2,
"selected": false,
"text": "<p>Use union. \n<a href=\"http://www.techonthenet.com/sql/union.php\" rel=\"nofollow noreferrer\">Here is explanation</a></p>\... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23447/"
] | I have four tables containing exactly the same columns, and want to create a view over all four so I can query them together.
Is this possible?
(for tedious reasons I cannot/am not permitted to combine them, which would make this irrelevant!) | Assuming that in addition to having the same column names, columns of the same contain the same data, you want to create a view that is the union of all those tables.
Something like the following should work, but my SQL is rusty:
```
(CREATE VIEW view_name AS
(SELECT * FROM table1
UNION
SELECT * FROM table2
UNION
SEL... |
352,586 | <p>I have an existing database of a film rental system. Each film has a has a rating attribute. In SQL they used a constraint to limit the allowed values of this attribute.</p>
<pre><code>CONSTRAINT film_rating_check CHECK
((((((((rating)::text = ''::text) OR
((rating)::text = 'G'::text)) OR
... | [
{
"answer_id": 352680,
"author": "Andreas Petersson",
"author_id": 16542,
"author_profile": "https://Stackoverflow.com/users/16542",
"pm_score": 2,
"selected": false,
"text": "<p>i don't know internals of toplink, but my educated guess is the following: it uses the Rating.valueOf(String... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44002/"
] | I have an existing database of a film rental system. Each film has a has a rating attribute. In SQL they used a constraint to limit the allowed values of this attribute.
```
CONSTRAINT film_rating_check CHECK
((((((((rating)::text = ''::text) OR
((rating)::text = 'G'::text)) OR
((rating)::te... | Sounds like you need to add support for a custom type:
[Extending OracleAS TopLink to Support Custom Type Conversions](http://www.oracle.com/technetwork/middleware/ias/index-097678.html) |
352,592 | <p>I use <a href="http://msdn.microsoft.com/en-us/library/system.web.services.webmethodattribute.aspx" rel="nofollow noreferrer">System.Web.Services.WebMethodAttribute</a> to make a public static method of an ASP.NET page callable from a client-side script:</p>
<p><strong><em>test.aspx.cs</em></strong></p>
<pre><code... | [
{
"answer_id": 352680,
"author": "Andreas Petersson",
"author_id": 16542,
"author_profile": "https://Stackoverflow.com/users/16542",
"pm_score": 2,
"selected": false,
"text": "<p>i don't know internals of toplink, but my educated guess is the following: it uses the Rating.valueOf(String... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] | I use [System.Web.Services.WebMethodAttribute](http://msdn.microsoft.com/en-us/library/system.web.services.webmethodattribute.aspx) to make a public static method of an ASP.NET page callable from a client-side script:
***test.aspx.cs***
```
[System.Web.Services.WebMethod]
public static string GetResult()
{
return... | Sounds like you need to add support for a custom type:
[Extending OracleAS TopLink to Support Custom Type Conversions](http://www.oracle.com/technetwork/middleware/ias/index-097678.html) |
352,599 | <p>i remember there being a way of marking a section of code in eclipse (special comment or annotation?) which made the autoformatter ignore that section. Or I may have drempt this...</p>
<p>Used mainly when I have strings which wrap onto several lines and i don't want the autoformatter to rearrange this.</p>
| [
{
"answer_id": 352609,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 2,
"selected": false,
"text": "<p>I only know the answer for comments:</p>\n\n<p>Eclipse is smart enough to only re-format the comments where the g... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44579/"
] | i remember there being a way of marking a section of code in eclipse (special comment or annotation?) which made the autoformatter ignore that section. Or I may have drempt this...
Used mainly when I have strings which wrap onto several lines and i don't want the autoformatter to rearrange this. | Since eclipse 3.5 (or 3.6) this is possible:
- Go to project properties -- Java Code Style -- Formatter -- Edit...
- choose the tab marked "Off/On Tags",
- include the tags in comments in your source code, like
```
/* @formatter:on */
``` |
352,600 | <p>Without using any third party program to do this (i.e. without VMware ThinApp, U3 or MojoPac etc.) How to move MSVC++ 6.0 from from its install on C: over to a USB drive? So that it can be used on different PCs with no admin rights and without installing anything on the host PC? Even if it's only usable as a console... | [
{
"answer_id": 353007,
"author": "EvilTeach",
"author_id": 7734,
"author_profile": "https://Stackoverflow.com/users/7734",
"pm_score": 1,
"selected": false,
"text": "<p>I am not sure exactly how one would do that.</p>\n\n<p>Here are a few ideas.</p>\n\n<p>The installation procedure creat... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25093/"
] | Without using any third party program to do this (i.e. without VMware ThinApp, U3 or MojoPac etc.) How to move MSVC++ 6.0 from from its install on C: over to a USB drive? So that it can be used on different PCs with no admin rights and without installing anything on the host PC? Even if it's only usable as a console ap... | Move the two folders that install created under `c:\program files\` to the USB drive (e.g. to `e:\progs\msvc\msvc6` and `e:\progs\msvc\vc98`), and append to the file `e:\progs\msvc\vc98\bin\vcvars32.bat` to suit e.g.
```
prompt $g
set path=e:\progs\uedit;e:\progs\utl;%PATH%
e:
cd e:\work
start e:\progs\uedit\uedit32.e... |
352,605 | <p>I'm trying to debug a rather complicated formula evaluator written in T-SQL UDFs (don't ask) that <strong>recursively</strong> (but indirectly through an intermediate function) calls itself, blah, blah.</p>
<p>And, of course, we have a bug.</p>
<p>Now, using PRINT statements (that can then be read from ADO.NET by ... | [
{
"answer_id": 352615,
"author": "SqlACID",
"author_id": 19797,
"author_profile": "https://Stackoverflow.com/users/19797",
"pm_score": 6,
"selected": true,
"text": "<p>Why not use SQL Profiler with statement level events added?</p>\n\n<p><strong>Edit</strong>: Add events for Stored Proce... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2260/"
] | I'm trying to debug a rather complicated formula evaluator written in T-SQL UDFs (don't ask) that **recursively** (but indirectly through an intermediate function) calls itself, blah, blah.
And, of course, we have a bug.
Now, using PRINT statements (that can then be read from ADO.NET by implementing a handler for the... | Why not use SQL Profiler with statement level events added?
**Edit**: Add events for Stored Procedures : SP:Stmt Starting or SP:Stmt Completed
Use variables to debug if needed, i.e. set @debug='i am here'; UDF's, while not technically stored procedures, will get traced with the statement level events. |
352,612 | <p>I have a Maven pom that uses <code><packaging>war</packaging></code>. But actually, I don't want build the war-file, I just want all the dependent jars collected and a full deployment directory created.</p>
<p>So I'm running the <code>war:exploded</code> goal to generate the deploy directory:</p>
<pre... | [
{
"answer_id": 375823,
"author": "l15a",
"author_id": 33178,
"author_profile": "https://Stackoverflow.com/users/33178",
"pm_score": 0,
"selected": false,
"text": "<p>As far as I know (I'm still new to maven) this is not possible. The only default lifecycle you can skip is 'test'. In or... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41861/"
] | I have a Maven pom that uses `<packaging>war</packaging>`. But actually, I don't want build the war-file, I just want all the dependent jars collected and a full deployment directory created.
So I'm running the `war:exploded` goal to generate the deploy directory:
```
<plugin>
<groupId>org.apache.maven.plugins</g... | According [builtin lifecycle bindings](http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Built-in_Lifecycle_Bindings) for war packaging in package phase war:war mojo is called.
You can call previous 'prepare-package' phase - all actions will be performed and after that call mojo war:explod... |
352,623 | <p>I have to interface with a slightly archaic system that doesn't use webservices. In order to send data to this system, I need to post an XML document into a <i>form</i> on the other system's website. This XML document can get very large so I would like to compress it.
The other system sits on IIS and I use C# my en... | [
{
"answer_id": 352656,
"author": "VVS",
"author_id": 21038,
"author_profile": "https://Stackoverflow.com/users/21038",
"pm_score": 2,
"selected": false,
"text": "<p>I see no way to compress the data on one side and receiving them uncompressed on the other side without actively uncompress... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11534/"
] | I have to interface with a slightly archaic system that doesn't use webservices. In order to send data to this system, I need to post an XML document into a *form* on the other system's website. This XML document can get very large so I would like to compress it.
The other system sits on IIS and I use C# my end. I cou... | No idea if this will work since all of the examples I could find were for download, but you could try using gzip to compress the data, then set the Content-Encoding header on the outgoing message to `gzip`. I believe that the Length should be the length of the zipped message, although you may want to play with making i... |
352,632 | <p>I'm making a WPF application that is comprised of Screens (Presenter + View). I want to be able to declare these screens in a config file or SQL database. I have been trying to come up with a good solution I've given up and am asking how some of you design this sort of thing? I've been working at this for over a wee... | [
{
"answer_id": 352656,
"author": "VVS",
"author_id": 21038,
"author_profile": "https://Stackoverflow.com/users/21038",
"pm_score": 2,
"selected": false,
"text": "<p>I see no way to compress the data on one side and receiving them uncompressed on the other side without actively uncompress... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36383/"
] | I'm making a WPF application that is comprised of Screens (Presenter + View). I want to be able to declare these screens in a config file or SQL database. I have been trying to come up with a good solution I've given up and am asking how some of you design this sort of thing? I've been working at this for over a week a... | No idea if this will work since all of the examples I could find were for download, but you could try using gzip to compress the data, then set the Content-Encoding header on the outgoing message to `gzip`. I believe that the Length should be the length of the zipped message, although you may want to play with making i... |
352,633 | <p>I need to write a script to set ip address/mask/broadcast as an alias on eth0:0 plus set the default gateway.</p>
<p>This solution works:</p>
<pre><code>ifconfig eth0:0 <ip> netmask <mask> up
ip route replace default via <ip>
</code></pre>
<p>but sometimes the second call gets an error "network ... | [
{
"answer_id": 354798,
"author": "PiedPiper",
"author_id": 19315,
"author_profile": "https://Stackoverflow.com/users/19315",
"pm_score": 1,
"selected": false,
"text": "<p>You could use <code>ping -c1 -w</code> on the gateway address in a loop until it comes up.</p>\n"
},
{
"answe... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23420/"
] | I need to write a script to set ip address/mask/broadcast as an alias on eth0:0 plus set the default gateway.
This solution works:
```
ifconfig eth0:0 <ip> netmask <mask> up
ip route replace default via <ip>
```
but sometimes the second call gets an error "network unavailable".
Adding a sleep between them fixes it... | You could use `ping -c1 -w` on the gateway address in a loop until it comes up. |
352,646 | <p>I'd like to run JSLint4Java as part of my build process. I have about 1000 JS files in a library, and don't really want to add a</p>
<pre><code>/*globals foo, bar, baz */
</code></pre>
<p>header to each of them -- especially since many of them are from an external library (Dojo). If I don't add the header, thoug... | [
{
"answer_id": 4167395,
"author": "Mark Bessey",
"author_id": 17826,
"author_profile": "https://Stackoverflow.com/users/17826",
"pm_score": 3,
"selected": true,
"text": "<p>From <a href=\"http://www.ohloh.net/p/jslint4java\" rel=\"nofollow\">http://www.ohloh.net/p/jslint4java</a></p>\n\n... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | I'd like to run JSLint4Java as part of my build process. I have about 1000 JS files in a library, and don't really want to add a
```
/*globals foo, bar, baz */
```
header to each of them -- especially since many of them are from an external library (Dojo). If I don't add the header, though, JSLint complains about th... | From <http://www.ohloh.net/p/jslint4java>
>
> News 2009-12-02. jslint4java 1.3.3 is
> released. Noteworthy alterations: Add
> support for the predef option, to
> allow specifying a list of predefined
> global variables.
>
>
>
Sounds like what you might be looking for. Try the --help option to get the syntax, ... |
352,654 | <p>I've added a proxy to a webservice to a VS2008/.NET 3.5 solution. When constructing the client .NET throws this error:</p>
<blockquote>
<p>Could not find default endpoint element that references contract 'IMySOAPWebService' in the ServiceModel client configuration section. This might be because no configuaration ... | [
{
"answer_id": 356011,
"author": "edosoft",
"author_id": 6399,
"author_profile": "https://Stackoverflow.com/users/6399",
"pm_score": 7,
"selected": true,
"text": "<p>Having tested several options, I finally solved this by using </p>\n\n<blockquote>\n <p>contract=\"IMySOAPWebService\"</p... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6399/"
] | I've added a proxy to a webservice to a VS2008/.NET 3.5 solution. When constructing the client .NET throws this error:
>
> Could not find default endpoint element that references contract 'IMySOAPWebService' in the ServiceModel client configuration section. This might be because no configuaration file was found for y... | Having tested several options, I finally solved this by using
>
> contract="IMySOAPWebService"
>
>
>
i.e. without the full namespace in the config. For some reason the full name didn't resolve properly |
352,673 | <p>I know I can update a single record like this - but then how to I get access to the id of the record that was updated? (I'm using MSSQL so I can't use Oracles RowId)</p>
<pre><code>update myTable
set myCol = 'foo'
where itemId in (select top 1 itemId from myTable )
</code></pre>
<p>If I was peforming an Insert I ... | [
{
"answer_id": 352737,
"author": "Rich Andrews",
"author_id": 37381,
"author_profile": "https://Stackoverflow.com/users/37381",
"pm_score": 4,
"selected": true,
"text": "<p>This example works really well in MSSQL 2005...</p>\n\n<pre><code>SET ANSI_NULLS ON\nGO\nSET QUOTED_IDENTIFIER ON\n... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44538/"
] | I know I can update a single record like this - but then how to I get access to the id of the record that was updated? (I'm using MSSQL so I can't use Oracles RowId)
```
update myTable
set myCol = 'foo'
where itemId in (select top 1 itemId from myTable )
```
If I was peforming an Insert I could use getGeneratedKeys ... | This example works really well in MSSQL 2005...
```
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
DROP TABLE [dbo].[TEST_TABLE]
GO
CREATE TABLE [dbo].[TEST_TABLE](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
CONSTRAINT [PK_TEST_TABLE] PRIMARY K... |
352,676 | <p>I know how to connect to web server using an iPhone but now I have to connect the iPhone to a web service. I don't know how to do it and there is no demo or class available online.</p>
<p>Does anyone have any ideas?</p>
| [
{
"answer_id": 352700,
"author": "Guido",
"author_id": 12388,
"author_profile": "https://Stackoverflow.com/users/12388",
"pm_score": 2,
"selected": false,
"text": "<p>In my opinion, you have two options :</p>\n\n<ul>\n<li>Use a third party library. You can try <a href=\"http://code.googl... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I know how to connect to web server using an iPhone but now I have to connect the iPhone to a web service. I don't know how to do it and there is no demo or class available online.
Does anyone have any ideas? | You can use these 2 lines which return the response of your HTTP request. You don't need any configuration. This code is usefull if you try to access a PHP scritp for example. After you just have to parse your result.
```
NSURL *URL=[[NSURL alloc] initWithString:stringForURL];
NSString *results = [[NSString alloc] ini... |
352,693 | <pre><code>class Trial
{ static int i;
int getI()
{ return i;}
void setI(int value)
{ i = value;}
}
public class ttest
{ public static void main(String args[])
{ Trial t1 = new Trial();
t1.setI(10);
System.out.println(t1.getI());
Trial t2 = new Tr... | [
{
"answer_id": 352702,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 2,
"selected": false,
"text": "<p>Yes it's the correct way.</p>\n\n<p>When a class is not static you need to instance it with new keyword. Lik... | 2008/12/09 | [
"https://Stackoverflow.com/questions/352693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
class Trial
{ static int i;
int getI()
{ return i;}
void setI(int value)
{ i = value;}
}
public class ttest
{ public static void main(String args[])
{ Trial t1 = new Trial();
t1.setI(10);
System.out.println(t1.getI());
Trial t2 = new Trial(); ... | Yes it's the correct way.
When a class is not static you need to instance it with new keyword. Like you did
```
Trial t1 = new Trial();
```
The static variable i shouldn't be static if you do not want to share its value between all Trial object. If you want to use this value (in "sharing mode") you can do it the ... |