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
427,395
<p>I'm trying to get the Poll tutorial working at my Dreamhost account (I don't have any prior experience of deploying Django). I downloaded the script I found here (<a href="http://gabrielfalcao.com/2008/12/02/hosting-and-deploying-django-apps-on-dreamhost/" rel="nofollow noreferrer">http://gabrielfalcao.com/2008/12/0...
[ { "answer_id": 427401, "author": "sastanin", "author_id": 25450, "author_profile": "https://Stackoverflow.com/users/25450", "pm_score": 1, "selected": false, "text": "<p>This is the official <a href=\"http://wiki.dreamhost.com/index.php/Django\" rel=\"nofollow noreferrer\">Dreamhost wiki...
2009/01/09
[ "https://Stackoverflow.com/questions/427395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1897/" ]
I'm trying to get the Poll tutorial working at my Dreamhost account (I don't have any prior experience of deploying Django). I downloaded the script I found here (<http://gabrielfalcao.com/2008/12/02/hosting-and-deploying-django-apps-on-dreamhost/>) at my home directory and executed it. Now I have Python 2.5 and Django...
Since DreamHost supports mod\_passenger, and AFAIK it works not only for Ruby/Rails apps but also for Python/Django - you might give it a try. Just put app there and select directory where execute script are (eg. dispatch.fcgi). You might wanna see/study [a working example](http://github.com/kwe/passenger-django-wsgi-...
427,400
<p>I'm a newbie to python and the app engine.</p> <p>I have this code that sends an email based on request params after some auth logic. in my Unit tests (i'm using <a href="http://code.google.com/p/gaeunit/" rel="nofollow noreferrer">GAEUnit</a>), how do I confirm an email with specific contents were sent? - i.e. how...
[ { "answer_id": 427418, "author": "guerda", "author_id": 32043, "author_profile": "https://Stackoverflow.com/users/32043", "pm_score": 3, "selected": true, "text": "<p>A very short introduction provides <a href=\"http://pypi.python.org/pypi/MiniMock/1.0\" rel=\"nofollow noreferrer\">PyPI:...
2009/01/09
[ "https://Stackoverflow.com/questions/427400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/209/" ]
I'm a newbie to python and the app engine. I have this code that sends an email based on request params after some auth logic. in my Unit tests (i'm using [GAEUnit](http://code.google.com/p/gaeunit/)), how do I confirm an email with specific contents were sent? - i.e. how do I mock the emailer with a fake emailer to v...
A very short introduction provides [PyPI: MiniMock 1.0](http://pypi.python.org/pypi/MiniMock/1.0). It's a very small library to establish mocks. 1. Inject your mock into the module, that should be mocked 2. Define, what your mock will return 3. Call the method 4. Your mock will say, which method were called. Good luc...
427,447
<p>Let say there is a table:</p> <pre><code>TableA:Field1, Field2, Field3 </code></pre> <p>and associated JPA entity class</p> <pre><code>@Entity @Table(name="TableA") public class TableA{ @Id @Column(name="Field1") private Long id; @Column(name="Field2") private Long field2; @Column(name="Field3") p...
[ { "answer_id": 517493, "author": "aledbf", "author_id": 53078, "author_profile": "https://Stackoverflow.com/users/53078", "pm_score": 2, "selected": false, "text": "<p>You can use the event listeners provided by Jpa to do something when you load one row of the db, ie:</p>\n\n<pre><code>@...
2009/01/09
[ "https://Stackoverflow.com/questions/427447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29669/" ]
Let say there is a table: ``` TableA:Field1, Field2, Field3 ``` and associated JPA entity class ``` @Entity @Table(name="TableA") public class TableA{ @Id @Column(name="Field1") private Long id; @Column(name="Field2") private Long field2; @Column(name="Field3") private Long field3; //... more ass...
It has been added in JPA 2.0 **Usage:** ``` SELECT e.name, CASE WHEN (e.salary >= 100000) THEN 1 WHEN (e.salary < 100000) THEN 2 ELSE 0 END FROM Employee e ``` **Ref:** <http://en.wikibooks.org/wiki/Java_Persistence/JPQL_BNF#New_in_JPA_2.0>
427,448
<p>Hi I have following data in the table:</p> <p>ID-----startDate----endDate<br> 5549 2008-05-01 4712-12-31<br> <strong>5567 2008-04-17 2008-04-30 1<br> 5567 2008-05-01 2008-07-31 1<br> 5567 2008-09-01 4712-12-31 2</strong><br> 5569 2008-05-01 2008-08-31<br> 5569 2008-09...
[ { "answer_id": 427484, "author": "Dheer", "author_id": 17266, "author_profile": "https://Stackoverflow.com/users/17266", "pm_score": 0, "selected": false, "text": "<p>you will have to write a PL/SQL block sample logic as below;</p>\n\n<pre><code>Create or Replace someproc\nDeclare\n C...
2009/01/09
[ "https://Stackoverflow.com/questions/427448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3515/" ]
Hi I have following data in the table: ID-----startDate----endDate 5549 2008-05-01 4712-12-31 **5567 2008-04-17 2008-04-30 1 5567 2008-05-01 2008-07-31 1 5567 2008-09-01 4712-12-31 2** 5569 2008-05-01 2008-08-31 5569 2008-09-01 4712-12-31 5589 2008-04-18 2008-04-30 5589 2008-05-01 4712-1...
I think this will do what you need: (note that it will probably get confused by overlapping ranges; don't know if they're possible in your data set) ``` select id, min(start_date) period_start, max(end_date) period_end from ( select id, start_date, end_date, max(contig) over (partition by id order by end_date...
427,451
<p>I have a unit test (example is modified <a href="http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html" rel="noreferrer">Test::Unit documentation</a>)</p> <pre><code>require 'test/unit' class TC_MyTest &lt; Test::Unit::TestCase def test_something assert(true) end end </code></pre> <p...
[ { "answer_id": 427475, "author": "Željko Filipin", "author_id": 17469, "author_profile": "https://Stackoverflow.com/users/17469", "pm_score": 4, "selected": true, "text": "<p>Run unit test with <a href=\"http://spattendesign.com/2007/10/11/ruby-unit-test-command-line-options\" rel=\"nore...
2009/01/09
[ "https://Stackoverflow.com/questions/427451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17469/" ]
I have a unit test (example is modified [Test::Unit documentation](http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html)) ``` require 'test/unit' class TC_MyTest < Test::Unit::TestCase def test_something assert(true) end end ``` When I execute it, I get: ``` Loaded suite C:/test Star...
Run unit test with [verbose](http://spattendesign.com/2007/10/11/ruby-unit-test-command-line-options) option. ``` test.rb -v v ``` or ``` test.rb --verbose=verbose ``` Output: ``` Loaded suite C:/test Started test_something(TC_MyTest): . Finished in 0.0 seconds. 1 tests, 1 assertions, 0 failures, 0 errors ``...
427,452
<p>In the following setup, does method B run in a (new) transaction?</p> <p>An EJB, having two methods, method A and method B</p> <pre><code>public class MyEJB implements SessionBean public void methodA() { doImportantStuff(); methodB(); doMoreImportantStuff(); } public void methodB(...
[ { "answer_id": 427493, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 2, "selected": false, "text": "<p>They will use the same transaction.</p>\n\n<p>If I remember well, the transaction is started by the container \"before...
2009/01/09
[ "https://Stackoverflow.com/questions/427452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In the following setup, does method B run in a (new) transaction? An EJB, having two methods, method A and method B ``` public class MyEJB implements SessionBean public void methodA() { doImportantStuff(); methodB(); doMoreImportantStuff(); } public void methodB() { doDatabase...
Your call to `methodB()` is an ordinary call of a method, not intercepted by the EJB container; at run-time the EJB container will inject a [proxy](http://en.wikipedia.org/wiki/Proxy_pattern) and not an instance of your class, this is the way it intercepts calls and setup the environment before calling your method. If ...
427,453
<p>Suppose I have a Python function as defined below:</p> <pre><code>def foo(arg1,arg2): #do something with args a = arg1 + arg2 return a </code></pre> <p>I can get the name of the function using <code>foo.func_name</code>. How can I programmatically get its source code, as I typed above?</p>
[ { "answer_id": 427504, "author": "runeh", "author_id": 2906, "author_profile": "https://Stackoverflow.com/users/2906", "pm_score": 8, "selected": false, "text": "<p>The <a href=\"http://docs.python.org/library/inspect.html?highlight=inspect#retrieving-source-code\" rel=\"noreferrer\">ins...
2009/01/09
[ "https://Stackoverflow.com/questions/427453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Suppose I have a Python function as defined below: ``` def foo(arg1,arg2): #do something with args a = arg1 + arg2 return a ``` I can get the name of the function using `foo.func_name`. How can I programmatically get its source code, as I typed above?
If the function is from a source file available on the filesystem, then [`inspect.getsource(foo)`](https://docs.python.org/3/library/inspect.html#inspect.getsource) might be of help: If `foo` is defined as: ``` def foo(arg1,arg2): #do something with args a = arg1 + arg2 return a ``` ...
427,472
<p>my Python program can be launched with a range of different options (or subcommands) like:</p> <pre><code>$ myProgram doSomething $ myProgram doSomethingElse $ myProgram nowDoSomethingDifferent </code></pre> <p>I want it to use auto-completion with so that if i type "myProgram d" it returns "myProgram doSomething...
[ { "answer_id": 427490, "author": "sastanin", "author_id": 25450, "author_profile": "https://Stackoverflow.com/users/25450", "pm_score": 2, "selected": false, "text": "<p>As well as I know, PYTHONSTARTUP is for commands to be executed when the interpreter starts up <a href=\"http://www.py...
2009/01/09
[ "https://Stackoverflow.com/questions/427472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42636/" ]
my Python program can be launched with a range of different options (or subcommands) like: ``` $ myProgram doSomething $ myProgram doSomethingElse $ myProgram nowDoSomethingDifferent ``` I want it to use auto-completion with so that if i type "myProgram d" it returns "myProgram doSomething" and if i type "myProgram ...
Create a file "myprog-completion.bash" and source it in your .bashrc file. Something like this to get you started... ``` _myProgram() { cur=${COMP_WORDS[COMP_CWORD]} case "${cur}" in d*) use="doSomething" ;; n*) use="nowDoSomethingElse" ;; esac COMPREPLY=( $( compgen -W "$use" -- $cur ) ) } complete -o...
427,477
<p>Is there a more efficient way to clamp real numbers than using if statements or ternary operators? I want to do this both for doubles and for a 32-bit fixpoint implementation (16.16). I'm <strong>not</strong> asking for code that can handle both cases; they will be handled in separate functions.</p> <p>Obviously, I...
[ { "answer_id": 427491, "author": "abelenky", "author_id": 34824, "author_profile": "https://Stackoverflow.com/users/34824", "pm_score": 0, "selected": false, "text": "<p>If I understand properly, you want to limit a value \"a\" to a range between MY_MIN and MY_MAX. The type of \"a\" is ...
2009/01/09
[ "https://Stackoverflow.com/questions/427477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15323/" ]
Is there a more efficient way to clamp real numbers than using if statements or ternary operators? I want to do this both for doubles and for a 32-bit fixpoint implementation (16.16). I'm **not** asking for code that can handle both cases; they will be handled in separate functions. Obviously, I can do something like:...
For the 16.16 representation, the simple ternary is unlikely to be bettered speed-wise. And for doubles, because you need it standard/portable C, bit-fiddling of any kind will end badly. Even if a bit-fiddle was possible (which I doubt), you'd be relying on the binary representation of doubles. THIS (and their size)...
427,479
<p>I'm trying to "force" Safari or IE7 to open a new page <em>using a new tab</em>.</p> <p>Programmatically I mean something like:</p> <pre><code>window.open('page.html','newtaborsomething'); </code></pre>
[ { "answer_id": 427486, "author": "Sam Meldrum", "author_id": 16005, "author_profile": "https://Stackoverflow.com/users/16005", "pm_score": 4, "selected": false, "text": "<p>It's up to the user whether they want to use new tabs or new windows, it isn't the business of the developer to mod...
2009/01/09
[ "https://Stackoverflow.com/questions/427479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53246/" ]
I'm trying to "force" Safari or IE7 to open a new page *using a new tab*. Programmatically I mean something like: ``` window.open('page.html','newtaborsomething'); ```
You can't directly control this, because it's an option controlled by Internet Explorer users. Opening pages using Window.open with a different window name will open in a new browser window like a popup, *OR* open in a new tab, if the user configured the browser to do so.
427,482
<p>I have this simple Jsp page:</p> <pre><code>&lt;%@ page language="java" import="java.awt.Color"%&gt; &lt;% Color background = Color.white; %&gt; </code></pre> <p>Which fails with following error:</p> <pre><code>java.lang.NoClassDefFoundError at _text__jsp._jspService(/text.jsp:3) at com.caucho.jsp.JavaPag...
[ { "answer_id": 427506, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": -1, "selected": false, "text": "<p>Some VM with the -server option don't load the java.awt. package at all ( nor javax.swing and others ) </p>\n\n<p>Thi...
2009/01/09
[ "https://Stackoverflow.com/questions/427482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9789/" ]
I have this simple Jsp page: ``` <%@ page language="java" import="java.awt.Color"%> <% Color background = Color.white; %> ``` Which fails with following error: ``` java.lang.NoClassDefFoundError at _text__jsp._jspService(/text.jsp:3) at com.caucho.jsp.JavaPage.service(JavaPage.java:75) at com.caucho.jsp...
Not sure about the issue. I can run your code successfully in my Tomcat. May be this problem is particular to Resin. Or, as said by Dave, may be a headless issue. Your best bet is to convert the image in some POJO and then spit that to the browser, or may be save it somewhere on the disk and then link it in your JSP. ...
427,485
<p>Suppose I start two threads like this:</p> <pre><code>// Start first thread Thread loaderThread1 = new Thread(loader.Load); loaderThread1.Name = "Rope"; loaderThread1.Start(); // Start second thread Thread loaderThread2 = new Thread(loader.Load); loaderThread2.Name = "String"; loaderThread2.Start(); </code></pre> ...
[ { "answer_id": 427502, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "<p>I suspect you might have to put the threads into a <code>Dictionary&lt;string,Thread&gt;</code> for that to work -...
2009/01/09
[ "https://Stackoverflow.com/questions/427485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7174/" ]
Suppose I start two threads like this: ``` // Start first thread Thread loaderThread1 = new Thread(loader.Load); loaderThread1.Name = "Rope"; loaderThread1.Start(); // Start second thread Thread loaderThread2 = new Thread(loader.Load); loaderThread2.Name = "String"; loaderThread2.Start(); ``` Is there any way I can...
I suspect you might have to put the threads into a `Dictionary<string,Thread>` for that to work - but why do you want it anyway? There are usually other ways of communicating between threads (any of the lock / wait objects). To work at the process level (i.e. not thinking of the `Thread` object), see [here](http://www...
427,488
<p>I have a csv file of 1.2 million records of text. The alphanumeric fields are wrapped in quotation marks, the date/time or numeric fields are not.</p> <p>For example "Fred","Smith",01/07/1967,2,"7, The High Street","Anytown","Anycounty","LS1 7AA"</p> <p>What I want do is write some VBA in Excel (more or less the ...
[ { "answer_id": 427511, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 3, "selected": false, "text": "<p>How about VBScript, though this would also work in Excel:</p>\n\n<pre><code>Set cn = CreateObject(\"ADODB.Connection\")...
2009/01/09
[ "https://Stackoverflow.com/questions/427488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a csv file of 1.2 million records of text. The alphanumeric fields are wrapped in quotation marks, the date/time or numeric fields are not. For example "Fred","Smith",01/07/1967,2,"7, The High Street","Anytown","Anycounty","LS1 7AA" What I want do is write some VBA in Excel (more or less the only tool availabl...
How about VBScript, though this would also work in Excel: ``` Set cn = CreateObject("ADODB.Connection") 'Note HDR=Yes, that is, first row contains field names ' 'and FMT delimted, ie CSV ' strCon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Docs\;" _ & "Extended Properties=""text;HDR=Yes;FMT=Delimited"";" cn.op...
427,516
<p>I'm using the new CompositeScript feature that's available in the ASP.NET 3.5 SP1 for the ScriptManager. </p> <p>When I test this with the ASP.NET Development Server it works fine but when I publish the site to my IIS webserver the combined files cannot be downloaded, I always get the following error: Invalid ViewS...
[ { "answer_id": 427535, "author": "Jesper Blad Jensen", "author_id": 11559, "author_profile": "https://Stackoverflow.com/users/11559", "pm_score": 2, "selected": true, "text": "<p>Im not use about your question, but if you need to link to a EXE file on another computer like:</p>\n\n<p>Com...
2009/01/09
[ "https://Stackoverflow.com/questions/427516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm using the new CompositeScript feature that's available in the ASP.NET 3.5 SP1 for the ScriptManager. When I test this with the ASP.NET Development Server it works fine but when I publish the site to my IIS webserver the combined files cannot be downloaded, I always get the following error: Invalid ViewState. The...
Im not use about your question, but if you need to link to a EXE file on another computer like: Computer A has a EXE file, computer A sends a email to Computer B, with a hyperlink to the EXE file Computer B runs the EXE file on own computer, or make Computer A run the EXE file Sorry, but that is not possible. If you ...
427,517
<p>I need to get the interface name by providing an IP address. There is no system call to get this.</p> <p>I need an implementation for this in C or C++</p> <p>Already the reverse of this is available on Stack Overflow, <em><a href="https://stackoverflow.com/questions/259389/finding-an-ip-from-an-interface-name">Fin...
[ { "answer_id": 427530, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 4, "selected": false, "text": "<p>Could you simply parse the output from something like</p>\n\n<pre><code> netstat -ie | grep -B1 \"192.168.21.10\"\n</c...
2009/01/09
[ "https://Stackoverflow.com/questions/427517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to get the interface name by providing an IP address. There is no system call to get this. I need an implementation for this in C or C++ Already the reverse of this is available on Stack Overflow, *[Finding an IP address from an interface name](https://stackoverflow.com/questions/259389/finding-an-ip-from-an-i...
Could you simply parse the output from something like ``` netstat -ie | grep -B1 "192.168.21.10" ``` The -B1 part tells grep we want to include the line *before* the match in the output, so we get this: ``` eth0 Link encap:Ethernet HWaddr 00:13:72:79:65:23 inet addr:192.168.21.10 Bcast:192.168.21....
427,549
<p>I've two tables: TableA and TableB, joined by TableA.TableA_Id->1..n&lt;-TableB.TableA_Id. A simple PK-FK.</p> <p>I need to extract <strong>distinct</strong> TableA records given a certain condition on TableB. Here's my 1st approach:</p> <p>SELECT * FROM TableA A INNER JOIN TableB B ON A.idA = B.IdA AND B.Date = '...
[ { "answer_id": 427564, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 1, "selected": false, "text": "<p>And the problem using </p>\n\n<pre>\nSELECT DISTINCT * FROM TableA A INNER JOIN TableB B ON A.idA = B.IdA \nAND B...
2009/01/09
[ "https://Stackoverflow.com/questions/427549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2684/" ]
I've two tables: TableA and TableB, joined by TableA.TableA\_Id->1..n<-TableB.TableA\_Id. A simple PK-FK. I need to extract **distinct** TableA records given a certain condition on TableB. Here's my 1st approach: SELECT \* FROM TableA A INNER JOIN TableB B ON A.idA = B.IdA AND B.Date = '2009-01-10' ORDER BY A.Id; Th...
use a derived table ``` SELECT * FROM TableA JOIN (SELECT DISTINCT IdA FROM TableB WHERE Date = '20090110') a ON a.IDA = TAbleA.IDA ORDER BY TableA.IdA ```
427,575
<p>I have a simple ControlTemplate for buttons which creates a link-like look and feel for them:</p> <pre><code> &lt;ControlTemplate x:Key="LinkTemplate" TargetType="{x:Type Button}"&gt; &lt;TextBlock Text="{TemplateBinding Content}"&gt; &lt;TextBlock.Style&gt; &lt;Style TargetType="{x:Type Tex...
[ { "answer_id": 606725, "author": "jschroedl", "author_id": 2420, "author_profile": "https://Stackoverflow.com/users/2420", "pm_score": 0, "selected": false, "text": "<p>I did not find docs for \"ContentStringFormat\" so I may be missing something trivial here.</p>\n\n<p>How about using F...
2009/01/09
[ "https://Stackoverflow.com/questions/427575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19982/" ]
I have a simple ControlTemplate for buttons which creates a link-like look and feel for them: ``` <ControlTemplate x:Key="LinkTemplate" TargetType="{x:Type Button}"> <TextBlock Text="{TemplateBinding Content}"> <TextBlock.Style> <Style TargetType="{x:Type TextBlock}"> <Setter P...
I haven't any idea of what is ContentStringFormat's usage, but you can use ContentPresenter instead of TextBlock to use this property.
427,586
<p>Can anyone please provide me a sample build file demostrating the use of the task of nant-contrib for creating an installer of a web application project.</p>
[ { "answer_id": 751910, "author": "essamSALAH", "author_id": 78380, "author_profile": "https://Stackoverflow.com/users/78380", "pm_score": 1, "selected": false, "text": "<p>I have been using Visual Studio Setup projects for creating MSI for Web Apps and it was quick good and easy.</p>\n\n...
2009/01/09
[ "https://Stackoverflow.com/questions/427586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53270/" ]
Can anyone please provide me a sample build file demostrating the use of the task of nant-contrib for creating an installer of a web application project.
This one :) ``` <?xml version="1.0"?> <project name="Scanner" xmlns="http://nant.sf.net/release/0.85/nant.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://nant.sf.net/release/0.85/nant.xsd http://ilqhfaatc1ws628/nant.xsd"> <!-- Nant command line: c:\nant\nant -debug+ /f:"D:\L...
427,589
<p>Supposing to have something like this:</p> <pre><code>#include &lt;map&gt; int main(){ std::map&lt;int,int&gt; m; m[1] = 2; m[2] = 4; return 0; } </code></pre> <p>I would like to be able to inspect the contents of the map running the program from gdb.<br> If I try using the subscript operator I get...
[ { "answer_id": 427633, "author": "jpalecek", "author_id": 51831, "author_profile": "https://Stackoverflow.com/users/51831", "pm_score": 6, "selected": true, "text": "<p>I think there isn't, at least not if your source is optimized etc. However, there are some macros for gdb that can insp...
2009/01/09
[ "https://Stackoverflow.com/questions/427589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15622/" ]
Supposing to have something like this: ``` #include <map> int main(){ std::map<int,int> m; m[1] = 2; m[2] = 4; return 0; } ``` I would like to be able to inspect the contents of the map running the program from gdb. If I try using the subscript operator I get: ``` (gdb) p m[1] Attempt to take ad...
I think there isn't, at least not if your source is optimized etc. However, there are some macros for gdb that can inspect STL containers for you: <http://sourceware.org/ml/gdb/2008-02/msg00064.html> However, I don't use this, so YMMV
427,590
<p>I hava a web application. In that i have a link called "Home". When the user clicks the starting page of the web application that is index.jsp should be displayed in the same page. How can i do that. It should work in internet explorer. </p> <p>I have the following html page.</p> <pre><code>&lt;html&gt; &lt;body ...
[ { "answer_id": 427601, "author": "Warrior", "author_id": 40933, "author_profile": "https://Stackoverflow.com/users/40933", "pm_score": 2, "selected": false, "text": "<p>&lt; a href=\"url\">home&lt; /a > </p>\n" }, { "answer_id": 427615, "author": "Paul Dixon", "author_id"...
2009/01/09
[ "https://Stackoverflow.com/questions/427590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48094/" ]
I hava a web application. In that i have a link called "Home". When the user clicks the starting page of the web application that is index.jsp should be displayed in the same page. How can i do that. It should work in internet explorer. I have the following html page. ``` <html> <body bgcolor="#FFF8DC"> <a href="i...
< a href="url">home< /a >
427,594
<p>I have an array which contains a list of nibbles:</p> <pre><code>{0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, ...} </code></pre> <p>I want to combine adjacent nibbles into single bytes by left-shifting the upper nibble and concatenating it with the lower one. The output should look as follows:</p> <pre><code>{0xab, 0xcd,...
[ { "answer_id": 427610, "author": "ChrisN", "author_id": 3853, "author_profile": "https://Stackoverflow.com/users/3853", "pm_score": 3, "selected": false, "text": "<p>Without writing the whole code for you, here's a hint:</p>\n\n<pre><code>unsigned int Nibble1 = 0x0A;\nunsigned int Nibble...
2009/01/09
[ "https://Stackoverflow.com/questions/427594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an array which contains a list of nibbles: ``` {0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, ...} ``` I want to combine adjacent nibbles into single bytes by left-shifting the upper nibble and concatenating it with the lower one. The output should look as follows: ``` {0xab, 0xcd, 0xef, ...} ``` How can I accomplis...
Without writing the whole code for you, here's a hint: ``` unsigned int Nibble1 = 0x0A; unsigned int Nibble2 = 0x0B; unsigned int Result = (Nibble1 << 4) | Nibble2; // Result = 0xAB ``` You then just need to write a loop that iterates through your input array two elements at a time and writes to an output array. I...
427,597
<p>I have a spec in my current project that requires us to advise the user which browsers are best to use the web application. If their current browser version they are using is not in our list of "ideal" browsers we want to display a message.</p> <p>What is the best way to check a specific version of the users brows...
[ { "answer_id": 427606, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 2, "selected": false, "text": "<p>Check out the <a href=\"http://developer.yahoo.com/yui/examples/yahoo/yahoo_ua_detection.html\" rel=\"nofollow noreferre...
2009/01/09
[ "https://Stackoverflow.com/questions/427597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32021/" ]
I have a spec in my current project that requires us to advise the user which browsers are best to use the web application. If their current browser version they are using is not in our list of "ideal" browsers we want to display a message. What is the best way to check a specific version of the users browser. I am aw...
[Here](http://davecardwell.co.uk/javascript/jquery/plugins/jquery-browserdetect/) is a JQuery plugin that'll help
427,598
<p>My Controller class is decorated with an AuthorizeAttribute to protect the actions:</p> <pre><code>[Authorize(Roles = "User Level 2")] public class BuyController : Controller { ... } </code></pre> <p>Anytime an action is invoked, but the user is not in at least the role "User Level 2", the user is automaticall...
[ { "answer_id": 428266, "author": "Trevor de Koekkoek", "author_id": 41783, "author_profile": "https://Stackoverflow.com/users/41783", "pm_score": 6, "selected": true, "text": "<p>You can build your own authorize attribute like this:</p>\n\n<pre><code>public class ClubAuthorizeAttribute :...
2009/01/09
[ "https://Stackoverflow.com/questions/427598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2374/" ]
My Controller class is decorated with an AuthorizeAttribute to protect the actions: ``` [Authorize(Roles = "User Level 2")] public class BuyController : Controller { ... } ``` Anytime an action is invoked, but the user is not in at least the role "User Level 2", the user is automatically redirected to the login ...
You can build your own authorize attribute like this: ``` public class ClubAuthorizeAttribute : AuthorizeAttribute { public override void OnAuthorization(AuthorizationContext filterContext) { base.OnAuthorization(filterContext); if (filterContext.Cancel && filterContext.Result is HttpUnauthorizedResult) { fi...
427,604
<p>I've been tinkering with Yahoo Pipes and the <a href="http://docs.aws.amazon.com/AWSECommerceService/latest/DG/" rel="nofollow noreferrer">Amazon Product Advertising API (formerly ECS) SDK</a> to retrieve my wishlist.</p> <p>The problem is that although I can get all the items on my wishlist just fine, it seems to ...
[ { "answer_id": 428266, "author": "Trevor de Koekkoek", "author_id": 41783, "author_profile": "https://Stackoverflow.com/users/41783", "pm_score": 6, "selected": true, "text": "<p>You can build your own authorize attribute like this:</p>\n\n<pre><code>public class ClubAuthorizeAttribute :...
2009/01/09
[ "https://Stackoverflow.com/questions/427604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/974/" ]
I've been tinkering with Yahoo Pipes and the [Amazon Product Advertising API (formerly ECS) SDK](http://docs.aws.amazon.com/AWSECommerceService/latest/DG/) to retrieve my wishlist. The problem is that although I can get all the items on my wishlist just fine, it seems to include items that I've deleted too. Has anyon...
You can build your own authorize attribute like this: ``` public class ClubAuthorizeAttribute : AuthorizeAttribute { public override void OnAuthorization(AuthorizationContext filterContext) { base.OnAuthorization(filterContext); if (filterContext.Cancel && filterContext.Result is HttpUnauthorizedResult) { fi...
427,609
<p>I am trying to write a javascript class that loads script files as they are needed. I have most of this working. It is possible to use the library with the following Syntax:</p> <pre><code>var scriptResource = new ScriptResource('location/of/my/script.js'); scriptResource.call('methodName', arg1, arg2); </code></pr...
[ { "answer_id": 427735, "author": "Rene Saarsoo", "author_id": 15982, "author_profile": "https://Stackoverflow.com/users/15982", "pm_score": 0, "selected": false, "text": "<p>If the set of method names is limited, then you could generate those methods:</p>\n\n<pre><code>var methods = [\"f...
2009/01/09
[ "https://Stackoverflow.com/questions/427609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28882/" ]
I am trying to write a javascript class that loads script files as they are needed. I have most of this working. It is possible to use the library with the following Syntax: ``` var scriptResource = new ScriptResource('location/of/my/script.js'); scriptResource.call('methodName', arg1, arg2); ``` I would like to add...
There is a non standard method, \_\_noSuchMethod\_\_ in Firefox that does what you're looking for have a look at [https://developer.mozilla.org/en/Core\_JavaScript\_1.5\_Reference/Global\_Objects/Object/noSuchMethod](https://developer.mozilla.org/en/Core%5C_JavaScript%5C_1.5%5C_Reference/Global%5C_Objects/Object/...
427,648
<p>In an HTML page, if I align some <code>&lt;div&gt;</code>s with "right: 0px", they all look very nice, as I expect. However, if I make the browser window smaller and the horizontal scroll bar appears, when I scroll the page to the right, I see an unexpected white space (instead of the background colors of my <code>&...
[ { "answer_id": 427681, "author": "meouw", "author_id": 12161, "author_profile": "https://Stackoverflow.com/users/12161", "pm_score": 0, "selected": false, "text": "<p>if you add</p>\n\n<pre><code>html{ border: 3px solid red }\n</code></pre>\n\n<p>to your stylesheet,\nyou'll see that you ...
2009/01/09
[ "https://Stackoverflow.com/questions/427648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11384/" ]
In an HTML page, if I align some `<div>`s with "right: 0px", they all look very nice, as I expect. However, if I make the browser window smaller and the horizontal scroll bar appears, when I scroll the page to the right, I see an unexpected white space (instead of the background colors of my `<div>`s). It seems that my...
The Problem is the "absolute" position in the parent element, because it's scrollable per definition. If you set the position to "fixed" and an additional attribute overflow to "scroll", it should look like expected. ``` #parent {position: fixed; overflow: scroll; left: 0px; top: 0...
427,652
<p>I've got a django project that contain some apps. The main urls.py includes the urls.py from the apps I've enabled, and all is good.</p> <p>Now I want to configure the project so that when you go to <a href="http://testsite/" rel="nofollow noreferrer">http://testsite/</a>, you'll get the same page that you get whe...
[ { "answer_id": 427685, "author": "bruno desthuilliers", "author_id": 41316, "author_profile": "https://Stackoverflow.com/users/41316", "pm_score": 4, "selected": true, "text": "<p>Set up a redirect_to from the first url to the second, ie:</p>\n\n<pre><code>from django.conf.urls.defaults ...
2009/01/09
[ "https://Stackoverflow.com/questions/427652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11682/" ]
I've got a django project that contain some apps. The main urls.py includes the urls.py from the apps I've enabled, and all is good. Now I want to configure the project so that when you go to <http://testsite/>, you'll get the same page that you get when you go to <http://testsite/app/>. I can do this by duplicating ...
Set up a redirect\_to from the first url to the second, ie: ``` from django.conf.urls.defaults import patterns, url, include from django.views.generic.simple import redirect_to urlpatterns = patterns('', # Example: url(r'^$', redirect_to, {'url':'/app/'}), url(r'^app/', include('app.urls')...
427,653
<p>I often find myself confused with how the terms 'arguments' and 'parameters' are used. They seem to be used interchangeably in the programming world.</p> <p>What's the correct convention for their use?</p>
[ { "answer_id": 427657, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 9, "selected": true, "text": "<p>Parameters are the things defined by functions as input, arguments are the things passed as parameters.</p>\n\n<pre><code>vo...
2009/01/09
[ "https://Stackoverflow.com/questions/427653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47036/" ]
I often find myself confused with how the terms 'arguments' and 'parameters' are used. They seem to be used interchangeably in the programming world. What's the correct convention for their use?
Parameters are the things defined by functions as input, arguments are the things passed as parameters. ``` void foo(int bar) { ... } foo(baz); ``` In this example, `bar` is a parameter for `foo`. `baz` is an argument passed to `foo`.
427,654
<p>Is there any implementation of regex that allow to replace group in regex with lowercase version of it? </p>
[ { "answer_id": 427664, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 2, "selected": false, "text": "<p>In Perl, there's</p>\n\n<pre><code>$string =~ tr/[A-Z]/[a-z]/;\n</code></pre>\n" }, { "answer_id": 427671, "...
2009/01/09
[ "https://Stackoverflow.com/questions/427654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there any implementation of regex that allow to replace group in regex with lowercase version of it?
In Perl, you can do: ``` $string =~ s/(some_regex)/lc($1)/ge; ``` The `/e` option causes the replacement expression to be interpreted as Perl code to be evaluated, whose return value is used as the final replacement value. `lc($x)` returns the lowercased version of `$x`. (Not sure but I assume `lc()` will handle int...
427,659
<p>With the latest additions to our dependency injection framework (annotations in spring), the marginal cost of creating DI-managed components seems to have hit some critical new threshold. While there previously was an overhead associated with spring (tons of XML and additional indirections), dependency injection see...
[ { "answer_id": 427784, "author": "Robert MacLean", "author_id": 53236, "author_profile": "https://Stackoverflow.com/users/53236", "pm_score": 2, "selected": false, "text": "<p>Pure DI perfect universe, I think single classes+method design is ideal. In reality we need to balance the cost ...
2009/01/09
[ "https://Stackoverflow.com/questions/427659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23691/" ]
With the latest additions to our dependency injection framework (annotations in spring), the marginal cost of creating DI-managed components seems to have hit some critical new threshold. While there previously was an overhead associated with spring (tons of XML and additional indirections), dependency injection seems ...
The overriding principals of good OO Design do not stop at loose coupling, but also **high cohesion**, which gets ignored in most discussions. **High Cohesion** > > In computer programming, cohesion is a > measure of how strongly-related or > focused the responsibilities of a > single module are. As applied to > ...
427,689
<p>What I want to do is very simple but I'm trying to find the best or most elegant way to do this. The Rails application I'm building now will have a schedule of daily classes. For each class the fields relevant to this question are:</p> <ul> <li>Day of the week</li> <li>Starting time</li> <li>Ending time</li> </ul> ...
[ { "answer_id": 427813, "author": "DanSingerman", "author_id": 43965, "author_profile": "https://Stackoverflow.com/users/43965", "pm_score": 2, "selected": false, "text": "<p>If your data is a Time then I would store that as a Time - otherwise you will always have to convert it out of the...
2009/01/09
[ "https://Stackoverflow.com/questions/427689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19893/" ]
What I want to do is very simple but I'm trying to find the best or most elegant way to do this. The Rails application I'm building now will have a schedule of daily classes. For each class the fields relevant to this question are: * Day of the week * Starting time * Ending time A single entry could be something such...
I would just store the day of the week as an integer. 0 => Monday ... 6 => Sunday (or any way you want. ie. 0 => Sunday). Then store the start time and end time as Time. That would make grouping really easy. All you would have to do is sort by the day of the week and the start time. You can display this in multiple w...
427,717
<p>I have a table that's generated by a normal PHP loop. What I want to do is create a form in the first column of each row that's hidden by default but appears when you click a toggle link in that row. </p> <p>I can make a normal toggle-able div by creating a CSS id called hidden and setting <code>display: none;</c...
[ { "answer_id": 427731, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "<p>Make it a span instead of a DIV as I think that some browsers don't support divs inside table elements. Also, inste...
2009/01/09
[ "https://Stackoverflow.com/questions/427717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30098/" ]
I have a table that's generated by a normal PHP loop. What I want to do is create a form in the first column of each row that's hidden by default but appears when you click a toggle link in that row. I can make a normal toggle-able div by creating a CSS id called hidden and setting `display: none;`. Unfortunately I c...
Just use a different ID for each row: ``` <?php $count = 0; while($array = mysql_fetch_array($sql)) { $id = 'hidden' . $count++; $data = $array['some_data']; $hidden = $array['hidden_thing']; $other_data = $array['other_data']; echo <<<END <tr> <td>$data <a href="#" onclick="toggle('$id');>Toggle</a> <...
427,721
<p>Does anyone have a suggestion for creating paragraph-type line spaces within a <code>&lt;li&gt;</code> tag that includes a hovered pop-up pseudo-class?</p> <p>I have a <code>&lt;span&gt;</code> that pops up on <code>a:hover</code> and I want the text that pops up to be broken into 2 paragraphs. It works with <code...
[ { "answer_id": 427738, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 1, "selected": false, "text": "<p>You could stick another span in there as a \"fake\" p tag:</p>\n\n<pre><code> &lt;li&gt;&lt;a href=\"\"&gt;List item\n ...
2009/01/09
[ "https://Stackoverflow.com/questions/427721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Does anyone have a suggestion for creating paragraph-type line spaces within a `<li>` tag that includes a hovered pop-up pseudo-class? I have a `<span>` that pops up on `a:hover` and I want the text that pops up to be broken into 2 paragraphs. It works with `<br>` in FF but I want to do the right thing (now that I've ...
Your problem may arise from the fact that you're using a <span> tag incorrectly. Spans are supposed to be inline elements and you're styling it as though it were a block element. Admittedly you can force a span to behave as a block element by adding the right style, but this may not always be honoured by the various ...
427,725
<p>I've got a function creating some XmlDocument:</p> <pre><code>public string CreateOutputXmlString(ICollection&lt;Field&gt; fields) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.Encoding = Encoding.GetEncoding("windows-1250"); StringBuilder builder = new St...
[ { "answer_id": 427737, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>You need to use a StringWriter with the appropriate encoding. Unfortunately StringWriter doesn't let you specify the e...
2009/01/09
[ "https://Stackoverflow.com/questions/427725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40872/" ]
I've got a function creating some XmlDocument: ``` public string CreateOutputXmlString(ICollection<Field> fields) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.Encoding = Encoding.GetEncoding("windows-1250"); StringBuilder builder = new StringBuilder(); X...
You need to use a StringWriter with the appropriate encoding. Unfortunately StringWriter doesn't let you specify the encoding directly, so you need a class like this: ``` public sealed class StringWriterWithEncoding : StringWriter { private readonly Encoding encoding; public StringWriterWithEncoding (Encoding...
427,726
<p>I am trying to show the current date in my JSP page using JSTL. below is the code I am using.</p> <pre><code>&lt;jsp:useBean id="now" class="java.util.Date" scope="request" /&gt; &lt;fmt:formatDate value="${now}" pattern="MM.dd.yyyy" /&gt; </code></pre> <p>But the above code is not producing any results? Am I miss...
[ { "answer_id": 427872, "author": "Adeel Ansari", "author_id": 42769, "author_profile": "https://Stackoverflow.com/users/42769", "pm_score": 5, "selected": true, "text": "<p>Try to print it without formatting, ${now}, you probably have <em>null</em> in there. Do you have this attribute in...
2009/01/09
[ "https://Stackoverflow.com/questions/427726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42372/" ]
I am trying to show the current date in my JSP page using JSTL. below is the code I am using. ``` <jsp:useBean id="now" class="java.util.Date" scope="request" /> <fmt:formatDate value="${now}" pattern="MM.dd.yyyy" /> ``` But the above code is not producing any results? Am I missing anything here or is there any bett...
Try to print it without formatting, ${now}, you probably have *null* in there. Do you have this attribute in request scope? Just double check, if yes it might be *null*. If not, then try remove this *scope* attribute from the tag, yeah it doesn't matter but just to make the things clear.
427,728
<p>I'm using the <strong><a href="http://nvelocity.sourceforge.net/" rel="nofollow noreferrer">NVelocity Templating engine</a></strong> to produce a <strong>fixed-length</strong> field output - you know the kind of thing:</p> <pre><code>Field Start Pos Field Length Notes ---------- --------- ------------...
[ { "answer_id": 427982, "author": "Andrew", "author_id": 5662, "author_profile": "https://Stackoverflow.com/users/5662", "pm_score": 1, "selected": true, "text": "<p>One solution that a colleague has come up with is to create another property in the Document object that returns the format...
2009/01/09
[ "https://Stackoverflow.com/questions/427728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5662/" ]
I'm using the **[NVelocity Templating engine](http://nvelocity.sourceforge.net/)** to produce a **fixed-length** field output - you know the kind of thing: ``` Field Start Pos Field Length Notes ---------- --------- ------------ --------- Supplier 1 7 Leading Zeros GRN ...
One solution that a colleague has come up with is to create another property in the Document object that returns the formatted String: E.g. ``` Public ReadOnly Property SupplierCodeFormatted() As String Get Return Supplier.Code.PadLeft(7, "0") End Get End Property ```
427,736
<p>I'm trying to make the following code smaller. Is this possible?</p> <pre><code>select a.* from table1 a WHERE a."cola1" = 'valuea1' UNION ALL select a.* from tablea1 a inner join tablea2 b on a."cola2" = b."colb2" WHERE a."cola1" = 'valuea2' and b."colb3" = 'valueb3' </code></pre> <p>In effect I'm looking for ...
[ { "answer_id": 427762, "author": "Hosam Aly", "author_id": 41283, "author_profile": "https://Stackoverflow.com/users/41283", "pm_score": 3, "selected": false, "text": "<p>I think <code>CASE</code> statements work in join conditions, but I'm not sure. But would this work for you?</p>\n\n<...
2009/01/09
[ "https://Stackoverflow.com/questions/427736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to make the following code smaller. Is this possible? ``` select a.* from table1 a WHERE a."cola1" = 'valuea1' UNION ALL select a.* from tablea1 a inner join tablea2 b on a."cola2" = b."colb2" WHERE a."cola1" = 'valuea2' and b."colb3" = 'valueb3' ``` In effect I'm looking for records from table1 for val...
I think `CASE` statements work in join conditions, but I'm not sure. But would this work for you? ``` select * from table1 a where a.cola1 = 'valuea1' or (a.cola1 = 'valuea2' and Exists(select 1 from table2 b where a.cola2 = b.colb2 and b.co...
427,744
<p>In my application (Main form is TTntForm, C++Builder 2006):</p> <pre><code>void __fastcall TForm1::Button1Click(TObject *Sender) { Caption=L"1st caption"; // This works. Form1-&gt;Caption=L"2nd caption"; // But this doesn't work, // Caption of the form remains "1st captio...
[ { "answer_id": 427765, "author": "Birger", "author_id": 11485, "author_profile": "https://Stackoverflow.com/users/11485", "pm_score": 1, "selected": false, "text": "<p>Are you sure the TForm1 class form you are working with is instantiated as Form1?</p>\n" }, { "answer_id": 42777...
2009/01/09
[ "https://Stackoverflow.com/questions/427744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38856/" ]
In my application (Main form is TTntForm, C++Builder 2006): ``` void __fastcall TForm1::Button1Click(TObject *Sender) { Caption=L"1st caption"; // This works. Form1->Caption=L"2nd caption"; // But this doesn't work, // Caption of the form remains "1st caption". } ``` What ...
Thanks you all for your answers. I found the bug. There was a twice form creation in project file: ``` Application->CreateForm(__classid(TForm1), &Form1); Application->CreateForm(__classid(TForm1), &Form1); ```
427,746
<p>I'm building a questionnaire mvc webapp, and i cant figure out how to pass an unknown number of arguments to the controller from the form.</p> <p>My form is something like:</p> <pre><code>&lt;% using (Html.BeginForm()) { %&gt; &lt;div id="Content"&gt; &lt;% foreach (var group in ViewData.Model.QuestionGroup...
[ { "answer_id": 427785, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 3, "selected": false, "text": "<p>You can add an argument to your action like</p>\n\n<pre><code>public ActionResult MyAction(FormCollection form)\n</...
2009/01/09
[ "https://Stackoverflow.com/questions/427746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53293/" ]
I'm building a questionnaire mvc webapp, and i cant figure out how to pass an unknown number of arguments to the controller from the form. My form is something like: ``` <% using (Html.BeginForm()) { %> <div id="Content"> <% foreach (var group in ViewData.Model.QuestionGroups) { %> <div class="Group...
Garry's answer will work (and hence, up voted). However, you can model bind directly to a list, and I think it's a bit more elegant. [There are instructions in this blog post.](http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx)
427,755
<p>Before asking question, let me explain the current setup:</p> <p>I have an service interface, say Service, and one implementation, say ServiceImpl. This ServiceImpl uses some other services. All the services are loaded as bean by spring.</p> <p>Now, I want to write junit test cases for the ServiceImpl. For the sam...
[ { "answer_id": 427809, "author": "Markus Lausberg", "author_id": 39062, "author_profile": "https://Stackoverflow.com/users/39062", "pm_score": 0, "selected": false, "text": "<p>I think you should split the testcases.</p>\n\n<p>First you test the class which is calling the different imple...
2009/01/09
[ "https://Stackoverflow.com/questions/427755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4406/" ]
Before asking question, let me explain the current setup: I have an service interface, say Service, and one implementation, say ServiceImpl. This ServiceImpl uses some other services. All the services are loaded as bean by spring. Now, I want to write junit test cases for the ServiceImpl. For the same, I use the appl...
The purist answer is that private methods are called that for a reason! ;-) Turn the question around: given only the specification of a (publicly-accessible) interface, how would you lay out your test plan before writing the code? That interface describes the expected *behavior* of an object that implements it; if it ...
427,760
<p>Why you would want to use a <code>switch</code> block over a series of <code>if</code> statements?</p> <p><code>switch</code> statements seem to do the same thing but take longer to type.</p>
[ { "answer_id": 427771, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 6, "selected": false, "text": "<p>If you are switching on the value of a single variable then I'd use a switch every time, it's what the construct wa...
2009/01/09
[ "https://Stackoverflow.com/questions/427760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52381/" ]
Why you would want to use a `switch` block over a series of `if` statements? `switch` statements seem to do the same thing but take longer to type.
As with most things you should pick which to use based on the context and what is conceptually the correct way to go. A switch is really saying "pick one of these based on this variables value" but an if statement is just a series of boolean checks. As an example, if you were doing: ``` int value = // some value if (...
427,761
<p>I've seen a class which is a class which is defined like this..</p> <pre><code>class StringChild : public StringBase { public: //some non-virtual functions static StringChild* CreateMe(int size); private: unsigned char iBuf[1]; }; </code></pre> <p>The static factory function has the following i...
[ { "answer_id": 427797, "author": "Timo Geusch", "author_id": 29068, "author_profile": "https://Stackoverflow.com/users/29068", "pm_score": 4, "selected": true, "text": "<p>It's an old C trick that was used to work around the non-availablity of variable length arrays in plain C. Yes, it a...
2009/01/09
[ "https://Stackoverflow.com/questions/427761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16177/" ]
I've seen a class which is a class which is defined like this.. ``` class StringChild : public StringBase { public: //some non-virtual functions static StringChild* CreateMe(int size); private: unsigned char iBuf[1]; }; ``` The static factory function has the following implementation.. ``` retur...
It's an old C trick that was used to work around the non-availablity of variable length arrays in plain C. Yes, it also works in C++ as long as you use suitable allocator constructs (like allocating a bunch of raw memory the desired size and then placement newing the object in there). It's safe as long as you don't wan...
427,781
<p>How would I retrieve all files from the repository, along with the folder structure, changed in a range of revisions, say from 1000-1920?</p>
[ { "answer_id": 427807, "author": "JesperE", "author_id": 13051, "author_profile": "https://Stackoverflow.com/users/13051", "pm_score": 4, "selected": false, "text": "<p>That depends a little on what you intend to do with the data. If you're only interested in inspecting the data manually...
2009/01/09
[ "https://Stackoverflow.com/questions/427781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47437/" ]
How would I retrieve all files from the repository, along with the folder structure, changed in a range of revisions, say from 1000-1920?
If you just want the list of changed paths, have a look at the --summarize option on diff. ``` svn diff --summarize -r1000:1920 https://my.org/myrepo/ ```
427,789
<p>I work on a Flex app that loads external Flash resources created in CS3. I've just been reading about how I can use the Flex mx.managers.CursorManager class to change the mouse cursor explicitly. But what I'd ideally like to do is to set a mouse cursor property on some elements in the loaded Flash SWF, so as the cur...
[ { "answer_id": 428279, "author": "Yaba", "author_id": 7524, "author_profile": "https://Stackoverflow.com/users/7524", "pm_score": 2, "selected": false, "text": "<p>To set the the \"Hand\" cursor, as soon as the mouse hovers over a element you have to specify these properties:</p>\n\n<pr...
2009/01/09
[ "https://Stackoverflow.com/questions/427789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13220/" ]
I work on a Flex app that loads external Flash resources created in CS3. I've just been reading about how I can use the Flex mx.managers.CursorManager class to change the mouse cursor explicitly. But what I'd ideally like to do is to set a mouse cursor property on some elements in the loaded Flash SWF, so as the cursor...
To set the the "Hand" cursor, as soon as the mouse hovers over a element you have to specify these properties: ``` <mx:VBox useHandCursor="true" mouseChildren="false" buttonMode="true"> ``` However this only works for the Hand cursor. Also take care of the required **mouseChildren** attribute...
427,796
<p>What is the best way to approximate a cubic Bezier curve? Ideally I would want a function y(x) which would give the exact y value for any given x, but this would involve solving a cubic equation for every x value, which is too slow for my needs, and there may be numerical stability issues as well with this approach...
[ { "answer_id": 430006, "author": "jpalecek", "author_id": 51831, "author_profile": "https://Stackoverflow.com/users/51831", "pm_score": 2, "selected": false, "text": "<p>Yes, de Casteljau algorithm would work for you. However, I don't know if it will be faster than solving the cubic equa...
2009/01/09
[ "https://Stackoverflow.com/questions/427796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50129/" ]
What is the best way to approximate a cubic Bezier curve? Ideally I would want a function y(x) which would give the exact y value for any given x, but this would involve solving a cubic equation for every x value, which is too slow for my needs, and there may be numerical stability issues as well with this approach. W...
Just solve the cubic. If you're talking about Bezier plane curves, where x(t) and y(t) are cubic polynomials, then y(x) might be undefined or have multiple values. An extreme degenerate case would be the line x= 1.0, which can be expressed as a cubic Bezier (control point 2 is the same as end point 1; control point 3 ...
427,799
<p><b>Duplicate</b>: <a href="https://stackoverflow.com/questions/420275/">C# Accessing data in System.Object[]</a></p> <hr> <p>When I run the following code:</p> <pre><code> foreach (object bar in list) { Console.WriteLine = bar; } </code></pre> <p>I get the following output:</p> <blockquote> ...
[ { "answer_id": 427801, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<pre><code>foreach (DictionaryEntry entry in list)\n{\n Console.WriteLine(\"{0}={1}\", entry.Key, entry.Value);\n}\n<...
2009/01/09
[ "https://Stackoverflow.com/questions/427799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
**Duplicate**: [C# Accessing data in System.Object[]](https://stackoverflow.com/questions/420275/) --- When I run the following code: ``` foreach (object bar in list) { Console.WriteLine = bar; } ``` I get the following output: > > System.Collections.DictionaryEntry > > > System.Collections...
``` foreach (DictionaryEntry entry in list) { Console.WriteLine("{0}={1}", entry.Key, entry.Value); } ``` EDIT: If you want it to work for *anything*, and recurse down into whatever objects are within the results (e.g. into the children Object[] as per Kloti's reply) you'll basically need to use reflection. I wou...
427,825
<p>I want cscope to open files in MacVim instead of vim, so I'm trying to have the path to MacVim as the Value of the EDITOR environment variable which is used by cscope:</p> <pre>$ export EDITOR=/Applications/MacVim.app/Contents/MacOS/MacVim</pre> <p>If I'm now trying to edit a file from within ctags, it won't work ...
[ { "answer_id": 427911, "author": "frankodwyer", "author_id": 42404, "author_profile": "https://Stackoverflow.com/users/42404", "pm_score": 0, "selected": false, "text": "<p>Have you tried export EDITOR=/Applications/MacVim.app?</p>\n\n<p>Or wrapping MacVim in a small script that uses ope...
2009/01/09
[ "https://Stackoverflow.com/questions/427825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53305/" ]
I want cscope to open files in MacVim instead of vim, so I'm trying to have the path to MacVim as the Value of the EDITOR environment variable which is used by cscope: ``` $ export EDITOR=/Applications/MacVim.app/Contents/MacOS/MacVim ``` If I'm now trying to edit a file from within ctags, it won't work and throws th...
Make sure you put the mvim script in your path, and try this out: export EDITOR="mvim -f" This was the ticket for me when using MacVim as editing git commit messages.
427,850
<p>Our Windows CE 5.0 application has a problem with our wildcard SSL certificate (*.domain.com) - it won't accept it as valid.</p> <p>I understand that Windows Mobile 6.0 has support for wildcard certificates (earlier versions don't) and that is built on WinCE 5 which suggests it should be possible to change WinCE 5 ...
[ { "answer_id": 428218, "author": "ctacke", "author_id": 13154, "author_profile": "https://Stackoverflow.com/users/13154", "pm_score": 0, "selected": false, "text": "<p>Why would the fact that WinMo supports them suggest that CE 5.0 would? You need to understand that CE is a modular OS, ...
2009/01/09
[ "https://Stackoverflow.com/questions/427850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1456/" ]
Our Windows CE 5.0 application has a problem with our wildcard SSL certificate (\*.domain.com) - it won't accept it as valid. I understand that Windows Mobile 6.0 has support for wildcard certificates (earlier versions don't) and that is built on WinCE 5 which suggests it should be possible to change WinCE 5 to accept...
This will accept all certs, modify as needed. System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy(); ``` public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy { public TrustAllCertificatePolicy() { } public bool CheckValidationResult(ServicePoint sp, System.S...
427,851
<p>I have a table with the columns employee, address, city, state and zipcode. I have merged address, city, state, zipcode to a single column 'address' separating each field by comma. </p> <p>My issue is, if one of the fields is null, an extra comma will be inserted. For example if <code>city</code> is null the result...
[ { "answer_id": 427860, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 4, "selected": false, "text": "<p>You could use a <code>case when</code> construct</p>\n\n<pre><code> ... = case when city is null then '' else city + '...
2009/01/09
[ "https://Stackoverflow.com/questions/427851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a table with the columns employee, address, city, state and zipcode. I have merged address, city, state, zipcode to a single column 'address' separating each field by comma. My issue is, if one of the fields is null, an extra comma will be inserted. For example if `city` is null the resulting value will be lik...
You could use a `case when` construct ``` ... = case when city is null then '' else city + ',' end ``` If the values are already in the database you could replace it this way: ``` UPDATE tableX SET address= replace(address, ',,', ',') ``` Execute it N times to be sure to cover even the "all fields are null"...
427,853
<p>In C, is there a difference between writing "struct foo" instead of just "foo" if foo is a struct?</p> <p>For example:</p> <pre><code>struct sockaddr_in sin; struct sockaddr *sa; // Are these two lines equivalent? sa = (struct sockaddr*)&amp;sin; sa = (sockaddr*)&amp;sin; </code></pre> <p>Thanks /Erik</p>
[ { "answer_id": 427863, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 5, "selected": true, "text": "<p>In fact, in standard \"C\" it's required to specify <code>struct</code> keyword. This is optional in C++.</p>\n\n<p>This is ...
2009/01/09
[ "https://Stackoverflow.com/questions/427853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/276/" ]
In C, is there a difference between writing "struct foo" instead of just "foo" if foo is a struct? For example: ``` struct sockaddr_in sin; struct sockaddr *sa; // Are these two lines equivalent? sa = (struct sockaddr*)&sin; sa = (sockaddr*)&sin; ``` Thanks /Erik
In fact, in standard "C" it's required to specify `struct` keyword. This is optional in C++. This is the reason some people define structs like this: ``` typedef struct foo { ... } bar; ``` to be able to use `bar` instead of `struct foo`. However, some C compilers do not enforce this rule.
427,858
<p>I'd like to create a list and be able to toggle the display of children items on click. Should be simple but i can't get it to work. Any thoughts?</p> <pre><code>&lt;script&gt; $(document).ready(function(){ $("dt a").click(function(e){ $(e.target).children("dd").toggle(); }); }); &lt;/script&gt...
[ { "answer_id": 427886, "author": "Robin Minto", "author_id": 1456, "author_profile": "https://Stackoverflow.com/users/1456", "pm_score": 0, "selected": false, "text": "<p>There are a couple of problems here.</p>\n\n<ol>\n<li><p><strike>$(\"dt a\") - your selector is wrong as you don't ha...
2009/01/09
[ "https://Stackoverflow.com/questions/427858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'd like to create a list and be able to toggle the display of children items on click. Should be simple but i can't get it to work. Any thoughts? ``` <script> $(document).ready(function(){ $("dt a").click(function(e){ $(e.target).children("dd").toggle(); }); }); </script> <style> dd{display:none;...
A few notes: 1. "i can't get it to work" is no problem description. What is displayed? What do you do? What do you expect to happen? What is in fact happening? 2. Without the HTML code this is very hard to answer. 3. dd is not normally a child of dt, but a sibling.
427,859
<p>I have models (simplified example):</p> <pre><code>class Group(models.Model): name = models.CharField(max_length = 32) class Person(models.Model): group = models.ForeignKey(Group) class Task(models.Model): group = models.ForeignKey(Group) people = models.ManyToManyField(Person) def save(self, **kwargs)...
[ { "answer_id": 427869, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 1, "selected": true, "text": "<p>Here's an <a href=\"http://www.djangoproject.com/documentation/models/many_to_many/\" rel=\"nofollow noreferrer\">example...
2009/01/09
[ "https://Stackoverflow.com/questions/427859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36832/" ]
I have models (simplified example): ``` class Group(models.Model): name = models.CharField(max_length = 32) class Person(models.Model): group = models.ForeignKey(Group) class Task(models.Model): group = models.ForeignKey(Group) people = models.ManyToManyField(Person) def save(self, **kwargs): ppl = Pe...
Here's an [example](http://www.djangoproject.com/documentation/models/many_to_many/) that doesn't involve overriding save. It looks simpler than what you're doing.
427,880
<p>I am wrestling with a binding problem in WPF/Silverlight. I have a Listview witch is filled by a DataContext form an EF linq query. In the same usercontrol are textboxes. When changing their values, the listview gets refresht and the data is changed in de db bij .SaveChanges. The problem is that if I use a combobox ...
[ { "answer_id": 427883, "author": "PEZ", "author_id": 44639, "author_profile": "https://Stackoverflow.com/users/44639", "pm_score": 1, "selected": false, "text": "<p>The server must take part in this. Check with the hosting provider what modules are available. Or try to convince them to s...
2009/01/09
[ "https://Stackoverflow.com/questions/427880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am wrestling with a binding problem in WPF/Silverlight. I have a Listview witch is filled by a DataContext form an EF linq query. In the same usercontrol are textboxes. When changing their values, the listview gets refresht and the data is changed in de db bij .SaveChanges. The problem is that if I use a combobox the...
Here's a solution - use a SaaS comet provider, such as [WebSync On-Demand](http://www.frozenmountain.com/websync). No server resources to worry about, shared hosting or not, since it's all offloaded, and you can push out the information as needed. Since it's SaaS, it'll work with any server language. For PHP, there's ...
427,888
<p><a href="http://msdn.microsoft.com/en-us/library/cc645984.aspx" rel="noreferrer">Here</a>, it is said that Sql Server Compact allows up to 256 connections.</p> <p>But when I try to open 2 connections, I receive a file sharing error. How can I solve this?</p> <pre><code>SqlCeConnection c1 = new SqlCeConnection("Dat...
[ { "answer_id": 438485, "author": "Serhat Ozgel", "author_id": 31505, "author_profile": "https://Stackoverflow.com/users/31505", "pm_score": 4, "selected": true, "text": "<p>This was a connection string issue.</p>\n\n<pre><code>File Mode=Read Write\n</code></pre>\n\n<p>solved the problem....
2009/01/09
[ "https://Stackoverflow.com/questions/427888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
[Here](http://msdn.microsoft.com/en-us/library/cc645984.aspx), it is said that Sql Server Compact allows up to 256 connections. But when I try to open 2 connections, I receive a file sharing error. How can I solve this? ``` SqlCeConnection c1 = new SqlCeConnection("Data Source=testDB.sdf;Encrypt Database=True;Passwor...
This was a connection string issue. ``` File Mode=Read Write ``` solved the problem.
427,902
<p>Building on what has been written in SO question <a href="https://stackoverflow.com/questions/70689/best-singleton-implementation-in-java">Best Singleton Implementation In Java</a> - namely about using an enum to create a singleton - what are the differences/pros/cons between (constructor omitted)</p> <pre><code>pu...
[ { "answer_id": 427919, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 8, "selected": true, "text": "<p>Suppose you're binding to something which will use the properties of any object it's given - you can pass Elvis.INSTAN...
2009/01/09
[ "https://Stackoverflow.com/questions/427902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3898/" ]
Building on what has been written in SO question [Best Singleton Implementation In Java](https://stackoverflow.com/questions/70689/best-singleton-implementation-in-java) - namely about using an enum to create a singleton - what are the differences/pros/cons between (constructor omitted) ``` public enum Elvis { INS...
Suppose you're binding to something which will use the properties of any object it's given - you can pass Elvis.INSTANCE very easily, but you can't pass Elvis.class and expect it to find the property (unless it's deliberately coded to find static properties of classes). Basically you only use the singleton pattern whe...
427,909
<p>I need to store the first byte of data read from the network stream as a string, so I can call it back later.</p> <pre><code>prinf(" While 1 Dim tcpListener As New TcpListener(IPAddress.Any, 80) ' Listen to port given Console.WriteLine("Waiting for connection...") tcpListener.Start() ...
[ { "answer_id": 427924, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>You'll need to define exactly what you mean by \"1st piece of data\" - is this data delimited in some form (like HTTP...
2009/01/09
[ "https://Stackoverflow.com/questions/427909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to store the first byte of data read from the network stream as a string, so I can call it back later. ``` prinf(" While 1 Dim tcpListener As New TcpListener(IPAddress.Any, 80) ' Listen to port given Console.WriteLine("Waiting for connection...") tcpListener.Start() 'Accept t...
You'll need to define exactly what you mean by "1st piece of data" - is this data delimited in some form (like HTTP headers - key/value pairs are delimited by carriage-return line-feed)? Length-prefixed (like HTTP bodies when the Content-Length header is specified)? You almost certainly don't just want the first byte. ...
427,954
<p>I cannot figure out how to enable per-session instances for my WCF service while using HTTPS. (I'm not an ASP.NET expert but don't want to use ASP.NET session state if possible.) I am using .NET Framework 3.0.</p> <p>I have arrived at the following contradiction and am hoping that someone can tell me where there is...
[ { "answer_id": 441095, "author": "Enrico Campidoglio", "author_id": 26396, "author_profile": "https://Stackoverflow.com/users/26396", "pm_score": 5, "selected": true, "text": "<p>3) <strong>True</strong>, <strong>wsHttpBinding</strong> and <strong>wsDualHttpBinding</strong> are the only ...
2009/01/09
[ "https://Stackoverflow.com/questions/427954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5816/" ]
I cannot figure out how to enable per-session instances for my WCF service while using HTTPS. (I'm not an ASP.NET expert but don't want to use ASP.NET session state if possible.) I am using .NET Framework 3.0. I have arrived at the following contradiction and am hoping that someone can tell me where there is a flaw in...
3) **True**, **wsHttpBinding** and **wsDualHttpBinding** are the only HTTP bindings that support sessions 5) **False**, in order to authenticate the service callers you don't necessarily need to have any transport-level security (such as SSL/HTTPS). The only requirement is to configure IIS to enable **Integrated Windo...
427,957
<p>Although the <a href="http://en.wikipedia.org/wiki/Adobe_Flex" rel="nofollow noreferrer">Flex</a> command-line compiler (mxmlc) can compile <a href="http://en.wikipedia.org/wiki/MXML" rel="nofollow noreferrer">MXML</a>+<a href="http://en.wikipedia.org/wiki/ActionScript" rel="nofollow noreferrer">ActionScript</a> fil...
[ { "answer_id": 428040, "author": "inferis", "author_id": 51998, "author_profile": "https://Stackoverflow.com/users/51998", "pm_score": 3, "selected": true, "text": "<pre>$&gt; mxmlc --help target-player\n\n-target-player &lt;version&gt;\n specifies the version of the player the applic...
2009/01/09
[ "https://Stackoverflow.com/questions/427957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41021/" ]
Although the [Flex](http://en.wikipedia.org/wiki/Adobe_Flex) command-line compiler (mxmlc) can compile [MXML](http://en.wikipedia.org/wiki/MXML)+[ActionScript](http://en.wikipedia.org/wiki/ActionScript) files into [SWFs](http://en.wikipedia.org/wiki/SWF), I need specific insights into its capabilities, via the command-...
``` $> mxmlc --help target-player -target-player <version> specifies the version of the player the application is targeting. Features requiring a later version will not be compiled into the application. The minimum value supported is "9.0.0". ``` You can't define the language afaik - mxmlc version 3 is an...
427,960
<p>I'm developing an user control that I need for a project, the control have around 13 rows, 7 columns of textboxes, comboboxes... everything on a form autoscrollable. The problem is that in execution time when scrolling the content refreshing is very very slow. Some idea?</p> <p>Using a datagridview is not an option...
[ { "answer_id": 428040, "author": "inferis", "author_id": 51998, "author_profile": "https://Stackoverflow.com/users/51998", "pm_score": 3, "selected": true, "text": "<pre>$&gt; mxmlc --help target-player\n\n-target-player &lt;version&gt;\n specifies the version of the player the applic...
2009/01/09
[ "https://Stackoverflow.com/questions/427960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22672/" ]
I'm developing an user control that I need for a project, the control have around 13 rows, 7 columns of textboxes, comboboxes... everything on a form autoscrollable. The problem is that in execution time when scrolling the content refreshing is very very slow. Some idea? Using a datagridview is not an option. Edit: ...
``` $> mxmlc --help target-player -target-player <version> specifies the version of the player the application is targeting. Features requiring a later version will not be compiled into the application. The minimum value supported is "9.0.0". ``` You can't define the language afaik - mxmlc version 3 is an...
427,966
<p>We have a bunch of VB6 apps at our company. We are trying to debug a random SQL timeout error and did a trace with SQL Server Profiler on the Audit Login event. We noticed that the connections were coming in as nonpooled. We use the SQLOLEDB provider with SQL Server 2000 &amp; 2005. I searched the internet and every...
[ { "answer_id": 428037, "author": "cmsjr", "author_id": 23114, "author_profile": "https://Stackoverflow.com/users/23114", "pm_score": 4, "selected": true, "text": "<p>Disposing the connection on every call could prevent pooling</p>\n\n<blockquote>\n <p>...at least one instance of a Conne...
2009/01/09
[ "https://Stackoverflow.com/questions/427966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36383/" ]
We have a bunch of VB6 apps at our company. We are trying to debug a random SQL timeout error and did a trace with SQL Server Profiler on the Audit Login event. We noticed that the connections were coming in as nonpooled. We use the SQLOLEDB provider with SQL Server 2000 & 2005. I searched the internet and everything I...
Disposing the connection on every call could prevent pooling > > ...at least one instance of a Connection > object instantiated for each unique > user—at all times. Otherwise, the pool > will be destroyed when the last > Connection object for that string is > closed. > > > <http://msdn.microsoft.com/en-us/li...
427,979
<p>How to extract a text part by regexp in linux shell? Lets say, I have a file where in every line is an IP address, but on a different position. What is the simplest way to extract those IP addresses using common unix command-line tools?</p>
[ { "answer_id": 427985, "author": "PolyThinker", "author_id": 47707, "author_profile": "https://Stackoverflow.com/users/47707", "pm_score": 0, "selected": false, "text": "<p>I'd suggest perl. (\\d+.\\d+.\\d+.\\d+) should probably do the trick. </p>\n\n<p>EDIT: Just to make it more like a ...
2009/01/09
[ "https://Stackoverflow.com/questions/427979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53319/" ]
How to extract a text part by regexp in linux shell? Lets say, I have a file where in every line is an IP address, but on a different position. What is the simplest way to extract those IP addresses using common unix command-line tools?
You could use [grep](http://unixhelp.ed.ac.uk/CGI/man-cgi?grep) to pull them out. ``` grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' file.txt ```
428,001
<p>I have a Gridview in which i have two templatefields of dropdownlist. I bound them on runtime with same list item.</p> <pre><code>li = new listitem ("1","1"); dl1.items.add(li); dl2.items.add(li); li = new listitem ("2","2"); dl1.items.add(li); dl2.items.add(li); li = new listitem ("3","3"); dl1.items.add(li); dl...
[ { "answer_id": 428008, "author": "Ali Ersöz", "author_id": 4215, "author_profile": "https://Stackoverflow.com/users/4215", "pm_score": 2, "selected": false, "text": "<p>You have to instantiate each list item for each drop down list.</p>\n\n<pre><code>ListItem li1 = new ListItem(\"1\",\"1...
2009/01/09
[ "https://Stackoverflow.com/questions/428001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29515/" ]
I have a Gridview in which i have two templatefields of dropdownlist. I bound them on runtime with same list item. ``` li = new listitem ("1","1"); dl1.items.add(li); dl2.items.add(li); li = new listitem ("2","2"); dl1.items.add(li); dl2.items.add(li); li = new listitem ("3","3"); dl1.items.add(li); dl2.items.add(li...
The ListItem class has a property "Selected" which marks if the item is selected. I haven't checked the DDL SelectedValue property to see what it does, but my guess is that the ListItem.Selected property is being set to true, and since you are using the same object in both drop-down lists, it is being marked as 'select...
428,012
<p>When it comes to writing custom MySQL database-driven PHP session management for a VERY dynamic website, what is the best (fastest read/write access) structure for your session table?</p> <p>Bad Example (Not Optimized):</p> <pre> CREATE TABLE `session` ( `session_id` VARCHAR(32) NOT NULL, `session_data` TE...
[ { "answer_id": 430230, "author": "Ry Biesemeyer", "author_id": 53098, "author_profile": "https://Stackoverflow.com/users/53098", "pm_score": 2, "selected": true, "text": "<p>Your intuition seems to be about right. I'd recommend creating the table as follows:</p>\n\n<pre><code>CREATE TABL...
2009/01/09
[ "https://Stackoverflow.com/questions/428012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53303/" ]
When it comes to writing custom MySQL database-driven PHP session management for a VERY dynamic website, what is the best (fastest read/write access) structure for your session table? Bad Example (Not Optimized): ``` CREATE TABLE `session` ( `session_id` VARCHAR(32) NOT NULL, `session_data` TEXT NOT NULL, ...
Your intuition seems to be about right. I'd recommend creating the table as follows: ``` CREATE TABLE session ( id CHAR(32) NOT NULL, data BLOB NOT NULL, t_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, t_updated TIMESTAMP, PRIMARY KEY (session_id), INDEX t_created(t_created), INDEX t_updated(t_up...
428,013
<p>I've got a bunch of strings like:</p> <pre><code>"Hello, here's a test colon&amp;#58;. Here's a test semi-colon&amp;#59;" </code></pre> <p>I would like to replace that with</p> <pre><code>"Hello, here's a test colon:. Here's a test semi-colon;" </code></pre> <p>And so on for all <a href="http://www.w3schools.com...
[ { "answer_id": 428043, "author": "PEZ", "author_id": 44639, "author_profile": "https://Stackoverflow.com/users/44639", "pm_score": 2, "selected": false, "text": "<p>I don't know about the regex support in boost, but check if it has a replace() method that supports callbacks or lambdas or...
2009/01/09
[ "https://Stackoverflow.com/questions/428013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20972/" ]
I've got a bunch of strings like: ``` "Hello, here's a test colon&#58;. Here's a test semi-colon&#59;" ``` I would like to replace that with ``` "Hello, here's a test colon:. Here's a test semi-colon;" ``` And so on for all [printable ASCII values](http://www.w3schools.com/tags/ref_ascii.asp). At present I'm usi...
The big advantage of using a regex is to deal with the tricky cases like `&#38;#38;` Entity replacement isn't iterative, it's a single step. The regex is also going to be fairly efficient: the two lead characters are fixed, so it will quickly skip anything not starting with `&#`. Finally, the regex solution is one with...
428,021
<p>While looking for a light-weight Scala development environment, I came upon an <a href="http://github.com/djspiewak/jedit-modes/tree/master/scala.xml" rel="noreferrer">Scala edit mode</a> for jEdit. I don't know how to put it to use, though. How does one put a new edit mode in jEdit?</p>
[ { "answer_id": 428045, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 1, "selected": false, "text": "<p>May be this <a href=\"http://liftweb.net/index.php/SetUp_jEdit\" rel=\"nofollow noreferrer\">JEdit Setup with Scala</a> can ...
2009/01/09
[ "https://Stackoverflow.com/questions/428021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53013/" ]
While looking for a light-weight Scala development environment, I came upon an [Scala edit mode](http://github.com/djspiewak/jedit-modes/tree/master/scala.xml) for jEdit. I don't know how to put it to use, though. How does one put a new edit mode in jEdit?
All of this can be found inside jEdit's help, Using jEdit -> Writing Edit Modes -> Installing Edit Modes. But, if you are like me, and tried StackOverflow first, here's the short of it. Place the mode file (in this case, scala.xml) inside the "modes" directory in jEdit home directory -- this can be found through the U...
428,041
<p>I am trying to turn a table 90 degrees: make columns rows. No PIVOT is allowed since PIVOT requires aggregate functions. </p> <p>Example: I have a table with the columns:<br> ID int,<br> ISO char(2),<br> Text varchar(255). </p> <p>So I have this:</p> <pre> ID ISO Text -- --- ---- 1 DE Auto 2 EN Car </pre> ...
[ { "answer_id": 428244, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 0, "selected": false, "text": "<p>Since you explicitly asked for a non-pivot solution: this should work, if you know which ISOs you will have in the rows....
2009/01/09
[ "https://Stackoverflow.com/questions/428041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53332/" ]
I am trying to turn a table 90 degrees: make columns rows. No PIVOT is allowed since PIVOT requires aggregate functions. Example: I have a table with the columns: ID int, ISO char(2), Text varchar(255). So I have this: ``` ID ISO Text -- --- ---- 1 DE Auto 2 EN Car ``` I'd like to get the followin...
[This answer is really frantisek's](https://stackoverflow.com/questions/428041/sql-server-2005-turn-columns-into-rows#428344), I'm just copying here to correct the mistake (I can't edit directly). Basically, you use that solution, with a tweak: ``` SELECT max(DE) as DE, max(EN) as EN FROM test PIVOT (MAX(...
428,065
<p>When I say simple, I mean, within an expression, so that I can stick it in as a value in a hash without preparing it first. I'll post my solution but I'm looking for a better one that reminds me less of VB. :)</p>
[ { "answer_id": 428077, "author": "Kev", "author_id": 16777, "author_profile": "https://Stackoverflow.com/users/16777", "pm_score": 0, "selected": false, "text": "<pre><code>substr($s, 0, index($s, $/) &gt; -1 ? index($s, $/) || () )\n</code></pre>\n" }, { "answer_id": 428115, ...
2009/01/09
[ "https://Stackoverflow.com/questions/428065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16777/" ]
When I say simple, I mean, within an expression, so that I can stick it in as a value in a hash without preparing it first. I'll post my solution but I'm looking for a better one that reminds me less of VB. :)
How about ``` ( split /\n/, $s )[0] ``` ? You don't have to worry about \n being not cross-platform because [Perl is clever enough to take care of that](http://search.cpan.org/~rgarcia/perl/pod/perlport.pod#Newlines).
428,066
<p>I'm wondering what the easiest/most elegant way of selecting attributes from join models in has_many :through associations is.</p> <p>Lets say we have Items, Catalogs, and CatalogItems with the following Item class:</p> <pre><code>class Item &lt; ActiveRecord::Base has_many :catalog_items has_many :cat...
[ { "answer_id": 428231, "author": "Milan Novota", "author_id": 26123, "author_profile": "https://Stackoverflow.com/users/26123", "pm_score": 0, "selected": false, "text": "<p>You can do something like this:</p>\n\n<pre><code># which is basically same as your \"frustrating way\" of doing i...
2009/01/09
[ "https://Stackoverflow.com/questions/428066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52932/" ]
I'm wondering what the easiest/most elegant way of selecting attributes from join models in has\_many :through associations is. Lets say we have Items, Catalogs, and CatalogItems with the following Item class: ``` class Item < ActiveRecord::Base has_many :catalog_items has_many :catalogs, :through => :cat...
You can do something like this: ``` # which is basically same as your "frustrating way" of doing it @item.catalog_items.find_by_catalogue_id(@item.catalogs.first.id).position ``` Or you can wrap it into in an instance method of the Item model: ``` def position_in_first_catalogue self.catalog_items.find_by_catalo...
428,068
<pre><code>procedure matrixvector(n:integer); var i,j:integer; begin for i&lt;-1 to n do begin B[i] = 0; C[i] = 0; for j&lt;-1 to i do B[i]&lt;- B[i]+ A[i,j]; for j&lt;-n down to i+1 do C[i]&lt;-C[i] + A[i,j] end end; </code></pre>
[ { "answer_id": 428078, "author": "duffymo", "author_id": 37213, "author_profile": "https://Stackoverflow.com/users/37213", "pm_score": 3, "selected": false, "text": "<p>O(n^2), if I read it right. </p>\n\n<p>Why you need two inner loops is beyond me. Why not sum B and C in the same loo...
2009/01/09
[ "https://Stackoverflow.com/questions/428068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` procedure matrixvector(n:integer); var i,j:integer; begin for i<-1 to n do begin B[i] = 0; C[i] = 0; for j<-1 to i do B[i]<- B[i]+ A[i,j]; for j<-n down to i+1 do C[i]<-C[i] + A[i,j] end end; ```
O(n^2), if I read it right. Why you need two inner loops is beyond me. Why not sum B and C in the same loop?
428,073
<p>Currently our Java application uses the values held within a tab delimited *.cfg file. We need to change this application so that it now uses an XML file.</p> <p>What is the best/simplest library to use in order to read in values from this file?</p>
[ { "answer_id": 428091, "author": "Guillaume", "author_id": 23704, "author_profile": "https://Stackoverflow.com/users/23704", "pm_score": 7, "selected": true, "text": "<p>There are of course a lot of good solutions based on what you need. If it is just configuration, you should have a loo...
2009/01/09
[ "https://Stackoverflow.com/questions/428073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42435/" ]
Currently our Java application uses the values held within a tab delimited \*.cfg file. We need to change this application so that it now uses an XML file. What is the best/simplest library to use in order to read in values from this file?
There are of course a lot of good solutions based on what you need. If it is just configuration, you should have a look at Jakarta [commons-configuration](http://commons.apache.org/configuration/) and [commons-digester](http://commons.apache.org/digester/). You could always use the standard JDK method of getting a doc...
428,109
<p>Given a filename in the form <code>someletters_12345_moreleters.ext</code>, I want to extract the 5 digits and put them into a variable.</p> <p>So to emphasize the point, I have a filename with x number of characters then a five digit sequence surrounded by a single underscore on either side then another set of x n...
[ { "answer_id": 428118, "author": "FerranB", "author_id": 40441, "author_profile": "https://Stackoverflow.com/users/40441", "pm_score": 11, "selected": true, "text": "<p>Use <a href=\"http://www.manpagez.com/man/1/cut/\" rel=\"noreferrer\">cut</a>:</p>\n\n<pre><code>echo 'someletters_1234...
2009/01/09
[ "https://Stackoverflow.com/questions/428109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39666/" ]
Given a filename in the form `someletters_12345_moreleters.ext`, I want to extract the 5 digits and put them into a variable. So to emphasize the point, I have a filename with x number of characters then a five digit sequence surrounded by a single underscore on either side then another set of x number of characters. ...
Use [cut](http://www.manpagez.com/man/1/cut/): ``` echo 'someletters_12345_moreleters.ext' | cut -d'_' -f 2 ``` More generic: ``` INPUT='someletters_12345_moreleters.ext' SUBSTRING=$(echo $INPUT| cut -d'_' -f 2) echo $SUBSTRING ```
428,110
<p>In my iPhone app, I have put a UIBarBUtton of type UIBarButtonSystemItemTrash in my UIToolBar. When pressed, I'd like to replicate the animation of Mail.app: the bin opens, the UIView folds and flies into it.<br> Is there a way to access this animation ithrough the iPhone SDK? </p> <p>Presently I am using a custom...
[ { "answer_id": 429394, "author": "Brad Larson", "author_id": 19679, "author_profile": "https://Stackoverflow.com/users/19679", "pm_score": 3, "selected": false, "text": "<p>Unfortunately, I think this is going to need to be an entirely custom animation. The UIView folding can be approxi...
2009/01/09
[ "https://Stackoverflow.com/questions/428110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52224/" ]
In my iPhone app, I have put a UIBarBUtton of type UIBarButtonSystemItemTrash in my UIToolBar. When pressed, I'd like to replicate the animation of Mail.app: the bin opens, the UIView folds and flies into it. Is there a way to access this animation ithrough the iPhone SDK? Presently I am using a custom made animat...
Use the suckEffect type on an animation. Also: spewEffect, genieEffect, unGenieEffect, twist, tubey, swirl, cameraIris, cameraIrisHollowClose, cameraIrisHollowOpen, rippleEffect, charminUltra, zoomyIn, and zoomyOut. Doesn't work in the simulator. ``` CATransition *animation = [CATransition animation]; animation.type =...
428,112
<p>I am using JavaScript and jQuery. My main file has <code>My.js</code> and Ajax.</p> <h3>My.js</h3> <pre><code>function build_one(){ alert("inside build_one"); } </code></pre> <h3>My main file</h3> <pre><code>&lt;script type="text/javascript"&gt; .. // Here I want to make call function defined in My...
[ { "answer_id": 428137, "author": "d4nt", "author_id": 1039, "author_profile": "https://Stackoverflow.com/users/1039", "pm_score": 4, "selected": true, "text": "<p>This should work:</p>\n\n<pre><code>&lt;script type=\"text/javascript\" src=\"My.js\"&gt;&lt;/script&gt;\n&lt;script type=\"t...
2009/01/09
[ "https://Stackoverflow.com/questions/428112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44984/" ]
I am using JavaScript and jQuery. My main file has `My.js` and Ajax. ### My.js ``` function build_one(){ alert("inside build_one"); } ``` ### My main file ``` <script type="text/javascript"> .. // Here I want to make call function defined in My.js build_one() .. // Here is the Ajax call ...
This should work: ``` <script type="text/javascript" src="My.js"></script> <script type="text/javascript"> build_one(); $.ajax({ type:'POST', url: 'ajax.php', data:'id='+id , success: function(data){ $("#response").html(data); } ...
428,121
<p>I have an application that gets installed with a Wise installer (EDIT: Wise creates a Setup.exe file, not an MSI). Upon installation, an icon is set for a certain file type:</p> <pre><code>HKEY_CLASSES_ROOT\.auz\DefaultIcon = C:\Path\To\App\some_icon.ico,0 </code></pre> <p>Right after the installation, however, Ex...
[ { "answer_id": 428137, "author": "d4nt", "author_id": 1039, "author_profile": "https://Stackoverflow.com/users/1039", "pm_score": 4, "selected": true, "text": "<p>This should work:</p>\n\n<pre><code>&lt;script type=\"text/javascript\" src=\"My.js\"&gt;&lt;/script&gt;\n&lt;script type=\"t...
2009/01/09
[ "https://Stackoverflow.com/questions/428121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2095/" ]
I have an application that gets installed with a Wise installer (EDIT: Wise creates a Setup.exe file, not an MSI). Upon installation, an icon is set for a certain file type: ``` HKEY_CLASSES_ROOT\.auz\DefaultIcon = C:\Path\To\App\some_icon.ico,0 ``` Right after the installation, however, Explorer chooses to display ...
This should work: ``` <script type="text/javascript" src="My.js"></script> <script type="text/javascript"> build_one(); $.ajax({ type:'POST', url: 'ajax.php', data:'id='+id , success: function(data){ $("#response").html(data); } ...
428,124
<p>What I want is, I think, relatively simple:</p> <pre><code>&gt; Bin = &lt;&lt;"Hello.world.howdy?"&gt;&gt;. &gt; split(Bin, "."). [&lt;&lt;"Hello"&gt;&gt;, &lt;&lt;"world"&gt;&gt;, &lt;&lt;"howdy?"&gt;&gt;] </code></pre> <p>Any pointers?</p>
[ { "answer_id": 428332, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>Here's one way:</p>\n\n<pre><code>re:split(&lt;&lt;\"Hello.world.howdy?\"&gt;&gt;, \"\\\\.\").\n</code></pre>\n" }, { ...
2009/01/09
[ "https://Stackoverflow.com/questions/428124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21000/" ]
What I want is, I think, relatively simple: ``` > Bin = <<"Hello.world.howdy?">>. > split(Bin, "."). [<<"Hello">>, <<"world">>, <<"howdy?">>] ``` Any pointers?
There is no current OTP function that is the equivalent of `lists:split/2` that works on a binary string. Until [EEP-9](http://www.erlang.org/eeps/eep-0009.html) is made public, you might write a binary split function like: ``` split(Binary, Chars) -> split(Binary, Chars, 0, 0, []). split(Bin, Chars, Idx, LastSpl...
428,126
<p>does anyone know how to return a value from a (sql) database into an MSBuild script? I want to get the value into a property so I can pass it to subsequent build tasks.</p> <p>I am fiddling round with something like the following at the moment, but this is returning -1 to indicate the query has executed successfull...
[ { "answer_id": 428170, "author": "flq", "author_id": 51428, "author_profile": "https://Stackoverflow.com/users/51428", "pm_score": 0, "selected": false, "text": "<p>Have you tried \"select * from dbo.trade\" ? \nAccording to the msbuild communitytasks docs the Result returns the number o...
2009/01/09
[ "https://Stackoverflow.com/questions/428126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44950/" ]
does anyone know how to return a value from a (sql) database into an MSBuild script? I want to get the value into a property so I can pass it to subsequent build tasks. I am fiddling round with something like the following at the moment, but this is returning -1 to indicate the query has executed successfully, whereas...
It's often easiest to just open up the community tasks in Reflector or check the codebase directly to see how it's intended to be used.
428,144
<p>On RedHat Enterprise Linux 5 the latest Ruby version available via RPM is 1.8.5. My Rails app requires 1.8.6 or above so I need to compile Ruby from source.</p> <p>I have tried the following to build it and it seems to build ok, but then I'm seeing gcc compilation errors when trying to run a plug-in which requires...
[ { "answer_id": 428314, "author": "Jörg W Mittag", "author_id": 2988, "author_profile": "https://Stackoverflow.com/users/2988", "pm_score": 3, "selected": true, "text": "<p>The best way would probably be to just \"steal\" a Ruby 1.8.6 RPM from Fedora. The second best way would be to steal...
2009/01/09
[ "https://Stackoverflow.com/questions/428144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1174/" ]
On RedHat Enterprise Linux 5 the latest Ruby version available via RPM is 1.8.5. My Rails app requires 1.8.6 or above so I need to compile Ruby from source. I have tried the following to build it and it seems to build ok, but then I'm seeing gcc compilation errors when trying to run a plug-in which requires RubyInline...
The best way would probably be to just "steal" a Ruby 1.8.6 RPM from Fedora. The second best way would be to steal a Ruby 1.8.6 SRPM from Fedora and build it yourself. However, there is one thing you could do: add a `--disable-pthread` flag to the `configure` line and remove `--enable-pthread` if it's there. `--enable...
428,147
<p>We have a set of databases that have a table defined with an Identity column as the primary key. As a sub-set of these are replicated to other servers, a seed system was created so that they could never clash. That system was by using a starting seed with an increment of 50.</p> <p>In this way the table on DB1 woul...
[ { "answer_id": 428162, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 2, "selected": false, "text": "<p>Replication = GUID column.</p>\n\n<p>To set the value of the next ID to be 1000:</p>\n\n<pre><code>DBCC CHECKIDENT...
2009/01/09
[ "https://Stackoverflow.com/questions/428147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16156/" ]
We have a set of databases that have a table defined with an Identity column as the primary key. As a sub-set of these are replicated to other servers, a seed system was created so that they could never clash. That system was by using a starting seed with an increment of 50. In this way the table on DB1 would generate...
Replication = GUID column. To set the value of the next ID to be 1000: ``` DBCC CHECKIDENT (orders, RESEED, 999) ```
428,149
<p>i have very simple problem. I need to create model, that represent element of ordered list. This model can be implemented like this:</p> <pre><code>class Item(models.Model): data = models.TextField() order = models.IntegerField() </code></pre> <p>or like this:</p> <pre><code>class Item(models.Model): ...
[ { "answer_id": 428165, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 3, "selected": false, "text": "<p>That depends on what you want to do. </p>\n\n<p>The first one seems better to make a single query in the database and ge...
2009/01/09
[ "https://Stackoverflow.com/questions/428149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42371/" ]
i have very simple problem. I need to create model, that represent element of ordered list. This model can be implemented like this: ``` class Item(models.Model): data = models.TextField() order = models.IntegerField() ``` or like this: ``` class Item(models.Model): data = models.TextField() next = ...
Essentially, the second solution you propose is a linked list. Linked list implemented at the database level are usually not a good idea. To retrieve a list of `n` elements, you will need `n` database access (or use complicated queries). Performance wise, retrieving a list in O(n) is awfully not efficient. In regular ...
428,175
<p>Say that I have two tables like those:</p> <pre> Employers (id, name, .... , deptId). Depts(id, deptName, ...). </pre> <p>But Those data is not going to be modified so often and I want that a query like this</p> <pre><code>SELECT name, deptName FROM Employers, Depts WHERE deptId = Depts.id AND Employers.id=&quo...
[ { "answer_id": 428239, "author": "Ian Varley", "author_id": 37539, "author_profile": "https://Stackoverflow.com/users/37539", "pm_score": 4, "selected": true, "text": "<p>Generally, unless you \"materialize\" a view, which is an option in some software like MS SQL Server, the view is jus...
2009/01/09
[ "https://Stackoverflow.com/questions/428175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24097/" ]
Say that I have two tables like those: ``` Employers (id, name, .... , deptId). Depts(id, deptName, ...). ``` But Those data is not going to be modified so often and I want that a query like this ``` SELECT name, deptName FROM Employers, Depts WHERE deptId = Depts.id AND Employers.id="ID" ``` be as faster a...
Generally, unless you "materialize" a view, which is an option in some software like MS SQL Server, the view is just translated into queries against the base tables, and is therefore no faster or slower than the original (minus the minuscule amount of time it takes to translate the query, which is nothing compared to a...
428,183
<p>I want to re-write a method that has way too many nested <code>if</code> statements.</p> <p>I came up with this approach and wanted your opinions:</p> <pre><code>public void MyMethod() { bool hasFailed = false; try { GetNewOrders(out hasFailed); if(!hasFailed) CheckInventory(out ha...
[ { "answer_id": 428194, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 1, "selected": false, "text": "<p>This doesn't really look good to me. The use of the hasFailed variable is really not nice. if GetNewOrders fails wit...
2009/01/09
[ "https://Stackoverflow.com/questions/428183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
I want to re-write a method that has way too many nested `if` statements. I came up with this approach and wanted your opinions: ``` public void MyMethod() { bool hasFailed = false; try { GetNewOrders(out hasFailed); if(!hasFailed) CheckInventory(out hasFailed); if(!hasFailed) ...
I've done stuff similar to that, but without the exception handling: ``` BOOL ok = CallSomeFunction(); if( ok ) ok = CallSomeOtherFunction(); if( ok ) ok = CallYetAnotherFunction(); if( ok ) ok = WowThatsALotOfFunctions(); if( !ok ) { // handle failure } ``` Or if you want to be clever: ``` BOOL ok = CallSomeFu...
428,196
<p>This is just a question to satisfy my curiosity. But to me it is interesting.</p> <p>I wrote this little simple benchmark. It calls 3 variants of Regexp execution in a random order a few thousand times:</p> <p>Basically, I use the same pattern but in different ways.</p> <ol> <li><p>Your ordinary way without any <...
[ { "answer_id": 428259, "author": "P Daddy", "author_id": 36388, "author_profile": "https://Stackoverflow.com/users/36388", "pm_score": 2, "selected": false, "text": "<p><a href=\"https://stackoverflow.com/questions/414328/using-static-regex-ismatch-vs-creating-an-instance-of-regex#414411...
2009/01/09
[ "https://Stackoverflow.com/questions/428196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51710/" ]
This is just a question to satisfy my curiosity. But to me it is interesting. I wrote this little simple benchmark. It calls 3 variants of Regexp execution in a random order a few thousand times: Basically, I use the same pattern but in different ways. 1. Your ordinary way without any `RegexOptions`. Starting with ....
In the Regex.Match version you are looking for the input in the pattern. Try swapping the parameters around. ``` var m3 = Regex.Match(pattern, item); // Wrong var m3 = Regex.Match(item, pattern); // Correct ```
428,214
<p>I have small problem with my .net 2.0 winforms application. I want to embed a few different icons to app.</p> <p>There are also other requirements:</p> <ul> <li>must be automatic rebuildable by ms-build; using external gui apps for preparation isn't allowed</li> <li>application must contain versioninfo.</li> </ul>...
[ { "answer_id": 428249, "author": "Sailing Judo", "author_id": 42620, "author_profile": "https://Stackoverflow.com/users/42620", "pm_score": 1, "selected": false, "text": "<p>Just like in 2005, you can add the icons to the resources (via the project properties). After you do that, go to ...
2009/01/09
[ "https://Stackoverflow.com/questions/428214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39656/" ]
I have small problem with my .net 2.0 winforms application. I want to embed a few different icons to app. There are also other requirements: * must be automatic rebuildable by ms-build; using external gui apps for preparation isn't allowed * application must contain versioninfo. After embeding multiple icons, I want...
I decided to put all icons into separate old-school plain win32 c++ \*.dll. It's more convienient and I don't need to do any tricks with versioninfo/win32resources.
428,216
<p>I'm trying to read a 16-bit greyscale TIFF file (BitsPerSample=16) using a small C program to convert into an array of floating point numbers for further analysis. The pixel data are, according to the header information, in a single strip of 2048x2048 pixels. Encoding is little-endian.<br> With that header informa...
[ { "answer_id": 428270, "author": "plinth", "author_id": 20481, "author_profile": "https://Stackoverflow.com/users/20481", "pm_score": 0, "selected": false, "text": "<p>You understand that if StripOffsets is an array, it is an offset to an array of offsets, right? You might not be doing ...
2009/01/09
[ "https://Stackoverflow.com/questions/428216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53343/" ]
I'm trying to read a 16-bit greyscale TIFF file (BitsPerSample=16) using a small C program to convert into an array of floating point numbers for further analysis. The pixel data are, according to the header information, in a single strip of 2048x2048 pixels. Encoding is little-endian. With that header information, ...
I've found the problem - it was in my C program... I had allocated memory for an array of longs and used fread() to read in the data: ``` #define PPR 2048; #define BPP 2; long *pix; pix=malloc(PPR*PPR*sizeof(long)); fread(pix,BPP,PPR*PPR,in); ``` But since the data come in 2-byte chunks (BPP=2) but sizeof(long)=4, ...
428,225
<p>I just started Shader programming(GLSL) and created a few with RenderMonkey. Now I want to use this Shaders in my java code. Are there any simple examples of how I do that?</p>
[ { "answer_id": 428247, "author": "glenatron", "author_id": 15394, "author_profile": "https://Stackoverflow.com/users/15394", "pm_score": 2, "selected": false, "text": "<p>I don't have any myself, but if I have a problem along these lines I have often found the best place for 3D programmi...
2009/01/09
[ "https://Stackoverflow.com/questions/428225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2450/" ]
I just started Shader programming(GLSL) and created a few with RenderMonkey. Now I want to use this Shaders in my java code. Are there any simple examples of how I do that?
I have found a very simple example ``` int v = gl.glCreateShader(GL.GL_VERTEX_SHADER); int f = gl.glCreateShader(GL.GL_FRAGMENT_SHADER); BufferedReader brv = new BufferedReader(new FileReader("vertexshader.glsl")); String vsrc = ""; String line; while ((line=brv.readLine()) != null) { vsrc += line + "\n"; } gl.glSh...
428,237
<p>I'm writing a C# program to convert a FoxPro database to XML, and everything works except the memo field is blank. Is there something I'm missing to convert that bit?</p> <p>I'm using C# .Net 3.5 SP1, Visual FoxPro 9 SP 1 OLE DB Driver. Connection string is okay, as all other data is being pulled properly.</p> <p>...
[ { "answer_id": 428294, "author": "Adam Paynter", "author_id": 41619, "author_profile": "https://Stackoverflow.com/users/41619", "pm_score": 1, "selected": false, "text": "<p>I am not terribly familiar with C# or FoxPro or SQL Server, so I cannot give you much advice in that regard.</p>\n...
2009/01/09
[ "https://Stackoverflow.com/questions/428237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39421/" ]
I'm writing a C# program to convert a FoxPro database to XML, and everything works except the memo field is blank. Is there something I'm missing to convert that bit? I'm using C# .Net 3.5 SP1, Visual FoxPro 9 SP 1 OLE DB Driver. Connection string is okay, as all other data is being pulled properly. When I converted ...
Ended up having to do some work myself, but maybe it can help someone else out in the future: ``` public static object GetDbaseOrFoxproRawValue(string DBPath, string TableName, string ColumnName, string CompareColumnName, string CompareValue, bool CompareColumnIsAutoKey) { using (BinaryRea...
428,238
<p>Hmmm, a new odd issue that has just started. Every now and then VS drops a whole bunch of projects from the solution. It will say at the top of Solution explorer "42 projects" when it is displaying only about 20 or so. Closing VS and re-opening it fixes this, although it is a bit of a pain as it takes a little while...
[ { "answer_id": 428294, "author": "Adam Paynter", "author_id": 41619, "author_profile": "https://Stackoverflow.com/users/41619", "pm_score": 1, "selected": false, "text": "<p>I am not terribly familiar with C# or FoxPro or SQL Server, so I cannot give you much advice in that regard.</p>\n...
2009/01/09
[ "https://Stackoverflow.com/questions/428238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1143/" ]
Hmmm, a new odd issue that has just started. Every now and then VS drops a whole bunch of projects from the solution. It will say at the top of Solution explorer "42 projects" when it is displaying only about 20 or so. Closing VS and re-opening it fixes this, although it is a bit of a pain as it takes a little while fo...
Ended up having to do some work myself, but maybe it can help someone else out in the future: ``` public static object GetDbaseOrFoxproRawValue(string DBPath, string TableName, string ColumnName, string CompareColumnName, string CompareValue, bool CompareColumnIsAutoKey) { using (BinaryRea...
428,243
<p>I'm designing a database of statistics about the operation of mechanical equipment. Each batch of data will contain hundreds of statistics, so I'm trying to decide whether to create a single table with hundreds of columns or to split it up into multiple tables, each containing related statistics. For example, I co...
[ { "answer_id": 428321, "author": "duffymo", "author_id": 37213, "author_profile": "https://Stackoverflow.com/users/37213", "pm_score": 1, "selected": false, "text": "<p>Normalization ensures that you don't repeat data in your schema. </p>\n\n<p>There are limits to how far you should go,...
2009/01/09
[ "https://Stackoverflow.com/questions/428243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1694/" ]
I'm designing a database of statistics about the operation of mechanical equipment. Each batch of data will contain hundreds of statistics, so I'm trying to decide whether to create a single table with hundreds of columns or to split it up into multiple tables, each containing related statistics. For example, I could h...
I think we need to know more about your design to answer properly. For example, I'm curious that there could be lots of columns relating to malfunctions, lots (of different ones) relating to jams etc. (Isn't a jam just a kind of malfunction anyway?) Is your design normalised? Presumably you don't have columns like "ja...
428,257
<p>I have a datalist control which some controls(ex: button) are in it. I want to write some code into click event of button which is in the datalist control. But in the code behind page I can't see the name of controls into datalist. How can I solve this problem?</p>
[ { "answer_id": 428293, "author": "cmsjr", "author_id": 23114, "author_profile": "https://Stackoverflow.com/users/23114", "pm_score": 2, "selected": false, "text": "<p>Attach your event to the controls in the OnItemCreated event of the datalist.</p>\n\n<p><strong>EDITED TO ADD SAMPLE</str...
2009/01/09
[ "https://Stackoverflow.com/questions/428257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/439507/" ]
I have a datalist control which some controls(ex: button) are in it. I want to write some code into click event of button which is in the datalist control. But in the code behind page I can't see the name of controls into datalist. How can I solve this problem?
If you don't want to add a handler to all the child events, you could instead add your code to the OnItemCommand. ``` <asp:DataList id="DataList1" runat="server"> <ItemTemplate> <asp:Button ID="btnDoSomething" Runat=server CommandName="DoSomething" CommandArgument="<%# DataBinder.Eval(Container.DataItem, "SomeID") %>...
428,262
<p>Ok I want some opinions how I can fix this mess of a method!</p> <p>It has WAY to many nested 'if' statements.</p> <p>But realize I have to know exactly where the method fails, currently in each of the respective 'else' clause I am logging the error (the failed 'if' condition').</p> <p><b>Note: ignore any logic b...
[ { "answer_id": 428302, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 1, "selected": false, "text": "<p>You can start by putting the toplevel if (true branch) in a separate method. And continue until satisfied. </p>\n\...
2009/01/09
[ "https://Stackoverflow.com/questions/428262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
Ok I want some opinions how I can fix this mess of a method! It has WAY to many nested 'if' statements. But realize I have to know exactly where the method fails, currently in each of the respective 'else' clause I am logging the error (the failed 'if' condition'). **Note: ignore any logic behind the things, please ...
I would work on changing your logic so you can return from the method as soon as possible instead of nesting more logic. Fore example: ``` // GOOD if (!file.exists()) return; // Rest of the code // BAD if (file.exists()){ // Code goes here } return; ``` This may help remove some nesting and make things les...
428,264
<p>To illustrate the question check the following code:</p> <pre><code>class MyDescriptor(object): def __get__(self, obj, type=None): print "get", self, obj, type return self._v def __set__(self, obj, value): self._v = value print "set", self, obj, value return None class SomeClass1(object): ...
[ { "answer_id": 428357, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 3, "selected": true, "text": "<p>To answer your second question, where is <code>_v</code>?</p>\n\n<p>Your version of the descriptor keeps <code>_v</code> ...
2009/01/09
[ "https://Stackoverflow.com/questions/428264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51200/" ]
To illustrate the question check the following code: ``` class MyDescriptor(object): def __get__(self, obj, type=None): print "get", self, obj, type return self._v def __set__(self, obj, value): self._v = value print "set", self, obj, value return None class SomeClass1(object): m = MyDescrip...
To answer your second question, where is `_v`? Your version of the descriptor keeps `_v` in the descriptor itself. Each instance of the descriptor (the class-level instance `SomeClass1`, and all of the object-level instances in objects of class `SomeClass2` will have distinct values of `_v`. Look at this version. Thi...
428,267
<p>Given you have the following class (bad C#, but you get the drift):</p> <pre><code>public abstract class AmICircular { // assume Children is never null private List&lt;AmICircular&gt; Children {get;set;} // assume target is never null public void Add(AmICircular target) { target.PerformCircularRefere...
[ { "answer_id": 428619, "author": "MSalters", "author_id": 15416, "author_profile": "https://Stackoverflow.com/users/15416", "pm_score": 3, "selected": false, "text": "<p>The iterative solution is to define a set R (reachable) and CR (children of Reachable). </p>\n\n<p>You start of with <...
2009/01/09
[ "https://Stackoverflow.com/questions/428267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Given you have the following class (bad C#, but you get the drift): ``` public abstract class AmICircular { // assume Children is never null private List<AmICircular> Children {get;set;} // assume target is never null public void Add(AmICircular target) { target.PerformCircularReferenceCheck(this); ...
In the case where you never add self-referencing (to be defined later) objects, your data structure describes a directed acyclic graph (<http://en.wikipedia.org/wiki/Directed_acyclic_graph>), where each instance of the of the IAmCircular class describes a node with a set of direct successor nodes = Children. Assuming ...
428,276
<p>I have a shared folder in a server and I need to remotely execute a command on some files. How do I do that? </p> <p>What services need to be running on the server to make that work?</p> <p>Some details: Only C# can be used. Nothing can be installed in the server.</p>
[ { "answer_id": 428358, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 3, "selected": false, "text": "<p>You could use SysInternal's <a href=\"http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx\" rel=\"norefe...
2009/01/09
[ "https://Stackoverflow.com/questions/428276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53179/" ]
I have a shared folder in a server and I need to remotely execute a command on some files. How do I do that? What services need to be running on the server to make that work? Some details: Only C# can be used. Nothing can be installed in the server.
Another solution is to use [WMI.NET or Windows Management Instrumentation](http://msdn.microsoft.com/en-us/library/bb404655.aspx). > > Using the .NET Framework namespace System.Management, you can automate administrative tasks using Windows Management Instrumentation (WMI). > > > **Code Sample** ``` using Syste...
428,280
<p>I am trying to accomplish something that seemed quite simple... </p> <p>I have 3 <code>div</code>s that contain a radiobutton and some content:</p> <pre><code> Content of DIV1, [] this can be as long or as tall as wanted [] Content of DIV2 [] Content of DIV3 </code></pre> <p>It's easy to create r...
[ { "answer_id": 428322, "author": "Antony Delaney", "author_id": 53366, "author_profile": "https://Stackoverflow.com/users/53366", "pm_score": 0, "selected": false, "text": "<p>I am sure you could do it with jquery.<br>\n<a href=\"http://docs.jquery.com/CSS\" rel=\"nofollow noreferrer\"><...
2009/01/09
[ "https://Stackoverflow.com/questions/428280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25152/" ]
I am trying to accomplish something that seemed quite simple... I have 3 `div`s that contain a radiobutton and some content: ``` Content of DIV1, [] this can be as long or as tall as wanted [] Content of DIV2 [] Content of DIV3 ``` It's easy to create rounded corners for each div using any techni...
this changes the CSS with jquery on the hover of a div ``` print("<div id="output" class="div"></div> <script> jQuery(document).ready(function() { $("#output").hover(function() { $(this).css({ 'background-color': 'yellow', 'font-weight': 'bolder' }); }, function() { $(this).css({ 'backgroun...
428,282
<p>I'm faced with a design decision that doesn't smell to me, but gives me pause. Take a look at the following code sample:</p> <pre><code>public interface IGenerator { ///&lt;summary&gt; /// Combines two generators; performs magic as well /// &lt;/summary&gt; BaseGenerator Combine(BaseGenerator next); ///...
[ { "answer_id": 428296, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": false, "text": "<p>Could that be done with an extension method instead? Then you can just use the interface. Extension methods are a ...
2009/01/09
[ "https://Stackoverflow.com/questions/428282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm faced with a design decision that doesn't smell to me, but gives me pause. Take a look at the following code sample: ``` public interface IGenerator { ///<summary> /// Combines two generators; performs magic as well /// </summary> BaseGenerator Combine(BaseGenerator next); ///<summary> /// Does what a...
> > I'm interested in reasons WHY this might be a code smell > > > Here's my answer: one of the purposes (perhaps even the main one) of separating interface from implementation is to make it possible to create many different implementations for an interface. Binding an interface to a particular implementing class ...
428,308
<p>I have a set of word documents that contains a lot of non-embedded images in them. The url that the images point to no longer exist. I would like to programmatically change the domain name of the url to something else. How can I go about doing this in Java or Python ?</p>
[ { "answer_id": 428338, "author": "schnaader", "author_id": 34065, "author_profile": "https://Stackoverflow.com/users/34065", "pm_score": 0, "selected": false, "text": "<p>Perhaps the <a href=\"http://download.microsoft.com/download/0/B/E/0BE8BDD7-E5E8-422A-ABFD-4342ED7AD886/Word97-2007Bi...
2009/01/09
[ "https://Stackoverflow.com/questions/428308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27474/" ]
I have a set of word documents that contains a lot of non-embedded images in them. The url that the images point to no longer exist. I would like to programmatically change the domain name of the url to something else. How can I go about doing this in Java or Python ?
This is the sort of thing that VBA is for: ``` Sub HlinkChanger() Dim oRange As Word.Range Dim oField As Field Dim link As Variant With ActiveDocument .Range.AutoFormat For Each oRange In .StoryRanges For Each oFld In oRange.Fields If oFld.Type = wdFieldHyperlink Then For Each link ...
428,377
<p>How do I draw a class in UML that uses a web service?</p>
[ { "answer_id": 428412, "author": "duffymo", "author_id": 37213, "author_profile": "https://Stackoverflow.com/users/37213", "pm_score": 0, "selected": false, "text": "<p>Sounds like a sequence diagram, with client and service instances, where the client makes the call to the service. If ...
2009/01/09
[ "https://Stackoverflow.com/questions/428377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40676/" ]
How do I draw a class in UML that uses a web service?
You could also use [WSDL (Web Services Description Language) UML profile](http://webservices.xml.com/lpt/a/1259) with the appropriate WSDL stereotypes. That would give for example: ``` -------------------- | <<wsdl:service>> | -------------------- | MyWebService | -------------------- | | -------...
428,384
<p>I'm trying to enforce integrity on a table in a way which I do not think a Constraint can...</p> <pre><code>CREATE TABLE myData ( id INTEGER IDENTITY(1,1) NOT NULL, fk_item_id INTEGER NOT NULL, valid_from DATETIME NOT NULL, invlaid_from DATETIME ...
[ { "answer_id": 428405, "author": "cmsjr", "author_id": 23114, "author_profile": "https://Stackoverflow.com/users/23114", "pm_score": 3, "selected": true, "text": "<p>You can't delete directly from inserted (updates to the logical tables raise an error) but you can join back to the source...
2009/01/09
[ "https://Stackoverflow.com/questions/428384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53341/" ]
I'm trying to enforce integrity on a table in a way which I do not think a Constraint can... ``` CREATE TABLE myData ( id INTEGER IDENTITY(1,1) NOT NULL, fk_item_id INTEGER NOT NULL, valid_from DATETIME NOT NULL, invlaid_from DATETIME NOT NULL )...
You can't delete directly from inserted (updates to the logical tables raise an error) but you can join back to the source table as seen below ``` create table triggertest (id int null, val varchar(20)) Go create trigger after on [dbo].triggertest for Update as Begin delete tt from triggertest tt inner join ...
428,406
<p>I was wondering what is the best way (if at all possible) to determine on the server side if a given HttpRequest was sent via ajax?</p>
[ { "answer_id": 428479, "author": "Tony", "author_id": 34101, "author_profile": "https://Stackoverflow.com/users/34101", "pm_score": 2, "selected": false, "text": "<p>An XMLHttpRequest appears just like any other browser request. As far as I know, there's no way to distinguish them, unles...
2009/01/09
[ "https://Stackoverflow.com/questions/428406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1789/" ]
I was wondering what is the best way (if at all possible) to determine on the server side if a given HttpRequest was sent via ajax?
This may or may not help you out, but you can at least determine if the postback is an asynchronous one (meaning that it was likely sent via ajax). You can do this via the following: ``` if (sm1.IsInAsyncPostBack) { //code here } ``` The sm1 referenced above would be provided for with this: ``` <asp:ScriptManag...
428,414
<p>I'm trying to write a custom function that will let me retrieve a cell from the first row in a range that meets x number of criteria. I imagine this would be very similar to the way SUMIFS works, just simpler in that it doesn't continue processing after the first match. </p> <p>Does anyone know code to reproduce th...
[ { "answer_id": 428570, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 2, "selected": false, "text": "<p>An example using ADO. </p>\n\n<pre><code>strFile = Workbooks(1).FullName\nstrCon = \"Provider=Microsoft.Jet.OLEDB.4.0;D...
2009/01/09
[ "https://Stackoverflow.com/questions/428414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1946/" ]
I'm trying to write a custom function that will let me retrieve a cell from the first row in a range that meets x number of criteria. I imagine this would be very similar to the way SUMIFS works, just simpler in that it doesn't continue processing after the first match. Does anyone know code to reproduce the SUMIFS (...
IMHO ADO is not suitable for use in excel worksheet functions (poor performance and cannot easily be used on the worksheet containing the data). here is a VBA alternative: ``` Function MFind(theRange As Range, ParamArray Tests() As Variant) As Variant ' ' Parameters are: ' The Range to be searched ' the values to be ...