qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
287,474
<p>What is the difference between <code>HAVING</code> and <code>WHERE</code> in an <code>SQL SELECT</code> statement?</p> <p>EDIT: I have marked Steven's answer as the correct one as it contained the key bit of information on the link:</p> <blockquote> <p>When <code>GROUP BY</code> is not used, <code>HAVING</code> behaves like a <code>WHERE</code> clause</p> </blockquote> <p>The situation I had seen the <code>WHERE</code> in did not have <code>GROUP BY</code> and is where my confusion started. Of course, until you know this you can't specify it in the question.</p>
[ { "answer_id": 287475, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 4, "selected": false, "text": "HAVING" }, { "answer_id": 287480, "author": "Kaiser Advisor", "author_id": 32462, "author_profile": "h...
2008/11/13
[ "https://Stackoverflow.com/questions/287474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1223/" ]
287,489
<p>I have a CSS class called grid which I place on my tables. I want to Zebra strip my even rows so I use the following jQuery code</p> <pre><code>$(".grid tr:nth-child(even)").addClass("even"); </code></pre> <p>This basically says "Apply the css class even to any tr tag which has a parent (at any level) with a class of grid." The problem with this is when I have nested tables, the child table's tr tags will also get the even style. Since I did not specify the child table with a class of grid, I don't want it to pick up the zebra stripe. </p> <p>How can I specify to only apply the even class on tr tags which are a direct descendant of the tag which has the grid class? </p>
[ { "answer_id": 287499, "author": "MrKurt", "author_id": 35296, "author_profile": "https://Stackoverflow.com/users/35296", "pm_score": 4, "selected": true, "text": "$(\".grid > tr:nth-child(even)\").addClass(\"even\");\n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/287489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45/" ]
287,517
<p>I've <strong>inherited</strong> a web app that I've just discovered stores over 300,000 usernames/passwords in plain text in a SQL Server database. I realize that this is a Very Bad Thing™.</p> <p>Knowing that I'll have to update the login and password update processes to encrypt/decrypt, and with the smallest impact on the rest of the system, what would you recommend as the best way to remove the plain text passwords from the database?</p> <p>Any help is appreciated.</p> <p><strong>Edit: Sorry if I was unclear, I meant to ask what would be your procedure to encrypt/hash the passwords, not specific encryption/hashing methods.</strong> </p> <p>Should I just:</p> <ol> <li>Make a backup of the DB</li> <li>Update login/update password code</li> <li>After hours, go through all records in the users table hashing the password and replacing each one</li> <li>Test to ensure users can still login/update passwords</li> </ol> <p>I guess my concern is more from the sheer number of users so I want to make sure I'm doing this correctly.</p>
[ { "answer_id": 287539, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": -1, "selected": false, "text": "ALTER TABLE users ADD COLUMN hashedPassword varbinary(max);\nALTER TABLE users ADD COLUMN salt char(10);\n--Generat...
2008/11/13
[ "https://Stackoverflow.com/questions/287517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2034/" ]
287,540
<p>I have an object created in a host application and can access it remotely using remoting, is there any way I can test the connection to ensure it is still "alive"? Maybe an event I can use that fires if the remoting connection gets disconnected, or some property that can tell me the state of the remoting connection. Is there something like this available?</p>
[ { "answer_id": 287567, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 4, "selected": true, "text": " public void Ping() {} \n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/287540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9266/" ]
287,541
<p>What I'd like to do is produce an HTML/CSS/JS version of the following. The gridlines and other aspects are not important. It's more of a question how to do the background databars.</p> <p><a href="https://i.stack.imgur.com/tPLAD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tPLAD.png" alt="alt text"></a><br> <sub>(source: <a href="http://blogs.tech-recipes.com/shamanstears/files/2008/04/excel_databars2.png" rel="nofollow noreferrer">tech-recipes.com</a>)</sub> </p>
[ { "answer_id": 287617, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 2, "selected": true, "text": "<div style=\"background: url(bg.gif) -50px 0 no-repeat;\">5</div>\n<div style=\"background: url(bg.gif) -20px 0 no-repeat;\...
2008/11/13
[ "https://Stackoverflow.com/questions/287541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
287,543
<p>I can't seem to find in the SDK how to programatically sense the mute button/switch on the iPhone. When my app plays background music, it responds properly to the volume button without me having any code to follow that but, when I use the mute switch, it just keeps playing away.</p> <p>How do I test the position of mute?</p> <p>(NOTE: My program has its own mute switch, but I'd like the physical switch to override that.)</p>
[ { "answer_id": 292918, "author": "Olie", "author_id": 34820, "author_profile": "https://Stackoverflow.com/users/34820", "pm_score": 6, "selected": true, "text": "// \"Ambient\" makes it respect the mute switch\n// Must call this once to init session\nif (!gAudioSessionInited)\n{\n Aud...
2008/11/13
[ "https://Stackoverflow.com/questions/287543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34820/" ]
287,553
<p>Every time I have to build a form with a <code>DateTime</code> field I try to find a decent free custom control - I always fail.</p> <p>I cannot figure out why it isn't built in the .NET but let's forget about for a minute and concentrate on my question :D</p> <p>Anyone got one?</p>
[ { "answer_id": 287815, "author": "Ryan Lundy", "author_id": 5486, "author_profile": "https://Stackoverflow.com/users/5486", "pm_score": 2, "selected": true, "text": "Mask=\"99:99\"\nAutoCompleteValue=\"00:00\"\nAcceptAMPM=\"true\"\nMaskType=\"Time\"\n" }, { "answer_id": 289808, ...
2008/11/13
[ "https://Stackoverflow.com/questions/287553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31765/" ]
287,563
<p>Is there a way in Oracle to select the date on which daylight savings will switch over for my locale?</p> <p>Something vaguely equivalent to this would be nice:</p> <pre><code>SELECT CHANGEOVER_DATE FROM SOME_SYSTEM_TABLE WHERE DATE_TYPE = 'DAYLIGHT_SAVINGS_CHANGEOVER' AND TO_CHAR(CHANGEOVER_DATE,'YYYY') = TO_CHAR(SYSDATE,'YYYY'); -- in the current year </code></pre> <p><em>Edit: I was hoping for a solution that would not require changes when Congress adjusts DST laws, as they did in 2007. The posted solutions will work, though.</em></p>
[ { "answer_id": 287855, "author": "Leigh Riffel", "author_id": 27010, "author_profile": "https://Stackoverflow.com/users/27010", "pm_score": 3, "selected": true, "text": "Function DaylightSavingTimeStart (p_Date IN Date)\nReturn Date Is\n v_Date Date;\n v_LoopIndex Integer;\nBe...
2008/11/13
[ "https://Stackoverflow.com/questions/287563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/672/" ]
287,585
<p>I'm trying to pass a null value for the first parameter in the code below, but MySQL complains that </p> <pre> Incorrect number of arguments for PROCEDURE myProc; expected 2, got 1 </pre> <p>When I manually call the procedure with the first argument as null, it works, but when <code>EmptyAsNullStartsWith(employeeNumberText.Text)</code> returns null, it complains. </p> <pre><code>Database db = DatabaseFactory.CreateDatabase( ConfigurationManager.AppSettings["dbType"] ); DbCommand cmd = db.GetStoredProcCommand("staff_listforinquiry"); db.AddeParameter( cmd, "in_employeeNumber", DbType.String, EmptyAsNullStartsWith(employeeNumberText.Text) ); db.AddeParameter( cmd, "in_name", DbType.String, EmptyAsNullContains(employeeNameText.Text) ); </code></pre>
[ { "answer_id": 9112404, "author": "yanke", "author_id": 1185115, "author_profile": "https://Stackoverflow.com/users/1185115", "pm_score": 0, "selected": false, "text": "if(employeeNumberText.Text != \"\")\n db.AddInParameter(dbCommand, \"in_employeeNumber\", DbType.String, employeeN...
2008/11/13
[ "https://Stackoverflow.com/questions/287585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8741/" ]
287,587
<p>I have the following code, I'm trying to get a table with 4 columns across. If I run out of columns, create a new row and make 4 more coumns. rinse. lather. repeat.</p> <pre><code>&lt;tbody&gt; &lt;% int i = 0; foreach (ItmXtnMultimedia multimedia in ViewData.Model.ItmXtnMultimedia) { if (i%4 == 0 &amp;&amp; i== 0) { %&gt;&lt;tr&gt;&lt;% } if (i%4 == 0 &amp;&amp; i != 0) { %&gt;&lt;/tr&gt;&lt;tr&gt;&lt;% } %&gt; &lt;td&gt;&lt;%= multimedia.ImgTag100 %&gt;&lt;/td&gt; &lt;% i++; } %&gt; </code></pre> <p></p> <p>It works, but it sucks. Is there something built in to the framework or an extension method I can use? I guess I could roll my own, but figured there had to be something out there.</p>
[ { "answer_id": 287667, "author": "Ian P", "author_id": 10853, "author_profile": "https://Stackoverflow.com/users/10853", "pm_score": 0, "selected": false, "text": "foreach (ItmXtnMultimedia multimedia in ViewData.Model.ItmXtnMultimedia) \n{\n if (i%4 == 0 && i== 0)\n {\n %><tr><%\...
2008/11/13
[ "https://Stackoverflow.com/questions/287587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34133/" ]
287,588
<p>Why does the select statement below return two different values ?</p> <pre><code>declare @tempDec decimal set @tempDec = 1.0 / (1.0 + 1.0) select @tempDec, 1.0 / (1.0 + 1.0) </code></pre>
[ { "answer_id": 288285, "author": "Gordon Bell", "author_id": 16473, "author_profile": "https://Stackoverflow.com/users/16473", "pm_score": 3, "selected": true, "text": "convert(decimal, [col1]) / ([col2] + [col3])\n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/287588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16162/" ]
287,592
<p>Why does the following have the effect it does - it prints a terminal full of random characters and then exits leaving a command prompt that produces garbage when you type in it. (I tried it because I thought it would produce a seg fault).</p> <p><img src="https://i.stack.imgur.com/kGkf4.png" alt="http://oi38.tinypic.com/r9qxbt.jpg"></p> <pre><code>#include &lt;stdio.h&gt; int main(){ char* s = "lololololololol"; while(1){ printf("%c", *s); s++; } } </code></pre> <p>it was compiled with:</p> <pre>gcc -std=c99 hello.c</pre>
[ { "answer_id": 287607, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 3, "selected": false, "text": "while(1)" }, { "answer_id": 287820, "author": "John Rudy", "author_id": 14048, "author_profile": "https...
2008/11/13
[ "https://Stackoverflow.com/questions/287592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
287,594
<p>I have a rather simple scenario where I have two tables in which I want to add data. They are managed with primary key/foreign key. I want to add new data into TABLE A and then retrieve the Id and insert into TABLE B. </p> <p>I can certainly do it with a stored procedure, but I'm looking at trying to do it using Linq. </p> <p>What is the best approach ? </p> <p>I can certainly get the ID and do two separate inserts but that doesn't certainly seem to be a very good way of doing things.</p> <pre><code>db.Table.InsertOnSubmit(dbObject); db.SubmitChanges(); Int32 id = dbOject.Id; //Rest of the code </code></pre> <p>Any way to elegantly do this?</p>
[ { "answer_id": 313042, "author": "BigJoe714", "author_id": 37786, "author_profile": "https://Stackoverflow.com/users/37786", "pm_score": 5, "selected": true, "text": "Order order = new Order();\nOrder.OrderDate = DateTime.Now();\ndataContext.InsertOnSubmit(order);\n\nOrderItem item1 = ne...
2008/11/13
[ "https://Stackoverflow.com/questions/287594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31148/" ]
287,595
<p>This seems like a very simple and a very common problem. The simplest example I can think of is this:</p> <p>The form has five checkboxes with a "check all/check none" checkbox above them. When a user selects checking all checkboxes, I toggle the states of the "children" - obviously I don't want to fire the check events of all the children until I am done setting all of the checkboxes.</p> <p>I can't find a form-wide suspend control event. If I'm simply missing it then great simple answer. Barring a simple solution that I am just missing, what is the best way (best practice? accepted solution?) to suspend form control events?</p>
[ { "answer_id": 287659, "author": "Ryan Lundy", "author_id": 5486, "author_profile": "https://Stackoverflow.com/users/5486", "pm_score": 2, "selected": false, "text": "AddHandler chk1.CheckedChanged, AddressOf DoSomething\n" }, { "answer_id": 287671, "author": "Rob Stevenson-L...
2008/11/13
[ "https://Stackoverflow.com/questions/287595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35555/" ]
287,596
<p>Is it safe to use MS SQL's WITH (NOLOCK) option for select statements and insert statements if you never modify a row, but only insert or delete rows?</p> <p>I..e you never do an UPDATE to any of the rows.</p>
[ { "answer_id": 287635, "author": "Tom H", "author_id": 5696608, "author_profile": "https://Stackoverflow.com/users/5696608", "pm_score": 4, "selected": true, "text": "SELECT\n my_id,\n my_date\nFROM\n My_Table\nWHERE\n my_date >= '2008-01-01'\n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/287596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
287,597
<p>If a hacker has access to the hashes in my DB, he has access to the rest of the information in the DB anyways. So why would he bother trying to decrypt the passwords? Should I be storing the passwords on a different server to the rest of my data? That is the only scenario in which I can envision it being useful. </p>
[ { "answer_id": 16133410, "author": "bobobobo", "author_id": 111307, "author_profile": "https://Stackoverflow.com/users/111307", "pm_score": 0, "selected": false, "text": "SELECT * FROM USERS" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/287597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37412/" ]
287,630
<p>I have a right outer join, that almost does what I want...</p> <pre><code>SELECT users_usr.firstname_usr, users_usr.lastname_usr, credit_acc.given_credit_acc, users_usr.created_usr, users_usr.sitenum_usr, users_usr.original_aff_usr, users_usr.id_usr FROM credit_acc right Outer Join users_usr ON credit_acc.uid_usr = users_usr.id_usr </code></pre> <p>The problem is, I want to add a </p> <pre><code>where credit_acc.type_acc = 'init' </code></pre> <p>But this gets rid of all users who don't have a row in credit_acc... which is WHY I need a right outer join.</p> <p>Is there a way to get this without having to do two queries and a union?</p>
[ { "answer_id": 287638, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 3, "selected": true, "text": "SELECT\nusers_usr.firstname_usr,\nusers_usr.lastname_usr,\ncredit_acc.given_credit_acc,\nusers_usr.created_usr,\nuser...
2008/11/13
[ "https://Stackoverflow.com/questions/287630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13704/" ]
287,633
<p>Is it possible to do a "C like" fork in java, using an new independent jvm process ?</p> <p>How?</p>
[ { "answer_id": 21028141, "author": "Markus Malkusch", "author_id": 1346207, "author_profile": "https://Stackoverflow.com/users/1346207", "pm_score": 2, "selected": false, "text": "Isolate" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/287633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28921/" ]
287,645
<p>I want to discover at run-time ONLY the static Methods of a class, how can I do this? Or, how to differentiate between static and non-static methods.</p>
[ { "answer_id": 287654, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 9, "selected": true, "text": "Modifier.isStatic(method.getModifiers())" }, { "answer_id": 287674, "author": "Daniel Spiewak", ...
2008/11/13
[ "https://Stackoverflow.com/questions/287645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/518/" ]
287,655
<p>In OpenGL I'm trying to rotate a camera around a point, with camera being distance r from the point and facing the point when it rotates. In other words, I want the camera to move along the circumference of a circle at a radius r from the center, with the camera facing the center at any point along the circumference.</p> <p>Lets say that in 3d space the center of the circle is (3, 0, 3);</p> <p>I've tried:</p> <pre><code>// move to center of circle glTranslatef(-3, 0, -3) // move a distance away from the circle glTranslatef(0, 0, r); // rotate along the y "up" axis glRotatef(CameraAngle, 0, 1, 0); </code></pre> <p>where CameraAngle is the degrees being moved around the circle.</p> <p>My end result is the camera is still rotating along the origin, not the center of the circle. Can anyone help me fix this problem? Thanks!</p>
[ { "answer_id": 287675, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 6, "selected": true, "text": "gluLookAt" }, { "answer_id": 712850, "author": "neoedmund", "author_id": 86600, "author_profile": "https:...
2008/11/13
[ "https://Stackoverflow.com/questions/287655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/396/" ]
287,663
<p>I have 2 handlers using the same form. How do I remove the handlers before adding the new one (C#)?</p>
[ { "answer_id": 287694, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 4, "selected": true, "text": "Delegate[] events = Form1.SomeEvent.GetInvokationList();\n\nforeach (Delegate d in events)\n{\n Form1.SomeEvent -= d;\n}\...
2008/11/13
[ "https://Stackoverflow.com/questions/287663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6013/" ]
287,679
<p>How do I create tabbed navigation with the "Current" tab highlighted in the UI?</p>
[ { "answer_id": 287688, "author": "Kyle West", "author_id": 34133, "author_profile": "https://Stackoverflow.com/users/34133", "pm_score": 4, "selected": true, "text": "public partial class AdminNavigation : ViewUserControl\n{\n /// <summary>\n /// This hold a collection of controlle...
2008/11/13
[ "https://Stackoverflow.com/questions/287679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34133/" ]
287,684
<p>I'm using this simple regular expression to validate a hex string:</p> <pre><code>^[A-Fa-f0-9]{16}$ </code></pre> <p>As you can see, I'm using a quantifier to validate that the string is 16 characters long. I was wondering if I can use another quantifier in the same regex to validate the string length to be either 16 or 18 (not 17).</p>
[ { "answer_id": 287687, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": false, "text": "^(?:[A-Fa-f0-9]{16}|[A-Fa-f0-9]{18})$\n" }, { "answer_id": 287692, "author": "Jon Skeet", "author_id": 22656, ...
2008/11/13
[ "https://Stackoverflow.com/questions/287684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24927/" ]
287,685
<p>I have a bunch of controls (textbox and combobox) on a form with toolstripcontainer and toolstripbuttons for save, cancel etc for edits. We are using .Net 3.5 SP1<br> There is bunch of logic written in control.lostfocus and control.leave events. These events are not being called when clicked on the toolstrip buttons. Is there a way to call these events manually when any of these buttons are pressed.</p> <p>Thanks.<br> Kishore</p> <p>[Edit]</p> <p>This is how I solved the problem. Thanks <em><a href="https://stackoverflow.com/questions/287685/raise-lostfocus-event-on-a-control-manually-c#287740">Chris Marasti-Georg</a></em> for the pointer. In the button click event I calling focus on the toolstrip instead of the button as the toolstripbutton does not have a focus event. We can access the toolstrip on which the button is placed using</p> <p>((ToolStripButton)sender).Owner.Focus()</p> <p>-Kishore</p>
[ { "answer_id": 287740, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 3, "selected": true, "text": "private void ButtonClick(object sender, EventArgs e) {\n if(sender != null) {\n sender.Focus();\n }\n}\n...
2008/11/13
[ "https://Stackoverflow.com/questions/287685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18169/" ]
287,702
<p>I need to read data added to the end of an executable from within that executable .<br> On win32 I have a problem that I cannot open the .exe for reading. I have tried CreateFile and std::ifstream.<br> Is there a way of specifying non-exclusive read access to a file that wasn't initially opened with sharing.</p> <p>EDIT- Great thing about stackoverflow, you ask the wrong question and get the right answer.</p>
[ { "answer_id": 287742, "author": "Head Geek", "author_id": 12193, "author_profile": "https://Stackoverflow.com/users/12193", "pm_score": 1, "selected": false, "text": "HANDLE file=CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);\n" }, { "answer_id": 28...
2008/11/13
[ "https://Stackoverflow.com/questions/287702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10897/" ]
287,703
<p>I'm using IIS 6 with EPiserver CMS which requires all requests to go through aspnet_isapi.dll.</p> <p>I want to gzip all my static files (js, css mainly). Trying to setup compression in IIS didn't work.</p> <p>Is there a setting in EPiServer that will allow me to achieve this? Can .net framework compress files automatically?</p>
[ { "answer_id": 287771, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 3, "selected": true, "text": "HcScriptFileExtensions=\"asp\ndll \nexe \njs\ncss\"\n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/287703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29555/" ]
287,708
<p>I am looking for any best practices or ideas on how you would create an interface with a DB from a .NET web application to upload data from Excel files Should I use a mechanism that allows all the records to be loaded and flags the errors or should I use a mechanism that stops the load when an error occurs.</p> <p>I've never had to deal with this type of requirement before so any help would be super!</p> <p>Thanks</p>
[ { "answer_id": 287749, "author": "ConcernedOfTunbridgeWells", "author_id": 15401, "author_profile": "https://Stackoverflow.com/users/15401", "pm_score": 2, "selected": false, "text": " public void Load() {\n bool OK = File.Exists(_filename);\n if (OK) {\n string...
2008/11/13
[ "https://Stackoverflow.com/questions/287708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12255/" ]
287,713
<p>I thought this code would work, but the regular expression doesn't ever match the \r\n. I have viewed the data I am reading in a hex editor and verified there really is a hex D and hex A pattern in the file.</p> <p>I have also tried the regular expressions /\xD\xA/m and /\x0D\x0A/m but they also didn't match.</p> <p>This is my code right now:</p> <pre><code> lines2 = lines.gsub( /\r\n/m, "\n" ) if ( lines == lines2 ) print "still the same\n" else print "made the change\n" end </code></pre> <p>In addition to alternatives, it would be nice to know what I'm doing wrong (to facilitate some learning on my part). :)</p>
[ { "answer_id": 287735, "author": "Cameron Price", "author_id": 35526, "author_profile": "https://Stackoverflow.com/users/35526", "pm_score": 4, "selected": false, "text": "lines2 = lines.split.join(\"\\n\")\n" }, { "answer_id": 287739, "author": "mwilliams", "author_id": ...
2008/11/13
[ "https://Stackoverflow.com/questions/287713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7893/" ]
287,750
<p>I have a webpage where I want the user to see a new image when they put thier mouse over a certain part of the image. I used an image map.</p> <pre><code>&lt;img src="pic.jpg" usemap="#picmap" /&gt; &lt;map id="picmap" name="picmap"&gt;&lt;area shape="rect" coords ="10,20,30,40" onMouseOver="mouse_on_write('mouse is on spot')" onMouseOut="mouse_off('mouse is off spot')" href="http://www....html" target="_blank" /&gt; &lt;/map&gt; &lt;p id="desc"&gt;&lt;/p&gt; </code></pre> <p>Where in the header I defined these functions:</p> <pre><code> &lt;script type="text/javascript"&gt; function mouse_off(txt) { document.getElementById("desc").innerHTML=txt; document.p1.src="pic.jpg"; } function mouse_on_write(txt) { document.getElementById("desc").innerHTML=txt; document.p1.src="pic2.jpg"; &lt;/script&gt; </code></pre> <p>It works, but it is slow. When the mouse is put over the second image it takes some few seconds to appear; my temporary solution was to drastically reduce the size of the images because they were huge (at 2.5mb they switch fast now, but still not seamless). <strong>How can I make the image switching more seamless without reduction in picture quality?</strong> On second thought I realize that I could also just have both images displayed, at a small and a large scale, and <strong>on mouse over they would switch places; How would I do this?</strong> Would this reduce lag? </p>
[ { "answer_id": 287766, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 1, "selected": false, "text": "function preloadImage(imagePath)\n{\n var img = document.createElement('IMG');\n img.src = imagePath; \n}\n\npr...
2008/11/13
[ "https://Stackoverflow.com/questions/287750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30181/" ]
287,757
<p>I read the part of <a href="http://docs.python.org/library/configparser.html" rel="noreferrer">the docs</a> and saw that the <code>ConfigParser</code> returns a list of key/value pairs for the options within a section. I figured that keys did not need to be unique within a section, otherwise the parser would just return a mapping. I designed my config file schema around this assumption, then sadly realized that this is not the case:</p> <pre><code>&gt;&gt;&gt; from ConfigParser import ConfigParser &gt;&gt;&gt; from StringIO import StringIO &gt;&gt;&gt; fh = StringIO(""" ... [Some Section] ... spam: eggs ... spam: ham ... """) &gt;&gt;&gt; parser = ConfigParser() &gt;&gt;&gt; parser.readfp(fh) &gt;&gt;&gt; print parser.items('Some Section') [('spam', 'ham')] </code></pre> <p>Then I went back and found the part of the docs that I <em>should</em> have read:</p> <blockquote> <p>Sections are normally stored in a builtin dictionary. An alternative dictionary type can be passed to the ConfigParser constructor. For example, if a dictionary type is passed that sorts its keys, the sections will be sorted on write-back, as will be the keys within each section.</p> </blockquote> <p>To keep my existing configuration file scheme (which I really like now ;) I'm thinking of passing a mapping-like object as mentioned above that accumulates values instead of clobbering them. Is there a simpler way to prevent key/value collapse that I'm missing? Instead of making a crazy adapter (that could break if <code>ConfigParser</code>'s implementation changes) should I just write a variant of the <code>ConfigParser</code> itself?</p> <p>I feel like this may be one of those 'duh' moments where I'm only seeing the difficult solutions.</p> <p><strong>[Edit:]</strong> Here's a more precise example of how I'd like to use the same key multiple times:</p> <pre><code>[Ignored Paths] ignore-extension: .swp ignore-filename: tags ignore-directory: bin </code></pre> <p>I dislike the comma-delimited-list syntax because it's hard on the eyes when you scale it to many values; for example, a comma delimited list of fifty extensions would not be particularly readable.</p>
[ { "answer_id": 287942, "author": "Jeremy Cantrell", "author_id": 18866, "author_profile": "https://Stackoverflow.com/users/18866", "pm_score": 4, "selected": true, "text": "[('spam', 'eggs'), ('spam', 'ham')]\n" }, { "answer_id": 13340655, "author": "anatoly techtonik", "...
2008/11/13
[ "https://Stackoverflow.com/questions/287757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
287,783
<p>I am using an ancient version of Oracle (8.something) and my ADO.NET application needs to do some fairly large transactions. Large enough to not fin in our small rollback segments. Now we have a large rollback segment as well but it is not used by default.</p> <p>Oracle has a command to select the rollback segment to be used (<code>SET TRANSACTION USE ROLLBACK SEGMENT MY_ROLLBACK_SEGMENT</code>) but it needs to be the first command issued in the transaction. Unfortunately, it seems that ADO.NET issues some other commands at the beginning of a transaction since issuing this command right after .BeginTransaction() throws an error about SET TRANSACTION not being the first command.</p> <p>I am sure I am not the only one who faced this issue. How do you solve it or how would you get around it?</p> <p>Thanks</p>
[ { "answer_id": 289832, "author": "pablo", "author_id": 16112, "author_profile": "https://Stackoverflow.com/users/16112", "pm_score": 2, "selected": true, "text": "ALTER ROLLBACK SEGMENT <name> OFFLINE;\n\nALTER ROLLBACK SEGMENT <name> ONLINE;\n" }, { "answer_id": 291629, "aut...
2008/11/13
[ "https://Stackoverflow.com/questions/287783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8954/" ]
287,789
<p>I have a huge file that I must parse line by line. Speed is of the essence. </p> <p>Example of a line:</p> <blockquote> <pre><code>Token-1 Here-is-the-Next-Token Last-Token-on-Line ^ ^ Current Position Position after GetToken </code></pre> </blockquote> <p>GetToken is called, returning "Here-is-the-Next-Token" and sets the CurrentPosition to the position of the last character of the token so that it is ready for the next call to GetToken. Tokens are separated by one or more spaces.</p> <p>Assume the file is already in a StringList in memory. It fits in memory easily, say 200 MB.</p> <p>I am worried only about the execution time for the parsing. What code will produce the absolute fastest execution in Delphi (Pascal)?</p>
[ { "answer_id": 287808, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 2, "selected": false, "text": "state := 0;\nresult := tkNoToken;\nwhile (result = tkNoToken) do begin\n if table[state].c1 > table[state].c2 then\n...
2008/11/13
[ "https://Stackoverflow.com/questions/287789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30176/" ]
287,794
<p>How should a relational database be designed to handle multi-valued attributes ?</p> <p><strong>edit</strong>: To elaborate: </p> <p>There are two ways I could think of for doing this -</p> <ol> <li>Trying something like putting comma separated values in the field, which appears a bit clumsy.</li> <li>Create another table for the field and let the multiple values go to the field. This might lead to very large number of tables, if I have too many fields of this kind.</li> </ol> <p>The question is:</p> <ol> <li>Are there any more ways of handling this?</li> <li>Which of the above two methods is generally used?</li> </ol> <p>Thanks in advance</p>
[ { "answer_id": 287836, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 4, "selected": false, "text": "CREATE TABLE team (\n team_id INT PRIMARY KEY,\n team_name VARCHAR(50),\n team_members VARCHAR(200)\n);\nIN...
2008/11/13
[ "https://Stackoverflow.com/questions/287794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30252/" ]
287,797
<p>Recently an application I wrote started not working on Internet Explorer. There has been no change to the underlying (ruby on rails) code.</p> <p>In IE 6 or IE 7, I can make one request (HTTP Post) to the app, but when I try to make a 2nd request, I get an "Operation Aborted" message. Everything works fine in firefox. The HTTP Request and Response headers are exactly the same. The response header for the correct and incorrect results both have the same content-length (about 104k). The correct response has the full content, but the incorrect response has the content cut off after bout 40k. (So about 65k of the response is just gone.)</p> <p>The even trickier thing is that if I use the IP address instead of the domain name to make the request, everything works great.</p> <p>This is an apache2 web server.</p> <p>Any ideas?</p>
[ { "answer_id": 287831, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 4, "selected": true, "text": "http://<Web site>.com" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/287797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1486/" ]
287,811
<p>I'm working with an existing Java codebase which, while it can be invoked from an HTML page using an &lt;APPLET&gt; tag, does not actually subclass the Applet class. The same jars are also used in a non-browser context, so they did not subclass Applet.</p> <p>Now I need to communicate some values from Java back to the Javascript of the invoking page. Normally one would do this using JSObject, but so far as I can one has to use JSObject.getWindow which only works for subclasses of Applet.</p> <p>Is there either:</p> <ul> <li>a way to use JSObject from something which isn't an Applet subclass?</li> <li>some other mechanism to communicate back to the Javascript of the invoking page?</li> </ul>
[ { "answer_id": 287833, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 2, "selected": false, "text": "JSObject.getWindow(this)" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/287811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4761/" ]
287,828
<p>Is there an .net c# wrapper for the libFLAC library? If not, how can I read FLAC tags using the libFLAC in a .net framework c# application? If neither, are there other opensource libraries to read flac tags in c#? </p> <p>Thanks!</p>
[ { "answer_id": 38485614, "author": "Yoda", "author_id": 3941350, "author_profile": "https://Stackoverflow.com/users/3941350", "pm_score": 2, "selected": false, "text": "SortedList<string, List<string>>" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/287828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26754/" ]
287,832
<p>I am creating a form in HTML that will be printed, with fields that need to be written in by the recipient. Basically what I want is a single line that stretches from the end of the field label to the side of the page. Here's how I'm doing it right now:</p> <pre><code>&lt;table width="100%"&gt; &lt;tr&gt; &lt;td width="1%"&gt; Label: &lt;/td&gt; &lt;td style="border-bottom-style:solid; border-bottom-width:1px;"&gt; &amp;nbsp; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>This works, but there must be an easier way to do this without needing a whole table element. Any ideas?</p>
[ { "answer_id": 287838, "author": "billjamesdev", "author_id": 13824, "author_profile": "https://Stackoverflow.com/users/13824", "pm_score": 2, "selected": false, "text": "<span style=\"border-bottom....\">Text</span>\n" }, { "answer_id": 287847, "author": "Jon Smock", "au...
2008/11/13
[ "https://Stackoverflow.com/questions/287832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23935/" ]
287,839
<p>[former title: Is there a way to force a relationship structure on a tag-based organizational methodology?]</p> <p>I have some entities, and they have a series of attributes. Some of the attributes affect what other attributes the entity can have, many of the attributes are organized into groups, and occasionally entities are requited to have certain numbers of attributes from certain groups, or possibly a range of attributes from certain groups.</p> <p>Is there a way to model these sorts of tag-to-tag relationships, such as requirement, grouping, exclusion, etc. using a database, or is this only possible with programmed "business rules"? Ideally, I would like the possible tags and their relationships to be easily configurable, and hence highly flexible.</p> <p>One of the ways I have considered is to have the tags and possible relationships, and then you get a tag-tag-applied relationship sort of table, but this seems like a rather brittle approach.</p> <p>So, is this possible in a more rigorous fashion, and if so, how would I even begin to go about it?</p>
[ { "answer_id": 287977, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 3, "selected": true, "text": "CREATE TABLE Vehicles (\n vehicle_id INT PRIMARY KEY\n ...attributes common to all vehicles...\n);\n\nCREATE TABLE Au...
2008/11/13
[ "https://Stackoverflow.com/questions/287839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20770/" ]
287,842
<p>If you have to use String.Replace() to replace test 50 times, you essentially have to create a new string 50 times. Does StringBuilder.Replace() do this more efficiently? E.g., should I use a StringBuilder if I'm going to be replacing a lot of text, even while I won't be appending any data to it?</p> <p>I'm using .NET, but I assume this would be the same as Java and possibly other languages.</p>
[ { "answer_id": 287854, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 3, "selected": false, "text": "String.Replace" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/287842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/681/" ]
287,845
<p>I have a fair number of Python scripts that contain reusable code that are used and referenced by other Python scripts. However, these scripts tend to be scattered across different directories and I find it to be somewhat tedious to have to include (most often multiple) calls to sys.path.append on my top-level scripts. I just want to provide the 'import' statements without the additional file references in the same script.</p> <p>Currently, I have this:</p> <pre><code>import sys sys.path.append('..//shared1//reusable_foo') import Foo sys.path.append('..//shared2//reusable_bar') import Bar </code></pre> <p>My preference would be the following:</p> <pre><code>import Foo import Bar </code></pre> <p>My background is primarily in the .NET platform so I am accustomed to having meta files such as *.csproj, *.vbproj, *.sln, etc. to manage and contain the actual file path references outside of the source files. This allows me to just provide 'using' directives (equivalent to Python's import) without exposing all of the references and allowing for reuse of the path references themselves across multiple scripts.</p> <p>Does Python have equivalent support for this and, if not, what are some techniques and approaches?</p>
[ { "answer_id": 287884, "author": "bouvard", "author_id": 24608, "author_profile": "https://Stackoverflow.com/users/24608", "pm_score": 2, "selected": false, "text": "__init__.py" }, { "answer_id": 288123, "author": "S.Lott", "author_id": 10661, "author_profile": "http...
2008/11/13
[ "https://Stackoverflow.com/questions/287845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
287,849
<p>I'm trying to replace the programs that run from my startup directory with a batch script. The batch script will simply warn me that the programs are going to run and I can either continue running the script or stop it. </p> <p>Here's the script as I have written so far:</p> <pre><code>@echo off echo You are about to run startup programs! pause ::load outlook cmd /k "C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE" /recycle ::load Visual Studio 2008 call "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" </code></pre> <p>Both of these commands will load the first program and wait until I close it to load the second. I want the script to load the processes simultaneously. How do I accomplish this?</p> <p>Edit: When I use the start command it opens up a new shell with the string that I typed in as the title. The edited script looks like this:</p> <pre><code>start "C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE" ::load Visual Studio 2008 start "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" </code></pre>
[ { "answer_id": 287866, "author": "Carl Seleborg", "author_id": 2095, "author_profile": "https://Stackoverflow.com/users/2095", "pm_score": 2, "selected": false, "text": "start" }, { "answer_id": 287943, "author": "aphoria", "author_id": 2441, "author_profile": "https:...
2008/11/13
[ "https://Stackoverflow.com/questions/287849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2916/" ]
287,871
<p>How do I output colored text to the terminal in Python?</p>
[ { "answer_id": 287896, "author": "UberJumper", "author_id": 34395, "author_profile": "https://Stackoverflow.com/users/34395", "pm_score": 5, "selected": false, "text": "#\n" }, { "answer_id": 287919, "author": "daharon", "author_id": 23597, "author_profile": "https://...
2008/11/13
[ "https://Stackoverflow.com/questions/287871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35062/" ]
287,875
<p>I'm trying to come up with a reusable JS or jQuery function that would allow me to test if one object is a DOM descendant of another. </p> <p>I've seen a model of testing for </p> <pre><code>$b.parents('nodename').length&gt;0 </code></pre> <p>Which is fantastic when you only need to check if an element is a child of any node by that name.</p> <p>But what about a specific node? You can't test</p> <pre><code>$b.parents($a).length&gt;0 </code></pre> <p>Because jQuery parents takes a nodename expression as an argument to filter.</p> <p>As a little background, I'm trying to test if a document click event's target is a child of a specific object. For instance, if the event.target is a child of $b, return true, otherwise, return false. But this function could have other implications later on.</p> <p>Thanks!</p>
[ { "answer_id": 287889, "author": "picardo", "author_id": 32816, "author_profile": "https://Stackoverflow.com/users/32816", "pm_score": 2, "selected": false, "text": "$('#foo').filter(function(){\n\n return $(this).parent().is('#foo-parent');\n\n});\n" }, { "answer_id": 287923, ...
2008/11/13
[ "https://Stackoverflow.com/questions/287875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37429/" ]
287,897
<p>I have a .NET 3.5 Web application on VS 2008 SP1 running on Vista Ultimate 32 SP1. I created an Application under the Default Web Site. So the url to the app is "<a href="http://localhost/mysite" rel="noreferrer">http://localhost/mysite</a>". The application folder is pointing to the solution folder and it is outside the iisroot folder. Anonymous and Integrated Auth (Windows) is enabled in IIS7 for this web application "mysite".</p> <p>I gave full permissions to "Network Service" user to the application folder (which is outside of iisroot).</p> <p>When I hit F5 to star debugging, I get the "Unable to start debugging on the web server. The web server could not find the requested resource." error.</p> <hr> <p>I fired up TcpView (Sysinternals) to see what app is actually running and keeping an handle on that port and I found out there is no app listening on that port. This is really weird... Any creative ideas?</p> <hr> <p>I can hit the URL "<a href="http://localhost/mysite" rel="noreferrer">http://localhost/mysite</a>" without a problem. That web application is set up to be the start up project and Default.aspx is the start up page.</p> <p>There is an .asmx service in the prject as well. The Default.aspx is making use of that asmx service. The AutoCompleteExtender (From the AJAX Control Toolkit) is using this asmx service.</p> <p>Everything works by the way. The issue is the debugging... I suspect the asmx service is causing this but i don't know. This is driving me nuts...</p>
[ { "answer_id": 13691092, "author": "Chuck Savage", "author_id": 353147, "author_profile": "https://Stackoverflow.com/users/353147", "pm_score": 5, "selected": false, "text": "Asp.Net 3.5" }, { "answer_id": 17152725, "author": "Ciaran", "author_id": 65765, "author_prof...
2008/11/13
[ "https://Stackoverflow.com/questions/287897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35609/" ]
287,899
<p>Can anyone think of a good solution for getting IOC into a console application?</p> <p>At the moment we are just using a static class with the following method:</p> <pre><code>public static T Resolve&lt;T&gt;() { return dependencyResolver.Resolve&lt;T&gt;(); } </code></pre> <p>I would like the experience to be seamless but cannot think of a way of achieving this from a console application.</p>
[ { "answer_id": 433902, "author": "Matt Hinze", "author_id": 2676, "author_profile": "https://Stackoverflow.com/users/2676", "pm_score": 4, "selected": true, "text": "Resolve<T>()" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/287899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11755/" ]
287,903
<p>Would the following make the objects fulfil all characteristics that enums have in JavaScript? Something like:</p> <pre class="lang-js prettyprint-override"><code>my.namespace.ColorEnum = { RED : 0, GREEN : 1, BLUE : 2 } // later on if(currentColor == my.namespace.ColorEnum.RED) { // whatever } </code></pre> <p>Or is there some other way I can do this?</p>
[ { "answer_id": 1314191, "author": "Randolpho", "author_id": 12716, "author_profile": "https://Stackoverflow.com/users/12716", "pm_score": 7, "selected": false, "text": "var DaysEnum = {\"monday\":1, \"tuesday\":2, \"wednesday\":3, ...}\n\nDocument.Write(\"Enumerant: \" + DaysEnum.tuesday...
2008/11/13
[ "https://Stackoverflow.com/questions/287903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5309/" ]
287,907
<p>I want to transfer data between a smart phone app and a website. What are the conventional and not-so-conventional ways of doing it? </p> <p>Here's what I have thought of so far:</p> <ol> <li>Simple HTTP GET/POST with data being represented as JSON array string, variations of this being encrypted/compressed string as parameter.</li> <li>Webservice calls ( I am not sure if this is even possible, just a guess)</li> <li>Two step communication : Smartphone to/fro Desktop App to/fro Website) (Cumbersome to develop/use)</li> </ol> <p>Also, what do I need to consider to avoid spamming/snooping?</p>
[ { "answer_id": 1314191, "author": "Randolpho", "author_id": 12716, "author_profile": "https://Stackoverflow.com/users/12716", "pm_score": 7, "selected": false, "text": "var DaysEnum = {\"monday\":1, \"tuesday\":2, \"wednesday\":3, ...}\n\nDocument.Write(\"Enumerant: \" + DaysEnum.tuesday...
2008/11/13
[ "https://Stackoverflow.com/questions/287907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16071/" ]
287,928
<p>DataGridView, for example, lets you do this:</p> <pre><code>DataGridView dgv = ...; DataGridViewCell cell = dgv[1,5]; </code></pre> <p>but for the life of me I can't find the documentation on the index/square-bracket operator. What do they call it? Where is it implemented? Can it throw? How can I do the same thing in my own classes?</p> <p>ETA: Thanks for all the quick answers. Briefly: the relevant documentation is under the "Item" property; the way to overload is by declaring a property like <code>public object this[int x, int y]{ get{...}; set{...} }</code>; the indexer for DataGridView does not throw, at least according to the documentation. It doesn't mention what happens if you supply invalid coordinates.</p> <p>ETA Again: OK, even though the documentation makes no mention of it (naughty Microsoft!), it turns out that the indexer for DataGridView will in fact throw an ArgumentOutOfRangeException if you supply it with invalid coordinates. Fair warning.</p>
[ { "answer_id": 287938, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 5, "selected": false, "text": "Operators Overloadability\n\n+, -, *, /, %, &, |, <<, >> All C# binary operat...
2008/11/13
[ "https://Stackoverflow.com/questions/287928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26286/" ]
287,954
<p>To add a NOT NULL Column to a table with many records, a DEFAULT constraint needs to be applied. This constraint causes the entire ALTER TABLE command to take a long time to run if the table is very large. This is because:</p> <p>Assumptions:</p> <ol> <li>The DEFAULT constraint modifies existing records. This means that the db needs to increase the size of each record, which causes it to shift records on full data-pages to other data-pages and that takes time.</li> <li>The DEFAULT update executes as an atomic transaction. This means that the transaction log will need to be grown so that a roll-back can be executed if necessary.</li> <li>The transaction log keeps track of the entire record. Therefore, even though only a single field is modified, the space needed by the log will be based on the size of the entire record multiplied by the # of existing records. This means that adding a column to a table with small records will be faster than adding a column to a table with large records even if the total # of records are the same for both tables.</li> </ol> <p>Possible solutions:</p> <ol> <li>Suck it up and wait for the process to complete. Just make sure to set the timeout period to be very long. The problem with this is that it may take hours or days to do depending on the # of records.</li> <li>Add the column but allow NULL. Afterward, run an UPDATE query to set the DEFAULT value for existing rows. Do not do UPDATE *. Update batches of records at a time or you'll end up with the same problem as solution #1. The problem with this approach is that you end up with a column that allows NULL when you know that this is an unnecessary option. I believe that there are some best practice documents out there that says that you should not have columns that allow NULL unless it's necessary.</li> <li>Create a new table with the same schema. Add the column to that schema. Transfer the data over from the original table. Drop the original table and rename the new table. I'm not certain how this is any better than #1.</li> </ol> <p>Questions:</p> <ol> <li>Are my assumptions correct? </li> <li>Are these my only solutions? If so, which one is the best? I f not, what else could I do?</li> </ol>
[ { "answer_id": 288717, "author": "Grzegorz Gierlik", "author_id": 1483, "author_profile": "https://Stackoverflow.com/users/1483", "pm_score": -1, "selected": false, "text": "-- without NOT NULL constrain -- we will add it in the end\nALTER TABLE table ADD new_column INT DEFAULT 0\n\nDECL...
2008/11/13
[ "https://Stackoverflow.com/questions/287954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13484/" ]
287,960
<p>I know that jQuery and prototype have a $.each() function for iterating over each element in an array. Does YUI offer any help with this?</p>
[ { "answer_id": 288083, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": false, "text": "for(var i=0; i<ary.length; i++)\n // assuming that ary[] contains objects with a DoSometing() method\n ary[i].doSomethin...
2008/11/13
[ "https://Stackoverflow.com/questions/287960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
287,965
<p>I have two tables: Client(id,name,...)<br> Purchase(id,item,date,client_id,...)</p> <p>They have their respective Model, with their validations. What I need is to create a new client with a new purchase, all into the create method of Client controller. Something like this:</p> <pre><code>def create @client = Client.new(params[:client]) respond_to do |format| if @client.save # Add purchase @sell = Purchase.new @sell.client_id = @client.id @sell.date = params[:date] # Fill another fields if @sell.save # Do another stuff... else format.html { render :action =&gt; "new" } format.xml { render :xml =&gt; @client.errors, :status =&gt; :unprocessable_entity } end flash[:notice] = 'You have a new client!' format.html { redirect_to(:action =&gt; :show, :id =&gt; @evento.id) } format.xml { render :xml =&gt; @client, :status =&gt; :created, :location =&gt; @client } else format.html { render :action =&gt; "new" } format.xml { render :xml =&gt; @evento.client, :status =&gt; :unprocessable_entity } end end end </code></pre> <p>In Purchase's model I have:</p> <pre><code>belongs_to :client validates_format_of :date, :with =&gt; /^20[0-9]{2}[-][0-9]{2}[-][0-9]{2}$/, :message =&gt; 'not valid' validates_presence_of :date </code></pre> <p>And there is my problem: how can I validate the date input, through validations into the model, from Client controller? And, how can I rollback the new client created when errors?</p> <p>Yes, I can do the check as the very first instruction in the method, with a regular expression, but I think it's ugly. I feel like might exist a conventional method for doing this validation or even doing all the stuff in another way (i.e. calling create method for Purchase from Client controller).</p> <p>Can you put me back in the right way?</p> <p>Thank you in advance.</p>
[ { "answer_id": 288026, "author": "mwilliams", "author_id": 23909, "author_profile": "https://Stackoverflow.com/users/23909", "pm_score": 3, "selected": true, "text": "Client.purchases.empty?\nClient.purchases.size,\nClient.purchases\nClient.purchases<<(purchase)\nClient.purchases.delete(...
2008/11/13
[ "https://Stackoverflow.com/questions/287965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36599/" ]
287,976
<p>I'd like to make an (MS)SQL query that returns something like this:</p> <pre><code>Col1 Col2 Col3 ---- --------------------- ------ AAA 18.92 18.92 BBB 20.00 40.00 AAA 30.84 30.84 BBB 06.00 12.00 AAA 30.84 30.84 AAA 46.79 46.79 AAA 86.40 86.40 </code></pre> <p>where Col3 is equal to Col2 when Col1 = AAA and Col3 is twice Col2 when Col1 = BBB. Can someone point me in the rigth direction please?</p>
[ { "answer_id": 287982, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 6, "selected": true, "text": "SELECT Col1, Col2, \n CASE WHEN Col1='AAA' THEN Col2 WHEN Col1='BBB' THEN Col2*2 ELSE NULL END AS Col3\nFROM ...\n" ...
2008/11/13
[ "https://Stackoverflow.com/questions/287976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34632/" ]
287,986
<p>Ruby on Rails controllers will automatically convert parameters to an array if they have a specific format, like so:</p> <pre><code>http://foo.com?x[]=1&amp;x[]=5&amp;x[]=bar </code></pre> <p>This would get converted into the following array:</p> <pre><code>['1','5','bar'] </code></pre> <p>Is there any way I can do this with an ActionScript 3 HTTPService object, by using the request parameter? For example, It would be nice to do something like the following:</p> <pre><code>var s:HTTPService = new HTTPService(); s.request['x[]'] = 1; s.request['x[]'] = 5; s.request['x[]'] = 'bar'; </code></pre> <p>However, that will simply overwrite each value, resulting in only the last value being sent. Anyone have a better idea? I know I could just append stuff to the query string, but I'd like to do it in the POST body.</p>
[ { "answer_id": 288004, "author": "mmattax", "author_id": 1638, "author_profile": "https://Stackoverflow.com/users/1638", "pm_score": 1, "selected": false, "text": "\nvar s:HTTPService = new HTTPService();\ns.url = \"http://foo.com\";\ns.method = \"post\";\n// add listeners...\ns.addEvent...
2008/11/13
[ "https://Stackoverflow.com/questions/287986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19964/" ]
287,991
<p>How can I match (PCRE) everything inbetween two tags?</p> <p>I tried something like this:</p> <blockquote> <p>&lt;!--\s&#42;LoginStart\s&#42;--&gt;(.*)&lt;!--\s&#42;LoginEnd\s&#42;--&gt;</p> </blockquote> <p>But it didn't work out too well for me..</p> <p>I'm kind of new to regular expressions, so I was hoping if someone would be kind enough to explain to me how I would accomplish this, if its even possible with regular expressions.</p> <p>Thanks</p>
[ { "answer_id": 288006, "author": "John Fiala", "author_id": 9143, "author_profile": "https://Stackoverflow.com/users/9143", "pm_score": 1, "selected": false, "text": "'/<!--\\s*LoginStart\\s*-->(.*)<!--\\s*LoginEnd\\s*-->/Us'\n" }, { "answer_id": 288015, "author": "Owen", ...
2008/11/13
[ "https://Stackoverflow.com/questions/287991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37439/" ]
288,007
<pre><code>SELECT DISTINCT 'LRS-TECH 1' || rpad(code,7) || rpad('APPTYPE',30) || rpad(licensing_no,30) || rpad(' ',300) AS RECORD FROM APPS WHERE L_code = '1000' AND licensing_no IS NOT NULL </code></pre> <p>This seems to be the primary culprit in why I cannot export these records to a textfile in my development environment. Is there any way I can get this query to run quicker. It returns roughly 2000+ lines of text. </p>
[ { "answer_id": 289075, "author": "David Aldridge", "author_id": 6742, "author_profile": "https://Stackoverflow.com/users/6742", "pm_score": 2, "selected": false, "text": "explain plan for SELECT DISTINCT \n'LRS-TECH 1' || rpad(code,7) || rpad('APPTYPE',30) || \n rpad(licensing_no,30) ||...
2008/11/13
[ "https://Stackoverflow.com/questions/288007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
288,009
<p>So, I've been tasked with making a kiosk for the office for showing statistics about our SCRUM progress, build server status, rentability and so forth. It should ideally run a slideshow with bunch of different pages, some of them showing text, some showing graphs and so on. </p> <p>What is the best approach for this? I first thought of powerpoint, but It should be able to take the images from a webserver so I can automate the graph generation procedure. I would also like to take text from an external source when showing "Who broke the build" or some page like that.</p> <p>I have no doubt that ready-made systems exist, but I don't really know where to look for them.</p> <p>Is this easy/hard in powerpoint? Or are there an ubiquous app that everybody but me knows about?</p>
[ { "answer_id": 289219, "author": "dbr", "author_id": 745, "author_profile": "https://Stackoverflow.com/users/745", "pm_score": 3, "selected": true, "text": "<img>" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/288009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24610/" ]
288,020
<p>I found one source which successfully overrode <code>Time.strftime</code> like this:</p> <pre><code>class Time alias :old_strftime :strftime def strftime #do something old_strftime end end </code></pre> <p>The trouble is, <code>strftime</code> is an instance method. I need to override <code>Time.now</code> - a class method - in such away that any caller gets my new method, while the new method still calls the original <code>.now</code> method. I've looked at <code>alias_method</code> and have met with no success.</p>
[ { "answer_id": 288077, "author": "Austin Ziegler", "author_id": 36378, "author_profile": "https://Stackoverflow.com/users/36378", "pm_score": 2, "selected": false, "text": "class Time\n class << self\n alias_method :old_time_now, :now\n\n def now\n my_now = old_time_now\n ...
2008/11/13
[ "https://Stackoverflow.com/questions/288020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30997/" ]
288,027
<p>In Object Oriented Paradigm, I would create an object/conceptual model before I start implementing it using OO language.</p> <p>Is there anything parallel to object model in functional programming. Is it called functional model? or we create the same conceptual model in both the paradigm before implementing it in one of the language.. </p> <p>Are there articles/books where I can read about functional model in case it exist? </p> <p>or to put it in different way... even if we are using functional programming language, would we start with object model?</p>
[ { "answer_id": 333145, "author": "Daishiman", "author_id": 42345, "author_profile": "https://Stackoverflow.com/users/42345", "pm_score": 3, "selected": false, "text": "-nil\n-bin(left:bt, root: a, right:bt)\n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/288027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30917/" ]
288,034
<p>I need some help regarding algorithm for randomness. So Problem is.</p> <p>There are 50 events going to happen in 8 hours duration. Events can happen at random times. Now it means in each second there is a chance of event happening is 50/(8*60*60)= .001736. How can I do this with random generation algorithm?</p> <p>I can get random number </p> <pre><code>int r = rand(); double chance = r/RAND_MAX; if(chance &lt; 0.001736) then event happens else no event </code></pre> <p>But most of times rand() returns 0 and 0&lt;0.001736 and I am getting more events than required.</p> <p>Any suggestions?</p> <hr> <p>sorry I forget to mention I calculated chance as double chance = (static_cast )(r) / (static_cast)(RAND_MAX);</p> <hr> <p>It removed double from static_cast</p> <p>double chance = (double)r/(double)(RAND_MAX);</p>
[ { "answer_id": 288046, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "r" }, { "answer_id": 288133, "author": "Dan Dyer", "author_id": 5171, "author_profile": "https://Stac...
2008/11/13
[ "https://Stackoverflow.com/questions/288034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33411/" ]
288,038
<p>I'm writing a simple program to browse the local network and pass on filenames to mplayer using "system". However, sometimes filenames contain spaces or quotes. Obviously I could write my own function to escape those, but I'm not sure exactly what characters do or do not need escaping.</p> <p>Is there a function available in the CRT or somewhere in the linux headers to safely escape a string to pass to the command line ?</p>
[ { "answer_id": 288067, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 2, "selected": false, "text": "'...'" }, { "answer_id": 288071, "author": "Robert Gamble", "author_id": 25222, "author...
2008/11/13
[ "https://Stackoverflow.com/questions/288038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34014/" ]
288,044
<p>I am using a <code>ListView</code> to display the main screen of my application.<br> The main screen is essentially a <code>menu</code> to get into the different sections of application. Currently, I have the <code>ListView</code> whose contents are added programmatically in the <code>onCreate</code> method. </p> <p>Here is the code snippet that does this:</p> <pre><code>String[] mainItems = { "Inbox", "Projects", "Contexts", "Next Actions" } @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); setListAdapter(new ArrayAdapter&lt;String&gt;( this, android.R.layout.simple_list_item_1, mainItems)); registerForContextMenu(getListView()); } </code></pre> <p>So the menu is essentially just a bunch of nodes with the text contained in the mainItems array. I know that I can create an XML layout (i.e. <code>R.layout.mainMenu_item</code>) that has an ImageView and TextView in it, but I am unsure how to set the ImageView's icon. I have seen that there is a setImageResouce(int resId) method, but the way to use this when generating with an ArrayAdapter is eluding me. Is there a better way to do this?</p>
[ { "answer_id": 339021, "author": "jasonhudgins", "author_id": 24590, "author_profile": "https://Stackoverflow.com/users/24590", "pm_score": 5, "selected": true, "text": "public View getView(int position, View convertView, ViewGroup parent) {\n\n View row = inflater.inflate(R.layout.me...
2008/11/13
[ "https://Stackoverflow.com/questions/288044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37436/" ]
288,045
<p>I am accessing a .NET COM object from C++. I want to know the version information about this COM object. When I open the TLB in OLEVIEW.exe I can see the version information associated with the coclass. How can I access this information from C++? This is the information I get:</p> <pre><code>[ uuid(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX), version(1.0), custom(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX, XXXX) ] coclass XXXXXXXX{ [default] interface XXXXXXXX; interface _Object; interface XXXXXXXX; }; </code></pre>
[ { "answer_id": 339021, "author": "jasonhudgins", "author_id": 24590, "author_profile": "https://Stackoverflow.com/users/24590", "pm_score": 5, "selected": true, "text": "public View getView(int position, View convertView, ViewGroup parent) {\n\n View row = inflater.inflate(R.layout.me...
2008/11/13
[ "https://Stackoverflow.com/questions/288045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8661/" ]
288,047
<p>I have some UserControls that I created in ProjectA. I have ProjectB that has a windows form that I want to put the controls on. Both of these projects are in a single solution. There's a reference to ProjectA from ProjectB so it can "see" the UserControls.</p> <p>However, the UserControls do not show up in the toolbox for me to drag to the windows form.</p> <p>I've tried rebuilding. I've also deleted the 'bin' directory to force a rebuild-all.</p> <p>How do I get VS2008 to populate the toolbox with my UserControls?</p>
[ { "answer_id": 1672504, "author": "DavidMB", "author_id": 202441, "author_profile": "https://Stackoverflow.com/users/202441", "pm_score": 1, "selected": false, "text": "MyCustomControls" }, { "answer_id": 8235736, "author": "Dan7", "author_id": 232288, "author_profile...
2008/11/13
[ "https://Stackoverflow.com/questions/288047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9516/" ]
288,061
<p>I have often wondered why it is that non-English speaking programmers are forced to use a different language when programming when it would seem to be so easy to offer an IDE that could replace keywords with localized versions. Why can't the Germans use a "während..macht" loop?</p> <p>Do programmers in Japan, Germany, France, Spain, Botswana just make extensive use of macros/define statements to make life more tolerable or do they just get used to the functional significance of print, if, then, while, do, begin, end, var, double, function, etc?</p> <p>Perhaps the increased use of frameworks (J2EE/.NET) makes this more complicated, but it still seems worthwhile. On the other hand, if Klingon became the de-facto programming language in the US I'd probably regret suggesting this.</p>
[ { "answer_id": 289056, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 0, "selected": false, "text": "if" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/288061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30018/" ]
288,062
<p>It seems as though the following calls do what you'd expect (close the stream and not allow any further input - anything waiting for input on the stream returns error), but is it guaranteed to be correct across all compilers/platforms?</p> <pre><code>close(fileno(stdin)); fclose(stdin); </code></pre>
[ { "answer_id": 5925575, "author": "R.. GitHub STOP HELPING ICE", "author_id": 379897, "author_profile": "https://Stackoverflow.com/users/379897", "pm_score": 5, "selected": false, "text": "fclose(stdin)" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/288062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5963/" ]
288,068
<p>I need to add localization to the exceptions thrown by my application as a lot are ApplicationExceptions and handled and logged to an error report. Ideally I want to create a new Exception, imheriting from ApplicationException that I can pass the resource key as well as arguments to, so that the exception messsage can be built up from the resource information. Unfortunately (I think) the only way to set the message in an exception is in the New()...</p> <p>I would like something like:</p> <pre><code>public class LocalizedException Inherits ApplicationException public Sub New(ResourceKey as string, arg0 as Object) MyBase.New() ' get the localized text' Dim ResMan as New Global.System.Resources.ResourceManager("AppName.ExceptionResources", _ System.Reflection.Assembly.GetExecutingAssembly) Dim LocalText as string = ResMan.GetString(ResourceKey) Dim ErrorText as String = "" Try Dim ErrorText = String.Format(LocalText, arg0) Catch ErrorText = LocalText + arg0.ToString() ' in case String.Format fails' End Try ' cannot now set the exception message!' End Sub End Class </code></pre> <p>However I can only have MyBase.New() as the first line Message is ReadOnly</p> <p>Does anyone have any recommendations as to how to get localised strings into the Exception handler? I will need this in a few different exceptions, though could go the way of a exceptioncreation function that gets the localised string and creates teh exception, though the stack info would then be wrong. I also don't want too much in the main body before teh Throw as it obviously starts to impinge on readability of the flow. </p>
[ { "answer_id": 288129, "author": "labilbe", "author_id": 1195872, "author_profile": "https://Stackoverflow.com/users/1195872", "pm_score": 3, "selected": true, "text": "\nnamespace eMill.Model.Exceptions\n{\n public sealed class AccountNotFoundException : EmillException\n {\n ...
2008/11/13
[ "https://Stackoverflow.com/questions/288068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6684/" ]
288,070
<p>I am using a WCF service and a net.tcp endpoint with serviceAuthentication's principal PermissionMode set to UseWindowsGroups.</p> <p>Currently in the implementation of the service i am using the PrincipalPermission attribute to set the role requirements for each method. </p> <pre><code> [PrincipalPermission(SecurityAction.Demand, Role = "Administrators")] [OperationBehavior(Impersonation = ImpersonationOption.Required)] public string method1() </code></pre> <p>I am trying to do pretty much the same exact thing, except have the configuration for the role set in the app.config. Is there any way to do this and still be using windows groups authentication?</p> <p>Thanks</p>
[ { "answer_id": 288758, "author": "Panos", "author_id": 8049, "author_profile": "https://Stackoverflow.com/users/8049", "pm_score": 3, "selected": true, "text": "public string method1()\n{\n PrincipalPermission p = new PrincipalPermission(null, \"Administrators\");\n p.Demand();\n ...
2008/11/13
[ "https://Stackoverflow.com/questions/288070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37444/" ]
288,084
<p>Is there any other way to get a list of file names via <code>T-SQL</code> other than </p> <pre><code>INSERT INTO @backups(filename) EXEC master.sys.xp_cmdshell 'DIR /b c:\some folder with sql backups in it </code></pre> <p>I am attempting to get a list of SQL backup files from a folder to restore and I do NOT want to use the <code>xp_cmdshell</code> for obvious security reasons.</p>
[ { "answer_id": 288759, "author": "Kevin Crumley", "author_id": 1818, "author_profile": "https://Stackoverflow.com/users/1818", "pm_score": 1, "selected": false, "text": "RESTORE FILELISTONLY disk='FULL_PATH_TO_YOUR_FILE'" }, { "answer_id": 16380244, "author": "Jeff Moden", ...
2008/11/13
[ "https://Stackoverflow.com/questions/288084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4096/" ]
288,111
<p>I have an HTTPHandler that is reading in a set of CSS files and combining them and then GZipping them. However, some of the CSS files contain a Byte Order Mark (due to a bug in TFS 2005 auto merge) and in FireFox the BOM is being read as part of the actual content so it's screwing up my class names etc. How can I strip out the BOM characters? Is there an easy way to do this without manually going through the byte array looking for ""?</p>
[ { "answer_id": 289114, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 3, "selected": false, "text": "var name = GetFileName();\nvar bytes = System.IO.File.ReadAllBytes(name);\nSystem.IO.File.WriteAllBytes(name, bytes.Skip(...
2008/11/13
[ "https://Stackoverflow.com/questions/288111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4541/" ]
288,121
<p>I want to commit a large amount of XML files which have been modified. However, within the directory that I want to recursively search through, there are many folders/files which have been added locally, these I do not want to commit.</p> <p>Is there a way to do this on the command line?</p> <p>Update: I should have included the SVN version info: svn, version 1.4.6 (r28521), compiled Mar 11 2008, 08:26:35</p> <p>P.S. I'd be interested in answers which include how to force the commit, e.g. even if files have been locked.</p>
[ { "answer_id": 288170, "author": "Jason Coco", "author_id": 34218, "author_profile": "https://Stackoverflow.com/users/34218", "pm_score": 2, "selected": false, "text": "svnadmin lslocks /path/to/repository\n" }, { "answer_id": 289600, "author": "tommym", "author_id": 3760...
2008/11/13
[ "https://Stackoverflow.com/questions/288121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4120/" ]
288,127
<p>I would like to include some code coverage into our nightly build process. We're using CruiseControl, Ant, and Buckminster. Buckminster drives checkout from multiple repositories, and the PDE building and packaging of the product.</p> <p><strong>Has any one any experience integrating code coverage into an RCP headless build?</strong></p> <p>I have been looking at Cobertura, EMMA/EclEMMA, DbUnit though am very interested to hear of any experiences with these or any other tools. </p>
[ { "answer_id": 296506, "author": "jamesh", "author_id": 4737, "author_profile": "https://Stackoverflow.com/users/4737", "pm_score": 3, "selected": true, "text": "osgi.parentClassloader=app" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/288127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4737/" ]
288,138
<p>this is not a primary key, but merely used as a marker in existing system that marks these items with a 1 letter code ie 'N' for new, 'R' for return, etc. I was going to go with a varchar(50) as the data type but wondering if there's anything wrong with say varchar(2) instead aiming for efficiency. thx!</p>
[ { "answer_id": 289072, "author": "Ian Varley", "author_id": 37539, "author_profile": "https://Stackoverflow.com/users/37539", "pm_score": 1, "selected": false, "text": "CREATE TABLE Product_Status (\n status_id INT NOT NULL PRIMARY KEY, \n description VARCHAR(50) NOT NULL\n)\nINSER...
2008/11/13
[ "https://Stackoverflow.com/questions/288138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35286/" ]
288,142
<p>I'm trying to watch the execution of a VB6 app and I'm running into an issue because once I enter the debugger and then hit <code>Continue</code>, it no longer lets me step through the code until I hit another break point. I want to be able to execute a program without stepping through something until I hit a point where I want to watch it execute. Ideally this would be something to the effect of holding a key down while I pressed a button to 'step into' that function.</p> <p>Thanks in advance!</p> <p><strong>[EDIT]</strong>: I'm aware that I can use break points to stop the execution. To be more clear, the problem is that I don't know where the execution is going to, so I can't set the break point there (because I don't know where there is). That's why I essentially want to be able to say, 'after this next thing that I do, break, no matter what'. It sounds like this functionality does not exist, but I'm still keeping my fingers crossed.</p>
[ { "answer_id": 288159, "author": "George Mastros", "author_id": 1408129, "author_profile": "https://Stackoverflow.com/users/1408129", "pm_score": 1, "selected": false, "text": "Debug.Assert False\n" }, { "answer_id": 290720, "author": "RS Conley", "author_id": 7890, "...
2008/11/13
[ "https://Stackoverflow.com/questions/288142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16562/" ]
288,153
<p>I would like to know How to create a fps-game with SDL lib? </p> <p>Are there any books that explain with examples? </p>
[ { "answer_id": 288376, "author": "David Frenkel", "author_id": 28747, "author_profile": "https://Stackoverflow.com/users/28747", "pm_score": 5, "selected": true, "text": " xxxxxxxxxxxxxxxxxxxxxxxx\n xx..........P..........x\n xxxxxxx...........I....x\n xR....xxx...........E..x\n xx.........
2008/11/13
[ "https://Stackoverflow.com/questions/288153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24639/" ]
288,157
<p>Say we are traversing a graph and want to quickly determine if a node has been seen before or not. We have a few set preconditions.</p> <ol> <li>Nodes have been marked with integers values 1..N</li> <li>Graph is implemented with nodes having an adjacency list</li> <li>Every integer value from 1..N occurs in the graph, which is of size N</li> </ol> <p>Any ideas for doing this in a purely functional way?(No Hash tables or arrays allowed).</p> <p>I want a data structure with two functions working on it; add(adds an encountered integer) and lookup(checks if integer has been added). Both should preferably take O(n) time amortized for N repetitions.</p> <p>Is this possible?</p>
[ { "answer_id": 288254, "author": "namin", "author_id": 34596, "author_profile": "https://Stackoverflow.com/users/34596", "pm_score": 3, "selected": false, "text": "insert" }, { "answer_id": 874172, "author": "Dario", "author_id": 105459, "author_profile": "https://Sta...
2008/11/13
[ "https://Stackoverflow.com/questions/288157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
288,178
<p>I have been trying to learn more about lambda expressions lately, and thought of a interesting exercise...</p> <p>is there a way to simplify a c++ integration function like this:</p> <pre><code>// Integral Function double integrate(double a, double b, double (*f)(double)) { double sum = 0.0; // Evaluate integral{a,b} f(x) dx for(int n = 0 ; n &lt;= 100; ++n) { double x = a + n*(b-a)/100.0; sum += (*f)(x) * (b-a)/101.0; } return sum; } </code></pre> <p>by using c# and lambda expressions?</p>
[ { "answer_id": 288311, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 4, "selected": true, "text": "public double Integrate(double a,double b, Func<double, double> f)\n{\n double sum = 0.0;\n\n for (int n =...
2008/11/13
[ "https://Stackoverflow.com/questions/288178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
288,182
<p>Where should I be logging exceptions? At the data service tier(ExecuteDataSet, etc.) and/or at the data access layer and/or at the business layer?</p>
[ { "answer_id": 288215, "author": "James McMahon", "author_id": 20774, "author_profile": "https://Stackoverflow.com/users/20774", "pm_score": 1, "selected": false, "text": "main {\n try {\n application code\n } catch {\n preform logging\n }\n}\n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/288182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34214/" ]
288,190
<p>How do I ignore all files within a folder under source control?</p> <p><code>/project/published/</code> is a folder I want to keep</p> <p><code>/project/published/some_file(s)</code> are files/folders I don't want</p> <p>More Details: Currently when I go to commit changes for my project I see a lot of files that I don't want to. They are files that get published to a folder and I don't need them under source control. I won't ever know the names of these files as they are chosen by users.</p> <p>I tried to use the property <code>svn:ignore</code> with value <code>published/*</code> but that did not work. Any ideas?</p>
[ { "answer_id": 288213, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 2, "selected": false, "text": "svn propset svn:ignore published/*\n" }, { "answer_id": 3673549, "author": "Shiro", "author_id":...
2008/11/13
[ "https://Stackoverflow.com/questions/288190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
288,192
<p>I'm writing Application A and DLL B, both in C#.NET. How do I do the following: </p> <ol> <li>A calls function in B </li> <li>Want B to use delegate/callback to update status in UI of A </li> </ol> <p>This is <em>not</em> about BackgroundWorker...that part works fine in A. What I can't see is how to let B know what function to call in A.</p>
[ { "answer_id": 288234, "author": "Jeromy Irvine", "author_id": 8223, "author_profile": "https://Stackoverflow.com/users/8223", "pm_score": 4, "selected": false, "text": "public delegate void CallbackDelegate(string status);\n\npublic void DoWork(string param, CallbackDelegate callback)\n...
2008/11/13
[ "https://Stackoverflow.com/questions/288192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
288,200
<p>We're having a bit of fun here at work. It all started with one of the guys setting up a Hackintosh and we were wondering whether it was faster than a Windows Box of (nearly) same specs that we have. So we decided to write a little test for it. Just a simple Prime number calculator. It's written in Java and tells us the time it takes to calculate the first n Prime numbers.</p> <p>Optimised version below - now takes ~6.6secs</p> <pre><code>public class Primes { public static void main(String[] args) { int topPrime = 150000; int current = 2; int count = 0; int lastPrime = 2; long start = System.currentTimeMillis(); while (count &lt; topPrime) { boolean prime = true; int top = (int)Math.sqrt(current) + 1; for (int i = 2; i &lt; top; i++) { if (current % i == 0) { prime = false; break; } } if (prime) { count++; lastPrime = current; } if (current == 2) { current++; } else { current = current + 2; } } System.out.println("Last prime = " + lastPrime); System.out.println("Total time = " + (double)(System.currentTimeMillis() - start) / 1000); } } </code></pre> <p>We've pretty much lost the plot of the whole Hackintosh vs PC thing and are just having some fun with optimising it. First attempt with no optimisations (the above code has a couple) ran around 52.6min to find the first 150000 prime numbers. This optimisation is running around 47.2mins.</p> <p>If you want to have a go and post your results, then stick em up.</p> <p>Specs for the PC I'm running it on are Pentium D 2.8GHz, 2GB RAM, running Ubuntu 8.04.</p> <p><strong>Best Optimisation so far has been the square root of current, first mentioned by Jason Z.</strong></p>
[ { "answer_id": 288252, "author": "BP.", "author_id": 36984, "author_profile": "https://Stackoverflow.com/users/36984", "pm_score": 1, "selected": false, "text": "for (int i = 2; i < top; i++)" }, { "answer_id": 288263, "author": "Sani Singh Huttunen", "author_id": 26742, ...
2008/11/13
[ "https://Stackoverflow.com/questions/288200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18340/" ]
288,210
<p>I used to do this:</p> <pre><code>SELECT layerID FROM layers WHERE ownerID = ? AND collectionID = ? </code></pre> <p>Which would give me an array of layerID's, and then I'd loop and do this for each one:</p> <pre><code>SELECT DATA FROM drawings WHERE layerID = ? </code></pre> <p>And it all worked fine. So now I'm trying to do it in one step, so I try this:</p> <pre><code>SELECT DATA , layerID FROM drawings WHERE layerID = ANY ( SELECT layerID FROM layers WHERE ownerID = ? AND collectionID = ? ) </code></pre> <p>But for some reason, it doesn't use the index, for the main query, <code>SELECT DATA etc</code>! So this one combined query takes much much longer to complete, versus the separate queries I was doing before. (By theway, the subquery, <code>SELECT layerID etc</code> still uses the index).</p> <p>I've determined if it's using a query or not by using the 'EXPLAIN' statement.</p> <p>I have individual indexes on the <code>ownerID</code> and <code>collectionID</code> columns in the <code>layers</code> table, and on the <code>layerID</code> column in the <code>drawings</code> table.</p> <p>What am I doing wrong with my query?</p>
[ { "answer_id": 288237, "author": "dkretz", "author_id": 31641, "author_profile": "https://Stackoverflow.com/users/31641", "pm_score": 4, "selected": true, "text": "SELECT d.DATA, d.layerID \nFROM drawings AS d \nINNER JOIN layers AS l ON d.layerID = l.layerID \nWHERE l.ownerID = ? AND...
2008/11/13
[ "https://Stackoverflow.com/questions/288210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14569/" ]
288,217
<p>I am working on a C++ app which internally has some controller objects that are created and destroyed regularly (using new). It is necessary that these controllers register themselves with another object (let's call it controllerSupervisor), and unregister themselves when they are destructed.</p> <p>The problem I am now facing is happening when I quit the application: as order of destruction is not deterministic, it so happens that the single controllerSupervisor instance is destructed prior to (some) of the controllers themselves, and when they call the unregister method in their destructor, they do so upon an already destructed object. </p> <p>The only idea I came up with so far (having a big cold, so this may not mean much) is not having the controllerSupervisor as a global variable on the stack, but rather on the heap (i.e. using new). However in that case I do not have a place to delete it (this is all in a 3rd party kind of library). </p> <p>Any hints/suggestions on what possible options are would be appreciated.</p>
[ { "answer_id": 288223, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 3, "selected": false, "text": "!= 0" }, { "answer_id": 288272, "author": "maccullt", "author_id": 4945, "author_profil...
2008/11/13
[ "https://Stackoverflow.com/questions/288217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27101/" ]
288,222
<p>In SQL Server (in my case, 2005) how can I add the identity property to an existing table column using T-SQL?</p> <p>Something like:</p> <pre><code>alter table tblFoo alter column bar identity(1,1) </code></pre>
[ { "answer_id": 590913, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": -1, "selected": false, "text": "alter table tablename \nalter column columnname \nadd Identity(100,1)\n" }, { "answer_id": 912795, "author": "Nat...
2008/11/13
[ "https://Stackoverflow.com/questions/288222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30529/" ]
288,255
<p>While testing a console app, I set the properties of the console window to be only 3 lines high. </p> <p>This change has somehow stuck, meaning that new console windows default to 3 lines high. If I create a new shortcut on the desktop, and point it to cmd.exe, the window that opens is 3 lines high. </p> <p>Of course, I can alter this value using the properties panel, which ultimately results in "current window only"/"future windows with same title"/"shortcut that started this window" dialog to alter the stickiness of the setting. None of these choices results in the default being changed. If, subsequently, I make a new shortcut to cmd.exe, it's still 3 lines high.</p> <p>The principal problem is that for any new console app that I write, the first time I debug it, I must change the size setting, and when I run the release build, it's the same story.</p> <p>Does anyone know where the default settings for new (i.e. new title or from new shortcut) console app are stored/how to change them?</p> <p>[and, yes, I feel like a muppet for asking, but I can't find this info anywhere!]</p>
[ { "answer_id": 288286, "author": "Duncan Smart", "author_id": 1278, "author_profile": "https://Stackoverflow.com/users/1278", "pm_score": 4, "selected": false, "text": "HKEY_CURRENT_USER\\Console\n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/288255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14357/" ]
288,277
<p>I have a JavaScript variable which holds an HTML page and due to the setup I need to extract everything between <code>&lt;div id="LiveArea"&gt;</code> and <code>&lt;/div&gt;</code> from that variable using JavaScript.</p> <p>Any help is greatly appreciated.</p>
[ { "answer_id": 288297, "author": "mmattax", "author_id": 1638, "author_profile": "https://Stackoverflow.com/users/1638", "pm_score": 1, "selected": false, "text": "\nvar e = document.getElementById('LiveArea');\nif(e) alert(e.innerHTML);\n\n" }, { "answer_id": 288326, "author...
2008/11/13
[ "https://Stackoverflow.com/questions/288277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
288,282
<p>Here's some code I have:</p> <pre><code>MyClass* MyClass::getInstance() { static MyClass instance; return &amp;instance; } </code></pre> <p>I want to look into this singleton's current values. But I'm currently paused three hours into execution, and the reason I'm paused is that I'm out of memory. So I can't put a breakpoint in this method there to see what the value is.</p> <p>My question then is how to refer to this <code>instance</code> variable from a global scope. I've tried referring to it as <code>MyClass::getInstance::instance</code> but that doesn't work. I'm guessing <code>getInstance</code> has to be decorated somehow. Anyone know how?</p> <p>This is in Visual Studio 2008.</p>
[ { "answer_id": 288329, "author": "Nathan Kitchen", "author_id": 31000, "author_profile": "https://Stackoverflow.com/users/31000", "pm_score": 1, "selected": false, "text": "int f() {\n static int xyz = 0;\n ++xyz;\n\n return xyz;\n}\n" }, { "answer_id": 292962, "auth...
2008/11/13
[ "https://Stackoverflow.com/questions/288282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4790/" ]
288,294
<p>This may be too generic a question as is but... I am stumped by trying to move through the directories from within a shell script. I'm not a *nix power user, but I am comfortable working through the command line for most tasks. I'd like to call a script that can move 'me' to a directory instead of just the script process similar to the following:</p> <pre><code>prompt:&gt; goto lit </code></pre> <p>where <code>goto</code> is an alias -> <code>goto='./goscript'</code><br> and<br> <code>goscript</code> has some simple code in such as:</p> <pre><code>cd /path to work dirs/lit/user dir </code></pre> <p>(assuming each user has a directory inside /lit)</p> <p>I've avoided this issue myself by setting my personal alias' to move to the desired directory, run a script, then return to the original directory. This question was brought to me by a co-worker who uses a similar method, but wanted to make the process more generic so we don't need to create every single alias we need. I thought this would be an easy problem to solve, but I'm stumped as I don't really have a great deal of shell scripting experience ...as of yet. </p>
[ { "answer_id": 288308, "author": "Magus", "author_id": 2188, "author_profile": "https://Stackoverflow.com/users/2188", "pm_score": 0, "selected": false, "text": "alias goto='cd /path_to_work/usr/dir'\n" }, { "answer_id": 288314, "author": "Mitch Haile", "author_id": 28807...
2008/11/13
[ "https://Stackoverflow.com/questions/288294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
288,298
<p>How much code documentation in your .NET source is too much?</p> <p>Some background: I inherited a large codebase that I've talked about in some of the other questions I've posted here on SO. One of the "features" of this codebase is a God Class, a single static class with >3000 lines of code encompassing several dozen static methods. It's everything from <code>Utilities.CalculateFYBasedOnMonth()</code> to <code>Utilities.GetSharePointUserInfo()</code> to <code>Utilities.IsUserIE6()</code>. It's all good code that <a href="http://www.joelonsoftware.com/printerFriendly/articles/fog0000000069.html" rel="noreferrer">doesn't need to be rewritten</a>, just refactored into an appropriate set of libraries. I have that planned out.</p> <p>Since these methods are moving into a new business layer, and my role on this project is to prepare the system for maintenance by other developers, I'm thinking about solid code documentation. While these methods all have good inline comments, they don't all have good (or any) code doco in the form of XML comments. Using a combo of GhostDoc and Sandcastle (or Document X), I can create some pretty nice HTML documentation and post it to SharePoint, which would let developers understand more about what the code does without navigating through the code itself.</p> <p>As the amount of documentation in the code increases, the more difficult it becomes to navigate the code. I'm beginning to wonder if the XML comments will make the code more difficult to maintain than, say, a simpler <code>//comment</code> would on each method. </p> <p>These examples are <a href="http://www.innovasys.com/products/dx2008/overview.aspx" rel="noreferrer">from the Document X sample</a>:</p> <pre><code> /// &lt;summary&gt; /// Adds a new %Customer:CustomersLibrary.Customer% to the collection. /// &lt;/summary&gt; /// &lt;returns&gt;A new Customer instance that represents the new customer.&lt;/returns&gt; /// &lt;example&gt; /// The following example demonstrates adding a new customer to the customers /// collection. /// &lt;code lang="CS" title="Example"&gt; /// CustomersLibrary.Customer newCustomer = myCustomers.Add(CustomersLibrary.Title.Mr, "John", "J", "Smith"); /// &lt;/code&gt; /// &lt;code lang="VB" title="Example"&gt; /// Dim newCustomer As CustomersLibrary.Customer = myCustomers.Add(CustomersLibrary.Title.Mr, "John", "J", "Smith") /// &lt;/code&gt; /// &lt;/example&gt; /// &lt;seealso cref="Remove"&gt;Remove Method&lt;/seealso&gt; /// &lt;param name="Title"&gt;The customers title.&lt;/param&gt; /// &lt;param name="FirstName"&gt;The customers first name.&lt;/param&gt; /// &lt;param name="MiddleInitial"&gt;The customers middle initial.&lt;/param&gt; /// &lt;param name="LastName"&gt;The customers last name.&lt;/param&gt; public Customer Add(Title Title, string FirstName, string MiddleInitial, string LastName) { // create new customer instance Customer newCust = new Customer(Title, FirstName, MiddleInitial, LastName); // add to internal collection mItems.Add(newCust); // return ref to new customer instance return newCust; } </code></pre> <p>And:</p> <pre><code> /// &lt;summary&gt; /// Returns the number of %Customer:CustomersLibrary.Customer% instances in the collection. /// &lt;/summary&gt; /// &lt;value&gt; /// An Int value that specifies the number of Customer instances within the /// collection. /// &lt;/value&gt; public int Count { get { return mItems.Count; } } </code></pre> <p>So I was wondering from you: do you document <strong>all</strong> of your code with XML comments with the goal of using something like NDoc (RIP) or Sandcastle? If not, how do you decide what gets documentation and what doesn't? Something like an API would obviously have doco, but what about a codebase that you're going to hand off to another team to maintain?</p> <p>What do you think I should do?</p>
[ { "answer_id": 560540, "author": "Chris S", "author_id": 21574, "author_profile": "https://Stackoverflow.com/users/21574", "pm_score": 3, "selected": false, "text": "/// <include file=\"Documentation/XML/YourClass.xml\" path=\"//documentation/members[@name='YourClass']/*\"/>\n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/288298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7565/" ]
288,304
<p>I have some .NET remoting code where a factory method, implemented in some server side class, returns interfaces to concrete objects, also executing on the very same server. .NET remoting automagically creates proxies and allows me to pass the interfaces across to the client, which can then call them directly.</p> <p>Example interfaces:</p> <pre><code>public interface IFactory { IFoo GetFoo(); } public interface IFoo { void DoSomething(); } </code></pre> <p>Example client code:</p> <pre><code>... IFactory factory = (IFactory) System.Activator.GetObject (typeof (IFactory), url); ... IFoo foo = factory.GetFoo (); // the server returns an interface; we get a proxy to it foo.DoSomething (); ... </code></pre> <p>This all works great. However, now I am trying to migrate my code to WCF. I wonder if there is a means to pass around interfaces and having WCF generate the proxies on the fly on the client, as does the original .NET remoting.</p> <p>And I don't want to return class instances, since I don't want to expose real classes. And serializing the full instance and sending it back and forth between the server and the client is not an option either. I really just want the client to talk to the server object through an interface pointer/proxy.</p> <p>Any ideas?</p>
[ { "answer_id": 288425, "author": "Pierre Arnaud", "author_id": 4597, "author_profile": "https://Stackoverflow.com/users/4597", "pm_score": 1, "selected": false, "text": "ChannelFactory" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/288304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4597/" ]
288,319
<p>I realized the solution to this problem while I was creating the documentation to ASK this question...so I am posting the answer if for no other reason than to keep me from wasting time on this in the future</p>
[ { "answer_id": 288328, "author": "Jay Corbett", "author_id": 2755, "author_profile": "https://Stackoverflow.com/users/2755", "pm_score": 2, "selected": false, "text": "<html>\n<head>\n<style>\n #upperDiv {width:200px; height:20px; text-align:center; cursor:pointer; }\n #lowerDiv {width:2...
2008/11/13
[ "https://Stackoverflow.com/questions/288319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
288,349
<p>Does anyone know of a good alternative to cron? I would like something that can be run with different time zones.</p>
[ { "answer_id": 288399, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": true, "text": "Date" }, { "answer_id": 5895518, "author": "mecano", "author_id": 731772, "author_profile": "https://Stackov...
2008/11/13
[ "https://Stackoverflow.com/questions/288349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30636/" ]
288,350
<p>Can anybody tell me when Application_End is triggered in a lifecycle of an application? When all sessions are ended, will Application_End be triggered automatically? + Are there any other reasons why Application_End could be triggered?</p>
[ { "answer_id": 288411, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 6, "selected": true, "text": "application_end" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/288350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26521/" ]
288,357
<p>So if I have:</p> <pre><code>public class ChildClass : BaseClass { public new virtual string TempProperty { get; set; } } public class BaseClass { public virtual string TempProperty { get; set; } } </code></pre> <p>How can I use reflection to see that ChildClass is hiding the Base implementation of TempProperty?</p> <p>I'd like the answer to be agnostic between c# and vb.net</p>
[ { "answer_id": 288372, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": -1, "selected": false, "text": "Module Module1\n\n Class Foo\n Public Function SomeFunc() As Integer\n Return 42\n End Funct...
2008/11/13
[ "https://Stackoverflow.com/questions/288357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1946/" ]
288,364
<p>I have two system calls GetSystemTime() and GetThreadTimes() that I need to calculate the CPU utilization by a given Win32 thread.</p> <p>For the sake of accuracy, I need to ensure that both GetSystemTime() and GetThreadTimes() are executed atomically; i.e. there should be no context switch in between a call to GetSystemTime() &amp; GetThreadTimes().</p> <p>The reason is that occasionally I end up with a percentage of over 100% (~ 1 in 500).</p> <p>How can I ensure an atomic execution of the 2 function calls?</p> <p>Thanks, Sachin</p>
[ { "answer_id": 288403, "author": "Nicholas Mancuso", "author_id": 8945, "author_profile": "https://Stackoverflow.com/users/8945", "pm_score": 2, "selected": false, "text": "perc = ( perc > 100.0f ) ? 100.0f : perc;\n" } ]
2008/11/13
[ "https://Stackoverflow.com/questions/288364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33870/" ]
288,368
<p>Do any of the existing JavaScript frameworks have a non-regex <code>replace()</code> function, or has this already been posted on the web somewhere as a one-off function?</p> <p>For example I want to replace <code>"@!#$123=%"</code> and I don't want to worry about which characters to escape. Most languages seem to have both methods of doing replacements. I would like to see this simple thing added.</p>
[ { "answer_id": 288384, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 6, "selected": true, "text": "replace()" }, { "answer_id": 6724957, "author": "Nick Ager", "author_id": 848808, "author_profile": "https:/...
2008/11/13
[ "https://Stackoverflow.com/questions/288368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36590/" ]
288,374
<p>A method I work with that is called tens of thousands of times started throwing exceptions recently. In most debugging circumstances I would set a breakpoint at the top of this method and run through until I reach the call I'm interested in with a parameter value that triggers the exception. In this case that would be impractical, so I tried setting a breakpoint with a condition that will only break when that parameter value appears. I created a breakpoint at the position indicated below and gave it a condition <code>str == "OffendingValue"</code>. </p> <pre><code>class Foo { // Bar() is called many, many times void Bar(string str) { try { // Breakpoint inserted here ... } catch (Exception ex) { ... } } } </code></pre> <p>To my surprise, doing this caused Visual Studio and my application to stop functioning in Debug mode. My application started and output some simple logging messages but then stopped responding entirely. Thinking Visual Studio might just be performing a little slower due to the extra work it has to do to monitor the breakpoint condition, I stepped away from my desk for 15 mintues to give it some time to run. When I returned there was no change. I can reproduce the condition by deleting the breakpoint and recreating it with the same condition. Strangest of all, the Break All debugging command, which will usually break program execution on the statement that's currently execting whether it's a breakpoint or not, does nothing at all when I have this problematic breakpoint enabled. </p> <p>Has anyone encountered similar behavior with Visual Studio breakpoint conditions? I am able to use Hit Count conditions without problem. </p>
[ { "answer_id": 288521, "author": "asponge", "author_id": 19449, "author_profile": "https://Stackoverflow.com/users/19449", "pm_score": 4, "selected": true, "text": "class Foo\n{\n // Bar() is called many, many times\n void Bar(string str)\n {\n try\n {\n\n ...
2008/11/13
[ "https://Stackoverflow.com/questions/288374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28350/" ]
288,392
<p>My ASP.NET application needs a number of supporting services to run periodically in the background. For example:</p> <ul> <li>I need to query the database (or cache) every 1-5 minutes, identify overdue work items and notify users by email</li> <li>I need to generate nightly reports that are then emailed to subscribers</li> <li>Plus other system/non-user admin tasks</li> </ul> <p>What is the best way to implement these services? Should I include them as part of the web application, starting an instance of each 'service' in Application_Start()? Or create them as actual standalone services? If they were part of the web application I can potentially utilize my cached data store, but are there any downsides to this approach?</p> <p>Thanks for any advice.</p>
[ { "answer_id": 288539, "author": "Cristian Libardo", "author_id": 16526, "author_profile": "https://Stackoverflow.com/users/16526", "pm_score": 1, "selected": false, "text": "Timer timer = new Timer(intervalSeconds * 1000)\ntimer.Elapsed += delegate\n{\n // do the meat\n};\ntimer.Star...
2008/11/13
[ "https://Stackoverflow.com/questions/288392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27805/" ]
288,409
<p>If I create a UserControl and add some objects to it, how can I grab the HTML it would render?</p> <p>ex.</p> <pre><code>UserControl myControl = new UserControl(); myControl.Controls.Add(new TextBox()); // ...something happens return strHTMLofControl; </code></pre> <p>I'd like to just convert a newly built UserControl to a string of HTML.</p>
[ { "answer_id": 288414, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 1, "selected": false, "text": ".RenderControl()" }, { "answer_id": 288419, "author": "azamsharp", "author_id": 3797, "author_prof...
2008/11/13
[ "https://Stackoverflow.com/questions/288409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25538/" ]
288,412
<p>I did a few tests with TouchJSON last night and it worked pretty well in general for simple cases. I'm using the following code to read some JSON content from a file, and deserialize it:</p> <pre><code>NSString *jsonString = [[NSString alloc] initWithContentsOfFile:@"data.json"]; NSData *jsonData = [jsonString dataUsingEncoding:NSUTF32BigEndianStringEncoding]; NSError *error = nil; NSDictionary *items = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&amp;error]; NSLog(@"total items: %d", [items count]); NSLog(@"error: %@", [error localizedDescription]); </code></pre> <p>That works fine if I have a very simple JSON object in the file (i.e. a dictionary):</p> <pre><code>{"id": "54354", "name": "boohoo"} </code></pre> <p>This way I was able to get access to the array of values, as I wanted to get the item based on its index within the list:</p> <pre><code>NSArray *items_list = [items allValues]; NSString *name = [items_list objectAtIndex:1]; </code></pre> <p><em>(I understand that I could have fetched the name with the dictionary API)</em></p> <p>Now I would like to deserialize a semi-complex JSON string, which represents an array of dictionaries. An example of such a JSON string is below:</p> <pre><code>[{"id": "123456", "name": "touchjson"}, {"id": "3456", "name": "bleh"}] </code></pre> <p>When I try to run the same code above against this new content in the data.json file, I don't get any results back. My NSLog() call says "total items: 0", and no error is coming back in the NSError object.</p> <p>Any clues on what is going on? I'm completely lost on what to do, as there isn't much documentation available for TouchJSON, and much less usage examples.</p>
[ { "answer_id": 289175, "author": "wisequark", "author_id": 33159, "author_profile": "https://Stackoverflow.com/users/33159", "pm_score": 0, "selected": false, "text": "{\n \"objects\": [{\n \"id\": \"123456\",\n \"name\": \"touchjson\"\n }, {\n \"id\": \"3456\",\n \"name\":...
2008/11/13
[ "https://Stackoverflow.com/questions/288412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35478/" ]
288,413
<p>I am using this code to verify a behavior of a method I am testing:</p> <pre><code> _repository.Expect(f =&gt; f.FindAll(t =&gt; t.STATUS_CD == "A")) .Returns(new List&lt;JSOFile&gt;()) .AtMostOnce() .Verifiable(); </code></pre> <p>_repository is defined as:</p> <pre><code>private Mock&lt;IRepository&lt;JSOFile&gt;&gt; _repository; </code></pre> <p>When my test is run, I get this exception:</p> <p><strong>Expression t => (t.STATUS_CD = "A") is not supported.</strong></p> <p>Can someone please tell me how I can test this behavior if I can't pass an expression into the Expect method?</p> <p>Thanks!!</p>
[ { "answer_id": 288509, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "Func<JSOFile, bool> _myDelegate;\n\n_repository.Stub(f => FindAll(null)).IgnoreArguments()\n .Do( (Func<Func<JSOFile, bool>,...
2008/11/13
[ "https://Stackoverflow.com/questions/288413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10589/" ]