qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
347,250
<p>I need to generate a tone that I can manipulate frequency and wave. The overall goal is to create a basic piano. Does anyone know how I can achieve this?</p> <p>My development platform is the iPhone 2.x</p>
[ { "answer_id": 349037, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 3, "selected": false, "text": "sin" } ]
2008/12/07
[ "https://Stackoverflow.com/questions/347250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44048/" ]
347,254
<p>Is there a way to log(/var/log) commands executed by users in the Unix shell?</p>
[ { "answer_id": 347272, "author": "dmckee --- ex-moderator kitten", "author_id": 2509, "author_profile": "https://Stackoverflow.com/users/2509", "pm_score": 0, "selected": false, "text": "script" }, { "answer_id": 347442, "author": "paxdiablo", "author_id": 14860, "aut...
2008/12/07
[ "https://Stackoverflow.com/questions/347254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15474/" ]
347,274
<p>I have written a <a href="http://osirisdevelopment.com/BatteryBar" rel="nofollow noreferrer">toolbar</a> that runs on the taskbar. Unfortunately, after it is installed, the user has to enable it manually. Is there a way to tell explorer to open (or close) a given toolbar?</p> <p>I would like for the installer, NSIS, to turn on the toolbar when the installation is complete (I realize that a plugin would be necessary).</p> <p>I also want to know if it's possible to automatically enable a toolbar for all users, for example in a corporate environment where multiple users would share a PC.</p>
[ { "answer_id": 818055, "author": "Factor Mystic", "author_id": 1569, "author_profile": "https://Stackoverflow.com/users/1569", "pm_score": 4, "selected": true, "text": "[ComImport]\n[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]\n[Guid(\"4CF504B0-DE96-11D0-8B3F-00A0C911E8E5\")]\np...
2008/12/07
[ "https://Stackoverflow.com/questions/347274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5982/" ]
347,281
<p>After trying to setup my site for Google Webmaster Tools I found that my Custom ASP.NET 404 page was not returning the 404 status code. It displayed the correct custom page and told the browser that everything is OK. This is consider a soft 404 or false 404. Google doesn't like this. So I found many articles on the issue but the solution I want didn't seem to work.</p> <p>The solution I want to work is adding the following two lines to the code behind Page_Load method of the custom 404 page.</p> <pre><code>Response.Status = "404 Not Found"; Response.StatusCode = 404; </code></pre> <p>This doesn't work. The page still returns 200 OK. I found however that if I hard code the following code into the design code it will work properly.</p> <pre><code>&lt;asp:Content ID="ContentMain" ContentPlaceHolderID="ContentPlaceHolderMaster" runat="server"&gt; &lt;% Response.Status = "404 Not Found"; Response.StatusCode = 404; %&gt; ... Much more code ... &lt;/asp:content&gt; </code></pre> <p>The page is using a master page. And I am configuring custom error pages in my web.config. I would really rather use the code behind option but I can't seem to make it work without putting a the hack inline code in the design / layout.</p>
[ { "answer_id": 347304, "author": "Ryan Cook", "author_id": 43029, "author_profile": "https://Stackoverflow.com/users/43029", "pm_score": 7, "selected": true, "text": "protected override void Render(HtmlTextWriter writer)\n{\n base.Render(writer);\n Response.StatusCode = 404;\n}\n" ...
2008/12/07
[ "https://Stackoverflow.com/questions/347281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43976/" ]
347,286
<p>So I'm having a path issue on OS X Leopard. It seems OS X is adding other paths that I'm not stating and it's messing with my path priority. I only have a <code>.bash_login</code> file, I don't have a <code>.bashrc</code> or a .profile file. My <code>.bash_login</code> file is as such:</p> <pre><code>export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH" </code></pre> <p>When I run export this is the path it returns:</p> <pre><code>PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin" </code></pre> <p>Any ideas on what could be putting /usr/bin in there and how I could get <code>/usr/local/bin</code> to be a higher priority.</p> <p>I'm tagging this for Rails too because that's what I'm working on right now... it seems the Mac built-in Ruby, Rails, and Gems are taking priority over the one I have installed at <code>/usr/local/bin</code>, figured maybe you fellow Rubyists could help too.</p>
[ { "answer_id": 347292, "author": "ayaz", "author_id": 23191, "author_profile": "https://Stackoverflow.com/users/23191", "pm_score": 5, "selected": true, "text": "/etc/paths.d/\n/etc/manpaths.d\n" } ]
2008/12/07
[ "https://Stackoverflow.com/questions/347286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43043/" ]
347,294
<p>So I'm trying to take a bilinear interpolation algorithm for resizing images and add in alpha values as well. I'm using Actionscript 3 to do this, but I don't really think the language is relevant.</p> <p>The code I have below actually works really well, but edges around "erased" regions seem to get darker. Is there an easy way for it to not include what I can only assume is black (0x00000000) when it's finding its average?</p> <p>Code:</p> <pre><code>x_ratio = theX - x; y_ratio = theY - y; x_opposite = 1 - x_ratio; y_opposite = 1 - y_ratio; a = getPixel32(x, y); be =getPixel32(x + 1, y); c = getPixel32(x, y + 1); d = getPixel32(x + 1, y + 1); alph = (t(a) * x_opposite + t(be) * x_ratio) * y_opposite + (t(c) * x_opposite + t(d) * x_ratio) * y_ratio; red = (r(a) * x_opposite + r(be) * x_ratio) * y_opposite + (r(c) * x_opposite + r(d) * x_ratio) * y_ratio; green = (g(a) * x_opposite + g(be) * x_ratio) * y_opposite + (g(c) * x_opposite + g(d) * x_ratio) * y_ratio; blue = (b(a) * x_opposite + b(be) * x_ratio) * y_opposite + (b(c) * x_opposite + b(d) * x_ratio) * y_ratio; </code></pre> <p>Image of the effect: <a href="http://beta.shinyhammer.com/images/site/eraser_pixelborders.jpg" rel="nofollow noreferrer">http://beta.shinyhammer.com/images/site/eraser_pixelborders.jpg</a></p> <p><strong>Posting code of solution!</strong></p> <pre><code>a = getPixel32(x, y); be =getPixel32(x + 1, y); c = getPixel32(x, y + 1); d = getPixel32(x + 1, y + 1); asum = (t(a) + t(be) + t(c) + t(d)) / 4; alph = (t(a) * x_opposite + t(be) * x_ratio) * y_opposite + (t(c) * x_opposite + t(d) * x_ratio) * y_ratio; red = ((r(a) * t(a) * x_opposite + r(be) * t(be) * x_ratio) * y_opposite + (r(c) * t(c) * x_opposite + r(d) * t(d) * x_ratio) * y_ratio); red = (asum &gt; 0) ? red / asum : 0; green = ((g(a) * t(a) * x_opposite + g(be) * t(be) * x_ratio) * y_opposite + (g(c) * t(c) * x_opposite + g(d) * t(d) * x_ratio) * y_ratio); green = (asum &gt; 0) ? green / asum : 0; blue = ((b(a) * t(a) * x_opposite + b(be) * t(be) * x_ratio) * y_opposite + (b(c) * t(c) * x_opposite + b(d) * t(d) * x_ratio) * y_ratio); blue = (asum &gt; 0) ? blue / asum : 0; </code></pre>
[ { "answer_id": 347446, "author": "Roddy", "author_id": 1737, "author_profile": "https://Stackoverflow.com/users/1737", "pm_score": 2, "selected": false, "text": "d = Kf + (1-K)b\n" } ]
2008/12/07
[ "https://Stackoverflow.com/questions/347294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10680/" ]
347,298
<p>I have a c++ program that is using the openMPI library to pass messages between different processors. It is a parallel program that uses a genetic algorithm to get a good solution for the traveling salesperson problem. I am trying to set up the MPI environment on my two dual processor computers at my house so that I can run it. When I first created this program a year ago, I was able to run it fine on a cluster that was not set up by me. The problem that I am having now is that whenever I run it, all the processes are saying that they are of rank 0. If I have 3 nodes, instead of them being nodes 1, 2, and 3, they are all node 0. If anyone knows what is going on, I would sure appreciate some help. Thanks.</p>
[ { "answer_id": 348912, "author": "schnaader", "author_id": 34065, "author_profile": "https://Stackoverflow.com/users/34065", "pm_score": 1, "selected": false, "text": "MPI_Init(&argc, &argv);\nMPI_Comm_size(MPI_COMM_WORLD, &size);\nMPI_Comm_rank(MPI_COMM_WORLD, &rank);\nprintf(\"I am pro...
2008/12/07
[ "https://Stackoverflow.com/questions/347298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
347,306
<p>Whenever we have to update the database; we delete the values from the table first and then add the latest values. This ensures that everything is updated correctly.</p> <p>This adds little bit overhead to the system but we haven't faced any performance issues because of this.</p> <p>Is this always the best thing to do?</p>
[ { "answer_id": 347313, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 3, "selected": true, "text": "BEGIN TRAN T1\n\n-- This update is part of T1\nUPDATE Table1 SET Col1='New Value' WHERE Col2 = @Id;\n\n-- Time to commit your...
2008/12/07
[ "https://Stackoverflow.com/questions/347306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38997/" ]
347,311
<p>need help in Fortran...</p> <p>This is the main loop of the program..</p> <pre><code>do iStep=0,nStep write(7,*)iStep !* Compute new temperature using FTCS scheme. do i=1,N if( istep==0) then !only for t=0 tt_new(i)=250 write(7,*)tt_new(i) else if(i==1) then tt_new(i)=2*coeff*(tt(i+1)+35.494)-0.036*tt(i) write(7,*)tt(i) else if(i==N) then tt_new(i)=2*coeff*(tt(i-1)+35.494)-0.036*tt(i) write(7,*)tt(i) else tt_new(i) = coeff*(tt(i+1) + tt(i-1)+33.333)+(1 - 2*coeff)*tt(i) write (7,*) tt_new(i) end if end if end if end do do i=1,N tt(i) = tt_new(i) ! Reset temperature to new values enddo end do </code></pre> <p>this is the output....</p> <pre><code>0 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 2.5000000E+02 1 2.5000000E+02 &lt;-- 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.6666650E+02 2.5000000E+02 &lt;-- </code></pre> <p>As you can see...the programm doesn't calculate the values for the first and last node...Can you tell me why???</p>
[ { "answer_id": 347331, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 2, "selected": false, "text": "IF ELSE" }, { "answer_id": 347344, "author": "Tim Whitcomb", "author_id": 24895, "author_profile": "https:...
2008/12/07
[ "https://Stackoverflow.com/questions/347311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
347,316
<p>how do you encode words using the huffman code such as NEED</p>
[ { "answer_id": 347321, "author": "Schwern", "author_id": 14660, "author_profile": "https://Stackoverflow.com/users/14660", "pm_score": 1, "selected": false, "text": "<DIV" }, { "answer_id": 347341, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://...
2008/12/07
[ "https://Stackoverflow.com/questions/347316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
347,325
<p>I need to get a file into memory in my app from a secured web location. I have the URL of the file to capture, but can't seem to get the security issue resolved. Here's the code from the <a href="http://groovy.codehaus.org/Simple+file+download+from+URL" rel="nofollow noreferrer">Cookbook samples page</a>:</p> <pre><code>def download(address) { def file = new FileOutputStream(address.tokenize("/")[-1]) def out = new BufferedOutputStream(file) out &lt;&lt; new URL(address).openStream() out.close() } </code></pre> <p>and here's my "memory" version of the same function which should return a byte array of the file's contents:</p> <pre><code>def downloadIntoMem(address) { // btw, how frickin powerful is Groovy to do this in 3 lines (or less) def out = new ByteArrayOutputStream() out &lt;&lt; new URL(address).openStream() out.toByteArray() } </code></pre> <p>When I try this against an unsecured URL (pick any image file you can find on the net), it works just fine. However, if I pick a URL that requires a user/password, no go. </p> <p>All right, done a bit more work on this. It seems that the Authenticator method <strong>does</strong> work, but in a round-about way. The first time I access the URL, I get a 302 response with a location to a login server. If I access that location with an Authenticator set, then I get another 302 with a Cookie and the location set back to the original URL. If I then access the original, the download occurs correctly.</p> <p>So, I have to mimic a browser a bit, but eventually it all works.</p> <p>Making this a community wiki, so others can add other methods.</p> <p>Thanks!</p>
[ { "answer_id": 347397, "author": "Ted Naleid", "author_id": 8912, "author_profile": "https://Stackoverflow.com/users/8912", "pm_score": 2, "selected": false, "text": "def address = \"http://admin:sekr1t@myhost.com\"\ndef url = new URL(address)\nassert \"admin:sekr1t\" == url.userInfo\n" ...
2008/12/07
[ "https://Stackoverflow.com/questions/347325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13824/" ]
347,338
<p>Is releasing objects on a programs exit/close needed?</p> <p>In other words, let us say for the sake of argument, you have a button that closes your application, but right before you close you display an image, and then you close the application.</p> <p>Do you need to release that image view before you close the application? Will the memory automatically be freed when the program exits, or if you don't release it will the memory stay somehow "active"?</p> <p>I understand that you "should" release it, my question is about the technical side of it, and what happens behind the scenes.</p>
[ { "answer_id": 347349, "author": "Tom", "author_id": 40620, "author_profile": "https://Stackoverflow.com/users/40620", "pm_score": 6, "selected": true, "text": "valgrind" } ]
2008/12/07
[ "https://Stackoverflow.com/questions/347338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26728/" ]
347,358
<p>Why does this code:</p> <pre><code>class A { public: explicit A(int x) {} }; class B: public A { }; int main(void) { B *b = new B(5); delete b; } </code></pre> <p>Result in these errors:</p> <pre> main.cpp: In function ‘int main()’: main.cpp:13: error: no matching function for call to ‘B::B(int)’ main.cpp:8: note: candidates are: B::B() main.cpp:8: note: B::B(const B&) </pre> <p>Shouldn't B inherit A's constructor?</p> <p>(this is using gcc)</p>
[ { "answer_id": 347361, "author": "grepsedawk", "author_id": 14388, "author_profile": "https://Stackoverflow.com/users/14388", "pm_score": 4, "selected": false, "text": "B(int x) : A(x) { }\n" }, { "answer_id": 347362, "author": "Avi", "author_id": 1605, "author_profil...
2008/12/07
[ "https://Stackoverflow.com/questions/347358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43496/" ]
347,365
<p>I am using Delphi TApplication.OnException Event to catch unhandled exceptions</p> <p>This works well but does not give sufficient information about where the exception happened i.e. ‘Catastrophic failure’ </p> <p>How can I find out which procedure made the error happened?</p> <pre><code>procedure TFrmMain.FormCreate(Sender: TObject); begin Application.OnException := MyExceptionHandler; end; procedure TFrmMain.MyExceptionHandler(Sender : TObject; E : Exception ); begin LogException (E.Message); Application.ShowException( E ); end; </code></pre>
[ { "answer_id": 347381, "author": "Mihai Limbășan", "author_id": 14444, "author_profile": "https://Stackoverflow.com/users/14444", "pm_score": 3, "selected": false, "text": "jcl-install-dir\\experts\\debug\\dialog" } ]
2008/12/07
[ "https://Stackoverflow.com/questions/347365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17560/" ]
347,372
<p>I don't know how to save object with where clause. I need it to prevent saving object with range of dates overlapping on others.</p> <pre><code>public class TaskEvent { public DateTime StartDate {get;set;} public DateTime EndDate {get;set;} } </code></pre> <p>I want to check overlaping in criteria within saving operation but I don't know how.</p> <p>Any ideas?</p>
[ { "answer_id": 2087341, "author": "dotjoe", "author_id": 40822, "author_profile": "https://Stackoverflow.com/users/40822", "pm_score": 2, "selected": true, "text": "session.CreateQuery(\"UPDATE TaskEvent SET ... WHERE ID = :ID and ...\")\n.SetInt32(\"ID\", ID)\n//.SetDateTime(\"\", )\n//...
2008/12/07
[ "https://Stackoverflow.com/questions/347372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3644960/" ]
347,377
<p>Both Session.Clear() and Session.Abandon() get rid of session variables. As I understand it, Abandon() ends the current session, and causes a new session to be created thus causing the End and Start events to fire.</p> <p>It seems preferable to call Abandon() in most cases, such as logging a user out. Are there scenarios where I'd use Clear() instead? Is there much of a performance difference?</p>
[ { "answer_id": 347382, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 8, "selected": true, "text": "Session.Abandon()" }, { "answer_id": 347640, "author": "MatthewMartin", "author_id": 33264, "author_prof...
2008/12/07
[ "https://Stackoverflow.com/questions/347377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571/" ]
347,396
<p>I'm using the Accessibility API to detect when a certain application opens windows, closes windows, when the windows are moved or resized, or made main and/or focused. However the client app seems to move a window to front without an Accessibility API notification being fired.</p> <p>How can my application detect when another application brings a window to front, without making it key?</p> <p>I'm hoping to find a solution that works on OS X 10.4 and 10.5</p> <p>More info: I'm using these statements at the moment. They work fine when the user manually selects a window to bring it to front. But it doens't work when the app itself is bringing the window to the front.</p> <pre><code>AXObserverAddNotification(observer, element, kAXMainWindowChangedNotification, 0); AXObserverAddNotification(observer, element, kAXFocusedWindowChangedNotification, 0); </code></pre>
[ { "answer_id": 624866, "author": "Nick Haddad", "author_id": 2813, "author_profile": "https://Stackoverflow.com/users/2813", "pm_score": 3, "selected": false, "text": "@interface CurrentAppData : NSObject {\n NSString* _title;\n AXUIElementRef _systemWide;\n AXUIElementRef _app;...
2008/12/07
[ "https://Stackoverflow.com/questions/347396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2959/" ]
347,404
<p>I am currently doing IE-hacks on a website I'm working on: <a href="http://www.timkjaerlange.com/wip/co2penhagen/" rel="nofollow noreferrer">http://www.timkjaerlange.com/wip/co2penhagen/</a></p> <p>I got a problem with this unordered list. IE seems to add extra top-margin for every li-element, making my navigation look like a flight of stairs: <a href="http://dl.getdropbox.com/u/228089/ie-prob.jpg" rel="nofollow noreferrer">http://dl.getdropbox.com/u/228089/ie-prob.jpg</a></p> <p>I'm using conditional comments to target IE. I tried:</p> <pre><code>ul#mainnav li { top-margin: 0;} </code></pre> <p>But that doesn't do anything. I wish there was a Firebug-style plugin for IE, that would make it easier to sort out problems like these.</p> <p>Any ideas regarding what could be causing this problem?</p>
[ { "answer_id": 347424, "author": "Andrew G. Johnson", "author_id": 428190, "author_profile": "https://Stackoverflow.com/users/428190", "pm_score": 2, "selected": false, "text": "ul#mainnav li { top-margin: 0;}\n" } ]
2008/12/07
[ "https://Stackoverflow.com/questions/347404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24218/" ]
347,439
<p>I have a mouseenter and mouseleave event for a Panel control that changes the backcolor when the mouse enters and goes back to white when it leaves.</p> <p>I have Label control within this panel as well but when the mouse enters the Label control, the mouseleave event for the panel fires.</p> <p>This makes sense but how do I keep the backcolor of the Panel the same when the mouse is in its area without the other controls inside affecting it?</p>
[ { "answer_id": 347461, "author": "ng5000", "author_id": 36860, "author_profile": "https://Stackoverflow.com/users/36860", "pm_score": 0, "selected": false, "text": " private void panel1_ParentChanged(object sender, EventArgs e)\n {\n Panel thisPanel = sender as Panel;\n\n ...
2008/12/07
[ "https://Stackoverflow.com/questions/347439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17211/" ]
347,441
<p>I want to clear a element from a vector using the erase method. But the problem here is that the element is not guaranteed to occur only once in the vector. It may be present multiple times and I need to clear all of them. My code is something like this:</p> <pre><code>void erase(std::vector&lt;int&gt;&amp; myNumbers_in, int number_in) { std::vector&lt;int&gt;::iterator iter = myNumbers_in.begin(); std::vector&lt;int&gt;::iterator endIter = myNumbers_in.end(); for(; iter != endIter; ++iter) { if(*iter == number_in) { myNumbers_in.erase(iter); } } } int main(int argc, char* argv[]) { std::vector&lt;int&gt; myNmbers; for(int i = 0; i &lt; 2; ++i) { myNmbers.push_back(i); myNmbers.push_back(i); } erase(myNmbers, 1); return 0; } </code></pre> <p>This code obviously crashes because I am changing the end of the vector while iterating through it. What is the best way to achieve this? I.e. is there any way to do this without iterating through the vector multiple times or creating one more copy of the vector?</p>
[ { "answer_id": 347445, "author": "dalle", "author_id": 19100, "author_profile": "https://Stackoverflow.com/users/19100", "pm_score": 6, "selected": false, "text": "void erase(std::vector<int>& myNumbers_in, int number_in)\n{\n std::vector<int>::iterator iter = myNumbers_in.begin();\n ...
2008/12/07
[ "https://Stackoverflow.com/questions/347441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39742/" ]
347,449
<p>I'll be using the <a href="http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?ReleaseId=4004" rel="nofollow noreferrer">AdventureWorks Database</a> to illustrate my problem.</p> <p>I need to show for a particular customer a list of OrderDate with the most Orders.</p> <p>My intial attempt was as follows:</p> <pre><code>SELECT CustomerID, OrderDate, COUNT(1) Cnt FROM Sales.SalesOrderHeader WHERE CustomerID = 11300 GROUP BY CustomerID, OrderDate ORDER BY Cnt DESC </code></pre> <p>This will get us the following result:</p> <pre><code>CustomerID OrderDate Cnt ----------- ---------- ---- 11300 2003-11-22 00:00:00.000 2 11300 2004-01-28 00:00:00.000 2 11300 2004-02-18 00:00:00.000 2 11300 2004-02-08 00:00:00.000 2 11300 2004-02-15 00:00:00.000 1 11300 2004-03-11 00:00:00.000 1 11300 2004-03-24 00:00:00.000 1 11300 2004-03-30 00:00:00.000 1 11300 2004-04-28 00:00:00.000 1 11300 2004-05-03 00:00:00.000 1 11300 2004-05-17 00:00:00.000 1 11300 2004-06-18 00:00:00.000 1 ... </code></pre> <p>Not exactly what I wanted, as the result should only show all records where Cnt = 2, like so:</p> <pre><code>CustomerID OrderDate Cnt ----------- ---------- ---- 11300 2003-11-22 00:00:00.000 2 11300 2004-01-28 00:00:00.000 2 11300 2004-02-18 00:00:00.000 2 11300 2004-02-08 00:00:00.000 2 </code></pre> <p>I'm stuck because I can't wrap my mind around two problems:</p> <p>1) A customer might have more than one OrderDate with the same Cnt value. This means I can't do something like TOP 1 to get the desired result.<br> 2) Because the number of Orders for each customer may be different, I cannot use the following SQL statement:</p> <pre><code>SELECT CustomerID, OrderDate, COUNT(1) Cnt FROM Sales.SalesOrderHeader WHERE CustomerID = 11300 GROUP BY CustomerID, OrderDate HAVING COUNT(1) &gt; 1 ORDER BY Cnt DESC </code></pre> <p>This will work for getting the right result for this customer, but will definitely be wrong if the next customer has only one Order for a particular day.</p> <p>So, either the query is impossible in this situation, or I am approaching the query in the wrong way. Any ideas on this problem is appreciated. </p> <p>Also, since this will be a query in a stored procedure, any ideas on solving this in T-SQL will be acceptable.</p> <p>UPDATE: Thanks to <a href="https://stackoverflow.com/questions/347449/sql-statement-help-select-list-of-customerid-orderdate-with-the-most-records-in#347460">Mehrdad</a>, I've been introduced to <a href="http://msdn.microsoft.com/en-us/library/ms190766(SQL.90).aspx" rel="nofollow noreferrer">Common Table Expressions</a>, and Life is Good®. :) </p>
[ { "answer_id": 347456, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 1, "selected": false, "text": "SELECT TOP 1 WITH TIES CustomerID, OrderDate, COUNT(*) Cnt\n...\nORDER BY COUNT(*) DESC\n" }, { "answer_id": 347...
2008/12/07
[ "https://Stackoverflow.com/questions/347449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19582/" ]
347,463
<p>I made a code that translate strings to match each word from the array 0ne to the array two and its showing the right results. But how to let the compiler take the number in the string and print it out as it is, ummmm see the code i wrote</p> <hr> <pre><code>class Program { public static string[] E = { "i", "go", "school", "to", "at" }; public static string[] A = { "Je", "vais", "ecole", "a", "a" }; public static string Translate(string s) { string str = ""; Regex Expression = new Regex(@"[a-zA-Z]+"); MatchCollection M = Expression.Matches(s); foreach (Match x in M) str = str + " " + TranslateWord(x.ToString()); return str; } public static string TranslateWord(string s) { for (int i = 0; i &lt; E.Length; i++) if (s.ToLower() == E[i].ToLower()) return A[i]; return "Undefined"; } </code></pre> <hr> <p>here I want to enter the the whole string and the code should translate it with the number, now i know how to do the word (by spliting them and translate) but what about the numbers)</p> <pre><code> static void Main(string[] args) { string str = "I go to school at 8"; Console.WriteLine(Translate(str)); } </code></pre> <p>how to continue ?!</p>
[ { "answer_id": 347466, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": true, "text": "[a-zA-Z0-9]+" }, { "answer_id": 347582, "author": "joel.neely", "author_id": 3525, "author_profile": "https...
2008/12/07
[ "https://Stackoverflow.com/questions/347463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
347,472
<p>I'm building a website in ASP.Net, using MVC, and need to list a set of results. Both of the following work as I want them to but I'm wondering which is faster, cleaner and/or better - or if another option entirely would be more appropriate?</p> <p>Note: <code>ViewData.Model</code> is of type <code>IEnumerable&lt;Thing&gt;</code> and I need to display more attributes than <code>Name</code> - I've cropped the code for this example.</p> <hr> <pre><code>&lt;% foreach (var thing in ViewData.Model) { %&gt; &lt;p&gt;&lt;%= thing.Name %&gt;&lt;/p&gt; &lt;% }; %&gt; </code></pre> <hr> <pre><code>&lt;% rptThings.DataSource = ViewData.Model; rptThings.DataBind(); %&gt; &lt;asp:Repeater ID="rptThings" runat="server"&gt; &lt;ItemTemplate&gt; &lt;p&gt;&lt;%# DataBinder.Eval(Container.DataItem, "Name") %&gt;&lt;/p&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <hr>
[ { "answer_id": 347474, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 4, "selected": true, "text": "foreach" }, { "answer_id": 347495, "author": "Pure.Krome", "author_id": 30674, "author_profile": "https://S...
2008/12/07
[ "https://Stackoverflow.com/questions/347472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40079/" ]
347,497
<p>I am writing a web-framework for Python, of which the goal is to be as "small" as possible (currently under 100 lines of code).. You can see the current code <a href="http://github.com/dbr/pyerweb/tree/master" rel="nofollow noreferrer">on github</a></p> <p>Basically it's written to be as simple to use as possible. An example "Hello World" like site:</p> <pre><code>from pyerweb import GET, runner @GET("/") def index(): return "&lt;strong&gt;This&lt;/strong&gt; would be the output HTML for the URL / " @GET("/view/([0-9]+?)$") def view_something(id): return "Viewing id %s" % (id) # URL /view/123 would output "Viewing id 123" runner(url = "/", # url would be from a web server, in actual use output_helper = "html_tidy" # run returned HTML though "HTML tidy" </code></pre> <p>Basically you have a function that returns HTML, and the GET decorator maps this to a URL.</p> <p>When <code>runner()</code> is called, each decorated function is checked, if the URL regex matches the request URL, the function is run, and the output is sent to the browser.</p> <p>Now, the problem - outputting headers. Currently for development I've just put a line before the <code>runner()</code> call which does <code>print Content-type:text/html\n</code> - this is obviously a bit limiting..</p> <p>My first ideas was to have the functions return a dict, something like..</p> <pre><code>@GET("/") def index(): return { "html": "&lt;html&gt;&lt;body&gt;...&lt;/body&gt;&lt;/html&gt;", "headers": {"Location":"http://google.com"} } </code></pre> <p>I really don't like this - having to return a dict with a specifically named key isn't nearly as nice as just returning a string..</p> <p>I could check if the returned data is a dict, if so use <code>returned_data['html']</code> as the output, if it's a string, there is no custom headers to be sent... but this means to go from no headers (which would be the case a huge majority of the time) to headers, you'd have to change the return function from <code>return my_html</code> to <code>return {'html':my_html}</code> which isn't very elegant either..</p> <p>After writing this, I discovered "Sinatra" - a similar-in-use Ruby library, and looked at how it dealt with headers:</p> <pre><code>get "/" do content_type 'text/css', :charset =&gt; 'utf-8' end </code></pre> <p>This seems like it could be nice enough in Python:</p> <pre><code>@GET("/") def index(): header("location", "http://google.com") </code></pre> <p>To implement this, I was considering changing how the functions are executed - instead of simply using the return value, I would change <code>sys.stdout</code> to a StringIO, so you could do..</p> <pre><code>def index(): print "&lt;html&gt;" print "&lt;head&gt;&lt;title&gt;Something&lt;/title&gt;&lt;/head&gt;" print "&lt;body&gt;...&lt;/body&gt;" print "&lt;/html&gt; </code></pre> <p>..without having to worry about concatenating a bunch of strings together. The upshot of this is I could have a separate stream for headers, so the above <code>header()</code> function would write to this.. Something like:</p> <pre><code>def header(name, value): pyerweb.header_stream.write("%s: %s" % (name, value)) </code></pre> <p>Basically, the question is, how would you output headers from this web-framework (mostly in terms of <em>use</em>, but to a lesser extent implementation)?</p>
[ { "answer_id": 347509, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 1, "selected": false, "text": "HTTP/1.1 200 OK\nDate: Mon, 23 May 2005 22:38:34 GMT\nServer: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)\nLast-Modified: Wed, 08 J...
2008/12/07
[ "https://Stackoverflow.com/questions/347497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
347,502
<p>I'm seeing some wierd behaviour when throwing exceptions and catching them in the <code>Application.ThreadException</code> event handler.</p> <p>Basically whats happening in the sample below is that an exception is thrown in the <code>DoWork</code> event handler of a <code>BackgroundWorker</code>. The <code>RunWorkerCompleted</code> event handler rethrows a new exception with the original as the inner exception.</p> <p>Why does the inner exception show up in the <code>ThreadException</code> event handler and not the acutal exception being thrown? If I do not provide an inner exception in the <code>RunWorkerCompleted</code> event handler, the correct exception will show up.</p> <pre><code>using System; using System.Windows.Forms; using System.ComponentModel; namespace WierdExceptionApp { class WierdExceptionForm : Form { BackgroundWorker worker = new BackgroundWorker(); public WierdExceptionForm() { worker.DoWork += new DoWorkEventHandler(worker_DoWork); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); worker.RunWorkerAsync(); } void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { throw new Exception("worker_RunWorkerCompleted", e.Error); } } void worker_DoWork(object sender, DoWorkEventArgs e) { throw new Exception("worker_DoWork"); } [STAThread] static void Main() { Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); Application.Run(new WierdExceptionForm()); } static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { MessageBox.Show(e.Exception.Message); } } } </code></pre>
[ { "answer_id": 347928, "author": "liggett78", "author_id": 19762, "author_profile": "https://Stackoverflow.com/users/19762", "pm_score": 1, "selected": false, "text": " if (e.Error != null)\n {\n throw new Exception(\"worker_RunWorkerCompleted\", new Exception(\"...
2008/12/07
[ "https://Stackoverflow.com/questions/347502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/966/" ]
347,512
<p>I have an element with an <strong>onclick</strong> method.</p> <p>I would like to activate that method (or: fake a click on this element) within another function.</p> <p>Is this possible?</p>
[ { "answer_id": 347517, "author": "Ben", "author_id": 36522, "author_profile": "https://Stackoverflow.com/users/36522", "pm_score": 6, "selected": false, "text": "document.getElementById('link').click();\n" }, { "answer_id": 347520, "author": "Eduardo Campañó", "author_id"...
2008/12/07
[ "https://Stackoverflow.com/questions/347512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1011/" ]
347,524
<p>I'm having trouble with <code>TryUpdateModel()</code>. My form fields are named with a prefix but I am using - as my separator and not the default dot.</p> <pre><code>&lt;input type="text" id="Record-Title" name="Record-Title" /&gt; </code></pre> <p>When I try to update the model it does not get updated. If i change the name attribute to <code>Record.Title</code> it works perfectly but that is not what I want to do.</p> <pre><code>bool success = TryUpdateModel(record, "Record"); </code></pre> <p>Is it possible to use a custom separator?</p>
[ { "answer_id": 348665, "author": "Todd Smith", "author_id": 31624, "author_profile": "https://Stackoverflow.com/users/31624", "pm_score": 3, "selected": false, "text": "public class Customer\n{\n public string FirstName {get; set;}\n public string LastName {get; set;}\n}\n\npublic ...
2008/12/07
[ "https://Stackoverflow.com/questions/347524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44085/" ]
347,528
<p>I'm fairly new to ASP.NET MVC, and I'm having a little trouble with scripts... in particular, I want to use jQuery in most pages, so it makes sense to put it in the master page. However, if I do (from my <code>~/Views/Shared/Site.Master</code>):</p> <pre><code>&lt;script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>Then that is literally what goes down to the client - which of course only works if our current route happens to have the right number of levels. Starting with <code>~/Scripts/...</code> doesn't work. Starting with <code>/Scripts/...</code> would only work if the project was at the site root (which I don't want to assume).</p> <p>I have one working approach (I'll post below) - but: am I missing something?</p> <p>I'd rather not have to involve a script-manager, as that seems to defeat the simplicity of the ASP.NET MVC model... or am I worrying too much?</p> <p>Here's the way I can get it working, which works also for non-trivial virtuals - but it seems over-complicated:</p> <pre><code>&lt;script src="&lt;%=Url.Content("~/Scripts/jquery-1.2.6.js")%&gt;" type="text/javascript"&gt;&lt;/script&gt; </code></pre>
[ { "answer_id": 347565, "author": "Eduardo Campañó", "author_id": 12091, "author_profile": "https://Stackoverflow.com/users/12091", "pm_score": 7, "selected": true, "text": "public static string ReferenceScript(string scriptFile)\n{\n var filePath = VirtualPathUtility.ToAbsolute(\"~/Sc...
2008/12/07
[ "https://Stackoverflow.com/questions/347528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23354/" ]
347,529
<p>I need to add Workflows to an existing solution, which already contains a class library and a web site. If I add the workflows to the class library, where they fit logically, I have no designer support. If I create them in a separate project, I tend to have circular dependencies because my domain objects run the workflows and the workflows need my domain objects.</p> <p>What is the preferred architecture to avoid this problem?</p>
[ { "answer_id": 374977, "author": "kay.herzam", "author_id": 47093, "author_profile": "https://Stackoverflow.com/users/47093", "pm_score": 3, "selected": true, "text": "<ProjectTypeGuids>{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>" } ...
2008/12/07
[ "https://Stackoverflow.com/questions/347529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40396/" ]
347,535
<p>I know that MSTest doesn't support <code>RowTest</code> and similar tests.</p> <p>What do <code>MSTests</code> users do? How is it possible to live without <code>RowTest</code> support? </p> <p>I've seen <code>DataDriven</code> test features but sounds like too much overhead, is there any 3rd party patch or tool which allow me to do <code>RowTest</code> similar tests in <code>MSTest</code>?</p>
[ { "answer_id": 1205297, "author": "Tormod", "author_id": 80577, "author_profile": "https://Stackoverflow.com/users/80577", "pm_score": 5, "selected": false, "text": "[TestMethod]\nTest1Row1\n{\n Test1(1,4,5);\n}\n\n[TestMethod]\nTest1Row2\n{\n Test1(1,7,8);\n}\n\nprivate Test1(int ...
2008/12/07
[ "https://Stackoverflow.com/questions/347535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40322/" ]
347,551
<p>Given a file tree - a directory with directories in it etc, how would you write a script to create a diagram of the file-tree as a graphic file that I can embed in a word processor document. I prefer vector (SVG, EPS, EMF...) files. The tool must run on Windows, but preferably cross-platform. The tool may be commercial but preferably free.</p> <p>Update 2012-02-20. The question was related to a documentation sub project. I had to explan where files (in particular resources and configuration files) reside. I ended up with using dos tree command. I both screen grabbed the result (for short folders) AND for longer folders I redirected to a text file, which I then edited. For example if a subfolder contained 20 similarly typed files that individually were not important to the point I was making, I left just two and replaced the rest with one ... line. I then printed out the file to console again and screen grabbed it. Before screen grabbing I had to modify foreground color to black and background color to white, to look better and save ink in a document should that be printed.</p> <p>It is very surprising that there is no better tool for it. If I had time, I'd write a Visio Extension or may be some command line that produces SVG. SVG being HTML5 substandard, would even allow painless inclusion into online documentation.</p> <p>Update 2017-10-17. I am sorry that this question was removed as not belonging to SO. So I have re-worded it. I need a script - not a WYSIWYG tool. So any scripting language or library is ok. So it is a code - writing question, and I believe belongs to SO. </p>
[ { "answer_id": 347577, "author": "Svante Svenson", "author_id": 19707, "author_profile": "https://Stackoverflow.com/users/19707", "pm_score": 8, "selected": true, "text": "tree" }, { "answer_id": 348254, "author": "PhiLho", "author_id": 15459, "author_profile": "https...
2008/12/07
[ "https://Stackoverflow.com/questions/347551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33427/" ]
347,553
<p>With the JavaFX 1.0 release I am trying to layout some SwingButton instances in a HBox such that they are aligned to the right. A lot of the tutorials on the net (admittedly pre 1.0 release) talk about layout classes (FlowPanel et. al) which dont seem to be in this release. Whats the simplest way to achieve this seemingly simple task?</p>
[ { "answer_id": 347577, "author": "Svante Svenson", "author_id": 19707, "author_profile": "https://Stackoverflow.com/users/19707", "pm_score": 8, "selected": true, "text": "tree" }, { "answer_id": 348254, "author": "PhiLho", "author_id": 15459, "author_profile": "https...
2008/12/07
[ "https://Stackoverflow.com/questions/347553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5193/" ]
347,564
<p>I have a problem with simple c++ programs... </p> <p>I would like to install a program, but always have the error like "c++ compiler is unable to create executables"...</p> <p>Now I tried to compile a simple "hello world" program, but I get errors as I would if I compile a c++ program with a c compiler ("`cout' undeclared"... although I included iostream)...</p> <p>Now I am not sure, if g++ does not work on my machine?</p> <p>Does anyone know about how to fix this problem?</p> <p>Thank you very much in advance...<br> Chris</p> <hr> <p><em>Added</em> In response to Pax's answer:</p> <p>Well, I think, my code is okay, I can compile it on another machine, and I use the namespace std...</p> <p>So, it's not possible, that the configuration of g++ is mismatched or something like that...?</p>
[ { "answer_id": 347595, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "g++\n" }, { "answer_id": 348535, "author": "Community", "author_id": -1, "author_profile": "https://Stacko...
2008/12/07
[ "https://Stackoverflow.com/questions/347564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
347,572
<p>I'm new to iPhone and Apple development and working on my first application. It simple with only a TableView and a "detail view" when an item in a table is selected.</p> <p>What I want to do is change the background color of the cell in the TableView based on some action taken in my "detail view".</p> <p>When the application initially loads I customize the colors in <code>-cellForRowAtIndexPath:</code> method, but when user navigates back from my detail view that function is not called, so my table view doesn't have the colors updated. The only way to get that refreshed now is to exit the application and start it up again. (I persist their selection with NSUserDefaults.)</p> <p>Obviously, I want the table view to be refreshed when they come back form the detail view, but I don't know how to get a reference to a cell and in which method to do that. I'm assuming it should go in <code>-viewDidAppear</code>, since that is called everything the view is shown.</p>
[ { "answer_id": 347598, "author": "millenomi", "author_id": 6061, "author_profile": "https://Stackoverflow.com/users/6061", "pm_score": 3, "selected": false, "text": "viewWillAppear:" }, { "answer_id": 347751, "author": "Adam Byram", "author_id": 25886, "author_profile...
2008/12/07
[ "https://Stackoverflow.com/questions/347572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44091/" ]
347,574
<p>This is a follow-up to a <a href="https://stackoverflow.com/questions/347109/how-do-i-concisely-implement-multiple-similar-unit-tests-in-the-python-unittest">previous question</a> of mine.</p> <p>In the previous question, methods were explored to implement what was essentially the same test over an entire family of functions, ensuring testing did not stop at the first function that failed.</p> <p>My preferred solution used a metaclass to dynamically insert the tests into a unittest.TestCase. Unfortunately, nose does not pick this up because nose statically scans for test cases.</p> <p>How do I get nose to discover and run such a TestCase? Please refer <a href="https://stackoverflow.com/questions/347109/how-do-i-concisely-implement-multiple-similar-unit-tests-in-the-python-unittest#347175">here</a> for an example of the TestCase in question.</p>
[ { "answer_id": 366620, "author": "ionelmc", "author_id": 23658, "author_profile": "https://Stackoverflow.com/users/23658", "pm_score": 1, "selected": false, "text": "class UnderTest_MixIn(object):\n\n def f1(self, i):\n return i + 1\n\n def f2(self, i):\n return i + 2...
2008/12/07
[ "https://Stackoverflow.com/questions/347574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37984/" ]
347,575
<p>What is the easiest way to check if a computer is alive and responding (say in ping/NetBios)? I'd like a deterministic method that I can time-limit.</p> <p>One solution is simple access the share (File.GetDirectories(@"\compname")) in a separate thread, and kill the thread if it takes too long.</p>
[ { "answer_id": 347587, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 4, "selected": true, "text": "System.Net.NetworkInformation" }, { "answer_id": 347616, "author": "gimel", "author_id": 6491, "author_prof...
2008/12/07
[ "https://Stackoverflow.com/questions/347575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
347,592
<p>The title pretty much says it all. I'm using a TClientDataset to store an array of objects, and one of the objects has a member defined as a <strong>set of</strong> an enumerated type. As I understand it, Delphi sets are bitfields whose size can vary from 1 to 32 bytes depending on how much data they contain, and Delphi doesn't define a TSetField. What sort of field should I use to load this value into?</p>
[ { "answer_id": 347604, "author": "Andreas Hausladen", "author_id": 44005, "author_profile": "https://Stackoverflow.com/users/44005", "pm_score": 5, "selected": true, "text": "var\n MySet: set of Byte;\n Bytes: array of Byte;\nbegin\n MySet := [1, 2, 4, 8, 16];\n\n // Write\n Assert(...
2008/12/07
[ "https://Stackoverflow.com/questions/347592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32914/" ]
347,606
<p>I was curious as to what other shops are doing regarding base application frameworks? I look at an application framework as being able to provide additional or extended functionality to improve the quality of applications built from it.</p> <p>There are a variety of out of the box frameworks, such as Spring (or Spring.NET), etc. I find that the largest problem with these being that they are not a la carte. Basically, they have too much functionality and unless every piece of that functionality is the best implementation available, chances are that you will end up using a patchwork of multiple frameworks to accomplish these tasks - causing bloat and confusion. This applies to free and commercial systems, in my opinion.</p> <p>Of course, writing is largely re-inventing the wheel. I don't think it is without merit, though, as it provides the most customizable option. Some things are just too large to develop, though, and seem to be poorly implemented or not implemented at all in this case because of the hesitation to commit to the upfront costs of development.</p> <p>There are a large variety of open source projects that address individual portions of a could-be application framework as well. These can be adopted or assimilated (obviously depending upon license agreements) to help frame in a comprehensive framework from diverse sources.</p> <p>We approached the situation by looking at some of the larger concerns in our applications across the entire enterprise and came up with a list of valid cross-cutting concerns and recurring implementation issues. In the end, we came up with hybrid solution that is partially open source, partially based on existing open source options, and partially custom developed.</p> <p>A few examples of things that are in our framework:</p> <ul> <li>Exception and event logging providers. A simple, uniform means by which every application can log exceptions and events in an identical fashion with a minimal coding effort. Out of the box, it can log to a SQL Server, text file, event viewer, etc. It contains extensibility points to log to other sources, as well.</li> <li>Variable assignment enforcement. A generic class that exposes extension methods based upon the object type, using a syntax that is inspired by JUnit. For example, to determine if myObject is not null, we can do a simple Enforce.That(myObject).IsNotNull(); or determine if it is a specific type by doing a simple Enforce.That(myObject).IsOfType(typeof(Hashtable)); Enforcement failures raise the appropriate exception, both reducing the amount of code and providing consistency in implementation.</li> <li>Unit testing helpers. A series of classes, based upon reflection that can automatically test classes and their properties. (Inspired by <a href="http://www.codeplex.com/classtester" rel="nofollow noreferrer">Automatic Class Tester</a> from CodePlex) but written from the ground up. Helps to simplify the creation of unit tests for things that are traditionally hard or time-consuming to test.</li> </ul> <p>We have also outright adopted some other functionality, as is. For example, we are using <a href="http://postsharp.org" rel="nofollow noreferrer">PostSharp</a> for AOP, <a href="http://code.google.com/p/moq" rel="nofollow noreferrer">moq</a> for mocking, and <a href="http://code.google.com/p/autofac/" rel="nofollow noreferrer">autofaq</a> for DI.</p> <p>Just wondering what other people might have done and what concerns your framework addresses that you did not find tooling that you were satisfied with? As for our experience, we are definitely reaping the benefits of the new framework and are content with the approach that we have taken.</p>
[ { "answer_id": 347604, "author": "Andreas Hausladen", "author_id": 44005, "author_profile": "https://Stackoverflow.com/users/44005", "pm_score": 5, "selected": true, "text": "var\n MySet: set of Byte;\n Bytes: array of Byte;\nbegin\n MySet := [1, 2, 4, 8, 16];\n\n // Write\n Assert(...
2008/12/07
[ "https://Stackoverflow.com/questions/347606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15906/" ]
347,614
<p>For a WPF application which will need 10 - 20 small icons and images for illustrative purposes, is storing these in the assembly as embedded resources the right way to go?</p> <p>If so, how do I specify in XAML that an Image control should load the image from an embedded resource?</p>
[ { "answer_id": 347805, "author": "ema", "author_id": 19520, "author_profile": "https://Stackoverflow.com/users/19520", "pm_score": 6, "selected": false, "text": "<Image Source=\"..\\Media\\Image.png\" />\n" }, { "answer_id": 606986, "author": "Drew Noakes", "author_id": 2...
2008/12/07
[ "https://Stackoverflow.com/questions/347614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13627/" ]
347,617
<p>I have a string that has angle brackets in it like this:</p> <pre><code>&lt;element1&gt;my text here&lt;/element1&gt; </code></pre> <p>The string literally looks like this when I write it to console or my dataGridView or anywhere else. However, I'm trying to write this as part of an XML document. </p> <p>Everything is fine except that in the xml file that is written, the above shows up as:</p> <pre><code>&amp;lt;element1&amp;gt;my text here&amp;lt;/element1&amp;gt; </code></pre> <p>How do I get this to write out as my literal text instead of with the codes?</p> <p>Thanks!</p> <p>-Adeena</p>
[ { "answer_id": 347651, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<xml><![CDATA[<element1>my text here</element1>]]></xml>\n" }, { "answer_id": 347752, "author": "kdgregory", "...
2008/12/07
[ "https://Stackoverflow.com/questions/347617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44004/" ]
347,620
<p>How do I find out which directories are responsible for chewing up all my inodes?</p> <p>Ultimately the root directory will be responsible for the largest number of inodes, so I'm not sure exactly what sort of answer I want..</p> <p>Basically, I'm running out of available inodes and need to find a unneeded directory to cull.</p> <p>Thanks, and sorry for the vague question.</p>
[ { "answer_id": 347633, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 5, "selected": true, "text": "find . -type d -print0 | xargs -0 -n1 count_files | sort -n\n" }, { "answer_id": 347700, "author": "Alnitak"...
2008/12/07
[ "https://Stackoverflow.com/questions/347620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31092/" ]
347,624
<p>I have a simple problem when querying the SQL Server 2005 database. I have tables called Customer and Products (1->M). One customer has most 2 products. Instead of output as</p> <p>CustomerName, ProductName ...</p> <p>I like to output as </p> <p>CustomerName, Product1Name, Product2Name ...</p> <p>Could anybody help me?</p> <p>Thanks!</p>
[ { "answer_id": 347673, "author": "Jeremiah Peschka", "author_id": 11780, "author_profile": "https://Stackoverflow.com/users/11780", "pm_score": 4, "selected": true, "text": "USE AdventureWorks;\nGO\n\nDECLARE @columns NVARCHAR(MAX);\n\nSELECT x.ProductName\nINTO #products\nFROM (SELECT p...
2008/12/07
[ "https://Stackoverflow.com/questions/347624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31689/" ]
347,625
<p>What do you recommend as minimum specs for a Windows laptop running Vista, an IDE, and Apache, MySQL, and PHP?</p>
[ { "answer_id": 347673, "author": "Jeremiah Peschka", "author_id": 11780, "author_profile": "https://Stackoverflow.com/users/11780", "pm_score": 4, "selected": true, "text": "USE AdventureWorks;\nGO\n\nDECLARE @columns NVARCHAR(MAX);\n\nSELECT x.ProductName\nINTO #products\nFROM (SELECT p...
2008/12/07
[ "https://Stackoverflow.com/questions/347625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
347,636
<p>I create a TCP socket without bothering about the port number to bind to [socket.sin_port = 0]. However later on if I want to print the port number of client how do I do that? The client C application (on Linux) creates many clients which get connected to server. To debug issues I capture the traffic on ethereal. I thought of printing the port number in logs while issue arises so that filtering on ethereal becomes easy. </p> <p>Any help would be appreciated.</p> <p>-Prabhu</p>
[ { "answer_id": 347709, "author": "D.Shawley", "author_id": 41747, "author_profile": "https://Stackoverflow.com/users/41747", "pm_score": 2, "selected": false, "text": "getsockname()" }, { "answer_id": 347882, "author": "Scott", "author_id": 7399, "author_profile": "ht...
2008/12/07
[ "https://Stackoverflow.com/questions/347636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
347,642
<p>I have a problem. One of the datatable colums value is a string value '001200' for example. When the Excel document creats the value became '1200'. How can I keep a data format as is? I'm working with ASP.NET 1.1.</p> <p>The part of the code is:</p> <pre><code>private void lnkExport_Click( object sender, System.EventArgs e ) { Response.Clear(); Response.Buffer= true; Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader( "Content-Disposition", "attachment; filename=" + "CartsList.xls" ); Response.Charset = "iso-8859-8"; Response.Cache.SetCacheability( HttpCacheability.Public ); Response.ContentEncoding = System.Text.Encoding.UTF7; this.EnableViewState = false; System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter( oStringWriter ); this.ClearControls( dtgCarts ); dtgCarts.RenderControl( oHtmlTextWriter ); Response.Write( oStringWriter.ToString() ); Response.End(); } </code></pre> <p>Thank you</p>
[ { "answer_id": 347650, "author": "Russ Cam", "author_id": 1831, "author_profile": "https://Stackoverflow.com/users/1831", "pm_score": 0, "selected": false, "text": "'001200\n" }, { "answer_id": 1973337, "author": "Binoj Antony", "author_id": 33015, "author_profile": "...
2008/12/07
[ "https://Stackoverflow.com/questions/347642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
347,656
<p>I have a table of data sorted by date, from which a user can select a set of data by supplying a start and end date. The data itself is non-continuous, in that I don't have data for weekends and public holidays. </p> <p>I would like to be able to list all the days that I don't have data for in the extracted dataset. Is there an easy way, in Java, to go:</p> <ol> <li>Here is an ordered array of dates. </li> <li>This is the selected start date. (The first date in the array is not always the start date)</li> <li>This is the selected end date. (The last date in the array is not always the end date)</li> <li>Return a list of dates which have no data.</li> </ol>
[ { "answer_id": 347688, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 3, "selected": true, "text": "dates = [...]; // list you have now;\n\n// build list\nunused = [];\nfor (Date i = startdate; i < enddate; i += d...
2008/12/07
[ "https://Stackoverflow.com/questions/347656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3410/" ]
347,659
<p>I looked at SQL Server dateformat codes but I couldn't find dd.mm.yyyy hh:mm format in the list. German Date Format(Code is 4) works for me but it doesn't contain hh:mm. Does someone know this format's code?</p>
[ { "answer_id": 347670, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "CONVERT(varchar,[datefield],104)\n + ' '\n + SUBSTRING(CONVERT(varchar,[datefield],108),1,5)\n" }, { "an...
2008/12/07
[ "https://Stackoverflow.com/questions/347659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
347,661
<p>How would I handle something like the below uri using ASP.NET MVC's routing capability:</p> <pre><code>http://localhost/users/{username}/bookmarks/ - GET http://localhost/users/{username}/bookmark/{bookmarkid} - PUT </code></pre> <p>Which lists the bookmarks for the user in {username}.</p> <p>Thanks</p>
[ { "answer_id": 347726, "author": "Pablo Retyk", "author_id": 30729, "author_profile": "https://Stackoverflow.com/users/30729", "pm_score": 3, "selected": true, "text": "routes.MapRoute(\"Bookmarks\", \"{controller}/{user}/{action}/{id}\");\n" }, { "answer_id": 348671, "author...
2008/12/07
[ "https://Stackoverflow.com/questions/347661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33764/" ]
347,664
<p>Is it possible to use something like:</p> <pre><code>require 'serialport.o' </code></pre> <p>with Shoes? serialport.o is compiled c code as a ruby extension.</p> <p>When I attempt to run the following code in shoes, I see no visible output to the screen and shoes crashes on OS X.</p> <p>Thank you</p> <p>CODE:</p> <pre><code>require "serialport.o" port = "/dev/tty.usbserial-A1001O0o" sp = SerialPort.new( port, 9600, 8, 1, SerialPort::NONE) Shoes.app :width =&gt; 300, :height =&gt; 150, :margin =&gt; 10 do button "On" do sp.write( "1" ) end end sp.close </code></pre>
[ { "answer_id": 347701, "author": "Moss Collum", "author_id": 13210, "author_profile": "https://Stackoverflow.com/users/13210", "pm_score": 1, "selected": false, "text": "require \"serialport.o\"\n\nport = \"/dev/tty.usbserial-A1001O0o\"\nsp = SerialPort.new( port, 9600, 8, 1, SerialPort:...
2008/12/07
[ "https://Stackoverflow.com/questions/347664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
347,675
<p>I have a class like this:</p> <pre><code>public class myClass { public List&lt;myOtherClass&gt; anewlist = new List&lt;myOtherClass&gt;; public void addToList(myOtherClass tmp) { anewList.Add(tmp); } } </code></pre> <p>So I call "addToList" a hundred times, each adding a unique item to the list. I've tested my items to show that before I run the "addToList" method, they are unique. I even put a line in to test "tmp" to make sure it was what I was expecting.</p> <p>However, when I do this (lets say myClass object is called tmpClass):</p> <pre><code>int i = tmpClass.anewList.Count(); for (int j = 0; j&lt;i; j++) { //write out each member of the list based on index j... } </code></pre> <p>I get the same exact item, and it's the last one that was written into my list. It's as if when I add, I'm overwriting the entire list with the last item I've added. </p> <p>Help? This makes no sense. I've also tried List.Insert, where I'm always inserting at the end or at index 0. Still no dice. Yes, I'm doubly source my indexing is correct and when I do my test I'm indexing through each of the elements.</p> <p>:)</p> <p>UPDATE: Okay, I tried this and still had the same problem:</p> <pre><code>foreach(myOtherClass tmpC in tmpClass.anewList) { Console.WriteLine(tmpC.theStringInMyClass.ToString()); } </code></pre> <p>and still for each of the 100 items, I got the same string output... I'm sure I'm doing something completely stupid, but I don't know what yet. I'm still 100% sure that the right string is getting passed in to begin with.</p> <p>-Adeena</p> <hr> <p>Okay, I tried this and still had the same problem:</p> <pre><code>foreach(myOtherClass tmpC in tmpClass.anewList) { Console.WriteLine(tmpC.theStringInMyClass.ToString()); } </code></pre> <p>and still for each of the 100 items, I got the same string output... I'm sure I'm doing something completely stupid, but I don't know what yet. I'm still 100% sure that the right string is getting passed in to begin with.</p> <p>-Adeena</p>
[ { "answer_id": 347679, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 1, "selected": false, "text": "foreach (MyOtherClass item in tmpClass.anewList)\n{\n Console.WriteLine( item ); // or whatever you use to write i...
2008/12/07
[ "https://Stackoverflow.com/questions/347675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44004/" ]
347,690
<p>Does any of you have a clue how to alter the contents of <code>Security.framework/TrustStore.sqlite3</code>. It seems as if the iPhone uses it to store trusted CA certificates. I really want my iPod touch to trust my custom certificate. Beside that, does anyone of you know an app (win32) to edit sqlite3 database files (except sqliteman, this one always crashes for me).</p>
[ { "answer_id": 45053184, "author": "Patrik", "author_id": 242026, "author_profile": "https://Stackoverflow.com/users/242026", "pm_score": 1, "selected": false, "text": "/System/Library/Security/Certificates.bundle" } ]
2008/12/07
[ "https://Stackoverflow.com/questions/347690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44107/" ]
347,703
<p>I made an array in PHP which holds a bucnh of unix timestamps.</p> <p>I'm trying to make a function that will return an array containing the indexes of the 3 largest numbers in that array.</p> <p>For instance, if the largest numbers are located at indexes 3,5 and 8</p> <p>And if the largest is 5, second largest is 8 and smallest of the three is number 3, I want an array that holds the values (5,8,3) in that order.</p> <p>And frankly, I don't have a clue how to pull this off. Does anybody know how to do this?</p>
[ { "answer_id": 347722, "author": "mepcotterell", "author_id": 43312, "author_profile": "https://Stackoverflow.com/users/43312", "pm_score": 0, "selected": false, "text": "function select(list[1..n], k)\n for i from 1 to k\n maxIndex = i\n maxValue = list[i]\n ...
2008/12/07
[ "https://Stackoverflow.com/questions/347703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11795/" ]
347,721
<p>I'm looking to perform a perspective transform on a UIView (such as seen in coverflow)</p> <p>Does anyonew know if this is possible? </p> <p>I've investigated using <code>CALayer</code> and have run through all the pragmatic programmer Core Animation podcasts, but I'm still no clearer on how to create this kind of transform on an iPhone.</p> <p>Any help, pointers or example code snippets would be really appreciated!</p>
[ { "answer_id": 353611, "author": "Brad Larson", "author_id": 19679, "author_profile": "https://Stackoverflow.com/users/19679", "pm_score": 9, "selected": true, "text": "UIView's" }, { "answer_id": 47924259, "author": "Sunil M.", "author_id": 7348569, "author_profile":...
2008/12/07
[ "https://Stackoverflow.com/questions/347721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1221378/" ]
347,724
<p>I have a Page with a UserControl on it. If the user presses Esc while anywhere on Page I want to handle.</p> <p>I thought this would be as easy as hooking up the PreviewKeyDown event, testing for the Esc key, and then handling it. However, when I placed I breakpoint in the event handler I found it was never getting called. I thought perhaps the UserControl might be getting hit, so I tried PreviewKeyDown there... same result.</p> <p>Does anyone know the proper place to test for a KeyDown or PreviewKeyDown on a Page object?</p>
[ { "answer_id": 14887563, "author": "Daniel", "author_id": 84873, "author_profile": "https://Stackoverflow.com/users/84873", "pm_score": 6, "selected": false, "text": "KeyDown" }, { "answer_id": 22282641, "author": "alansiqueira27", "author_id": 375422, "author_profile...
2008/12/07
[ "https://Stackoverflow.com/questions/347724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42620/" ]
347,734
<p>I need some help calculating Pi. I am trying to write a python program that will calculate Pi to X digits. I have tried several from the python mailing list, and it is to slow for my use. I have read about the <a href="http://en.wikipedia.org/wiki/Gauss-Legendre_algorithm" rel="noreferrer">Gauss-Legendre Algorithm</a>, and I have tried porting it to Python with no success.</p> <p>I am reading from <a href="http://www.geocities.com/hjsmithh/Pi/Gauss_L.html" rel="noreferrer">Here</a>, and I would appreciate any input as to where I am going wrong!</p> <p>It outputs: 0.163991276262</p> <pre><code>from __future__ import division import math def square(x):return x*x a = 1 b = 1/math.sqrt(2) t = 1/4 x = 1 for i in range(1000): y = a a = (a+b)/2 b = math.sqrt(b*y) t = t - x * square((y-a)) x = 2* x pi = (square((a+b)))/4*t print pi raw_input() </code></pre>
[ { "answer_id": 347749, "author": "jfs", "author_id": 4279, "author_profile": "https://Stackoverflow.com/users/4279", "pm_score": 6, "selected": true, "text": "4*t" }, { "answer_id": 347758, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverfl...
2008/12/07
[ "https://Stackoverflow.com/questions/347734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42584/" ]
347,741
<p>Why don't we get compile errors on inline code errors in asp.net mvc views f.eks</p> <pre><code>&lt;h1&gt;&lt;%= ViewData.Model.Title.Tostrig() %&gt;&lt;/h1&gt; </code></pre> <p>The code above will build just fine. Wrong spelling in webform controls will give you an error so I can't see why this isn't supported in asp.net mvc</p> <p>EDIT: Luckily there seem to be a fix included in the first RC for asp.net mvc <a href="http://weblogs.asp.net/scottgu/archive/2008/12/19/asp-net-mvc-design-gallery-and-upcoming-view-improvements-with-the-asp-net-mvc-release-candidate.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/scottgu/archive/2008/12/19/asp-net-mvc-design-gallery-and-upcoming-view-improvements-with-the-asp-net-mvc-release-candidate.aspx</a></p>
[ { "answer_id": 347836, "author": "Dan Atkinson", "author_id": 31532, "author_profile": "https://Stackoverflow.com/users/31532", "pm_score": 4, "selected": false, "text": " C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\aspnet_compiler -v / -p \"$(ProjectDir)\\\"\n" }, { "answ...
2008/12/07
[ "https://Stackoverflow.com/questions/347741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29519/" ]
347,798
<p>I need to change an element's ID using jQuery. </p> <p>Apparently these don't work:</p> <pre><code>jQuery(this).prev("li").attr("id")="newid" jQuery(this).prev("li")="newid" </code></pre> <p>I found out that I can make it happen with the following code:</p> <pre><code>jQuery(this).prev("li")show(function() { this.id="newid"; }); </code></pre> <p>But that doesn't seem right to me. There must be a better way, no? Also, in case there isn't, what other method can I use instead of show/hide or other effects? Obviously I don't want to show/hide or affect the element every time, just to change its ID.</p> <p>(Yep, I'm a jQuery newbie.)</p> <p><strong>Edit</strong><br> I can't use classes in this case, I must use IDs.</p>
[ { "answer_id": 347808, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 10, "selected": true, "text": "jQuery(this).prev(\"li\").attr(\"id\",\"newId\");\n" }, { "answer_id": 347810, "author": "Pim Jager", ...
2008/12/07
[ "https://Stackoverflow.com/questions/347798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1011/" ]
347,804
<p>I'm building a web application that guides my users through the configuration and installation of an application. It builds a set of configuration files dynamically, then sends them in an archive (.ZIP file) along with an installer for the application. The web page is generated from a linux shell script (sorry), and for security reasons, I'd prefer the file be sent directly from the script, rather than as a link, so the user can't access it directly.</p> <p>Here's the process: Once the user has entered some information, and the files have been generated, I want to display a page with instructions, then start the download automatically, without asking the user to click a "download this file" link:</p> <pre><code>#!/bin/bash echo_header_and_instructions # Standard HTML &lt;Magic HTML tag to start transfer&gt; # ??? What goes here??? command_to_stream_the_files # Probably 'cat' echo_end_tags # End the page. </code></pre> <p>Thanks for your help!</p>
[ { "answer_id": 347913, "author": "Tom Haigh", "author_id": 22224, "author_profile": "https://Stackoverflow.com/users/22224", "pm_score": 1, "selected": false, "text": "<meta http-equiv=\"refresh\" content=\"5;url=http://example.com/pathtodownload.zip\" />\n" }, { "answer_id": 347...
2008/12/07
[ "https://Stackoverflow.com/questions/347804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29157/" ]
347,811
<p>A few years ago, it was proven that <a href="http://www.cse.iitk.ac.in/~manindra/algebra/primality_v6.pdf" rel="noreferrer">PRIMES is in P</a>. Are there any algorithms implementing <a href="http://en.wikipedia.org/wiki/AKS_primality_test" rel="noreferrer">their primality test</a> in Python? I wanted to run some benchmarks with a naive generator and see for myself how fast it is. I'd implement it myself, but I don't understand the paper enough yet to do that.</p>
[ { "answer_id": 29834291, "author": "Jacques", "author_id": 2504116, "author_profile": "https://Stackoverflow.com/users/2504116", "pm_score": -1, "selected": false, "text": "def expand_x_1(p):\n ex = [1]\n for i in range(p):\n ex.append(ex[-1] * -(p-i) / (i+1))\n return ex...
2008/12/07
[ "https://Stackoverflow.com/questions/347811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
347,812
<p>Is there a way to be <strong>sure</strong> that a page is coming from cache on a production server and on the development server as well?</p> <p>The solution <strong>shouldn't</strong> involve caching middleware because not every project uses them. Though the solution itself might <strong>be</strong> a middleware.</p> <p>Just checking if the data is stale is not a very safe testing method IMO.</p>
[ { "answer_id": 348546, "author": "Peter Rowell", "author_id": 17017, "author_profile": "https://Stackoverflow.com/users/17017", "pm_score": 5, "selected": true, "text": "<!-- component_name {{host}} {{timestamp}} -->\n" }, { "answer_id": 5563503, "author": "Johannes", "au...
2008/12/07
[ "https://Stackoverflow.com/questions/347812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42188/" ]
347,818
<p>It is my understanding that I can test that a method call will occur if I call a higher level method, i.e.:</p> <pre><code>public abstract class SomeClass() { public void SomeMehod() { SomeOtherMethod(); } internal abstract void SomeOtherMethod(); } </code></pre> <p>I want to test that if I call <code>SomeMethod()</code> then I expect that <code>SomeOtherMethod()</code> will be called. </p> <p>Am I right in thinking this sort of test is available in a mocking framework?</p>
[ { "answer_id": 347907, "author": "Paul", "author_id": 41301, "author_profile": "https://Stackoverflow.com/users/41301", "pm_score": 9, "selected": true, "text": "static void Main(string[] args)\n{\n Mock<ITest> mock = new Mock<ITest>();\n\n ClassBeingTested testedClass = ne...
2008/12/07
[ "https://Stackoverflow.com/questions/347818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/425/" ]
347,851
<p>The project I'm working on has two type of accounts, "<code>people</code>" and "<code>companies</code>". </p> <p>I hold a single "<code>users</code>" table with all the accounts and just the basic info needed for login (email, pass, etc), and two other tables "<code>user_profiles</code>" (regular people) and "<code>company_profiles</code>" (companies) that hold more specific columns for each type, both of the tables linked to the general "<code>users</code>" table via a "<code>profile_user_id</code>" column.</p> <p>But, whenever I want to list users that can be both people and companies, I use :</p> <p>"<code>select user_id, user_type, concat_ws('', concat_ws(' ', user_profiles.profile_first_name, user_profiles.profile_last_name), company_profiles.profile_company_name) as user_fullname</code>".</p> <p>When I list these users I know whether they're people or companies by the "<code>user_type</code>". </p> <p>Is my approach using <code>concat_ws</code> the right (optimal) one? I did this instead of <code>select</code>-ing every <code>*_name</code> to avoid returning more columns than necessary.</p> <p>Thanks</p> <p>EDIT: the query above continues like: <code>from users left join user_profiles on ... left join company_profiles on ...</code></p>
[ { "answer_id": 347858, "author": "mson", "author_id": 36902, "author_profile": "https://Stackoverflow.com/users/36902", "pm_score": 4, "selected": true, "text": "select\n u.user_id, u.user_type, concat_ws(profile_first_name + profile_last_name) as full_name\nfrom \n users u, user_profile...
2008/12/07
[ "https://Stackoverflow.com/questions/347851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44126/" ]
347,856
<p>I have created a form to add a user to a database and make user available for login.</p> <p>Now I have two password fields (the second is for validation of the first). How can I add a validator for this kind of validation to zend_form?</p> <p>This is my code for the two password fields:</p> <pre><code> $password = new Zend_Form_Element_Password('password', array( 'validators'=&gt; array( 'Alnum', array('StringLength', array(6,20)) ), 'filters' =&gt; array('StringTrim'), 'label' =&gt; 'Wachtwoord:' )); $password-&gt;addFilter(new Ivo_Filters_Sha1Filter()); $password2 = new Zend_Form_Element_Password('password', array( 'validators'=&gt; array( 'Alnum', array('StringLength', array(6,20)) ), 'filters' =&gt; array('StringTrim'), 'required' =&gt; true, 'label' =&gt; 'Wachtwoord:' )); $password2-&gt;addFilter(new Ivo_Filters_Sha1Filter()); </code></pre>
[ { "answer_id": 348782, "author": "Irmantas", "author_id": 43182, "author_profile": "https://Stackoverflow.com/users/43182", "pm_score": 1, "selected": false, "text": "$password_2->addValidator('identical', false, $this->_request->getPost('password'));\n" }, { "answer_id": 348805,...
2008/12/07
[ "https://Stackoverflow.com/questions/347856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42111/" ]
347,862
<p>For the umpteenth time my laptop just shut down in the middle of my game because my power cable had disconnected without me noticing it.</p> <p>Now I want to write a little C# program that detects when my power cable disconnects and then emits a nice long System beep. What API could I use for that?</p>
[ { "answer_id": 24464382, "author": "ARK", "author_id": 3782508, "author_profile": "https://Stackoverflow.com/users/3782508", "pm_score": 1, "selected": false, "text": "PowerStatus powerStatus = SystemInformation.PowerStatus;\n\nif (powerStatus.PowerLineStatus == PowerLineStatus.Online)\n...
2008/12/07
[ "https://Stackoverflow.com/questions/347862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
347,889
<p>i have got an 32bit (hexadecimal)word 0xaabbccdd and have to swap the 2. and the 3. byte. in the end it should look like 0xaaccbbdd</p> <p>how can i "mask" the 2nd and the 3rd byte to first load them up to register r1 and r2 and the swap them.. i also know that i have to work with lsl and lsr commands but dont know how to start.</p> <p>sorry for my bad english.hope anyone could help me out!</p> <p>regards, sebastian</p>
[ { "answer_id": 348009, "author": "Nils Pipenbrinck", "author_id": 15955, "author_profile": "https://Stackoverflow.com/users/15955", "pm_score": 3, "selected": false, "text": " .text\n\nswap_v4:\n AND R2, R0, #0x00ff0000 @ R2=0x00BB0000 get byte 2\n AND R3...
2008/12/07
[ "https://Stackoverflow.com/questions/347889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30954/" ]
347,897
<p>I need to use <code>FtpWebRequest</code> to put a file in a FTP directory. Before the upload, I would first like to know if this file exists. </p> <p>What method or property should I use to check if this file exists?</p>
[ { "answer_id": 348334, "author": "user42467", "author_id": 42467, "author_profile": "https://Stackoverflow.com/users/42467", "pm_score": 8, "selected": true, "text": "var request = (FtpWebRequest)WebRequest.Create\n (\"ftp://ftp.domain.com/doesntexist.txt\");\nrequest.Credentials = ne...
2008/12/07
[ "https://Stackoverflow.com/questions/347897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38940/" ]
347,910
<p>The project I'm working on requires access to the users source control. To do this we are wrapping the Perforce API and the Subversion API ( using P4.NET and SubversionSharp respectively ). </p> <p>We would like to support as many as we can depending on user requirements and I've tried googling for an existing library but no luck. Does a C# library that wraps multiple SCM applications exist?</p>
[ { "answer_id": 350738, "author": "andrewbadera", "author_id": 25952, "author_profile": "https://Stackoverflow.com/users/25952", "pm_score": 1, "selected": false, "text": "[DllImport(@\"C:\\Program Files\\Microsoft Visual Studio\\Common\\VSS\\win32\\SSSCC.DLL\")]\n" }, { "answer_i...
2008/12/07
[ "https://Stackoverflow.com/questions/347910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41477/" ]
347,918
<p>I would like to generate some JavaScript on the server side in ASP.Net MVC. Is there a view engine that supports this? Ideally I would like to be able to get JavaScript from an url like: </p> <pre><code>http://myapp/controller/action.js </code></pre> <p>I've looked at the MonoRail project, and they seem to have this feature, but it's very lacking in documentation, and I can't find any ports to ASP.Net MVC.</p> <p><strong>Edit:</strong> The idea is to be able to render a page both as standard HTML by using a url like:</p> <pre><code>http://myapp/controller/action </code></pre> <p>and as js (specifically an ExtJS component) by using the first url in the question. There would be only a single action in the controller, but two views: one for HTML and one for JS.</p> <p><strong>Edit 2:</strong> I basically wanted to achieve the same result as <a href="http://www.pagebakers.nl/2007/06/05/using-json-in-cakephp-12/" rel="nofollow noreferrer">router extension parsing/request handling</a> in CakePHP.</p>
[ { "answer_id": 347946, "author": "Jennifer", "author_id": 22360, "author_profile": "https://Stackoverflow.com/users/22360", "pm_score": 1, "selected": false, "text": "RouteTable.Routes.Add(new Route\n{\n Url = \"[controller]/[action].js\",\n Defaults = new { controller=\"home\", requ...
2008/12/07
[ "https://Stackoverflow.com/questions/347918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22107/" ]
347,920
<p>I'm messing around with some C code using floats, and I'm getting 1.#INF00, -1.#IND00 and -1.#IND when I try to print floats in the screen. What does those values mean?</p> <p>I believe that 1.#INF00 means positive infinity, but what about -1.#IND00 and -1.#IND? I also saw sometimes this value: 1.$NaN which is Not a Number, but what causes those strange values and how can those help me with debugging?</p> <p>I'm using <a href="http://en.wikipedia.org/wiki/MinGW" rel="noreferrer">MinGW</a> which I believe uses <a href="https://en.wikipedia.org/wiki/IEEE_floating_point" rel="noreferrer">IEEE 754</a> representation for float point numbers.</p> <p>Can someone list all those invalid values and what they mean?</p>
[ { "answer_id": 11893772, "author": "Jeff", "author_id": 13338, "author_profile": "https://Stackoverflow.com/users/13338", "pm_score": 2, "selected": false, "text": "If Double.IsNaN(MyVariableName) Then\n MyVariableName = 0 ' Or whatever you want to do here to \"correct\" the situation...
2008/12/07
[ "https://Stackoverflow.com/questions/347920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3485/" ]
347,948
<p>Bonus points for explaining how you improved it.</p>
[ { "answer_id": 348000, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 3, "selected": false, "text": "$encrypted_password = md5( sha1( plaintext_password ) );\n" }, { "answer_id": 348106, "author": "Tom", ...
2008/12/07
[ "https://Stackoverflow.com/questions/347948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16511/" ]
347,949
<p>How can I convert an <code>std::string</code> to a <code>char*</code> or a <code>const char*</code>?</p>
[ { "answer_id": 347952, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 5, "selected": false, "text": ".c_str()" }, { "answer_id": 347959, "author": "Johannes Schaub - litb", "author_id": 34509, "author_...
2008/12/07
[ "https://Stackoverflow.com/questions/347949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37875/" ]
347,951
<p>I have two running processes in Windows, and each process has a pipe to the other.</p> <p>I want to serialize a complicated class and transmit it from one process to the other. I already have the serialization procedure worked out, and I understand that the pipes are sending binary streams. How should I go about sending my serialized data? I'm using WinAPI and C++.</p> <p>Should I develop a custom protocol? If so, should it be generic or unique to this particular class? Can I preserve virtual tables when sending the serialized class?</p> <p>Are there any models or design patterns that are commonly used in this case? A little bit of sample code would be greatly appreciated. Thank you!</p>
[ { "answer_id": 347999, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 3, "selected": true, "text": "boost::serialization" } ]
2008/12/07
[ "https://Stackoverflow.com/questions/347951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7003/" ]
347,954
<p>How can I do a script to catch strings as input and open them on a Firefox document? Each link would go to a different window or tab. Any ideas would be much appreciated.</p> <p>I just want to be able to take some links and open them. For example I have 50 Links. And copying and parsing those 50 Links take a really long time and also a lot of work. If I can just write a script to read those links and let the computer do the work, it will be very helpful for me. I just don't know how to write that or where because it does not sound too hard (just gotta know how to). Thanks for any suggestions. </p>
[ { "answer_id": 349403, "author": "Aaron Digulla", "author_id": 34088, "author_profile": "https://Stackoverflow.com/users/34088", "pm_score": 0, "selected": false, "text": "<html>\n<head><title>Your links</title></head>\n<body>\nYour links:<br />\n<a href=\"XXX\">XXX</a><br />\n</body>\n<...
2008/12/07
[ "https://Stackoverflow.com/questions/347954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
347,969
<p>My question is whether or not Flex's fcsh can be called from within a PHP script. Here is the background:</p> <p>I have been created a simple process that creates a simple quiz/tutorial by converting a text file into a .mxml file and compiling to a .swf file using the mxmlc compiler. This works well from the command line, but I wanted to make the process easier by creating a web-interface to do this. My initial attempts with PHP's exec() function have not worked. The Python scripts I use to create the .mxml file work fine (using exec()), but I have not been able to get the mxmlc compiler to work.</p> <p>After searching on the Web and on this site, I believe that using fcsh (instead of mxmlc) may be the way to go. Using fcsh would certainly compile the .mxml file faster (after the first run), and I think that fcsh can be launched as a service that might be able to be called from PHP.</p> <p>On the other hand, maybe I am approaching this the wrong way. Would it be better to write a Flex application that calls fcsh and avoid using PHP?</p> <p><strong>Edit:</strong> Using fcshctl as hasseg suggested in his answer below worked very well. Thanks Ali.</p>
[ { "answer_id": 348132, "author": "hasseg", "author_id": 4111, "author_profile": "https://Stackoverflow.com/users/4111", "pm_score": 2, "selected": true, "text": "fcshctl" }, { "answer_id": 368665, "author": "Theo", "author_id": 1109, "author_profile": "https://Stackov...
2008/12/07
[ "https://Stackoverflow.com/questions/347969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23089/" ]
348,021
<p>By means of a regular expression and Greasemonkey I have an array of results that looks like:<br> <code>choice1, choice2, choice3, choice3, choice1, etc..</code></p> <p>My question is how do I tally up the choices so I know how many times choice1 is in the array, choice2 is in the array, etc. if I do not know exactly how many choices there are or what they are.</p> <p>The ultimate goal is to create a Greasemonkey script that stores the number of votes each choice gets over multiple pages (probably using gm_setvalue although I'm open to other ideas.)</p> <p>Thanks!</p>
[ { "answer_id": 348032, "author": "Ryan Cook", "author_id": 43029, "author_profile": "https://Stackoverflow.com/users/43029", "pm_score": 1, "selected": false, "text": " // Original data\n var choices = [\n \"choice 1\",\n \"choice 1\",\n \"choice 2\",\n \"...
2008/12/07
[ "https://Stackoverflow.com/questions/348021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44133/" ]
348,022
<p>I'm trying to implement a Load / Save function for a Windows Forms application.</p> <p>I've got following components:</p> <ul> <li>A tree view</li> <li>A couple of list views</li> <li>A couple of text boxes</li> <li>A couple of objects (which holds a big dictionarylist)</li> </ul> <p>I want to implement a way to save all of this into a file, and resume/load it later on.</p> <p>What's the best way to do this? </p> <p>I think XML serialization is the way to go, but I'm not quite sure how, or where to start. Or will it require a really complex solution to be able to do this?</p>
[ { "answer_id": 348024, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": false, "text": "TreeView" }, { "answer_id": 348904, "author": "Marc Gravell", "author_id": 23354, "author_profile...
2008/12/07
[ "https://Stackoverflow.com/questions/348022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40322/" ]
348,037
<p>I have a problem with the following code:</p> <pre><code>for(i = 0;(i - 1)&lt; n;i++) { char* b; sprintf(b, "%d", i); } </code></pre> <p>It compiles fine but when I run it it give me the infamous "0XC0000005 Access Violation" error. I have tried setting b to NULL, "", "0", 0 and a bunch of other stuff but then I get the "0XC0000005 Access Violation" error or "Expression: string != NULL. Any help would be appreciated!</p>
[ { "answer_id": 348045, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "sprintf" }, { "answer_id": 348059, "author": "user37875", "author_id": 37875, "author_profile": "http...
2008/12/07
[ "https://Stackoverflow.com/questions/348037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37875/" ]
348,040
<p>I know that <a href="http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port" rel="noreferrer">OpenCV was ported to Mac OS X</a>, however I did not find any info about a port to the iPhone.</p> <p>I am not a Mac developer, so that I do not know whether a Mac OS X port is enough for the iPhone.</p> <p>Does anyone know better than me? </p>
[ { "answer_id": 34981960, "author": "Dair", "author_id": 667648, "author_profile": "https://Stackoverflow.com/users/667648", "pm_score": 1, "selected": false, "text": "target 'MyApp' do\n pod 'OpenCV', '~> 3.0' \nend\n" } ]
2008/12/07
[ "https://Stackoverflow.com/questions/348040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19816/" ]
348,090
<p>My web app has a secure area which users log in to via a JSP. The JSP posts the user name and password to a servlet, which then checks to see if the users credentials are valid. If they are valid then the user is directed to the secure resource. How can I ensure that users can't just navigate to the secure resource without validating first?</p>
[ { "answer_id": 348134, "author": "mtruesdell", "author_id": 6479, "author_profile": "https://Stackoverflow.com/users/6479", "pm_score": 3, "selected": false, "text": "session.setAttribute(\"loggedIn\", \"true\");" }, { "answer_id": 349287, "author": "LenW", "author_id": 4...
2008/12/07
[ "https://Stackoverflow.com/questions/348090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16684/" ]
348,093
<p>Can someone please let me know how do I implement "Did you mean" feature in Lucene.net?</p> <p>Thanks!</p>
[ { "answer_id": 490875, "author": "itsadok", "author_id": 7581, "author_profile": "https://Stackoverflow.com/users/7581", "pm_score": 6, "selected": true, "text": " import org.apache.lucene.search.spell.SpellChecker;\n\n SpellChecker spellchecker = new SpellChecker(spellIndexDirectory);...
2008/12/07
[ "https://Stackoverflow.com/questions/348093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40907/" ]
348,109
<p>Is hashing a password twice before storage any more or less secure than just hashing it once?</p> <p>What I'm talking about is doing this:</p> <pre><code>$hashed_password = hash(hash($plaintext_password)); </code></pre> <p>instead of just this:</p> <pre><code>$hashed_password = hash($plaintext_password); </code></pre> <p>If it is less secure, can you provide a good explanation (or a link to one)?</p> <p>Also, does the hash function used make a difference? Does it make any difference if you mix md5 and sha1 (for example) instead of repeating the same hash function?</p> <p>Note 1: When I say "double hashing" I'm talking about hashing a password twice in an attempt to make it more obscured. I'm not talking about the <a href="http://en.wikipedia.org/wiki/Double_hashing" rel="noreferrer">technique for resolving collisions</a>.</p> <p><strong>Note 2: I know I need to add a random salt to really make it secure. The question is whether hashing twice with the same algorithm helps or hurts the hash.</strong></p>
[ { "answer_id": 348163, "author": "CodeAndCats", "author_id": 26335, "author_profile": "https://Stackoverflow.com/users/26335", "pm_score": 2, "selected": false, "text": "$hashed_password = md5( \"xxx\" + \"|\" + user_name + \"|\" + plaintext_password);\n" }, { "answer_id": 122207...
2008/12/07
[ "https://Stackoverflow.com/questions/348109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
348,112
<p><a href="https://stackoverflow.com/questions/116090/how-do-i-kill-a-process-using-vbnet-or-c">This</a> only helps kills processes on the local machine. How do I kill processes on remote machines?</p>
[ { "answer_id": 20208856, "author": "Mubashar", "author_id": 806076, "author_profile": "https://Stackoverflow.com/users/806076", "pm_score": 1, "selected": false, "text": "ConnectionOptions connectoptions = new ConnectionOptions();\nconnectoptions.Username = string.Format(@\"carpark\\{0}\...
2008/12/07
[ "https://Stackoverflow.com/questions/348112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
348,122
<p>Is there a possibility to deactivate / activate all try catch blocks in the whole project as easy as clicking a button?</p> <p>I need this for debugging when I don't want the catch block to handle the exception, but instead prefer that VS breaks into the code as if the try catch block was not there. </p> <p>At the moment I am commenting out the try/catch blocks but this is inefficient.</p> <p>Environment: VS 2008 with C# as language.</p>
[ { "answer_id": 48085535, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "Namespace Global.System\n Public Class NeverOccurException\n Inherits Exception\n End Class\nEnd Namespace\n" } ]
2008/12/07
[ "https://Stackoverflow.com/questions/348122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
348,127
<p>I have the following situation:</p> <p>I have a certain function that runs a loop and does stuff, and error conditions may make it exit that loop. I want to be able to check whether the loop is still running or not.</p> <p>For this, i'm doing, for each loop run:</p> <pre><code>LastTimeIDidTheLoop = new Date(); </code></pre> <p>And in another function, which runs through SetInterval every 30 seconds, I want to do basically this:</p> <pre><code>if (LastTimeIDidTheLoop is more than 30 seconds ago) { alert("oops"); } </code></pre> <p>How do I do this?</p> <p>Thanks!</p>
[ { "answer_id": 348133, "author": "rob", "author_id": 43927, "author_profile": "https://Stackoverflow.com/users/43927", "pm_score": 4, "selected": true, "text": "newDate = new Date()\nnewDate.setSeconds(newDate.getSeconds()-30);\nif (newDate > LastTimeIDidTheLoop) {\n alert(\"oops\");\n}...
2008/12/07
[ "https://Stackoverflow.com/questions/348127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
348,128
<p>This is silly, but I haven't found this information. If you have names of concepts and suitable references, just let me know.</p> <p>I'd like to understand how should I validate a given named id for a generic entity, like, say, an email login, just like Yahoo, Google and Microsoft do.</p> <p>I mean... If you do have an user named foo, trying to create foo2 will be denied, as it is likely to be someone trying to mislead users by using a fake id.</p>
[ { "answer_id": 348133, "author": "rob", "author_id": 43927, "author_profile": "https://Stackoverflow.com/users/43927", "pm_score": 4, "selected": true, "text": "newDate = new Date()\nnewDate.setSeconds(newDate.getSeconds()-30);\nif (newDate > LastTimeIDidTheLoop) {\n alert(\"oops\");\n}...
2008/12/07
[ "https://Stackoverflow.com/questions/348128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39261/" ]
348,170
<p>I mistakenly added files to Git using the command:</p> <pre><code>git add myfile.txt </code></pre> <p>I have not yet run <code>git commit</code>. How do I undo this so that these changes will not be included in the commit?</p>
[ { "answer_id": 348234, "author": "genehack", "author_id": 39933, "author_profile": "https://Stackoverflow.com/users/39933", "pm_score": 15, "selected": true, "text": "git add" }, { "answer_id": 348303, "author": "Paul Beckingham", "author_id": 14356, "author_profile":...
2008/12/07
[ "https://Stackoverflow.com/questions/348170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14069/" ]
348,187
<p>I am trying to use the range property of the jQuery slider so that the slider control displays two handles from which the user can select a price range for real estate. The code I have is:</p> <pre><code>$("#price").slider({ range: true, minValue: 0, maxValue: 2000000, change: function(e, ui) { var range = (Math.round(ui.range) * 10) + " to " + ui.value; $("#pricedesc").text(range); } }); </code></pre> <p>The price range should be from $0 to $2,000,000. When I slide the handles on the slider though I get unusual values such as "690 to 13". How exactly is the double handle slider meant to work?</p>
[ { "answer_id": 348273, "author": "Brian Fisher", "author_id": 43816, "author_profile": "https://Stackoverflow.com/users/43816", "pm_score": 4, "selected": true, "text": "$(document).ready(function(){\n $(\"#price\").slider(\n { range: true, \n min: 0, \n max: 200000...
2008/12/07
[ "https://Stackoverflow.com/questions/348187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27294/" ]
348,196
<p>I'm trying to create a Python script that opens several databases and compares their contents. In the process of creating that script, I've run into a problem in creating a list whose contents are objects that I've created.</p> <p>I've simplified the program to its bare bones for this posting. First I create a new class, create a new instance of it, assign it an attribute and then write it to a list. Then I assign a new value to the instance and again write it to a list... and again and again...</p> <p>Problem is, it's always the same object so I'm really just changing the base object. When I read the list, I get a repeat of the same object over and over. </p> <p>So how do you write objects to a list within a loop?</p> <p>Here's my simplified code</p> <pre><code>class SimpleClass(object): pass x = SimpleClass # Then create an empty list simpleList = [] #Then loop through from 0 to 3 adding an attribute to the instance 'x' of SimpleClass for count in range(0,4): # each iteration creates a slightly different attribute value, and then prints it to # prove that step is working # but the problem is, I'm always updating a reference to 'x' and what I want to add to # simplelist is a new instance of x that contains the updated attribute x.attr1= '*Bob* '* count print "Loop Count: %s Attribute Value %s" % (count, x.attr1) simpleList.append(x) print '-'*20 # And here I print out each instance of the object stored in the list 'simpleList' # and the problem surfaces. Every element of 'simpleList' contains the same attribute value y = SimpleClass print "Reading the attributes from the objects in the list" for count in range(0,4): y = simpleList[count] print y.attr1 </code></pre> <p>So how do I (append, extend, copy or whatever) the elements of simpleList so that each entry contains a different instance of the object instead of all pointing to the same one?</p>
[ { "answer_id": 348215, "author": "ironfroggy", "author_id": 19687, "author_profile": "https://Stackoverflow.com/users/19687", "pm_score": 6, "selected": false, "text": "for count in xrange(4):\n x = SimpleClass()\n x.attr = count\n simplelist.append(x)\n" }, { "answer_id...
2008/12/07
[ "https://Stackoverflow.com/questions/348196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
348,201
<p>Is there any way I can specify a standard or custom numeric format string to always output the sign, be it +ve or -ve (although what it should do for zero, I'm not sure!)</p>
[ { "answer_id": 348242, "author": "gcores", "author_id": 40256, "author_profile": "https://Stackoverflow.com/users/40256", "pm_score": 9, "selected": true, "text": "string MyString = number.ToString(\"+0;-#\");\n" }, { "answer_id": 556853, "author": "Luk", "author_id": 578...
2008/12/07
[ "https://Stackoverflow.com/questions/348201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14537/" ]
348,202
<p>I want to warn users of Internet Explorer 6 using my site, that IE6 has had serious compatibility issues with my site in the past. What is the best way to do this?</p> <p>Ideally, I want to have a message appear (not a new window, but a message box, if possible) that warns IE6 users of the issues and reccommends they update to either IE7, Firefox 3 or Opera 9.5.</p>
[ { "answer_id": 348219, "author": "different", "author_id": 3654, "author_profile": "https://Stackoverflow.com/users/3654", "pm_score": 5, "selected": false, "text": "<!--[if IE 6]>\n<h1>Please upgrade your browser!</h1>\n<![endif]-->\n" }, { "answer_id": 348220, "author": "da...
2008/12/07
[ "https://Stackoverflow.com/questions/348202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5509/" ]
348,236
<p>I'm working on an AJAXy project (Dojo and Rails, if the particulars matter). There are several places where the user should be able to sort, group, and filter results. There are also places where a user fills out a short form and the resulting item gets added to a list on the same page.</p> <p>The non-AJAXy implementation works fine -- the view layer server-side already knows how to render this stuff, so it can just do it again in a different order or with an extra element. This, however, adds lots of burden to the server.</p> <p>So we switched to sending JSON from the server and doing lots of (re-)rendering client-side. The downside is that now we have duplicate code for rendering every page: once in Rails, which was built for this, and once in Dojo, which was not. The latter is basically just string concatenation.</p> <p>So question part one: is there a good Javascript MVC framework we could use to make the rendering on the client-side more maintainable?</p> <p>And question part two: is there a way to generate the client-side views in Javascript and the server-side views in ERB from the same template? I think that's what the Pragmatic Programmers would do.</p> <p>Alternatively, question part three: am I completely missing another angle? Perhaps send JSON from the server but also include the HTML snippet as an attribute so the Javascript can do the filtering, sorting, etc. and then just insert the given fragment?</p>
[ { "answer_id": 348565, "author": "Eugene Lazutkin", "author_id": 26394, "author_profile": "https://Stackoverflow.com/users/26394", "pm_score": 1, "selected": false, "text": "innerHTML" }, { "answer_id": 348608, "author": "James A. Rosen", "author_id": 1190, "author_pr...
2008/12/07
[ "https://Stackoverflow.com/questions/348236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1190/" ]
348,249
<p>I have no clue about trigonometry, despite learning it in school way back when, and I figure this should be pretty straightforward, but trawling through tons of trig stuff on the web makes my head hurt :) So maybe someone could help me...</p> <p>The title explains exactly what I want to do, I have a line: x1,y1 and x2,y2 and want a function to find x3,y3 to complete an isosceles triangle, given the altitude. </p> <p>Just to be clear, the line x1,y2 -> x2,y2 will be the base, and it will not be aligned any axis (it will be at a random angle..) </p> <p>Does anyone have a simple function for this??</p>
[ { "answer_id": 348258, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 2, "selected": false, "text": "altitude" } ]
2008/12/07
[ "https://Stackoverflow.com/questions/348249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
348,251
<p>Hopefully (but not necessarily) one that is independent of language or framework?</p>
[ { "answer_id": 348258, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 2, "selected": false, "text": "altitude" } ]
2008/12/07
[ "https://Stackoverflow.com/questions/348251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31641/" ]
348,256
<p>I want to match a block of code <em>multiple</em> times in a file but can't work out the regular expression to do this. An example of the code block is:</p> <pre><code>//@debug ... // code in here ... //@end-debug (possibly more comments here on same line) </code></pre> <p>Each code block I'm trying to match will start with <code>//@debug</code> and stop at the end of the line containing <code>//@end-debug</code></p> <p>I have this at the moment:</p> <pre><code>/(\/{2}\@debug)(.|\s)*(\/{2}\@end-debug).*/ </code></pre> <p>But this matches one big block from the first <code>//@debug</code> all the way to end of the line of the very last <code>//@end-debug</code> in the file.</p> <p>Any ideas?</p>
[ { "answer_id": 348309, "author": "Alan Moore", "author_id": 20938, "author_profile": "https://Stackoverflow.com/users/20938", "pm_score": 1, "selected": false, "text": "(.|\\s)" } ]
2008/12/07
[ "https://Stackoverflow.com/questions/348256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40754/" ]
348,260
<p>I am writing a Firefox extension. I would like to search the current webpage for a set of words, and count how many times each occurs. This activity is only performed when the user asks, but it must still happen reasonably quickly.</p> <p>I am currently using indexOf on the BODY tag's innerHTML element, but am finding it too slow to run repeatedly in the following manner:</p> <pre><code>function wordcount(doc, match) { var count = 0; var pos = 0; for(;;) { len=doc.indexOf(match, pos); if(len == -1) { break; } pos = len + match.length; count++; } return count; } var html = content.document.body.innerHTML.toLowerCase() for(var i=0; i&lt;keywords.length; i++) { var kw = keywords[i]; myDump(kw + ": " + wordcount(html, kw)); } </code></pre> <p>With 100 keywords, this takes approximately 10 to 20 seconds to run. There is some scope to reduce the number of keywords, but it will still need to run much quicker.</p> <p>Is there a more obvious way to do this? What is the most efficient method? I have some ideas, but am reluctant to code each up without some idea of the performance I can expect:</p> <ul> <li>Navigate the DOM rather than using innerHTML. Will this be likely quicker or slower? It would have the benefit of only searching textual content.</li> <li>Loop through the document word by word, accumulating a count of each word's occurence simultaneously. With this method I would have to do a bit more work parsing the HTML.</li> </ul> <p><em>Edit: Turns out that the slowest part was the myDump function writing to the error console. Duh! Nevertheless, there some interesting more efficient alternatives have been presented, which I am intending to use.</em></p>
[ { "answer_id": 348302, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "var keywords = new Hash(); // from prototype or use your own\n\nfunction traverseNode( node ) {\n if (node.nodeName...
2008/12/07
[ "https://Stackoverflow.com/questions/348260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42974/" ]
348,266
<p>I'm writing a basic planet viewer OpenGL Perl application, just for fun. I have the basics working, with the glorious planet, implemented through a <code>gluSphere()</code>, rotating with the classic earth texture map applied.</p> <p>Now, what if I want to apply a second texture map through OpenGL (say, the "earth clouds")?</p> <p>Of course, I can mix the two texture maps myself in PhotoShop or some other graphic application, but is there a way through OpenGL API?</p> <p>I tried loading the two textures and generating the mipmaps but the planet is shown with only the first texture applied, not the second.</p>
[ { "answer_id": 348566, "author": "Jim Buck", "author_id": 2666, "author_profile": "https://Stackoverflow.com/users/2666", "pm_score": 3, "selected": false, "text": "glEnable(GL_TEXTURE_2D);\n\nglActiveTexture(GL_TEXTURE0);\nglBindTexture(GL_TEXTURE_2D, texture0ID);\nglTexEnvf(GL_TEXTURE_...
2008/12/07
[ "https://Stackoverflow.com/questions/348266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11303/" ]
348,268
<p>I have a procedure that is run for a lot of items, skipping over certain items who don't meet a criterion. However, I then go back and run it for some of the individuals who were missed in the first pass. I currently do this by manually re-running the procedure for each individual person, but would ideally like a solution a little more hands off.</p> <p>Something my boss suggested might be effective would be creating a List (as in Data -> Lists) that contains the names of the items in question, and then iterating over the list. Sadly, my help-file fu seems to be failing me - I don't know whether I just don't know what to look for, or what.</p> <p>Running the "Generate Macro" command shows that the VBA to create a list in the first place is along the lines of ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1"), , xlYes).Name = "List1"</p> <p>Unfortunately, I can't seem to figure out how to then do stuff with the resulting list. I'm looking to making a loop along the lines of</p> <pre><code>For Each ListItem in List Run the procedure on the text in ListItem.Value Next ListItem </code></pre> <p>Any suggestions?</p>
[ { "answer_id": 348362, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 2, "selected": false, "text": "Dim Counter 'module level '\n\nSub RunSomeProc()\n Counter = 0\n '1st test '\n SomeProc\n\n '2nd Test skipped ...
2008/12/07
[ "https://Stackoverflow.com/questions/348268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27290/" ]
348,282
<p>I'm working on a site with multiple subdomains, some of which should get their own session.</p> <p>I think I've got it worked out, but have noticed something about cookie handling that I don't understand. I don't see anything in the docs that explains it, so thought I would see if anyone here has some light to shed on the question.</p> <p>If I just do:</p> <pre><code>session_start(); </code></pre> <p>I end up with a session cookie like this:</p> <p>subdomain.example.net</p> <p>However, if I make any attempt to set the cookie domain myself, either like</p> <pre><code>ini_set('session.cookie_domain', 'subdomain.example.net'); </code></pre> <p>or like</p> <pre><code>session_set_cookie_params( 0, "/", "subdomain.example.net", false, false); </code></pre> <p>I end up with a cookie for .subdomain.example.net (note the opening dot), which I believe means "match all subdomains (or in this case sub-subdomains).</p> <p>This seems to happen with all my cookies actually, not just session. If I set the cookie domain myself, it automatically has the dot prepended, meaning this domain and all subs of it. If I don't set the domain, then it gets it right by using only the current domain.</p> <p>Any idea what causes this, and what I can do to control that prepending dot?</p> <p>Thanks!</p>
[ { "answer_id": 348336, "author": "Brian Fisher", "author_id": 43816, "author_profile": "https://Stackoverflow.com/users/43816", "pm_score": 6, "selected": true, "text": "header(\"Set-Cookie: cookiename=cookievalue; expires=Tue, 06-Jan-2009 23:39:49 GMT; path=/; domain=subdomain.example.n...
2008/12/07
[ "https://Stackoverflow.com/questions/348282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27580/" ]
348,304
<p>I am developing a State Machine Workflow using C# and WF in visual studio 2008. On one of my states I need to wait for multiple events to happen until the workflow can transition to the next state. As an example think of a unanimous voting scenario. I cannot find a way to do this. Does anyone have a solution or workaround for this problem? </p>
[ { "answer_id": 348336, "author": "Brian Fisher", "author_id": 43816, "author_profile": "https://Stackoverflow.com/users/43816", "pm_score": 6, "selected": true, "text": "header(\"Set-Cookie: cookiename=cookievalue; expires=Tue, 06-Jan-2009 23:39:49 GMT; path=/; domain=subdomain.example.n...
2008/12/07
[ "https://Stackoverflow.com/questions/348304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22769/" ]
348,305
<p>I have a program that needs to do a <strong>compile time checkable</strong> map from one known set of values to another known set of values:</p> <pre> in out ------------ 8 37 10 61 12 92 13 1/4 109 15 1/4 151 etc </pre> <p>This would be easy if the inputs were either integers or evenly spaced. I'm going to be iterating over the rows but also want to be able to do lookups in a readable manor.</p> <p>My current thought (that I'm not liking) is to define an enum like</p> <pre><code>enum Size { _8, _10, _12, _13_25, _15_25, // etc } </code></pre> <p>and then set it up for 2 lookups.</p> <p>Any better ideas?</p> <p><strong>Edit:</strong> My primary concern is limiting what I can <em>try</em> to look up. I'd like stuff to <em>not even compile</em> if the code might try and look up something that is invalid.</p> <p>The set is small and iteration times are almost totally irrelevant. </p> <p>I haven't seen anything that gains me anything over the enum so for now I'm going with that. OTOH I'll keep watching this question.</p> <p><code>*</code> Note: I'm not worried about catching issues with pointers and what not, just straight forward code like for loops and variable assignments.</p> <hr> <p><strong>The nitty grity</strong>: I over simplified the above for clarity and generality. I actually have a table that has 3 non-integer, non-uniform axes and one non-numeric axis. And at this point I'm not sure what directions I'm going to need to enumerate it in.</p> <p>a few links to give a flavor of what I'm looking for:</p> <p><a href="http://www.boost.org/doc/libs/1_37_0/boost/units/systems/si.hpp" rel="nofollow noreferrer">Boost::SI</a> and my <a href="http://www.dsource.org/projects/scrapple/browser/trunk/units" rel="nofollow noreferrer">D version</a> of <a href="http://www.dsource.org/projects/scrapple/browser/trunk/units/constants.d" rel="nofollow noreferrer">the</a> same <a href="http://www.dsource.org/projects/scrapple/browser/trunk/units/types.d" rel="nofollow noreferrer">idea</a></p>
[ { "answer_id": 348452, "author": "jmucchiello", "author_id": 44065, "author_profile": "https://Stackoverflow.com/users/44065", "pm_score": 0, "selected": false, "text": "// this could be loaded from a file potentially\n// notice that the keys have been sorted.\nconst char* keys[] = { \"1...
2008/12/07
[ "https://Stackoverflow.com/questions/348305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]