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
376,468
<p>I'm using selenium to run some functional tests on the UI for our current application. </p> <p>I want to ensure that strings from the resource files in the Web project are being displayed at the correct time and place.</p> <p>Simple (I thought) all I have to do is reference the assembly of the web application and ...
[ { "answer_id": 376490, "author": "Draemon", "author_id": 26334, "author_profile": "https://Stackoverflow.com/users/26334", "pm_score": 0, "selected": false, "text": "<p>I use substitution wherever I can. I only use concatenation if I'm building a string up in say a for-loop.</p>\n" }, ...
2008/12/17
[ "https://Stackoverflow.com/questions/376468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42975/" ]
I'm using selenium to run some functional tests on the UI for our current application. I want to ensure that strings from the resource files in the Web project are being displayed at the correct time and place. Simple (I thought) all I have to do is reference the assembly of the web application and assert that the t...
Concatenation is (significantly) faster according to my machine. But stylistically, I'm willing to pay the price of substitution if performance is not critical. Well, and if I need formatting, there's no need to even ask the question... there's no option but to use interpolation/templating. ``` >>> import timeit >>> d...
376,471
<p>I have two routes:</p> <pre><code>routes.MapRoute( "FetchVenue", "venue/fetchlike/{q}", new { controller = "venue", action = "fetchlike" } ); routes.MapRoute( "venue", ...
[ { "answer_id": 376476, "author": "Strelok", "author_id": 2788, "author_profile": "https://Stackoverflow.com/users/2788", "pm_score": 2, "selected": false, "text": "<p>Just off the top of my head, shouldn't your URL look like <code>/venue/fetchlike?q=test</code>, instead of <code>/venue/f...
2008/12/17
[ "https://Stackoverflow.com/questions/376471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46616/" ]
I have two routes: ``` routes.MapRoute( "FetchVenue", "venue/fetchlike/{q}", new { controller = "venue", action = "fetchlike" } ); routes.MapRoute( "venue", ...
Just off the top of my head, shouldn't your URL look like `/venue/fetchlike?q=test`, instead of `/venue/fetchlike/?q=test`
376,502
<p>I have a database table called "Posts" which stores all the information regarding an article submission on a website. There is a column named "Views" which is a value that gets incremented each time that particular post gets viewed. </p> <p>The process is this:</p> <ol> <li>Get the record from the database </li> <...
[ { "answer_id": 376509, "author": "Martijn Laarman", "author_id": 47020, "author_profile": "https://Stackoverflow.com/users/47020", "pm_score": 4, "selected": true, "text": "<p>Do it in one go:</p>\n\n<pre><code>UPDATE table SET views=views+1 WHERE myId=12;\n</code></pre>\n" }, { ...
2008/12/18
[ "https://Stackoverflow.com/questions/376502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
I have a database table called "Posts" which stores all the information regarding an article submission on a website. There is a column named "Views" which is a value that gets incremented each time that particular post gets viewed. The process is this: 1. Get the record from the database 2. Increment the current by...
Do it in one go: ``` UPDATE table SET views=views+1 WHERE myId=12; ```
376,513
<p>When I get exceptions, it is often from deep within the call stack. When this happens, more often than not, the actual offending line of code is hidden from me:</p> <pre class="lang-none prettyprint-override"><code>tmp.rb:7:in `t': undefined method `bar' for nil:NilClass (NoMethodError) from tmp.rb:10:in `...
[ { "answer_id": 376521, "author": "Gareth", "author_id": 31582, "author_profile": "https://Stackoverflow.com/users/31582", "pm_score": 9, "selected": true, "text": "<p>Exception#backtrace has the entire stack in it:</p>\n\n<pre><code>def do_division_by_zero; 5 / 0; end\nbegin\n do_divisi...
2008/12/18
[ "https://Stackoverflow.com/questions/376513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30997/" ]
When I get exceptions, it is often from deep within the call stack. When this happens, more often than not, the actual offending line of code is hidden from me: ```none tmp.rb:7:in `t': undefined method `bar' for nil:NilClass (NoMethodError) from tmp.rb:10:in `s' from tmp.rb:13:in `r' from tmp....
Exception#backtrace has the entire stack in it: ``` def do_division_by_zero; 5 / 0; end begin do_division_by_zero rescue => exception puts exception.backtrace raise # always reraise end ``` (Inspired by Peter Cooper's [Ruby Inside](http://www.rubyinside.com/21-ruby-tricks-902.html) blog)
376,518
<p>Although this question looks simple, it is kind of tricky.</p> <p>Consider the following table:</p> <pre><code>CREATE TABLE A ( id INT, value FLOAT, &quot;date&quot; DATETIME, group VARCHAR(50) ); </code></pre> <p>I would like to obtain the <code>ID</code> and <code>value</code> of the records that contain ...
[ { "answer_id": 376535, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 3, "selected": false, "text": "<p>You could try with a subquery</p>\n\n<pre>\nselect group, id, value, date from A where date in\n( select MAX(date...
2008/12/18
[ "https://Stackoverflow.com/questions/376518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10833/" ]
Although this question looks simple, it is kind of tricky. Consider the following table: ``` CREATE TABLE A ( id INT, value FLOAT, "date" DATETIME, group VARCHAR(50) ); ``` I would like to obtain the `ID` and `value` of the records that contain the maximum `date` grouped by the column `group`. In other wor...
You could try with a subquery ``` select group, id, value, date from A where date in ( select MAX(date) as date from A group by group ) order by group ```
376,519
<p>Opinions: I want to disallow direct invocation of certain scripts, that have functionality accessible from a menu, via Web at the OS level (Linux). </p> <p>I was hoping to call a authorize.pl script that checks the session validity, checks user privileges etc. Then it will redirect to the target script. </p> <p...
[ { "answer_id": 376535, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 3, "selected": false, "text": "<p>You could try with a subquery</p>\n\n<pre>\nselect group, id, value, date from A where date in\n( select MAX(date...
2008/12/18
[ "https://Stackoverflow.com/questions/376519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Opinions: I want to disallow direct invocation of certain scripts, that have functionality accessible from a menu, via Web at the OS level (Linux). I was hoping to call a authorize.pl script that checks the session validity, checks user privileges etc. Then it will redirect to the target script. Does this get aroun...
You could try with a subquery ``` select group, id, value, date from A where date in ( select MAX(date) as date from A group by group ) order by group ```
376,524
<p>I am trying to send some data from a LINQ query in C# to an Excel speed sheet using OLE</p> <p>I have a query like this:</p> <pre><code>Var data = from d in db.{MyTable} where d.Name = "Test" select d; </code></pre> <p>I have the Excel OLE object working fine, I just can't figure out how to ...
[ { "answer_id": 376543, "author": "kwcto", "author_id": 45852, "author_profile": "https://Stackoverflow.com/users/45852", "pm_score": 0, "selected": false, "text": "<p>I assume you are not using OLE in a web scenario, because it will eventually fail. </p>\n\n<p>If you just need raw data,...
2008/12/18
[ "https://Stackoverflow.com/questions/376524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
I am trying to send some data from a LINQ query in C# to an Excel speed sheet using OLE I have a query like this: ``` Var data = from d in db.{MyTable} where d.Name = "Test" select d; ``` I have the Excel OLE object working fine, I just can't figure out how to populate the cells in Excel with ...
Sending individual OLE commands for each Excel cell is very slow so the key is to create an object array like this: ``` int noOfRows = data.Count - 1; int noOfColumns = mydataclass.GetType().GetProperties().Count() - 1; Object[noOfRows, noOfColumns] myArray; ``` Sending an object array allows you to send a mixture o...
376,544
<p>How do I increase the maxPoolSize in Grails when using mysql? It appears to be using a default connection pool only 8 connections. </p>
[ { "answer_id": 377493, "author": "Siegfried Puchbauer", "author_id": 46301, "author_profile": "https://Stackoverflow.com/users/46301", "pm_score": 4, "selected": true, "text": "<p>Unfortunately you will need to configure the dataSource spring bean for yourself if you want to gain more co...
2008/12/18
[ "https://Stackoverflow.com/questions/376544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6580/" ]
How do I increase the maxPoolSize in Grails when using mysql? It appears to be using a default connection pool only 8 connections.
Unfortunately you will need to configure the dataSource spring bean for yourself if you want to gain more control over it. This can be done by defining the bean in "grails-app/conf/spring/resources.groovy" ``` beans = { dataSource(org.apache.commons.dbcp.BasicDataSource) { driverClassName = "com.mysql.jdbc.D...
376,557
<p>I have a class named Page with a private property currently called <code>_pageData</code> which stores all the information (such as title, content, keywords etc). </p> <p>However, this to me doesn't look so good when I refer to it <code>$this-&gt;_pageData</code>. I want to think of a better name, and I'd imagine t...
[ { "answer_id": 376569, "author": "rfgamaral", "author_id": 40480, "author_profile": "https://Stackoverflow.com/users/40480", "pm_score": 0, "selected": false, "text": "<p>That's very specific and I don't think there is a \"standard\" or \"best practice\". Just call it whatever it feels b...
2008/12/18
[ "https://Stackoverflow.com/questions/376557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
I have a class named Page with a private property currently called `_pageData` which stores all the information (such as title, content, keywords etc). However, this to me doesn't look so good when I refer to it `$this->_pageData`. I want to think of a better name, and I'd imagine there would probably be a standard o...
``` class Page { public $title = ''; public $keywords = array(); public $content = ''; // etc. } $page = new Page(); echo '<title>' . $page->title . '</title>'; echo $page->content; ``` Or you can use accessors/get-set and the like to protect your data, allow it to be modified with persistence, or wh...
376,570
<p>Is there a best practice for instantiating / calling business logic layer service in a web app? I've got a large number services that I keep instantiating and then disposing for just one method call. </p> <p>Should these be implemented as providers? Or maybe accessed from a singleton?</p> <p>Example code:</p> <...
[ { "answer_id": 376575, "author": "Zachary Yates", "author_id": 8360, "author_profile": "https://Stackoverflow.com/users/8360", "pm_score": 2, "selected": false, "text": "<p>I've done both actually. It depends on what goal you are trying to accomplish. If you're trying to increase the br...
2008/12/18
[ "https://Stackoverflow.com/questions/376570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47261/" ]
Is there a best practice for instantiating / calling business logic layer service in a web app? I've got a large number services that I keep instantiating and then disposing for just one method call. Should these be implemented as providers? Or maybe accessed from a singleton? Example code: ``` void ShipProduct(){ ...
I've done both actually. It depends on what goal you are trying to accomplish. If you're trying to increase the brevity of your code, a singleton / static reference to the service you're trying to call helps. ``` Services.ProductService.Ship(aProduct) ``` However, you have to remember that anything you put into a si...
376,582
<p>I'm having difficulty searching for this. How would I define an element in an XML schema file for XML that looks like this:</p> <pre><code>&lt;option value="test"&gt;sometext&lt;/option&gt; </code></pre> <p>I can't figure out how to define an element that is of type <code>xs:string</code> and also has an attribute...
[ { "answer_id": 376713, "author": "David Norman", "author_id": 34502, "author_profile": "https://Stackoverflow.com/users/34502", "pm_score": 9, "selected": true, "text": "<p>Try</p>\n\n<pre><code> &lt;xs:element name=\"option\" type=\"AttrElement\" /&gt;\n\n &lt;xs:complexType name=\"At...
2008/12/18
[ "https://Stackoverflow.com/questions/376582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5291/" ]
I'm having difficulty searching for this. How would I define an element in an XML schema file for XML that looks like this: ``` <option value="test">sometext</option> ``` I can't figure out how to define an element that is of type `xs:string` and also has an attribute. Here's what I've got so far: ``` <xs:element...
Try ``` <xs:element name="option" type="AttrElement" /> <xs:complexType name="AttrElement"> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="value" type="xs:string"> </xs:attribute> </xs:extension> </xs:simpleContent> </xs:complexType> ```
376,598
<p>If I do something like this:</p> <pre><code>using (SqlCommand cmd = new SqlCommand("SELECT * FROM TBL")) { using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { string s = reader.GetString(7); } } } </code></pre> <p>does the Read() call read th...
[ { "answer_id": 376602, "author": "lomaxx", "author_id": 493, "author_profile": "https://Stackoverflow.com/users/493", "pm_score": 3, "selected": true, "text": "<p>it reads the whole row on the read operation.</p>\n" }, { "answer_id": 384197, "author": "MatthewMartin", "au...
2008/12/18
[ "https://Stackoverflow.com/questions/376598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14606/" ]
If I do something like this: ``` using (SqlCommand cmd = new SqlCommand("SELECT * FROM TBL")) { using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { string s = reader.GetString(7); } } } ``` does the Read() call read the entire row into memory, ...
it reads the whole row on the read operation.
376,622
<p>C#: How do you save a list of items like a Combobox to the .NET Settings file?</p>
[ { "answer_id": 376643, "author": "Zachary Yates", "author_id": 8360, "author_profile": "https://Stackoverflow.com/users/8360", "pm_score": 2, "selected": false, "text": "<p>If you are talking about the Application User Settings, I'd loop through the combobox and save the values in a deli...
2008/12/18
[ "https://Stackoverflow.com/questions/376622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
C#: How do you save a list of items like a Combobox to the .NET Settings file?
The only collection type of use that the Settings Designer lets you use is System.Collections.ArrayList. If you do use an ArrayList, all of its elements' types must be serializable (have the [Serializable] attribute or implement System.Runtime.Serialization.ISerializable.) Here's some code to get data from an ArrayLis...
376,623
<p>I'm just wondering if there is a quick way to echo undefined variables without getting a warning? (I can change error reporting level but I don't want to.) The smallest I have so far is:</p> <p><code>isset($variable)?$variable:''</code></p> <p>I dislike this for a few reasons:</p> <ul> <li>It's a bit "wordy" and ...
[ { "answer_id": 376628, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 4, "selected": false, "text": "<p>You can run it with the <a href=\"http://www.php.net/operators.errorcontrol\" rel=\"noreferrer\">error suppressio...
2008/12/18
[ "https://Stackoverflow.com/questions/376623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37947/" ]
I'm just wondering if there is a quick way to echo undefined variables without getting a warning? (I can change error reporting level but I don't want to.) The smallest I have so far is: `isset($variable)?$variable:''` I dislike this for a few reasons: * It's a bit "wordy" and complex * `$variable` is repeated * The...
you could use the ifsetor() example taken from [here](http://wiki.php.net/rfc/ifsetor): ``` function ifsetor(&$variable, $default = null) { if (isset($variable)) { $tmp = $variable; } else { $tmp = $default; } return $tmp; } ``` for example: ``` echo ifsetor($variable); echo ifsetor(...
376,642
<p>I'm not really sure how to title this question but basically I have an interface like this:</p> <pre><code>public interface IFoo { string ToCMD(); } </code></pre> <p>a couple of absract classes which implement IFoo like:</p> <pre><code>public abstract class Foo : IFoo { public abstract string ToCMD(); } p...
[ { "answer_id": 376648, "author": "Zachary Yates", "author_id": 8360, "author_profile": "https://Stackoverflow.com/users/8360", "pm_score": 1, "selected": false, "text": "<p>Well, that's what the where keyword is for. You probably need to evaluate your object model to make sure that the ...
2008/12/18
[ "https://Stackoverflow.com/questions/376642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
I'm not really sure how to title this question but basically I have an interface like this: ``` public interface IFoo { string ToCMD(); } ``` a couple of absract classes which implement IFoo like: ``` public abstract class Foo : IFoo { public abstract string ToCMD(); } public abstract class Bar : IFoo { ...
The need for an inheritance chain is questionable, in general. However the specific scenario of combining an abstract base class with an interface.. I see it this way: If you have an abstract base class like this, you should also have a corresponding interface. If you have an interface, then use the abstract base cl...
376,644
<p>When doing a Ajax call to an MVC action currently I have my javascript inside the View, not inside its own JS file.</p> <p>It is then very easy to do this:</p> <pre><code>var xhr = $.ajax({ url: '&lt;%= Url.Action("DisplayItem","Home") %&gt;/' + el1.siblings("input:hidden").val(), data: { ajax: "Y" }, ...
[ { "answer_id": 376656, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "<p>Wrap the AJAX call in a function that takes the URL (and any other data) as a parameter(s) and returns the response....
2008/12/18
[ "https://Stackoverflow.com/questions/376644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29376/" ]
When doing a Ajax call to an MVC action currently I have my javascript inside the View, not inside its own JS file. It is then very easy to do this: ``` var xhr = $.ajax({ url: '<%= Url.Action("DisplayItem","Home") %>/' + el1.siblings("input:hidden").val(), data: { ajax: "Y" }, cache: false, succe...
This way fully uses MVC Routing so you can fully take advantage of the MVC framework. Inspired by stusmith's answer. Here I have an action in `ApplicationController` for dynamic javascript for this URL : ``` /application/js ``` I'm including static files here because I want just one master javascript file to downl...
376,655
<p>I am having a problem setting the Authorize attribute Role value from a variable. The error message says it requires a const variable. When I create a const type variable it works fine but I am trying to load the value from the Web.Config file or anything else that will allow the end user to set this. I'm using in...
[ { "answer_id": 376670, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "<p>You can use <code>User.InRole( \"RoleName\" )</code> within a controller.</p>\n\n<p><strong>EDIT: The code below will...
2008/12/18
[ "https://Stackoverflow.com/questions/376655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45509/" ]
I am having a problem setting the Authorize attribute Role value from a variable. The error message says it requires a const variable. When I create a const type variable it works fine but I am trying to load the value from the Web.Config file or anything else that will allow the end user to set this. I'm using integra...
You can use `User.InRole( "RoleName" )` within a controller. **EDIT: The code below will not work since GetCustomAttributes() apparently returns a copy of each attribute instead of a reference to the actual attribute. Left as answer to provide context for other answers.** As far as setting it in the authorize attribu...
376,657
<p>What's the best algorithm to find the smallest non zero positive value from a fixed number (in this case 3) of values or return 0 if there are no positive questions?</p> <p>My naive approach is below (in Delphi, but feel free to use whatever you like), but I think there's a more elegant way.</p> <pre><code>value1T...
[ { "answer_id": 376666, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 2, "selected": false, "text": "<p>I'd do a little loop (This is in C, I'm not a Delphi guy):</p>\n\n<pre><code>int maxPositiveValue(int *number, int li...
2008/12/18
[ "https://Stackoverflow.com/questions/376657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/233/" ]
What's the best algorithm to find the smallest non zero positive value from a fixed number (in this case 3) of values or return 0 if there are no positive questions? My naive approach is below (in Delphi, but feel free to use whatever you like), but I think there's a more elegant way. ``` value1Temp := MaxInt; value2...
I'd do this: > > Result := MaxInt; > > if value1 > 0 then Result := min(Result, value1); > > > > If you want it in a loop with an arbitrary number of questions, then: > > Result := MaxInt; > > for I := 1 to N do > >    if value[I] > 0 then Result := min(Result, value[I]); > > if Result = MaxI...
376,683
<p><strong>Problem:</strong> I am looking for a way to run a test that is able to disambiguate between select controls that have the same value in more than one place.</p> <p><strong>Example:</strong> </p> <p>I am trying to choose the third "monday" from a select control</p> <pre><code>ie.select_list( :id , 'choose-...
[ { "answer_id": 376957, "author": "Moss Collum", "author_id": 13210, "author_profile": "https://Stackoverflow.com/users/13210", "pm_score": 3, "selected": true, "text": "<p>It looks like you could use element_by_xpath to find the option you want, with something like this:</p>\n\n<pre>\n//...
2008/12/18
[ "https://Stackoverflow.com/questions/376683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42223/" ]
**Problem:** I am looking for a way to run a test that is able to disambiguate between select controls that have the same value in more than one place. **Example:** I am trying to choose the third "monday" from a select control ``` ie.select_list( :id , 'choose-day' ).set( '-monday' ); ``` where the select contro...
It looks like you could use element\_by\_xpath to find the option you want, with something like this: ``` //select/option[text()='charlie']/following::option[text()='-monday'] ``` then you could check the value attribute of that option (not sure how to do this in Watir), and select it using: ``` ie.select_list( :i...
376,698
<p>I've a question about KConfig usage. I'm able to write and read settings in my .kde4/share/config/_appname_rc configuration file like that</p> <pre><code> KConfig basicconf; KConfigGroup conf = KConfigGroup(basicconf.group("Settings")); conf.writeEntry("filepath",QString("/path/")); basicconf.sync(); </code></pr...
[ { "answer_id": 377607, "author": "Bille", "author_id": 47358, "author_profile": "https://Stackoverflow.com/users/47358", "pm_score": 1, "selected": false, "text": "<p>Use <a href=\"http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/namespaceKGlobal.html#f056d0c68c6a17389f084a8112d2d...
2008/12/18
[ "https://Stackoverflow.com/questions/376698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39796/" ]
I've a question about KConfig usage. I'm able to write and read settings in my .kde4/share/config/\_appname\_rc configuration file like that ``` KConfig basicconf; KConfigGroup conf = KConfigGroup(basicconf.group("Settings")); conf.writeEntry("filepath",QString("/path/")); basicconf.sync(); ``` But I don't under...
First, this: KConfigGroup conf = KConfigGroup(basicconf.group("Settings")); can be written more clearly, at least imho, as: KConfigGroup conf(&basicconf, "Settings"); Also note that "General" is the most common "generic" group name used. Anyways... You can install a default config file with your application; insta...
376,723
<p>I'm having trouble capturing this data:</p> <pre><code> &lt;tr&gt; &lt;td&gt;&lt;span class="bodytext"&gt;&lt;b&gt;Contact:&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style='font-size:10.0pt;font-family:Verdana; mso-bidi-font-family:Arial'&gt;&lt;b&gt; &lt;/b&gt; ...
[ { "answer_id": 376746, "author": "Jan Goyvaerts", "author_id": 33358, "author_profile": "https://Stackoverflow.com/users/33358", "pm_score": 2, "selected": false, "text": "<p>If I understand you correctly, you're only interested in the text between the HTML tags. To ignore the HTML tags...
2008/12/18
[ "https://Stackoverflow.com/questions/376723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24416/" ]
I'm having trouble capturing this data: ``` <tr> <td><span class="bodytext"><b>Contact:</b><b></b></span><span style='font-size:10.0pt;font-family:Verdana; mso-bidi-font-family:Arial'><b> </b> <span class="bodytext">John Doe</span> </span></t...
If I understand you correctly, you're only interested in the text between the HTML tags. To ignore the HTML tags, simply strip them first: ``` $text = preg_replace('/<[^<>]+>/', '', $html); ``` To grab everything between "Contact:" and "Phone:", use: ``` if (preg_match('/Contact:(.*?)Phone:/s', $text, $regs)) { $...
376,732
<p>The Zend Framework based site I have been working on is now being migrated to its production server. This server turns out to be nginx (surprise!). Naturally the site does not work correctly as it was developed on Apache and relies on an htaccess file. </p> <p>My question is... anyone have any experience with this?...
[ { "answer_id": 376743, "author": "mooware", "author_id": 35951, "author_profile": "https://Stackoverflow.com/users/35951", "pm_score": 4, "selected": false, "text": "<p>I don't know of any automatic/systematic way to convert the htaccess-file, you'll probably have to do it manually. The ...
2008/12/18
[ "https://Stackoverflow.com/questions/376732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11252/" ]
The Zend Framework based site I have been working on is now being migrated to its production server. This server turns out to be nginx (surprise!). Naturally the site does not work correctly as it was developed on Apache and relies on an htaccess file. My question is... anyone have any experience with this? Any ideas...
I know it's a pretty old thread but it might help some people anyway. Basically it redirects any 404 error to index.php, but if the file exists (type file) it will set the right root. I did it from the top of my head. It might not be working right away, and you have to put the right path and fastcgi config. I also pu...
376,738
<p>I'm writing a PHP application with testability in mind, so my classes always ask in their constructors for the "collaborator objects" they depend on, in respect to the Dependency Injection pattern.</p> <p>That way, I'm able to pass in mocks or test implementations in my unit tests.</p> <p>What I want to achieve th...
[ { "answer_id": 377090, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "<p>Of course you'd better use an IoC/DIP container to do the job. Your code above (the if statements) increase the coupling of...
2008/12/18
[ "https://Stackoverflow.com/questions/376738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38072/" ]
I'm writing a PHP application with testability in mind, so my classes always ask in their constructors for the "collaborator objects" they depend on, in respect to the Dependency Injection pattern. That way, I'm able to pass in mocks or test implementations in my unit tests. What I want to achieve though, is to be ab...
Of course you'd better use an IoC/DIP container to do the job. Your code above (the if statements) increase the coupling of the classes. The client class (Engine) should not care what’s implementing the loader and logger roles. That’s the factory’s or DIP container work to know this. By putting a concrete class name in...
376,762
<p>I am running a query on Sybase ASE that produces a <code>ResultSet</code> that I then traverse and write the contents out to a file. Sometimes, this will throw a <code>NullPointerException</code>, stating that the <code>ResultSet</code> is <code>null</code>. However, it will do this after printing out one or two rec...
[ { "answer_id": 376806, "author": "Adeel Ansari", "author_id": 42769, "author_profile": "https://Stackoverflow.com/users/42769", "pm_score": 2, "selected": false, "text": "<p>I hope you will be doing it well, I mean after calling <em>rs.next()</em>. </p>\n\n<p>According to the specs. the ...
2008/12/18
[ "https://Stackoverflow.com/questions/376762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am running a query on Sybase ASE that produces a `ResultSet` that I then traverse and write the contents out to a file. Sometimes, this will throw a `NullPointerException`, stating that the `ResultSet` is `null`. However, it will do this after printing out one or two records. Other times, with the same exact input, I...
I hope you will be doing it well, I mean after calling *rs.next()*. According to the specs. the ResultSet object should never be *null*, in any case. Even if no records found. Posting the code snippet and the stack trace would definitely help us in giving you a better answer. **EDIT:** Since, the error is pointing t...
376,780
<p>I've got this textBox which triggers off an ajax request using jQuery:</p> <pre><code>&lt;asp:TextBox ID="postcodeTextBox" runat="server" Text='&lt;%# Bind("POSTAL_ZIP_CODE") %&gt;'&gt; $(document).ready(PageLoad); function PageLoad() { $(container + 'parentProjectTextBox').change(GetProjectName); } function...
[ { "answer_id": 376794, "author": "BobbyShaftoe", "author_id": 38426, "author_profile": "https://Stackoverflow.com/users/38426", "pm_score": 2, "selected": true, "text": "<p>You should create a hidden field store that value. Update that HiddenField in your Javascript and then read it on t...
2008/12/18
[ "https://Stackoverflow.com/questions/376780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14401/" ]
I've got this textBox which triggers off an ajax request using jQuery: ``` <asp:TextBox ID="postcodeTextBox" runat="server" Text='<%# Bind("POSTAL_ZIP_CODE") %>'> $(document).ready(PageLoad); function PageLoad() { $(container + 'parentProjectTextBox').change(GetProjectName); } function GetProjectName() { va...
You should create a hidden field store that value. Update that HiddenField in your Javascript and then read it on the server side. Also, if you have EventValidation=true and you change the items in the dropdown list you will get well known exceptions.
376,785
<p>Delphi has a $WARN compiler directive that allows one to selectively enable or disable specific warnings. The Delphi 2009 help file describes the syntax:</p> <pre><code>{$WARN identifier ON|OFF} </code></pre> <p>But it only lists the identifiers for 6 warnings.</p> <p>I'd like to have a complete list of all the ...
[ { "answer_id": 376951, "author": "Darian Miller", "author_id": 35696, "author_profile": "https://Stackoverflow.com/users/35696", "pm_score": 6, "selected": true, "text": "<p>I looked through the help and didn't see a full list...so poking around the code it appears the compiler warning c...
2008/12/18
[ "https://Stackoverflow.com/questions/376785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33358/" ]
Delphi has a $WARN compiler directive that allows one to selectively enable or disable specific warnings. The Delphi 2009 help file describes the syntax: ``` {$WARN identifier ON|OFF} ``` But it only lists the identifiers for 6 warnings. I'd like to have a complete list of all the warning identifiers. In particular...
I looked through the help and didn't see a full list...so poking around the code it appears the compiler warning constants are all listed in: CodeGear\RAD Studio\6.0\sources\toolsapi\DCCStrs.pas Search for "Implicit\_String\_Cast\_Loss" and you'll see the constant sIMPLICIT\_STRING\_CAST\_LOSS = 'DCC\_IMPLICIT\_STRIN...
376,786
<p>The code below continues many lines until it ends with a expected /veotherwise /vechoose. I started working on a development firm a little ago where they use this html version called vhtml. I have search the web but it brings different definitions for vhtml. I have seen some posts in Joomla about vhtml but they d...
[ { "answer_id": 376951, "author": "Darian Miller", "author_id": 35696, "author_profile": "https://Stackoverflow.com/users/35696", "pm_score": 6, "selected": true, "text": "<p>I looked through the help and didn't see a full list...so poking around the code it appears the compiler warning c...
2008/12/18
[ "https://Stackoverflow.com/questions/376786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47222/" ]
The code below continues many lines until it ends with a expected /veotherwise /vechoose. I started working on a development firm a little ago where they use this html version called vhtml. I have search the web but it brings different definitions for vhtml. I have seen some posts in Joomla about vhtml but they don't l...
I looked through the help and didn't see a full list...so poking around the code it appears the compiler warning constants are all listed in: CodeGear\RAD Studio\6.0\sources\toolsapi\DCCStrs.pas Search for "Implicit\_String\_Cast\_Loss" and you'll see the constant sIMPLICIT\_STRING\_CAST\_LOSS = 'DCC\_IMPLICIT\_STRIN...
376,793
<p>Can someone explain to me why my code:</p> <pre><code>string messageBody = "abc\n" + stringFromDatabaseProcedure; </code></pre> <p>where valueFromDatabaseProcedure is not a value from the SQL database entered as </p> <pre><code>'line1\nline2' </code></pre> <p>results in the string:</p> <pre><code>"abc\nline1\\n...
[ { "answer_id": 376800, "author": "George Stocker", "author_id": 16587, "author_profile": "https://Stackoverflow.com/users/16587", "pm_score": 0, "selected": false, "text": "<p>ASP.NET would use <code>&lt;br /&gt;</code> to make linebreaks. <code>\\n</code> would work with Console Applic...
2008/12/18
[ "https://Stackoverflow.com/questions/376793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13813/" ]
Can someone explain to me why my code: ``` string messageBody = "abc\n" + stringFromDatabaseProcedure; ``` where valueFromDatabaseProcedure is not a value from the SQL database entered as ``` 'line1\nline2' ``` results in the string: ``` "abc\nline1\\nline2" ``` This has resulted in me scratching my head some...
I just did a quick test on a test NorthwindDb and put in some junk data with a \n in middle. I then queried the data back using straight up ADO.NET and what do you know, it does in fact escape the backslash for you automatically. It has nothing to do with the n it just sees the backslash and escapes it for you. In fact...
376,798
<p>I inherited an application which uses a java properties file to define configuration parameters such as database name. </p> <p>There is a class called MyAppProps that looks like this:</p> <pre><code>public class MyAppProps { protected static final String PROP_FILENAME = "myapp.properties"; protected static...
[ { "answer_id": 376816, "author": "Adeel Ansari", "author_id": 42769, "author_profile": "https://Stackoverflow.com/users/42769", "pm_score": 1, "selected": false, "text": "<p>You can use either, a static block or a constructor. The only advice I have is to use ResourceBundle, instead. Tha...
2008/12/18
[ "https://Stackoverflow.com/questions/376798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I inherited an application which uses a java properties file to define configuration parameters such as database name. There is a class called MyAppProps that looks like this: ``` public class MyAppProps { protected static final String PROP_FILENAME = "myapp.properties"; protected static Properties myAppProps...
If I make my own wrapper class like this; I always prefer to make strongly typed getters for the values, instead of exposing all the inner workings through the static final variables. ``` private static final String DATABASE_NAME = "database_name" private static final String DATABASE_USER = "database_user" public Stri...
376,812
<p>This is my code:</p> <pre class="lang-hs prettyprint-override"><code>type HoraAtendimento = (String, Int, Int) htmlHAtendimento :: [HoraAtendimento] -&gt; Html htmlHAtendimento [] = toHtml "" htmlHAtendimento ((da,hia,hfa):[]) = toHtml da +++ "feira " +++ ...
[ { "answer_id": 376862, "author": "Apocalisp", "author_id": 3434, "author_profile": "https://Stackoverflow.com/users/3434", "pm_score": 5, "selected": true, "text": "<p>Look at the type of <code>map</code>. It is <code>(a -&gt; b) -&gt; [a] -&gt; [b]</code>. That doesn't look like your ty...
2008/12/18
[ "https://Stackoverflow.com/questions/376812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40480/" ]
This is my code: ```hs type HoraAtendimento = (String, Int, Int) htmlHAtendimento :: [HoraAtendimento] -> Html htmlHAtendimento [] = toHtml "" htmlHAtendimento ((da,hia,hfa):[]) = toHtml da +++ "feira " +++ show hia +++ "h - " +++ show hfa +++ ...
Look at the type of `map`. It is `(a -> b) -> [a] -> [b]`. That doesn't look like your type, which is [a] -> b. That's not a map, that's a fold. The higher-order function you want to look at is `foldr`. See [Hoogle](http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3Afoldr). Something like... ```...
376,840
<p>I'm using Java and I'm coding a chess engine.</p> <p>I'm trying to find the index of the first 1 bit and the index of the last 1 bit in a byte.</p> <p>I'm currently using Long.numberOfTrailingZeros() (or something like that) in Java, and would like to emulate that functionality, except with bytes.</p> <p>Would it...
[ { "answer_id": 376855, "author": "starmole", "author_id": 35706, "author_profile": "https://Stackoverflow.com/users/35706", "pm_score": 2, "selected": false, "text": "<p>use a lookup tabel with 256 entries. \nto create it: </p>\n\n<pre><code>unsigned int bitcount ( unsigned int i ) {\nun...
2008/12/18
[ "https://Stackoverflow.com/questions/376840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13852/" ]
I'm using Java and I'm coding a chess engine. I'm trying to find the index of the first 1 bit and the index of the last 1 bit in a byte. I'm currently using Long.numberOfTrailingZeros() (or something like that) in Java, and would like to emulate that functionality, except with bytes. Would it be something like: ```...
use a lookup tabel with 256 entries. to create it: ``` unsigned int bitcount ( unsigned int i ) { unsigned int r = 0; while ( i ) { r+=i&1; i>>=1; } /* bit shift is >>> in java afair */ return r; } ``` this of course does not need to be fast as you do it at most 256 times to init your tabel.
376,851
<p>I am using the standard outputcache tag in my MVC app which works great but I need to force it to be dumped at certain times. How do I achieve this? The page that gets cached is built from a very simple route {Controller}/{PageName} - so most pages are something like this: /Pages/About-Us</p> <p>Here is the outpu...
[ { "answer_id": 376875, "author": "Zachary Yates", "author_id": 8360, "author_profile": "https://Stackoverflow.com/users/8360", "pm_score": 4, "selected": false, "text": "<p><code>HttpResponse.RemoveOutputCacheItem()</code> is probably the method you want to use. If you can figure out wh...
2008/12/18
[ "https://Stackoverflow.com/questions/376851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34548/" ]
I am using the standard outputcache tag in my MVC app which works great but I need to force it to be dumped at certain times. How do I achieve this? The page that gets cached is built from a very simple route {Controller}/{PageName} - so most pages are something like this: /Pages/About-Us Here is the output cache tag ...
Be careful about using "None" vs. "". * If you send "" then the HttpHeader for [Vary](http://www.w3.org/Protocols/HTTP/Issues/vary-header.html) is *not* sent. * If you send "None" then the HttpHeader for [Vary](http://www.w3.org/Protocols/HTTP/Issues/vary-header.html) *is* sent. I used [Fiddler](http://www.fiddle2.co...
376,874
<p>I am not able to get the selection object's start and end offsets in Opera (v9.50) when the selection is collapsed (i.e. just point and click instead of highlighting text). This is my simple test code, which works in FF and Safari but does not work in Opera. </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script typ...
[ { "answer_id": 376883, "author": "Zachary Yates", "author_id": 8360, "author_profile": "https://Stackoverflow.com/users/8360", "pm_score": 2, "selected": false, "text": "<p>This question is very similar to <a href=\"https://stackoverflow.com/questions/49378/deploy-mysql-server-db-with-ne...
2008/12/18
[ "https://Stackoverflow.com/questions/376874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am not able to get the selection object's start and end offsets in Opera (v9.50) when the selection is collapsed (i.e. just point and click instead of highlighting text). This is my simple test code, which works in FF and Safari but does not work in Opera. ``` <html> <head> <script type="text/javascript"> func...
This question is very similar to [another question](https://stackoverflow.com/questions/49378/deploy-mysql-server-db-with-net-application). However, the answers don't really help. You can [run executables from a custom action in the .Net deployment project](http://www.simple-talk.com/dotnet/visual-studio/visual-studio...
376,910
<p>I have a ListBox and I want to add a context menu to each item in the list. I've seen the "solution" to have the right click select an item and suppress the context menu if on white space, but this solution feels dirty. </p> <p>Does anyone know a better way?</p>
[ { "answer_id": 377176, "author": "Frans Bouma", "author_id": 44991, "author_profile": "https://Stackoverflow.com/users/44991", "pm_score": 2, "selected": false, "text": "<p>There's no other way: the context menu isn't owned by the item in the listbox but by the listbox itself. It's simil...
2008/12/18
[ "https://Stackoverflow.com/questions/376910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40887/" ]
I have a ListBox and I want to add a context menu to each item in the list. I've seen the "solution" to have the right click select an item and suppress the context menu if on white space, but this solution feels dirty. Does anyone know a better way?
This way the menu will pop up next to the mouse ``` private string _selectedMenuItem; private readonly ContextMenuStrip collectionRoundMenuStrip; public Form1() { var toolStripMenuItem1 = new ToolStripMenuItem {Text = "Copy CR Name"}; toolStripMenuItem1.Click += toolStripMenuItem1_Click; var toolStripMe...
376,911
<p>I'm new to both ASP.Net MVC and jQuery and what I'm trying to do is make a form that either adds a new RockBand or updates an existing RockBand based on if the rockbandid is an empty guid or not. I figured now is a good time to get rolling with jQuery. So the first step is to make a list of bands and put an edit l...
[ { "answer_id": 377176, "author": "Frans Bouma", "author_id": 44991, "author_profile": "https://Stackoverflow.com/users/44991", "pm_score": 2, "selected": false, "text": "<p>There's no other way: the context menu isn't owned by the item in the listbox but by the listbox itself. It's simil...
2008/12/18
[ "https://Stackoverflow.com/questions/376911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1975/" ]
I'm new to both ASP.Net MVC and jQuery and what I'm trying to do is make a form that either adds a new RockBand or updates an existing RockBand based on if the rockbandid is an empty guid or not. I figured now is a good time to get rolling with jQuery. So the first step is to make a list of bands and put an edit link n...
This way the menu will pop up next to the mouse ``` private string _selectedMenuItem; private readonly ContextMenuStrip collectionRoundMenuStrip; public Form1() { var toolStripMenuItem1 = new ToolStripMenuItem {Text = "Copy CR Name"}; toolStripMenuItem1.Click += toolStripMenuItem1_Click; var toolStripMe...
376,915
<p>I recently took my Db initiating code out of the __construct of my Page class and placed it just after I initiate the Page class. I removed it from within the Page class because I want to be able to access it from anywhere (other classes for example). It also takes server, username, password and database arguments t...
[ { "answer_id": 376920, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 0, "selected": false, "text": "<p>Global variables do have a use, and this would be one of them. Unless it's likely that you're going to be needing multiple ...
2008/12/18
[ "https://Stackoverflow.com/questions/376915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
I recently took my Db initiating code out of the \_\_construct of my Page class and placed it just after I initiate the Page class. I removed it from within the Page class because I want to be able to access it from anywhere (other classes for example). It also takes server, username, password and database arguments to...
A global of some sort (Be that global variables, singleton or some other variant) is an improvement over your previous approach, and as such you're on the right track. Generally speaking though, you should try to minimise the scope of program state (For a number of reasons, which I won't get into here). Having a global...
376,921
<p>What is the difference between the scalar and list contexts in Perl and does this have any parallel in other languages such as Java or Javascript? </p>
[ { "answer_id": 376932, "author": "nicerobot", "author_id": 23056, "author_profile": "https://Stackoverflow.com/users/23056", "pm_score": 0, "selected": false, "text": "<p>This simply means that a data-type will be evaluated based on the mode of the operation. For example, an assignment t...
2008/12/18
[ "https://Stackoverflow.com/questions/376921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47145/" ]
What is the difference between the scalar and list contexts in Perl and does this have any parallel in other languages such as Java or Javascript?
Various operators in Perl are context sensitive and produce different results in list and scalar context. For example: ``` my(@array) = (1, 2, 4, 8, 16); my($first) = @array; my(@copy1) = @array; my @copy2 = @array; my $count = @array; print "array: @array\n"; print "first: $first\n"; print "copy1: @copy1\n"; prin...
376,948
<p>I was coding with 2 CStringList objects. Each has its own data, for eg one has name and other the phoneno, and both are in sync, i.e, if there is a phoneno there is a name and viceversa.</p> <p>Now, i have 2 combobox in which i show the names and the respective phonenos. The name combobox is sorted, hence the sync...
[ { "answer_id": 376978, "author": "lakshmanaraj", "author_id": 44541, "author_profile": "https://Stackoverflow.com/users/44541", "pm_score": 1, "selected": false, "text": "<p>I Hope U are using CStringArray and not CStringList. \nYou need to use FindIndex rather than Find since Find will ...
2008/12/18
[ "https://Stackoverflow.com/questions/376948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41518/" ]
I was coding with 2 CStringList objects. Each has its own data, for eg one has name and other the phoneno, and both are in sync, i.e, if there is a phoneno there is a name and viceversa. Now, i have 2 combobox in which i show the names and the respective phonenos. The name combobox is sorted, hence the sync between th...
I Hope U are using CStringArray and not CStringList. You need to use FindIndex rather than Find since Find will return OBJECT Pos rather than the Index count.... and to get the element with array use simply [] the operator. If You still want to use CStringList then through Iterator Find the Index Count of the first m...
376,953
<p>I am a beginner at SQL Server and I have a question about how best to do this.</p> <p>I have a table that looks like this:</p> <p>ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Parent&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Level<br> 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0<br> 2&nbsp...
[ { "answer_id": 376974, "author": "LeppyR64", "author_id": 16592, "author_profile": "https://Stackoverflow.com/users/16592", "pm_score": 2, "selected": false, "text": "<p>This will show you the rows that have issues.</p>\n\n<pre><code>select\n a.id,\n a.level,\n b.level as parentlevel\...
2008/12/18
[ "https://Stackoverflow.com/questions/376953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47299/" ]
I am a beginner at SQL Server and I have a question about how best to do this. I have a table that looks like this: ID      Parent     Level 1      NULL        0 2       1          1 3       1          1 4       2          2 5       2          2 6       3          2 7       2          2 8     ...
This will show you the rows that have issues. ``` select a.id, a.level, b.level as parentlevel from tablename a join tablename b on a.parent = b.id where a.level <> b.level+1 ```
376,959
<p>Let's say I have the following function:</p> <pre><code>sumAll :: [(Int,Int)] -&gt; Int sumAll xs = foldr (+) 0 (map f xs) where f (x,y) = x+y </code></pre> <p>The result of <code>sumAll [(1,1),(2,2),(3,3)]</code> will be <code>12</code>.</p> <p>What I don't understand is where the <code>(x,y)</code> values are...
[ { "answer_id": 376983, "author": "Akusete", "author_id": 40175, "author_profile": "https://Stackoverflow.com/users/40175", "pm_score": 4, "selected": true, "text": "<p>In Haskell, functions are first class datatypes.</p>\n\n<p>This means you can pass functions around like other types of ...
2008/12/18
[ "https://Stackoverflow.com/questions/376959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40480/" ]
Let's say I have the following function: ``` sumAll :: [(Int,Int)] -> Int sumAll xs = foldr (+) 0 (map f xs) where f (x,y) = x+y ``` The result of `sumAll [(1,1),(2,2),(3,3)]` will be `12`. What I don't understand is where the `(x,y)` values are coming from. Well, I know they come from the `xs` variable but I don...
In Haskell, functions are first class datatypes. This means you can pass functions around like other types of data such as integers and strings. In your code above you declare 'f' to be a function, which takes in one argumenta (a tuple of two values (x,y)) and returns the result of (x + y). foldr is another function...
376,966
<p>Is it possible to have a C static library API, which uses C++ internally and hide this from users of the library?</p> <p>I have writen a portable C++ library I wish to statically link to an iPhone application.</p> <p>I have created an Xcode project using the Max OS X 'static library' template, and copied the sourc...
[ { "answer_id": 376987, "author": "coppro", "author_id": 16855, "author_profile": "https://Stackoverflow.com/users/16855", "pm_score": 2, "selected": false, "text": "<p>You should declare the functions you want to be visible <code>extern \"C\"</code>. Their signatures need to be C-compati...
2008/12/18
[ "https://Stackoverflow.com/questions/376966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40175/" ]
Is it possible to have a C static library API, which uses C++ internally and hide this from users of the library? I have writen a portable C++ library I wish to statically link to an iPhone application. I have created an Xcode project using the Max OS X 'static library' template, and copied the source across, as well...
It's too hard to do this in comments, so I'm just going to demonstrate for you quickly what the linking issues are that you're having. When Xcode encounters files, it uses build rules based on the suffix to decide which compiler to use. By default, gcc links the files to the standard C library, but does not link with t...
376,968
<p>Suppose I have a variable of type Int = 08, how can I convert this to String keeping the leading zero?</p> <p>For instance:</p> <pre><code>v :: Int v = 08 show v </code></pre> <p>Output: 8</p> <p>I want the output to be "08".</p> <p>Is this possible?</p>
[ { "answer_id": 376982, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 5, "selected": false, "text": "<p>Use <code>Text.Printf.printf</code>:</p>\n\n<pre><code>printf \"%02d\" v\n</code></pre>\n\n<p>Make sure to import <code>...
2008/12/18
[ "https://Stackoverflow.com/questions/376968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40480/" ]
Suppose I have a variable of type Int = 08, how can I convert this to String keeping the leading zero? For instance: ``` v :: Int v = 08 show v ``` Output: 8 I want the output to be "08". Is this possible?
Depending on what you are planning to do you might want to store the "08" as a string and only convert to int when you need the value.
376,988
<p>I remember reading in some Java book about any operator other than 'instanceof' for comparing the type hierarchy between two objects.</p> <p>instanceof is the most used and common. I am not able to recall clearly whether there is indeed another way of doing that or not.</p>
[ { "answer_id": 376996, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "<p>You can also, for reflection mostly, use <code>Class.isInstance</code>.</p>\n\n<pre><code>Class&lt;?&gt; stringClass = Cl...
2008/12/18
[ "https://Stackoverflow.com/questions/376988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37626/" ]
I remember reading in some Java book about any operator other than 'instanceof' for comparing the type hierarchy between two objects. instanceof is the most used and common. I am not able to recall clearly whether there is indeed another way of doing that or not.
Yes, there is. Is not an operator but a method on the Class class. Here it is: [isIntance(Object o )](http://java.sun.com/javase/6/docs/api/java/lang/Class.html#isInstance(java.lang.Object)) Quote from the doc: > > *...This method is the dynamic equivalent of the Java language instanceof operator* > > > ``` pu...
376,998
<p>I want to redirect URLs from an old site that used raw URL requests to my new site which I have implemented in CodeIgniter. I simply want to redirect them to my index page. I also would like to get rid of &quot;index.php&quot; in my URLs so that my URLs can be as simple as example.com/this/that. So, this is the <...
[ { "answer_id": 376996, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "<p>You can also, for reflection mostly, use <code>Class.isInstance</code>.</p>\n\n<pre><code>Class&lt;?&gt; stringClass = Cl...
2008/12/18
[ "https://Stackoverflow.com/questions/376998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3831/" ]
I want to redirect URLs from an old site that used raw URL requests to my new site which I have implemented in CodeIgniter. I simply want to redirect them to my index page. I also would like to get rid of "index.php" in my URLs so that my URLs can be as simple as example.com/this/that. So, this is the `.htaccess` file ...
Yes, there is. Is not an operator but a method on the Class class. Here it is: [isIntance(Object o )](http://java.sun.com/javase/6/docs/api/java/lang/Class.html#isInstance(java.lang.Object)) Quote from the doc: > > *...This method is the dynamic equivalent of the Java language instanceof operator* > > > ``` pu...
377,000
<p><a href="https://stackoverflow.com/questions/374572/need-help-variable-creation-in-python#374604">That</a> was helpful kgiannakakis. I'm facing a problem as below:</p> <pre><code>a = ['zbc','2.3'] for i in range(0,5): exec('E%d=%s' %(i,a[i])) </code></pre> <p>This results in:</p> <pre> Traceback (most recent ...
[ { "answer_id": 377015, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 0, "selected": false, "text": "<p>Okay. this code is very weird.</p>\n\n<p>As a one liner like this, it's not syntactically correct, but I suspect...
2008/12/18
[ "https://Stackoverflow.com/questions/377000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46646/" ]
[That](https://stackoverflow.com/questions/374572/need-help-variable-creation-in-python#374604) was helpful kgiannakakis. I'm facing a problem as below: ``` a = ['zbc','2.3'] for i in range(0,5): exec('E%d=%s' %(i,a[i])) ``` This results in: ``` Traceback (most recent call last): File "", line 2, in exe...
It looks like the code you're generating expands to: ``` E0=zbc E1=2.3 ``` At the next iteration through the loop, you'll get an IndexError exception because `a` is only two elements long. So given the above, you are trying to assign the value of `zbc` to `E0`. If `zbc` doesn't exist (which it seems that it doesn't...
377,017
<p>In Python, is there a portable and simple way to test if an executable program exists?</p> <p>By simple I mean something like the <code>which</code> command which would be just perfect. I don't want to search PATH manually or something involving trying to execute it with <code>Popen</code> &amp; al and see if it fa...
[ { "answer_id": 377028, "author": "Jay", "author_id": 20840, "author_profile": "https://Stackoverflow.com/users/20840", "pm_score": 9, "selected": true, "text": "<p>Easiest way I can think of: </p>\n\n<pre><code>def which(program):\n import os\n def is_exe(fpath):\n return os...
2008/12/18
[ "https://Stackoverflow.com/questions/377017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38796/" ]
In Python, is there a portable and simple way to test if an executable program exists? By simple I mean something like the `which` command which would be just perfect. I don't want to search PATH manually or something involving trying to execute it with `Popen` & al and see if it fails (that's what I'm doing now, but ...
Easiest way I can think of: ``` def which(program): import os def is_exe(fpath): return os.path.isfile(fpath) and os.access(fpath, os.X_OK) fpath, fname = os.path.split(program) if fpath: if is_exe(program): return program else: for path in os.environ["PATH"].s...
377,023
<p>Does anyone know the query the last synchronization date from sql server (2008).</p> <p>It is the same information displayed in replication monitor, but I want to be able to get that date from a query.</p>
[ { "answer_id": 377528, "author": "Philippe Grondier", "author_id": 11436, "author_profile": "https://Stackoverflow.com/users/11436", "pm_score": 3, "selected": true, "text": "<p>You can see a lot of info about merge sessions by using the system table msMerge_sessions:</p>\n\n<pre><code>s...
2008/12/18
[ "https://Stackoverflow.com/questions/377023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36902/" ]
Does anyone know the query the last synchronization date from sql server (2008). It is the same information displayed in replication monitor, but I want to be able to get that date from a query.
You can see a lot of info about merge sessions by using the system table msMerge\_sessions: ``` select * from msMerge_sessions ``` Depending on the info you need, use the other system tables available in your database.
377,026
<p>I have a Linq Query where I do the following:</p> <pre><code>query = context.Select(a =&gt; new { Course = (CourseType)a.CourseCode, CourseDetail = sting.Format("Course: {0}\r\nCourse Detail: {1}", ((CourseType)a.CourseCode).ToString(), a.CourseDetail) }); enum CourseType{ Unknown = 0, FullTime = 1, Part...
[ { "answer_id": 377517, "author": "roomaroo", "author_id": 3464, "author_profile": "https://Stackoverflow.com/users/3464", "pm_score": 1, "selected": false, "text": "<p>Are you sure that's the exact code you're using? </p>\n\n<p>There's a typo: sting.Format instead of st<strong>r</strong>...
2008/12/18
[ "https://Stackoverflow.com/questions/377026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21586/" ]
I have a Linq Query where I do the following: ``` query = context.Select(a => new { Course = (CourseType)a.CourseCode, CourseDetail = sting.Format("Course: {0}\r\nCourse Detail: {1}", ((CourseType)a.CourseCode).ToString(), a.CourseDetail) }); enum CourseType{ Unknown = 0, FullTime = 1, PartTime = 2 } ``` ...
Are you sure that's the exact code you're using? There's a typo: sting.Format instead of st**r**ing.Format, so I guess you've retyped the code for this question. Check to make sure all your brackets are in the correct place etc. I've tried the following code, prints out "Fulltime", so the .ToString method should wor...
377,030
<p>I have some data. I want to go through that data and change cells (for example - Background color), if that data meets a certain condition. Somehow, I've not been able to figure it out how to do this seemingly easy thing in Silverlight.</p>
[ { "answer_id": 378169, "author": "Simon Steele", "author_id": 4591, "author_profile": "https://Stackoverflow.com/users/4591", "pm_score": 4, "selected": true, "text": "<p>This is slightly old code (from before RTM), but does something like what you're looking for. It checks some data on ...
2008/12/18
[ "https://Stackoverflow.com/questions/377030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26408/" ]
I have some data. I want to go through that data and change cells (for example - Background color), if that data meets a certain condition. Somehow, I've not been able to figure it out how to do this seemingly easy thing in Silverlight.
This is slightly old code (from before RTM), but does something like what you're looking for. It checks some data on an object in a row and then sets the colour of the row accordingly. **XAML:** ``` <my:DataGrid x:Name="Grid" Grid.Row="1" Margin="5" GridlinesVisibility="None" PreparingRow="Grid_PreparingRow"> <my...
377,035
<p>I'm building a photo gallery and what I would like to do is make it so that as the user rolls over an image (let's say for the purposes of this question it's a picture of an apple), all the other images of apples on the page also show their "over" state. </p> <p>Any and all help would be greatly appreciated, and th...
[ { "answer_id": 377066, "author": "kgiannakakis", "author_id": 24054, "author_profile": "https://Stackoverflow.com/users/24054", "pm_score": 3, "selected": false, "text": "<p>You could add the 'type' of the image as a class. For example an apple will be:</p>\n\n<pre><code>&lt;img src='' c...
2008/12/18
[ "https://Stackoverflow.com/questions/377035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm building a photo gallery and what I would like to do is make it so that as the user rolls over an image (let's say for the purposes of this question it's a picture of an apple), all the other images of apples on the page also show their "over" state. Any and all help would be greatly appreciated, and thank you fo...
You could add the 'type' of the image as a class. For example an apple will be: ``` <img src='' class='apple fruit red' /> ``` You can have as many space separated classes as you want. Then add the following handler: ``` $(".apple").mouseover(function() { $(".apple").addClass("overState"); }); ``` You need to...
377,058
<p>I need a simple SQL to accomplish the below:</p> <p>Problem:</p> <p>When a petrol bunk runs out of fuel, the admin makes note of the DateTime (RunOutDate) when it ran out of fuel and notes also the DateTime (ResupplyDate) when the fuel supply was back on.</p> <p>I need to create a report on how many <em>days</em>...
[ { "answer_id": 377068, "author": "gbn", "author_id": 27535, "author_profile": "https://Stackoverflow.com/users/27535", "pm_score": 2, "selected": false, "text": "<p>DATEDIFF using day, then add 1.</p>\n\n<p>DATEDIFF uses the midnight to count days so you'll get 0, 1, 1 for each example a...
2008/12/18
[ "https://Stackoverflow.com/questions/377058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4718/" ]
I need a simple SQL to accomplish the below: Problem: When a petrol bunk runs out of fuel, the admin makes note of the DateTime (RunOutDate) when it ran out of fuel and notes also the DateTime (ResupplyDate) when the fuel supply was back on. I need to create a report on how many *days* the bunk ran out of fuel. eg....
``` DATEDIFF(d, RunOutDate, ResupplyDate) + 1 ``` Remember that DATEDIFF always counts the number of BOUNDARIES that you cross. For days (first argument d), it counts the number of times the clock passed midnight. So to count the number of days covered you just add 1.
377,078
<p>I'm trying to make a little function to interpolate between two values with a given increment.</p> <pre><code>[ 1.0 .. 0.5 .. 20.0 ] </code></pre> <p>The compiler tells me that this is deprecated, and suggests using ints then casting to float. But this seems a bit long-winded if I have a fractional increment - do ...
[ { "answer_id": 377111, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 0, "selected": false, "text": "<p>Try the following sequence expression</p>\n\n<pre><code>seq { 2 .. 40 } |&gt; Seq.map (fun x -&gt; (float x) / 2.0)\n<...
2008/12/18
[ "https://Stackoverflow.com/questions/377078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11410/" ]
I'm trying to make a little function to interpolate between two values with a given increment. ``` [ 1.0 .. 0.5 .. 20.0 ] ``` The compiler tells me that this is deprecated, and suggests using ints then casting to float. But this seems a bit long-winded if I have a fractional increment - do I have to divide my start ...
TL;DR: **F# PowerPack's `BigRational` type is the way to go**. --- What's Wrong with Floating-point Loops -------------------------------------- As many have pointed out, `float` values are not suitable for looping: * They do have Round Off Error, just like with `1/3` in decimal, we inevitably lose all digits start...
377,093
<p>Coming from C++, I find generic programming indispensable. I wonder how people approach that in Haskell?</p> <p>Say how do write generic swap function in Haskell?</p> <p>Is there an equivalent concept of partial specialization in Haskell?</p> <p>In C++, I can partially specialize the generic swap function with a ...
[ { "answer_id": 377155, "author": "Daniel Earwicker", "author_id": 27423, "author_profile": "https://Stackoverflow.com/users/27423", "pm_score": 6, "selected": true, "text": "<p>This is closely related to your other question about Haskell and quicksort. I think you probably need to read a...
2008/12/18
[ "https://Stackoverflow.com/questions/377093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47303/" ]
Coming from C++, I find generic programming indispensable. I wonder how people approach that in Haskell? Say how do write generic swap function in Haskell? Is there an equivalent concept of partial specialization in Haskell? In C++, I can partially specialize the generic swap function with a special one for a generi...
This is closely related to your other question about Haskell and quicksort. I think you probably need to read at least the *introduction* of a book about Haskell. It sounds as if you haven't yet grasped the key point about it which is that it bans you from modifying the values of existing variables. Swap (as understoo...
377,094
<p>I have a C++ application that uses the Win32 API for Windows, and I'm having a problem with GDI+ dithering, when I don't know why it should be.</p> <p>I have a custom control (custom window). When I receive the WM_PAINT message, I draw some Polygons using FillPolygon on a Graphics device. This Graphics device was c...
[ { "answer_id": 377155, "author": "Daniel Earwicker", "author_id": 27423, "author_profile": "https://Stackoverflow.com/users/27423", "pm_score": 6, "selected": true, "text": "<p>This is closely related to your other question about Haskell and quicksort. I think you probably need to read a...
2008/12/18
[ "https://Stackoverflow.com/questions/377094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3641/" ]
I have a C++ application that uses the Win32 API for Windows, and I'm having a problem with GDI+ dithering, when I don't know why it should be. I have a custom control (custom window). When I receive the WM\_PAINT message, I draw some Polygons using FillPolygon on a Graphics device. This Graphics device was created us...
This is closely related to your other question about Haskell and quicksort. I think you probably need to read at least the *introduction* of a book about Haskell. It sounds as if you haven't yet grasped the key point about it which is that it bans you from modifying the values of existing variables. Swap (as understoo...
377,097
<p>I want to connect to DB using the iSeries Client Access driver. I use the following connection string:</p> <p>DRIVER=Client Access ODBC Driver (32-bit);QUERYTIMEOUT=0;PKG=QGPL/DEFAULT(IBM),2,0,1,0,512;LANGUAGEID=ENU;DFTPKGLIB=QGPL;DBQ=QGPL XXXXXXXX;SYSTEM=XXX.XXXXXXX.XXX;Signon=2</p> <p>I get an exception when co...
[ { "answer_id": 377155, "author": "Daniel Earwicker", "author_id": 27423, "author_profile": "https://Stackoverflow.com/users/27423", "pm_score": 6, "selected": true, "text": "<p>This is closely related to your other question about Haskell and quicksort. I think you probably need to read a...
2008/12/18
[ "https://Stackoverflow.com/questions/377097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to connect to DB using the iSeries Client Access driver. I use the following connection string: DRIVER=Client Access ODBC Driver (32-bit);QUERYTIMEOUT=0;PKG=QGPL/DEFAULT(IBM),2,0,1,0,512;LANGUAGEID=ENU;DFTPKGLIB=QGPL;DBQ=QGPL XXXXXXXX;SYSTEM=XXX.XXXXXXX.XXX;Signon=2 I get an exception when connecting: ERROR ...
This is closely related to your other question about Haskell and quicksort. I think you probably need to read at least the *introduction* of a book about Haskell. It sounds as if you haven't yet grasped the key point about it which is that it bans you from modifying the values of existing variables. Swap (as understoo...
377,105
<p>In Delphi 2007, in a mouse move event, I try to change the mouse cursor with:</p> <pre><code>procedure TFr_Board_Display.PaintBox_Proxy_BoardMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if left_mouse_button_down then begin if some_condition then begin Cursor := crDrag; e...
[ { "answer_id": 377158, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 5, "selected": true, "text": "<p>If you set the mouse cursor in the OnMouseDown and reset it in the OnMouseUp, anything works fine:</p>\n\n<pre><cod...
2008/12/18
[ "https://Stackoverflow.com/questions/377105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47309/" ]
In Delphi 2007, in a mouse move event, I try to change the mouse cursor with: ``` procedure TFr_Board_Display.PaintBox_Proxy_BoardMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if left_mouse_button_down then begin if some_condition then begin Cursor := crDrag; end else be...
If you set the mouse cursor in the OnMouseDown and reset it in the OnMouseUp, anything works fine: ``` procedure TForm4.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin Cursor := crCross; end; procedure TForm4.FormMouseUp(Sender: TObject; Button: TMouseButton; Shift...
377,109
<p>Hi I'm very new to sql but have been passed a job in which I need to query the db(MS SQL 2005) I need to return all workers where a HeadID is given.(tables below) So I need to get all the managers that match the HeadID and then all the workers that match those managers by ManagerID. How would I do this? Any help or ...
[ { "answer_id": 377115, "author": "Chaowlert Chaisrichalermpol", "author_id": 2398110, "author_profile": "https://Stackoverflow.com/users/2398110", "pm_score": 1, "selected": false, "text": "<p>Use common table expression</p>\n\n<pre><code>USE AdventureWorks;\nGO\nWITH DirectReports(Manag...
2008/12/18
[ "https://Stackoverflow.com/questions/377109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17510/" ]
Hi I'm very new to sql but have been passed a job in which I need to query the db(MS SQL 2005) I need to return all workers where a HeadID is given.(tables below) So I need to get all the managers that match the HeadID and then all the workers that match those managers by ManagerID. How would I do this? Any help or any...
A simple way would be to do something like this: ``` select * from tb_Worker join tb_Manager on tb_Worker.ManagerID = tb_Manager.ManagerID join tb_Head on tb_Manager.HeadID = Head.HeadID where tb_Head.HeadID = <given value> ``` Tune your table names and select columns as appropriate.
377,114
<p>Partial template specialization is one of the most important concepts for generic programming in C++. For example: to implement a generic swap function:</p> <pre><code>template &lt;typename T&gt; void swap(T &amp;x, T &amp;y) { const T tmp = x; y = x; x = tmp; } </code></pre> <p>To specialize it for a vector...
[ { "answer_id": 380071, "author": "Milhous", "author_id": 17712, "author_profile": "https://Stackoverflow.com/users/17712", "pm_score": -1, "selected": false, "text": "<p>Java has generics, which allow you to do similar sorts of things.</p>\n" }, { "answer_id": 380306, "author...
2008/12/18
[ "https://Stackoverflow.com/questions/377114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47303/" ]
Partial template specialization is one of the most important concepts for generic programming in C++. For example: to implement a generic swap function: ``` template <typename T> void swap(T &x, T &y) { const T tmp = x; y = x; x = tmp; } ``` To specialize it for a vector to support O(1) swap: ``` template <ty...
[D](http://www.digitalmars.com/d/1.0) supports partial specialization: * [Language overview](http://www.digitalmars.com/d/2.0/overview.html) * [Template feature comparison](http://www.digitalmars.com/d/2.0/template-comparison.html) (with C++ 98 and 0x). (scan for "partial" in the above links). The second link in par...
377,117
<p>I must be dense. After asking several questions on StackOverflow, I am still at a loss when it comes to grasping the new routing engine provided with ASP.NET MVC. I think I've narrowed down the problem to a very simple one, which, if solved, would probably allow me to solve the rest of my routing issues. So here ...
[ { "answer_id": 377142, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 0, "selected": false, "text": "<p>You could handle that in the home controller, but the controller method would not be very elegant. I'm guessing some...
2008/12/18
[ "https://Stackoverflow.com/questions/377117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
I must be dense. After asking several questions on StackOverflow, I am still at a loss when it comes to grasping the new routing engine provided with ASP.NET MVC. I think I've narrowed down the problem to a very simple one, which, if solved, would probably allow me to solve the rest of my routing issues. So here it is:...
What about ``` routes.MapRoute( "Profiles", "{userName}", new { controller = "Profiles", action = "ShowUser" } ); ``` and then, in ProfilesController, there would be a function ``` public ActionResult ShowUser(string userName) { ... ``` In the function, if no user with the specified userName is found,...
377,137
<p>I've been struggling with this for quite awhile and haven't been able to find a solution. I need a user to be able to view multiple top level domains with a single login.</p> <p>My understanding is that this needs to be set in <code>environment.rb</code> and called with <code>before_dispatch</code>. This is what I'...
[ { "answer_id": 378019, "author": "Keltia", "author_id": 16143, "author_profile": "https://Stackoverflow.com/users/16143", "pm_score": 0, "selected": false, "text": "<p>Your question is not really precise enough IMHO. Do you want a single cookie for all Rails apps you have or is it withi...
2008/12/18
[ "https://Stackoverflow.com/questions/377137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've been struggling with this for quite awhile and haven't been able to find a solution. I need a user to be able to view multiple top level domains with a single login. My understanding is that this needs to be set in `environment.rb` and called with `before_dispatch`. This is what I've come up with: ``` require 'a...
This one is a bit tricky. Since cookies can only be assigned to (and retrieved from) the current domain ("forms.example.com", say) and parent domains (".example.com", but not ".com"), but NOT to other domains ("othersite.com"), you'll have to find yourself another solution. This has nothing to do with Rails, but with h...
377,156
<p>Below is my table, a User could have multiple profiles in certain languages, non-English profiles have a higher priority.</p> <pre> +----------+--------+----------------+----------------+ |ProfileID |UserID |ProfileLanguage |ProfilePriority | +----------+--------+----------------+----------------+ |1 |1 ...
[ { "answer_id": 377165, "author": "Samiksha", "author_id": 29515, "author_profile": "https://Stackoverflow.com/users/29515", "pm_score": 1, "selected": false, "text": "<pre><code>SELECT *\nFROM Profile as tb1 inner join\n(SELECT UserID, MIN(ProfilePriority) AS ProfilePriority\nFROM Profil...
2008/12/18
[ "https://Stackoverflow.com/questions/377156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Below is my table, a User could have multiple profiles in certain languages, non-English profiles have a higher priority. ``` +----------+--------+----------------+----------------+ |ProfileID |UserID |ProfileLanguage |ProfilePriority | +----------+--------+----------------+----------------+ |1 |1 |en-...
This may work, if profilepriority and userid could be a composite unique key; ``` select p.* from Profile p join (SELECT UserID, MIN(ProfilePriority) AS ProfilePriority FROM Profile WHERE ProfileLanguage = 'en-US' OR ProfilePriority = 2 GROUP BY UserID) tt on p.userID = tt.UserID and p.ProfilePriority = tt.ProfilePri...
377,163
<p>How do you perform databinding against the MonthCalendar.SelectionRange property? Given the property is of type 'SelectionRange' which is a class I am not sure how to go about it. Any examples would be much appreciated.</p>
[ { "answer_id": 377350, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "<p>Well, there don't seem to be any obvious events for this either on the <code>MonthCalendar</code> or the <code>Sele...
2008/12/18
[ "https://Stackoverflow.com/questions/377163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6276/" ]
How do you perform databinding against the MonthCalendar.SelectionRange property? Given the property is of type 'SelectionRange' which is a class I am not sure how to go about it. Any examples would be much appreciated.
Well, there don't seem to be any obvious events for this either on the `MonthCalendar` or the `SelectionRange`, and neither implements `INotifyPropertyChanged`, so it *looks* like data-binding might not be possible here. Update: It does, however, raise the DateChanged, so you could hook some stuff together manually, o...
377,181
<p>I have a unmanaged DLL (the scilexer.dll of Scintilla code editor, used by Scintilla.Net from <a href="http://www.codeplex.com/ScintillaNET" rel="noreferrer">CodePlex</a>) that is loaded from a managed application trough the Scintilla.Net component. The windows managed application runs without problem on both 32 and...
[ { "answer_id": 377191, "author": "Igal Serban", "author_id": 25737, "author_profile": "https://Stackoverflow.com/users/25737", "pm_score": 1, "selected": false, "text": "<p>You can put the dll in system32. The 32 bit in syswow64 and the 64 bit in the real system32. For 32 bit application...
2008/12/18
[ "https://Stackoverflow.com/questions/377181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11673/" ]
I have a unmanaged DLL (the scilexer.dll of Scintilla code editor, used by Scintilla.Net from [CodePlex](http://www.codeplex.com/ScintillaNET)) that is loaded from a managed application trough the Scintilla.Net component. The windows managed application runs without problem on both 32 and 64 bit environments, but I nee...
P/Invoke uses LoadLibrary to load DLLs, and if there is already a library loaded with a given name, LoadLibrary will return it. So if you can give both versions of the DLL the same name, but put them in different directories, you can do something like this just once before your first call to a function from scilexer.dl...
377,185
<p>The db I am querying from is returning some null values. How do I safeguard against this and make sure the caller gets some data back.</p> <p>The code I have is:</p> <p>Using DataReader</p> <pre><code> while (dr.Read()) { vo = new PlacementVO(); vo.PlacementID = dr.GetString...
[ { "answer_id": 377193, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "<p>There is <code>IsDBNull(int ordinal)</code> if you are using ordinals (which you are).</p>\n\n<p>So:</p>\n\n<pre><c...
2008/12/18
[ "https://Stackoverflow.com/questions/377185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17510/" ]
The db I am querying from is returning some null values. How do I safeguard against this and make sure the caller gets some data back. The code I have is: Using DataReader ``` while (dr.Read()) { vo = new PlacementVO(); vo.PlacementID = dr.GetString(0); ``` If I use dataset,...
There is `IsDBNull(int ordinal)` if you are using ordinals (which you are). So: ``` string email = reader.IsDBNull(0) ? null : reader.GetString(0); ``` If you are working with string column names, then to use this you'll have to call `GetOrdinal` first, for example: ``` string GetSafeString(this IDataReader reader...
377,187
<p>I currently have code in my ApplicationController to check if a user is logged in and has the required access to perform a given action (the tests take place in a before_filter).</p> <p>I require the same functionality in the views to decide if I should be showing the admin links in a list view, but how do I best a...
[ { "answer_id": 377251, "author": "Hates_", "author_id": 3410, "author_profile": "https://Stackoverflow.com/users/3410", "pm_score": 3, "selected": true, "text": "<p>I would say do away with the wrappers and just call <em>can_edit_customers?</em> directly on the user object passed to the ...
2008/12/18
[ "https://Stackoverflow.com/questions/377187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15512/" ]
I currently have code in my ApplicationController to check if a user is logged in and has the required access to perform a given action (the tests take place in a before\_filter). I require the same functionality in the views to decide if I should be showing the admin links in a list view, but how do I best avoid dupl...
I would say do away with the wrappers and just call *can\_edit\_customers?* directly on the user object passed to the view. If you want to keep them a solution might be to use **[helper\_method](http://api.rubyonrails.org/classes/ActionController/Helpers/ClassMethods.html#M000323)** in your controller. ``` helper_me...
377,195
<p>I have a C linux application (A) that spawns another process (P) when it is started. When I want to debug P I start A as usual and I connect with ddd/gdb to P.</p> <p>Problems appear when I want to debug the entry-point (start of main) of P. If I follow the usual approach when I connect the debugger to P is already...
[ { "answer_id": 377252, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": -1, "selected": false, "text": "<p>You should be able to do this by making use of gdb's remote debugging features, specifically <code>gdbserver</code>....
2008/12/18
[ "https://Stackoverflow.com/questions/377195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a C linux application (A) that spawns another process (P) when it is started. When I want to debug P I start A as usual and I connect with ddd/gdb to P. Problems appear when I want to debug the entry-point (start of main) of P. If I follow the usual approach when I connect the debugger to P is already to late. ...
You should use this option: ``` set follow-fork-mode *mode* ``` Where *mode* is one of `parent`, `child` or `ask`. To follow the parent (this is the default) use: ``` set follow-fork-mode parent ``` To follow the child: ``` set follow-fork-mode child ``` To have the debugger ask you each time: ``` set follow-...
377,203
<p>Why does it (apparently) make a difference whether I pass <code>null</code> as an argument directly, or pass an <code>Object</code> that I assigned the <em>value</em> <code>null</code>?</p> <pre><code>Object testVal = null; test.foo(testVal); // dispatched to foo(Object) // test.foo(null); // compilation prob...
[ { "answer_id": 377214, "author": "Lawrence Dol", "author_id": 8946, "author_profile": "https://Stackoverflow.com/users/8946", "pm_score": 2, "selected": false, "text": "<p>Because the second commented out invocation with null is ambiguous to the compiler. The literal null could be a str...
2008/12/18
[ "https://Stackoverflow.com/questions/377203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45018/" ]
Why does it (apparently) make a difference whether I pass `null` as an argument directly, or pass an `Object` that I assigned the *value* `null`? ``` Object testVal = null; test.foo(testVal); // dispatched to foo(Object) // test.foo(null); // compilation problem -> "The method foo(String) is ambiguous" publi...
Which version of Java are you using? With 1.6.0\_11 the code (pasted below) compiles and runs. I am sure its obvious why `foo(testVal)` goes to `foo(Object)`. The reason why `foo(null)` goes to `foo(String)` is a little complex. The constant `null` is of type `nulltype`, which is a subtype of all types. So, this `nul...
377,204
<p>I use some wx.ListCtrl classes in wx.LC_REPORT mode, augmented with ListCtrlAutoWidthMixin.</p> <p>The problem is: When user double clicks the column divider (to auto resize column), column width is set to match the width of contents. This is done by the wx library and resizes column to just few pixels when the con...
[ { "answer_id": 380378, "author": "Abgan", "author_id": 46308, "author_profile": "https://Stackoverflow.com/users/46308", "pm_score": 2, "selected": true, "text": "<p>Ok, after some struggle I got working workaround for that. It is ugly from design point of view, but works well enough for...
2008/12/18
[ "https://Stackoverflow.com/questions/377204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46308/" ]
I use some wx.ListCtrl classes in wx.LC\_REPORT mode, augmented with ListCtrlAutoWidthMixin. The problem is: When user double clicks the column divider (to auto resize column), column width is set to match the width of contents. This is done by the wx library and resizes column to just few pixels when the control is e...
Ok, after some struggle I got working workaround for that. It is ugly from design point of view, but works well enough for me. That's how it works: 1. Store the initial width of column. ``` self.SetColumnWidth(colNum, wx.LIST_AUTOSIZE_USEHEADER) self.__columnWidth[colNum] = self.GetColumnWidth(c) ``` 2. Register h...
377,213
<p>I want to know how to simply publish over http = much like <a href="http://en.wikipedia.org/wiki/Mercurial" rel="noreferrer">Mercurial</a>'s hg serve! On the Windows/work box do this:</p> <pre><code>git serve </code></pre> <p>and then on the Linux box SIMPLY go:</p> <pre><code>git clone http://project project <...
[ { "answer_id": 377293, "author": "seanhodges", "author_id": 43662, "author_profile": "https://Stackoverflow.com/users/43662", "pm_score": 9, "selected": true, "text": "<p>Navigate into your project and start git-daemon with the following switches:</p>\n\n<pre><code>cd project\ngit daemon...
2008/12/18
[ "https://Stackoverflow.com/questions/377213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21537/" ]
I want to know how to simply publish over http = much like [Mercurial](http://en.wikipedia.org/wiki/Mercurial)'s hg serve! On the Windows/work box do this: ``` git serve ``` and then on the Linux box SIMPLY go: ``` git clone http://project project ``` finished.
Navigate into your project and start git-daemon with the following switches: ``` cd project git daemon --reuseaddr --base-path=. --export-all --verbose ``` This tells git-daemon to serve up all projects inside the current directory (which I assume is the project directory containing the .git/ folder). It also tells ...
377,217
<p>I am using the following methods:</p> <pre><code>public void M1(Int32 a) { // acquire MyMutex DoSomething(a); // release MyMutex } </code></pre> <p>and</p> <pre><code>public void M2(String s, String t) { // acquire MyMutex DoSomethingElse(s, t); // release MyMutex } </code></pre> <p>From what I have ...
[ { "answer_id": 377224, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "<p>Absolutely you can mix delegates with generics. In 2.0, <code>Predicate&lt;T&gt;</code> etc are good examples of th...
2008/12/18
[ "https://Stackoverflow.com/questions/377217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19756/" ]
I am using the following methods: ``` public void M1(Int32 a) { // acquire MyMutex DoSomething(a); // release MyMutex } ``` and ``` public void M2(String s, String t) { // acquire MyMutex DoSomethingElse(s, t); // release MyMutex } ``` From what I have found so far it seems that it is not possible to ...
Absolutely you can mix delegates with generics. In 2.0, `Predicate<T>` etc are good examples of this, but you must have the same number of args. In this scenario, perhaps an option is to use captures to include the args in the delegate? i.e. ``` public delegate void Action(); static void Main() { ...
377,219
<p>I'm studying an introductory course in databases and one of the exercises is to work with MS-Access. However I'm using Linux at home and although I can use the computer classes at the university it is far from convenient (limited open time - my studying time is mostly nights).</p> <p>So how can I use an Access file...
[ { "answer_id": 377274, "author": "dsm", "author_id": 7780, "author_profile": "https://Stackoverflow.com/users/7780", "pm_score": 1, "selected": false, "text": "<p>From the documentation: <a href=\"http://wiki.services.openoffice.org/wiki/Connecting_to_Microsoft_Access\" rel=\"nofollow no...
2008/12/18
[ "https://Stackoverflow.com/questions/377219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm studying an introductory course in databases and one of the exercises is to work with MS-Access. However I'm using Linux at home and although I can use the computer classes at the university it is far from convenient (limited open time - my studying time is mostly nights). So how can I use an Access file (`*.mdb`)...
Although a bit dated, I've had good success with `mdbtools` which is a set of command line tools for accessing and converting Access databases to other formats. I've used it for importing databases into PostgreSQL. If you're running an Ubuntu variant you can install it with: ``` sudo apt-get install mdbtools ``` or...
377,228
<p>I'm currently using Magento 1.1.6. My store only sells unique items (shirts with exclusive designs) which means at any one time, only 1 unit is available for each items.</p> <p>How do I omit those items which are already sold from being displayed in the front page?</p> <p>BTW, I'm using these code to show products...
[ { "answer_id": 449622, "author": "stunti", "author_id": 54949, "author_profile": "https://Stackoverflow.com/users/54949", "pm_score": 0, "selected": false, "text": "<p>I supposed the file catalog/product/list_home_batik.phtml is based on catalog/product/list.phtml</p>\n\n<p>You can modif...
2008/12/18
[ "https://Stackoverflow.com/questions/377228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm currently using Magento 1.1.6. My store only sells unique items (shirts with exclusive designs) which means at any one time, only 1 unit is available for each items. How do I omit those items which are already sold from being displayed in the front page? BTW, I'm using these code to show products on the front pag...
Go to System>Configuration>Catalog>Inventory>Stock Options. the dropdown for "Display Out of Stock Products" change to No.
377,231
<p>How do I handle the scenario where I making a synchronous request to the server using XMLHttpRequest and the server is not available?</p> <pre><code>xmlhttp.open("POST","Page.aspx",false); xmlhttp.send(null); </code></pre> <p>Right now this scenario results into a JavaScript error: "The system cannot locate the re...
[ { "answer_id": 377302, "author": "fasih.rana", "author_id": 46024, "author_profile": "https://Stackoverflow.com/users/46024", "pm_score": 2, "selected": false, "text": "<p>Try the timeout property.</p>\n\n<pre><code>xmlHTTP.TimeOut= 2000 \n</code></pre>\n" }, { "answer_id": 37760...
2008/12/18
[ "https://Stackoverflow.com/questions/377231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46279/" ]
How do I handle the scenario where I making a synchronous request to the server using XMLHttpRequest and the server is not available? ``` xmlhttp.open("POST","Page.aspx",false); xmlhttp.send(null); ``` Right now this scenario results into a JavaScript error: "The system cannot locate the resource specified"
Ok I resolved it by using try...catch around xmlhttprequest.send : ``` xmlhttp.open("POST","Page.aspx",false); try { xmlhttp.send(null); } catch(e) { alert('there was a problem communicating with the server'); } ```
377,237
<p>A long time ago I saw this trick in Ruby. Instead of doing (for example)</p> <pre><code>if array1.empty? and array2.empty? and array3.empty? </code></pre> <p>You could call all of the objects at once and append the operation at the end, kind of like</p> <pre><code>if %w(array1 array2 array3).each { |a| a.empty? }...
[ { "answer_id": 377280, "author": "J Cooper", "author_id": 38803, "author_profile": "https://Stackoverflow.com/users/38803", "pm_score": 5, "selected": true, "text": "<p><code>if [array1, array2, array3].all? { |a| a.empty? }</code></p>\n\n<p>I think that's what you're looking for</p>\n" ...
2008/12/18
[ "https://Stackoverflow.com/questions/377237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
A long time ago I saw this trick in Ruby. Instead of doing (for example) ``` if array1.empty? and array2.empty? and array3.empty? ``` You could call all of the objects at once and append the operation at the end, kind of like ``` if %w(array1 array2 array3).each { |a| a.empty? } ``` But I think it was simpler tha...
`if [array1, array2, array3].all? { |a| a.empty? }` I think that's what you're looking for
377,243
<p>Using the code below, I am returning an nvarchar field from <em>MS SQL 2005</em> and keep getting a System.InvalidCastException.</p> <pre><code>vo.PlacementID = dr.IsDBNull(0) ? null : dr.GetString(0); </code></pre> <p>The vo.PlacementID variable is of type String so there shouldn't be a problem. The values I am t...
[ { "answer_id": 377249, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 0, "selected": false, "text": "<p>The <code>InvalidCastException</code> isn't raised because of the type incompatibility between the <code>PlacementID</code>...
2008/12/18
[ "https://Stackoverflow.com/questions/377243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17510/" ]
Using the code below, I am returning an nvarchar field from *MS SQL 2005* and keep getting a System.InvalidCastException. ``` vo.PlacementID = dr.IsDBNull(0) ? null : dr.GetString(0); ``` The vo.PlacementID variable is of type String so there shouldn't be a problem. The values I am trying to return are like this (nu...
If you read the exception again it gives you a clue as to the problem: > > System.**InvalidCastException**: > ***Unable to cast object of type 'System.Int32' to type > 'System.String'***. at > System.Data.SqlClient.SqlBuffer.get\_String() > at > System.Data.SqlClient.SqlDataReader.GetString(Int32 > i) > > > ...
377,312
<p>HI,</p> <p>I m doing the folling stuff in the jsp code I need to do it using Struts or using JSTL tag can any body have relevant idea please share..</p> <p>The following is my JSP code</p> <pre><code>&lt;% Object category = request.getAttribute("categoryDetails"); ...
[ { "answer_id": 377456, "author": "Andrew Edgecombe", "author_id": 11694, "author_profile": "https://Stackoverflow.com/users/11694", "pm_score": 2, "selected": false, "text": "<p>According to <a href=\"http://net-snmp.sourceforge.net/wiki/index.php/Writing_your_own_MIBs\" rel=\"nofollow n...
2008/12/18
[ "https://Stackoverflow.com/questions/377312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28557/" ]
HI, I m doing the folling stuff in the jsp code I need to do it using Struts or using JSTL tag can any body have relevant idea please share.. The following is my JSP code ``` <% Object category = request.getAttribute("categoryDetails"); Hashtable<String, Hashtable<Str...
According to [this](http://net-snmp.sourceforge.net/wiki/index.php/Writing_your_own_MIBs) net-snmp howto, there is a tool called [smilint](http://www.ibr.cs.tu-bs.de/projects/libsmi/smilint.html) from the [smilib](http://www.ibr.cs.tu-bs.de/projects/libsmi/) package that they recommend. Sounds more directed than using ...
377,354
<p>Is there an elegant way to do this:</p> <pre><code>SELECT Cols from MyTable WHERE zip = 90210 OR zip = 23310 OR zip = 74245 OR zip = 77427 OR zip = 18817 OR zip = 94566 OR zip = 34533 OR zip = 96322 OR zip = 34566 OR zip = 52214 OR zip = 73455 OR zip = 52675 OR zip = 54724 OR zip = 98566 OR zip = 92344 OR zip = 90...
[ { "answer_id": 377358, "author": "Ben", "author_id": 11522, "author_profile": "https://Stackoverflow.com/users/11522", "pm_score": 5, "selected": false, "text": "<p>Yes: Try this sql query. </p>\n\n<pre><code>Select cols from MyTable where zip in (90210, 23310, ... etc.)\n</code></pre>\n...
2008/12/18
[ "https://Stackoverflow.com/questions/377354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18749/" ]
Is there an elegant way to do this: ``` SELECT Cols from MyTable WHERE zip = 90210 OR zip = 23310 OR zip = 74245 OR zip = 77427 OR zip = 18817 OR zip = 94566 OR zip = 34533 OR zip = 96322 OR zip = 34566 OR zip = 52214 OR zip = 73455 OR zip = 52675 OR zip = 54724 OR zip = 98566 OR zip = 92344 OR zip = 90432 OR zip = 9...
Yes: Try this sql query. ``` Select cols from MyTable where zip in (90210, 23310, ... etc.) ```
377,377
<p>I have the following xsl that sorts my xml alphabetically:</p> <pre><code>&lt;xsl:template match="/"&gt; &lt;xsl:apply-templates /&gt; &lt;/xsl:template&gt; &lt;xsl:key name="rows-by-title" match="Row" use="translate(substring(@Title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" /&gt; &lt;xsl...
[ { "answer_id": 377399, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": -1, "selected": false, "text": "<p>I'm sort of confused by the question but I think what you're looking for is an xsl:if test with a combination of <a h...
2008/12/18
[ "https://Stackoverflow.com/questions/377377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12318/" ]
I have the following xsl that sorts my xml alphabetically: ``` <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:key name="rows-by-title" match="Row" use="translate(substring(@Title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" /> <xsl:variable name="StartRow" select="string(...
Here is my solution. You can decide via parameters `"per-row"` and `"show-empty"` if you want empty cells to show up or if you want to hide them. I'm sure a much more elegant version exists, but I could not come up with one. ;-) Comments welcome. ``` <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL...
377,406
<p>This is a really basic question but this is the first time I've used MATLAB and I'm stuck. I need to simulate a simple series RC network using 3 different numerical integration techniques. I think I understand how to use the ode solvers, but I have no idea how to enter the differential equation of the system. Do I n...
[ { "answer_id": 377421, "author": "Dan Vinton", "author_id": 21849, "author_profile": "https://Stackoverflow.com/users/21849", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://www4.ncsu.edu/~mahaider/NCSU_RTG_Site/RTM_Matlab_Intro.pdf\" rel=\"nofollow noreferrer\">The Offici...
2008/12/18
[ "https://Stackoverflow.com/questions/377406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31168/" ]
This is a really basic question but this is the first time I've used MATLAB and I'm stuck. I need to simulate a simple series RC network using 3 different numerical integration techniques. I think I understand how to use the ode solvers, but I have no idea how to enter the differential equation of the system. Do I need...
You are going to need a function file that takes *t* and *y* as input and gives *dy* as output. It would be its own file with the following header. ``` function dy = rigid(t,y) ``` Save it as rigid.m on the MATLAB path. From there you would put in your differential equation. You now have a function. Here is a simpl...
377,407
<p>Assuming Windows, is there a way I can detect from within a batch file if it was launched from an open command prompt or by double-clicking? I'd like to add a pause to the end of the batch process if and only if it was double clicked, so that the window doesn't just disappear along with any useful output it may hav...
[ { "answer_id": 377416, "author": "Learning", "author_id": 18275, "author_profile": "https://Stackoverflow.com/users/18275", "pm_score": -1, "selected": false, "text": "<p>Just add pause regardless of how it was opened? If it was opened from command prompt no harm done apart from a harmle...
2008/12/18
[ "https://Stackoverflow.com/questions/377407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33346/" ]
Assuming Windows, is there a way I can detect from within a batch file if it was launched from an open command prompt or by double-clicking? I'd like to add a pause to the end of the batch process if and only if it was double clicked, so that the window doesn't just disappear along with any useful output it may have pr...
I just ran a quick test and noticed the following, which may help you: * When run from an open command prompt, the %0 variable does not have double quotes around the path. If the script resides in the current directory, the path isn't even given, just the batch file name. * When run from explorer, the %0 variable is a...
377,417
<p>A common mistake when configuring the compilation/linking/etc. settings in VC++ 2008 is to set them in Release but not Debug (or vice versa) rather than setting them for "All Configurations". Any suggestions on how to avoid this kind of mistake?</p> <p>Some beginnings of ideas that I have:</p> <ul> <li><p>Find a w...
[ { "answer_id": 377416, "author": "Learning", "author_id": 18275, "author_profile": "https://Stackoverflow.com/users/18275", "pm_score": -1, "selected": false, "text": "<p>Just add pause regardless of how it was opened? If it was opened from command prompt no harm done apart from a harmle...
2008/12/18
[ "https://Stackoverflow.com/questions/377417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38659/" ]
A common mistake when configuring the compilation/linking/etc. settings in VC++ 2008 is to set them in Release but not Debug (or vice versa) rather than setting them for "All Configurations". Any suggestions on how to avoid this kind of mistake? Some beginnings of ideas that I have: * Find a way to make VC++ go to th...
I just ran a quick test and noticed the following, which may help you: * When run from an open command prompt, the %0 variable does not have double quotes around the path. If the script resides in the current directory, the path isn't even given, just the batch file name. * When run from explorer, the %0 variable is a...
377,425
<p>For learning and demonstrating, I need a macro which prints its parameter <strong>and</strong> evaluates it. I suspect it is a very common case, may be even a FAQ but I cannot find actual references.</p> <p>My current code is:</p> <pre><code>#define PRINT(expr) (fprintf(stdout, "%s -&gt; %d\n", __STRING(expr), (ex...
[ { "answer_id": 377441, "author": "aib", "author_id": 1088, "author_profile": "https://Stackoverflow.com/users/1088", "pm_score": 5, "selected": true, "text": "<p>You can use the # preprocessor token which converts the parameter following it to a string literal:</p>\n<pre><code>#include &...
2008/12/18
[ "https://Stackoverflow.com/questions/377425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15625/" ]
For learning and demonstrating, I need a macro which prints its parameter **and** evaluates it. I suspect it is a very common case, may be even a FAQ but I cannot find actual references. My current code is: ``` #define PRINT(expr) (fprintf(stdout, "%s -> %d\n", __STRING(expr), (expr))) ``` and then: ``` PRINT(x & ...
You can use the # preprocessor token which converts the parameter following it to a string literal: ``` #include <stdlib.h> #include <stdio.h> #define STR(x) #x #define PRINT(expr) (fprintf(stdout, "%s -> %d\n", STR(expr), (expr))) int main(void) { int x = 7; PRINT(x & 0x01); return EXIT_SUCCESS; } ``...
377,454
<p>How do I get my Python program to sleep for 50 milliseconds?</p>
[ { "answer_id": 377460, "author": "Dan Olson", "author_id": 33346, "author_profile": "https://Stackoverflow.com/users/33346", "pm_score": 7, "selected": false, "text": "<p>Use <code>time.sleep()</code>:</p>\n<pre><code>import time\ntime.sleep(50 / 1000)\n</code></pre>\n<p>See the Python d...
2008/12/18
[ "https://Stackoverflow.com/questions/377454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816/" ]
How do I get my Python program to sleep for 50 milliseconds?
Use [`time.sleep()`](https://docs.python.org/library/time.html#time.sleep) ``` from time import sleep sleep(0.05) ```
377,457
<p>I have a rather large project developed on Sharepoint and Project Server, designed as a multi-tier application. I programmatically manage web parts on certain web part pages. According to the choices of the user in one of the web pages, appropriate web parts are added to the web part collection of another web part p...
[ { "answer_id": 377460, "author": "Dan Olson", "author_id": 33346, "author_profile": "https://Stackoverflow.com/users/33346", "pm_score": 7, "selected": false, "text": "<p>Use <code>time.sleep()</code>:</p>\n<pre><code>import time\ntime.sleep(50 / 1000)\n</code></pre>\n<p>See the Python d...
2008/12/18
[ "https://Stackoverflow.com/questions/377457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1360/" ]
I have a rather large project developed on Sharepoint and Project Server, designed as a multi-tier application. I programmatically manage web parts on certain web part pages. According to the choices of the user in one of the web pages, appropriate web parts are added to the web part collection of another web part page...
Use [`time.sleep()`](https://docs.python.org/library/time.html#time.sleep) ``` from time import sleep sleep(0.05) ```
377,464
<p>I have plsql procedure which accepts certain parameters e.g. v_name, v_country, v_type.</p> <p>I wish to have a cursor with a select statement like this:</p> <pre><code>select column from table1 t1, table2 t2 where t1.name = v_name and t1.country = v_country and t1.id = t2.id and t2.type = v_type </code></pre> <p...
[ { "answer_id": 377491, "author": "hamishmcn", "author_id": 3590, "author_profile": "https://Stackoverflow.com/users/3590", "pm_score": 2, "selected": false, "text": "<p>One way would be to build up your query as a string then use <a href=\"http://download.oracle.com/docs/cd/B19306_01/app...
2008/12/18
[ "https://Stackoverflow.com/questions/377464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26108/" ]
I have plsql procedure which accepts certain parameters e.g. v\_name, v\_country, v\_type. I wish to have a cursor with a select statement like this: ``` select column from table1 t1, table2 t2 where t1.name = v_name and t1.country = v_country and t1.id = t2.id and t2.type = v_type ``` If certain parameters are emp...
The best way to use this is with DBMS\_SQL. You create a string that represents your SQL statement. You still use bind variables. It's painful. It goes something like this (I haven't compiled this, but it should be close) :- ``` CREATE OR REPLACE FUNCTION find_country( v_name t1.country%TYPE, ...
377,477
<p>I'm trying to do some research on flash objects in browsers. For example memory usage etc. With Adobe Flex Builder 3 im trying to do some profiling on swf files but the problem is that I can only do this on debug swfs. Almost all adds/games/video are release version. Is there a way to some testing on those?</p>
[ { "answer_id": 377491, "author": "hamishmcn", "author_id": 3590, "author_profile": "https://Stackoverflow.com/users/3590", "pm_score": 2, "selected": false, "text": "<p>One way would be to build up your query as a string then use <a href=\"http://download.oracle.com/docs/cd/B19306_01/app...
2008/12/18
[ "https://Stackoverflow.com/questions/377477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47351/" ]
I'm trying to do some research on flash objects in browsers. For example memory usage etc. With Adobe Flex Builder 3 im trying to do some profiling on swf files but the problem is that I can only do this on debug swfs. Almost all adds/games/video are release version. Is there a way to some testing on those?
The best way to use this is with DBMS\_SQL. You create a string that represents your SQL statement. You still use bind variables. It's painful. It goes something like this (I haven't compiled this, but it should be close) :- ``` CREATE OR REPLACE FUNCTION find_country( v_name t1.country%TYPE, ...
377,480
<p>I've created a generic lookless control with virtual property:</p> <pre><code>public abstract class TestControlBase&lt;TValue&gt; : Control { public static readonly DependencyProperty ValueProperty; static TestControlBase() { ValueProperty = DependencyProperty.Register("Value", typeof(TValue), ...
[ { "answer_id": 390050, "author": "Jarek", "author_id": 47086, "author_profile": "https://Stackoverflow.com/users/47086", "pm_score": 1, "selected": false, "text": "<p>I think there is nothing you can do. It's just a bug. Same thing happens when developing WF controls.</p>\n\n<p>My collea...
2008/12/18
[ "https://Stackoverflow.com/questions/377480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've created a generic lookless control with virtual property: ``` public abstract class TestControlBase<TValue> : Control { public static readonly DependencyProperty ValueProperty; static TestControlBase() { ValueProperty = DependencyProperty.Register("Value", typeof(TValue), ...
Ivan, Maybe the answer is a little bit late to you but other people can use it too. I had the same problem and got very disappointed when I read that this is a bug. But after some googleing I found a [blog](http://jamescrisp.org/2008/05/26/wpf-control-inheritance-with-generics/) that shows a way to use this kind of in...
377,486
<p>I've got a simple class that inherits from Collection and adds a couple of properties. I need to serialize this class to XML, but the XMLSerializer ignores my additional properties.</p> <p>I assume this is because of the special treatment that XMLSerializer gives ICollection and IEnumerable objects. What's the best...
[ { "answer_id": 377494, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "<p>Collections generally don't make good places for extra properties. Both during serialization and in data-binding, t...
2008/12/18
[ "https://Stackoverflow.com/questions/377486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3464/" ]
I've got a simple class that inherits from Collection and adds a couple of properties. I need to serialize this class to XML, but the XMLSerializer ignores my additional properties. I assume this is because of the special treatment that XMLSerializer gives ICollection and IEnumerable objects. What's the best way aroun...
Collections generally don't make good places for extra properties. Both during serialization and in data-binding, they will be ignored if the item looks like a collection (`IList`, `IEnumerable`, etc - depending on the scenario). If it was me, I would encapsulate the collection - i.e. ``` [Serializable] public class ...
377,506
<p>I have the following code sample :</p> <pre><code>public class Base { public virtual void MyMethod(int param) { Console.WriteLine(&quot;Base:MyMethod - Int {0}&quot;, param); } } public class Derived1 : Base { public override void MyMethod(int param) { Console.WriteLine(&quot;Deri...
[ { "answer_id": 377519, "author": "schnaader", "author_id": 34065, "author_profile": "https://Stackoverflow.com/users/34065", "pm_score": 0, "selected": false, "text": "<p>I'd guess that when calling MyMethod(5), 5 could be a double or an int as well and double has higher priority. Have y...
2008/12/18
[ "https://Stackoverflow.com/questions/377506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40981/" ]
I have the following code sample : ``` public class Base { public virtual void MyMethod(int param) { Console.WriteLine("Base:MyMethod - Int {0}", param); } } public class Derived1 : Base { public override void MyMethod(int param) { Console.WriteLine("Derived1:MyMethod - Int {0}", pa...
Oddly, I was discussing this with Jon the other evening! There is a precedence issue - the overridden method is **defined** in the base-class, so for "best method" purposes, the overload (even with an implicit cast) is preferable, since it is defined in the most-specific type (the subclass). If you re-declared the met...
377,513
<p>I'm getting the following error when I try to use the JSTL XML taglib:</p> <pre><code>/server-side-transform.jsp(51,0) According to TLD or attribute directive in tag file, attribute xml does not accept any expressions </code></pre> <p>I'm looking into the tlds etc, but if anyone knows what this is an can save me ...
[ { "answer_id": 377553, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 3, "selected": true, "text": "<p>Your code is picking up an \"incorrect\" version of x-1_0.tld, probably due to classpath issues. I see for instance o...
2008/12/18
[ "https://Stackoverflow.com/questions/377513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2362/" ]
I'm getting the following error when I try to use the JSTL XML taglib: ``` /server-side-transform.jsp(51,0) According to TLD or attribute directive in tag file, attribute xml does not accept any expressions ``` I'm looking into the tlds etc, but if anyone knows what this is an can save me some time, it'd be appreci...
Your code is picking up an "incorrect" version of x-1\_0.tld, probably due to classpath issues. I see for instance on my current classpath, I have one version of x-1\_0.tld that ALLOWS runtime-expressions ${syntax} in this tag and one that does not. The one in standard.jar does not allow EL expressions, while the one I...
377,523
<p>How can I constrain a vertical WPF <code>StackPanel</code>'s width to the most narrow item it contains. The <code>StackPanel</code>'s width must not be greater than the width of any other child element.</p>
[ { "answer_id": 377767, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 1, "selected": false, "text": "<p>You can't. A vertically oriented <code>StackPanel</code> will always allocate as much width as its children request...
2008/12/18
[ "https://Stackoverflow.com/questions/377523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4227/" ]
How can I constrain a vertical WPF `StackPanel`'s width to the most narrow item it contains. The `StackPanel`'s width must not be greater than the width of any other child element.
Unfortunately the *IValueConverter* approach will not always work; if the children are added to *StackPanel* statically, for example, the child collection will be empty at the time of binding (so I discovered). The simplest solution is to create a custom panel: ``` public class ConstrainedStackPanel : StackPanel { ...
377,551
<p>How can I get the (physical) installed path of a DLL that is (may be) registered in GAC? This DLL is a control that may be hosted in things other than a .Net app (including IDEs other than VS...).</p> <p>When I use System.Reflection.Assembly.GetExecutingAssembly().Location, it gives path of GAC folder in winnt\syst...
[ { "answer_id": 377715, "author": "BFree", "author_id": 15861, "author_profile": "https://Stackoverflow.com/users/15861", "pm_score": 2, "selected": false, "text": "<p>Do you have the option of embedding a resource to this DLL? That way, it doesn't really matter where the DLL is located o...
2008/12/18
[ "https://Stackoverflow.com/questions/377551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41557/" ]
How can I get the (physical) installed path of a DLL that is (may be) registered in GAC? This DLL is a control that may be hosted in things other than a .Net app (including IDEs other than VS...). When I use System.Reflection.Assembly.GetExecutingAssembly().Location, it gives path of GAC folder in winnt\system32 - or ...
If something gets put in the GAC, it actually gets copied into a spot under %WINDIR%\assembly, like ``` C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll ``` I assume you're seeing something like that when you check the Location of the assembly in question when it's installed in the GA...
377,614
<p>I'm trying to have text spans pop up on a hover pseudo-class for different lines in a menu (list items). I can have the pop-ups occupy the same space in the div if the menu/list is horizontal, but a vertical list places the popups at the same vertical height as the "parent" list/menu item.</p> <p>Here is the relev...
[ { "answer_id": 378053, "author": "Jason", "author_id": 22786, "author_profile": "https://Stackoverflow.com/users/22786", "pm_score": 0, "selected": false, "text": "<p>So you want all the different spans to be appeared in the same place?\nYou set the relative position in A, which make the...
2008/12/18
[ "https://Stackoverflow.com/questions/377614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to have text spans pop up on a hover pseudo-class for different lines in a menu (list items). I can have the pop-ups occupy the same space in the div if the menu/list is horizontal, but a vertical list places the popups at the same vertical height as the "parent" list/menu item. Here is the relevant code I ...
My my, that's a whole lot of HTML and css for a simple task. I wont try to read through it all, but just give you your answer ``` <ul> <li><a href="">item 1<span>this is popup1.</span></a></li> <li><a href="">item 2<span>This is popup 2's text but I want it to appear in exactly the same place as popup 1's text doe...
377,631
<pre><code>echo date('r',strtotime("16 Dec, 2010")); //Tue, 16 Dec 2008 20:10:00 +0530 echo date('r',strtotime("16 Dec 2010")); //Sat, 16 Jan 2010 00:00:00 +0530 </code></pre> <p>That's just wrong... Either it should fail or it should parse correctly. Do you know any robust natural language date/time parser in php?...
[ { "answer_id": 377708, "author": "soulmerge", "author_id": 44562, "author_profile": "https://Stackoverflow.com/users/44562", "pm_score": 0, "selected": false, "text": "<p>strtotime is the best function you could find for that. I doubt that an arbitrary string representation of a date wil...
2008/12/18
[ "https://Stackoverflow.com/questions/377631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17674/" ]
``` echo date('r',strtotime("16 Dec, 2010")); //Tue, 16 Dec 2008 20:10:00 +0530 echo date('r',strtotime("16 Dec 2010")); //Sat, 16 Jan 2010 00:00:00 +0530 ``` That's just wrong... Either it should fail or it should parse correctly. Do you know any robust natural language date/time parser in php? How do you parse nat...
If you know in what format the time is represented in the string, you can use `strptime()` together with the appropriate format string to parse it. It will at least report an error when it cannot interpret the string according to the format. This function exists in PHP 5.1.0 and up. If you want to take arbitrary user...
377,632
<p>I have an xml file which I would like to create a form/table around to add, edit and delete records using PHP. Currently I use simpleXML to load the XML file, and display its content on various pages.</p> <p>Is there any way I can create a table that shows all results, and allows me to either edit or delete that p...
[ { "answer_id": 377646, "author": "troelskn", "author_id": 18180, "author_profile": "https://Stackoverflow.com/users/18180", "pm_score": 1, "selected": false, "text": "<p>I would suggest that you use DomDocument, and DomXPath, rather than SimpleXml. However, in general, XML is not an opti...
2008/12/18
[ "https://Stackoverflow.com/questions/377632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47378/" ]
I have an xml file which I would like to create a form/table around to add, edit and delete records using PHP. Currently I use simpleXML to load the XML file, and display its content on various pages. Is there any way I can create a table that shows all results, and allows me to either edit or delete that particular r...
XSLT is your friend for converting the XML database file to the format you want to display on the web-page. You create an XSL template that includes all the HTML you want for each record and then iterate through the XML file with a for-each statement. I'll give a rough overview and can help with more details if needed....
377,633
<p>I have searched high and low and cannot find a Samsung Omnia SDK.</p> <p>I know its possible to use the .net framework for development , but i want more , specifically being able to access the motion sensor and maybe the GPS as well.</p> <p>Any idea or directions are welcome.</p>
[ { "answer_id": 377646, "author": "troelskn", "author_id": 18180, "author_profile": "https://Stackoverflow.com/users/18180", "pm_score": 1, "selected": false, "text": "<p>I would suggest that you use DomDocument, and DomXPath, rather than SimpleXml. However, in general, XML is not an opti...
2008/12/18
[ "https://Stackoverflow.com/questions/377633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42069/" ]
I have searched high and low and cannot find a Samsung Omnia SDK. I know its possible to use the .net framework for development , but i want more , specifically being able to access the motion sensor and maybe the GPS as well. Any idea or directions are welcome.
XSLT is your friend for converting the XML database file to the format you want to display on the web-page. You create an XSL template that includes all the HTML you want for each record and then iterate through the XML file with a for-each statement. I'll give a rough overview and can help with more details if needed....
377,636
<p>ive got the problem that i dont know how to stop my function with mouseover and restart it with mouseout</p> <p>first here is my test-code:</p> <p> </p> <pre><code> &lt;script type="text/javascript"&gt; function fadeEngine(x) { var total_divs=3; //setze hier die nummer der gewollten di...
[ { "answer_id": 377679, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 0, "selected": false, "text": "<p>I'm not sure exactly what you want to happen with regards to your fadeIn and fadeOut effects in your fadeEngine, ...
2008/12/18
[ "https://Stackoverflow.com/questions/377636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
ive got the problem that i dont know how to stop my function with mouseover and restart it with mouseout first here is my test-code: ``` <script type="text/javascript"> function fadeEngine(x) { var total_divs=3; //setze hier die nummer der gewollten divs var y=x; if(x==to...
Give all of your `#fade`X elements a class (say .faders) and then use: ``` $('.faders').stop(); ``` Or give the container div an id like `#faderbox` and say: ``` $('#faderbox div').stop(); ```
377,640
<p>Which MVC-framework is the best option (performance/ease of development) for a web application, that will have + 2 million visits per week.</p> <p>Basically the site is a search engine,but also there will be large amounts of XML parsing, and high db traffic.</p> <p>We are using Java, over Jboss 4.2.3x, with PG as ...
[ { "answer_id": 377679, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 0, "selected": false, "text": "<p>I'm not sure exactly what you want to happen with regards to your fadeIn and fadeOut effects in your fadeEngine, ...
2008/12/18
[ "https://Stackoverflow.com/questions/377640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/314728/" ]
Which MVC-framework is the best option (performance/ease of development) for a web application, that will have + 2 million visits per week. Basically the site is a search engine,but also there will be large amounts of XML parsing, and high db traffic. We are using Java, over Jboss 4.2.3x, with PG as DB, and Solr for ...
Give all of your `#fade`X elements a class (say .faders) and then use: ``` $('.faders').stop(); ``` Or give the container div an id like `#faderbox` and say: ``` $('#faderbox div').stop(); ```
377,644
<p>Is there some way I can show custom exception messages as an alert in my jQuery AJAX error message?</p> <p>For example, if I want to throw an exception on the server side via <a href="http://en.wikipedia.org/wiki/Apache_Struts" rel="noreferrer">Struts</a> by <code>throw new ApplicationException(&quot;User name alrea...
[ { "answer_id": 381056, "author": "Vitor Silva", "author_id": 1842864, "author_profile": "https://Stackoverflow.com/users/1842864", "pm_score": 3, "selected": false, "text": "<p>I believe the Ajax response handler uses the HTTP status code to check if there was an error.</p>\n\n<p>So if y...
2008/12/18
[ "https://Stackoverflow.com/questions/377644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there some way I can show custom exception messages as an alert in my jQuery AJAX error message? For example, if I want to throw an exception on the server side via [Struts](http://en.wikipedia.org/wiki/Apache_Struts) by `throw new ApplicationException("User name already exists");`, I want to catch this message ('u...
Make sure you're setting `Response.StatusCode` to something other than 200. Write your exception's message using `Response.Write`, then use... ``` xhr.responseText ``` ..in your javascript.
377,647
<p>I have an action handling a form post, but I want to make sure they are authenticated before the action. The problem is that the post data is lost because they user is redirected to the login page, and then back. </p> <pre><code> [AcceptVerbs(HttpVerbs.Post)] [Authorize] public ActionResult AskQuestion(s...
[ { "answer_id": 377657, "author": "D'Arcy Rittich", "author_id": 39430, "author_profile": "https://Stackoverflow.com/users/39430", "pm_score": 2, "selected": false, "text": "<p>A POST is usually used for an add, update, or delete of data. By the time the user is doing this, if authenticat...
2008/12/18
[ "https://Stackoverflow.com/questions/377647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33647/" ]
I have an action handling a form post, but I want to make sure they are authenticated before the action. The problem is that the post data is lost because they user is redirected to the login page, and then back. ``` [AcceptVerbs(HttpVerbs.Post)] [Authorize] public ActionResult AskQuestion(string question...
You need to serialize your form values and a RedirectUrl to a hidden field. After authentication deserialize the data in your hidden field and redirect based on the value of the RedirectUrl. You will need a custom Authorize class to handle this.