qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
344,018
<p>I have an ASP.NET application which tracks statistics by creating and writing to custom performance counters. Occasionally, I see in the error logs that indicate that the counters have failed to open because they had already been used in the current process. I presume this is due to my .NET appdomain having been reset within the same w3wp.exe process. How can I avoid these errors and re-establish a connection to my performance counters when my app domain has been recycled?</p> <p>Counter construction:</p> <pre><code>PerformanceCounter pc = new PerformanceCounter(); pc.CategoryName = category_name; pc.CounterName = counter_name; pc.ReadOnly = false; pc.InstanceLifetime = PerformanceCounterInstanceLifetime.Process; pc.InstanceName = instance_name; </code></pre> <p>Counter usage:</p> <pre><code>pc.Increment() </code></pre> <p>[Update on 3/26/09] The error message received is:</p> <p>Instance '_lm_w3svc_1_root_myapp' already exists with a lifetime of Process. It cannot be recreated or reused until it has been removed or until the process using it has exited. already exists with a lifetime of Process.</p> <p>I tried to replicate the exception in a console application by initializing the performance counters and writing to one of them in a transient AppDomain. I then unload the AppDomain and do it again in a second Appdomain (same process). They both succeed. I'm unsure now exactly what the cause of this is, my assumption about AppDomain recycling in ASP.NET seems to be false.</p>
[ { "answer_id": 698491, "author": "Ender", "author_id": 84296, "author_profile": "https://Stackoverflow.com/users/84296", "pm_score": 0, "selected": false, "text": "lock (this.lockObject)\n{\n //Create performance counter\n}\n" }, { "answer_id": 1008759, "author": "Alan McBee", "author_id": 100596, "author_profile": "https://Stackoverflow.com/users/100596", "pm_score": 3, "selected": true, "text": "instance_name private static string GetFriendlyInstanceName()\n {\n string friendlyName = AppDomain.CurrentDomain.FriendlyName;\n int dashPosition = friendlyName.IndexOf('-');\n if (dashPosition > 0)\n {\n friendlyName = friendlyName.Substring(0, dashPosition);\n }\n friendlyName = friendlyName.TrimStart('_');\n string processID = Process.GetCurrentProcess().Id.ToString();\n string processName = Process.GetCurrentProcess().ProcessName;\n string instanceName = processName + \" \" + processID + \" \" + friendlyName.Replace('/', '_').Trim('_').Trim();\n return instanceName;\n }\n" }, { "answer_id": 13008053, "author": "SharpC", "author_id": 1741690, "author_profile": "https://Stackoverflow.com/users/1741690", "pm_score": 3, "selected": false, "text": "ServiceModelService 3.0.0.0 web.config <system.serviceModel> <diagnostics performanceCounters=\"All\" /> W3SVC System.ServiceModel 3.0.0.0 using System;\nusing System.Diagnostics;\nusing System.ServiceModel;\nusing System.ServiceModel.Activation;\n\nnamespace MyNamespace\n{\n public class WebFarmServiceHostFactory : ServiceHostFactory\n {\n protected override ServiceHost CreateServiceHost(\n Type serviceType, Uri[] baseAddresses)\n {\n return new WebFarmServiceHost(serviceType, baseAddresses);\n }\n }\n\n public class WebFarmServiceHost : ServiceHost\n {\n public WebFarmServiceHost(\n Type serviceType, params Uri[] baseAddresses)\n : base(serviceType, baseAddresses) { }\n\n protected override void ApplyConfiguration()\n {\n base.ApplyConfiguration();\n\n Description.Name = \"W3wp\" + Process.GetCurrentProcess().Id +\n Description.Name;\n }\n }\n}\n .svc <%@ ServiceHost Language=\"C#\" Debug=\"true\" Factory=\"MyNamespace.WebFarmServiceHostFactory\" Service=\"WcfService1.Service1\" CodeBehind=\"Service1.svc.cs\" %> base.ApplyConfiguration(); Thread.Sleep(1);\n DisallowOverlappingRotation MyAppPool cscript %SYSTEMDRIVE%\\inetpub\\adminscripts\\adsutil.vbs SET w3svc/AppPools/MyAppPool/DisallowOverlappingRotation TRUE\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7450/" ]
344,047
<p>I want to get at the item that is being data bound, during the ItemDataBound event of an asp:repeater.</p> <p>I tried the following (which was an unaccepted answer in a <a href="https://stackoverflow.com/questions/284420/datagridview-bindinghow-to-color-line-depending-of-the-object-binded#284470">stackoverflow question</a>):</p> <pre><code>protected void myRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { Object dataItem = e.Item.DataItem; ... } </code></pre> <p>but <code>e.Item.DataItem</code> is null.</p> <p>How can I access the item being data bound during the event called ItemDataBound. I assume the event ItemDataBound happens when an item is being data bound.</p> <p>I want to get at the object so I can take steps to control how it is displayed, in addition the object may have additional helpful properties to let me enrich how it is displayed.</p> <h2>Answer</h2> <p><a href="https://stackoverflow.com/questions/344047/aspnet-how-to-access-the-item-being-data-bound-during-itemdatabound#344073">Tool</a> had the right answer. The answer is that <code>e.Item.Data</code> is only valid when <code>e.Item.ItemType</code> is (Item, AlternatingItem). Other times it is not valid. In my case, I was receiving ItemDataBound events during header (or footer) rows, where there is no DataItem:</p> <pre><code>protected void myRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { // if the data bound item is an item or alternating item (not the header etc) if (e.Item.ItemType != ListItemType.Item &amp;&amp; e.Item.ItemType != ListItemType.AlternatingItem) { return; } Object dataItem = e.Item.DataItem; ... } </code></pre>
[ { "answer_id": 344073, "author": "Programmin Tool", "author_id": 21691, "author_profile": "https://Stackoverflow.com/users/21691", "pm_score": 5, "selected": true, "text": "if (e.Item.ItemType == ListItemType.Item ||\n e.Item.ItemType == ListItemType.AlternatingItem)\n{\n //Put stuff here\n}\n" }, { "answer_id": 635798, "author": "Adam Douglass", "author_id": 53035, "author_profile": "https://Stackoverflow.com/users/53035", "pm_score": 0, "selected": false, "text": " protected void myLV_ItemDataBound(object sender, ListViewItemEventArgs e)\n{\n if (e.Item.ItemType != ListViewItemType.DataItem)\n return;\n\n object dataItem = ((ListViewDataItem)e.Item).DataItem;\n\n}\n" }, { "answer_id": 1181696, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType...\n if (e.Item.DataItem != null) ...\n" }, { "answer_id": 3670128, "author": "Quantum Dynamix", "author_id": 442661, "author_profile": "https://Stackoverflow.com/users/442661", "pm_score": 4, "selected": false, "text": "protected void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e)\n {\n //determine if the row type is an Item\n if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))\n {\n DataRowView row = (DataRowView)e.Item.DataItem;\n if (row[\"RowName\"].ToString() == \"value\")\n {\n //INSERT CODE HERE\n }\n }\n }\n" }, { "answer_id": 29995087, "author": "civilator", "author_id": 1935056, "author_profile": "https://Stackoverflow.com/users/1935056", "pm_score": 0, "selected": false, "text": "Repeater1.HeaderTemplate = new PrintTemplate(ListItemType.Header);\nRepeater1.ItemTemplate = new PrintTemplate(ListItemType.Item);\nRepeater1.AlternatingItemTemplate = new PrintTemplate(ListItemType.AlternatingItem);\nRepeater1.FooterTemplate = new PrintTemplate(ListItemType.Footer);\n\n public class PrintTemplate : ITemplate\n{\n ListItemType templateType;\n\n public PrintTemplate(ListItemType type)\n {\n templateType = type;\n\n }\n public void InstantiateIn(System.Web.UI.Control container)\n { \n Literal lc = new Literal();\n\n switch(templateType)\n {\n case ListItemType.Header:\n lc.Text = \"<TABLE>\";\n container.Controls.Add(lc);\n break;\n case ListItemType.Item:\n case ListItemType.AlternatingItem:\n //lc.Text = \"<TR><TD>\";\n lc.DataBinding += new EventHandler(TemplateControl_DataBinding);\n container.Controls.Add(lc);\n break;\n case ListItemType.Footer:\n lc.Text = \"</TABLE>\";\n container.Controls.Add(lc);\n break;\n }\n }\n\n private void TemplateControl_DataBinding(object sender,\n System.EventArgs e)\n {\n\n Literal lc;\n lc = (Literal)sender;\n RepeaterItem container = (RepeaterItem)lc.NamingContainer;\n ListItemType itmType = container.ItemType;\n\n //construct the repeater row using a custom function that switches on item type; HEADER vs ITEM vs ALTERNATINGITEM\n lc.Text += GetPopulatedRepeaterRow(dataInterface, container.DataItem, container.ItemType); \n ...\n" }, { "answer_id": 47937949, "author": "Akshay Mishra", "author_id": 3901511, "author_profile": "https://Stackoverflow.com/users/3901511", "pm_score": 1, "selected": false, "text": " dynamic item = e.Item.DataItem;\n string style = item.Style;\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
344,068
<p>I have a table like so:</p> <pre><code>keyA keyB data </code></pre> <p>keyA and keyB together are unique, are the primary key of my table and make up a clustered index.</p> <p>There are 5 possible values of keyB but an unlimited number of possible values of keyA,. keyB generally increments.</p> <p>For example, the following data can be ordered in 2 ways depending on which key column is ordered first:</p> <pre><code>keyA keyB data A 1 X B 1 X A 3 X B 3 X A 5 X B 5 X A 7 X B 7 X </code></pre> <p>or</p> <pre><code>keyA keyB data A 1 X A 3 X A 5 X A 7 X B 1 X B 3 X B 5 X B 7 X </code></pre> <p>Do I need to tell the clustered index which of the key columns has fewer possible values to allow it to order the data by that value first? Or does it not matter in terms of performance which is ordered first?</p>
[ { "answer_id": 344397, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 1, "selected": false, "text": "ORDER BY KeyA, KeyB\n ORDER BY KeyB, KeyA\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34632/" ]
344,069
<p>I am unit testing a .NET application (.exe) that uses an app.config file to load configuration properties. The unit test application itself does not have an app.config file. </p> <p>When I try to unit test a method that utilizes any of the configuration properties, they return <em>null</em>. I'm assuming this is because the unit test application is not going to load in the target application's app.config.</p> <p>Is there a way to override this or do I have to write a script to copy the contents of the target app.config to a local app.config? </p> <p><a href="https://stackoverflow.com/questions/168931/unit-testing-the-appconfig-file-with-nunit">This</a> post kind-of asks this question but the author is really looking at it from a different angle than I am.</p> <p><strong>EDIT:</strong> I should mention that I'm using VS08 Team System for my unit tests.</p>
[ { "answer_id": 344124, "author": "Jeromy Irvine", "author_id": 8223, "author_profile": "https://Stackoverflow.com/users/8223", "pm_score": 7, "selected": true, "text": ".config .testrunconfig .config bin\\Debug .config" }, { "answer_id": 344233, "author": "bryanbcook", "author_id": 30809, "author_profile": "https://Stackoverflow.com/users/30809", "pm_score": 6, "selected": false, "text": "<configuration>\n <appSettings>\n <add key=\"TestValue\" value=\"true\" />\n </appSettings>\n</configuration>\n [TestFixture]\npublic class GeneralFixture\n{\n [Test]\n public void VerifyAppDomainHasConfigurationSettings()\n {\n string value = ConfigurationManager.AppSettings[\"TestValue\"];\n Assert.IsFalse(String.IsNullOrEmpty(value), \"No App.Config found.\");\n }\n}\n public class MyObject\n{\n public void Configure(MyConfigurationObject config)\n {\n _enabled = config.Enabled;\n }\n\n public string Foo()\n {\n if (_enabled)\n {\n return \"foo!\";\n }\n return String.Empty;\n }\n\n private bool _enabled;\n}\n\n[TestFixture]\npublic class MyObjectTestFixture\n{\n [Test]\n public void CanInitializeWithProperConfig()\n {\n MyConfigurationObject config = new MyConfigurationObject();\n config.Enabled = true;\n\n MyObject myObj = new MyObject();\n myObj.Configure(config);\n\n Assert.AreEqual(\"foo!\", myObj.Foo());\n }\n}\n" }, { "answer_id": 1528427, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 7, "selected": false, "text": "app.config" }, { "answer_id": 13322090, "author": "Antti", "author_id": 1719245, "author_profile": "https://Stackoverflow.com/users/1719245", "pm_score": 5, "selected": false, "text": "copy \"$(SolutionDir)\\WebApplication1\\web.config\" \"$(ProjectDir)$(OutDir)$(TargetFileName).config\"\n copy \"$(ProjectDir)bin\\WebProject.dll.config\" \"$(SolutionDir)WebProject.Tests\\bin\\Debug\\App.Config\"\n" }, { "answer_id": 17949170, "author": "Zyo", "author_id": 396337, "author_profile": "https://Stackoverflow.com/users/396337", "pm_score": 2, "selected": false, "text": "[TestMethod]\n[HostType(\"ASP.NET\")] // will load the ConnectionString from the App.Config file\npublic void Test() {\n\n}\n" }, { "answer_id": 35928943, "author": "MichaelChan", "author_id": 4200965, "author_profile": "https://Stackoverflow.com/users/4200965", "pm_score": 3, "selected": false, "text": "Mock<IConfig> _configMock;\n_configMock.Setup(config => config.ConfigKey).Returns(\"ConfigValue\");\nvar SUT = new SUT(_configMock.Object);\n Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);\nif(config.AppSettings.Settings[configName] != null)\n{\n config.AppSettings.Settings.Remove(configName);\n}\nconfig.AppSettings.Settings.Add(configName, configValue);\nconfig.Save(ConfigurationSaveMode.Modified, true);\nConfigurationManager.RefreshSection(\"appSettings\");\n" }, { "answer_id": 59144038, "author": "Ben", "author_id": 1037314, "author_profile": "https://Stackoverflow.com/users/1037314", "pm_score": -1, "selected": false, "text": ".config app.config App.config" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20133/" ]
344,070
<p>Good day,</p> <p>we just moved from asp.net 1.1 to asp.net 2.0. We are using ajax update panels.</p> <p>In an Apress book (Pro asp.net 2008) , I've read that when you use the updatepanel, you don't reduce the acount of bandwidth sent, because the entire page is still sent. </p> <p>That in mind, I've also read on many websites that it is better to use multiple updatepanels instead of only one containing the entire page to 'reduce the amount of bandwidth sent'. In my opinion, there is a contradiction with the Apress book, and I was wondering what you guys think.</p> <p>Is it better to use only one updatepanel containing the entire page, or many ones? The performance is my main concern.</p>
[ { "answer_id": 344124, "author": "Jeromy Irvine", "author_id": 8223, "author_profile": "https://Stackoverflow.com/users/8223", "pm_score": 7, "selected": true, "text": ".config .testrunconfig .config bin\\Debug .config" }, { "answer_id": 344233, "author": "bryanbcook", "author_id": 30809, "author_profile": "https://Stackoverflow.com/users/30809", "pm_score": 6, "selected": false, "text": "<configuration>\n <appSettings>\n <add key=\"TestValue\" value=\"true\" />\n </appSettings>\n</configuration>\n [TestFixture]\npublic class GeneralFixture\n{\n [Test]\n public void VerifyAppDomainHasConfigurationSettings()\n {\n string value = ConfigurationManager.AppSettings[\"TestValue\"];\n Assert.IsFalse(String.IsNullOrEmpty(value), \"No App.Config found.\");\n }\n}\n public class MyObject\n{\n public void Configure(MyConfigurationObject config)\n {\n _enabled = config.Enabled;\n }\n\n public string Foo()\n {\n if (_enabled)\n {\n return \"foo!\";\n }\n return String.Empty;\n }\n\n private bool _enabled;\n}\n\n[TestFixture]\npublic class MyObjectTestFixture\n{\n [Test]\n public void CanInitializeWithProperConfig()\n {\n MyConfigurationObject config = new MyConfigurationObject();\n config.Enabled = true;\n\n MyObject myObj = new MyObject();\n myObj.Configure(config);\n\n Assert.AreEqual(\"foo!\", myObj.Foo());\n }\n}\n" }, { "answer_id": 1528427, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 7, "selected": false, "text": "app.config" }, { "answer_id": 13322090, "author": "Antti", "author_id": 1719245, "author_profile": "https://Stackoverflow.com/users/1719245", "pm_score": 5, "selected": false, "text": "copy \"$(SolutionDir)\\WebApplication1\\web.config\" \"$(ProjectDir)$(OutDir)$(TargetFileName).config\"\n copy \"$(ProjectDir)bin\\WebProject.dll.config\" \"$(SolutionDir)WebProject.Tests\\bin\\Debug\\App.Config\"\n" }, { "answer_id": 17949170, "author": "Zyo", "author_id": 396337, "author_profile": "https://Stackoverflow.com/users/396337", "pm_score": 2, "selected": false, "text": "[TestMethod]\n[HostType(\"ASP.NET\")] // will load the ConnectionString from the App.Config file\npublic void Test() {\n\n}\n" }, { "answer_id": 35928943, "author": "MichaelChan", "author_id": 4200965, "author_profile": "https://Stackoverflow.com/users/4200965", "pm_score": 3, "selected": false, "text": "Mock<IConfig> _configMock;\n_configMock.Setup(config => config.ConfigKey).Returns(\"ConfigValue\");\nvar SUT = new SUT(_configMock.Object);\n Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);\nif(config.AppSettings.Settings[configName] != null)\n{\n config.AppSettings.Settings.Remove(configName);\n}\nconfig.AppSettings.Settings.Add(configName, configValue);\nconfig.Save(ConfigurationSaveMode.Modified, true);\nConfigurationManager.RefreshSection(\"appSettings\");\n" }, { "answer_id": 59144038, "author": "Ben", "author_id": 1037314, "author_profile": "https://Stackoverflow.com/users/1037314", "pm_score": -1, "selected": false, "text": ".config app.config App.config" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42848/" ]
344,072
<p>I have a table with a large amount of information, how do i select just the last months worth? (ie just the last 31 cells in the column?)</p> <p>The data is in the form</p> <pre><code>date1 numbers date2 numbers . . . . . . daten numbers </code></pre> <p>where date1 is dd/mm/ccyy</p> <p>cheers</p>
[ { "answer_id": 344123, "author": "CestLaGalere", "author_id": 6684, "author_profile": "https://Stackoverflow.com/users/6684", "pm_score": 1, "selected": false, "text": "LastRow = Sheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row\n" }, { "answer_id": 344131, "author": "LeppyR64", "author_id": 16592, "author_profile": "https://Stackoverflow.com/users/16592", "pm_score": 3, "selected": true, "text": "Public Sub selectLastMonth()\n Dim ws As Worksheet\n Dim dStart As Date, dEnd As Date\n\n Set ws = ActiveSheet\n ws.Range(\"A:B\").Sort key1:=ws.Range(\"A2\"), header:=xlYes\n\n dEnd = ws.Range(\"A1\").End(xlDown).Value\n dStart = DateSerial(DatePart(\"yyyy\", dEnd), DatePart(\"m\", dEnd), 1)\n\n ws.Range(\"A:B\").AutoFilter field:=1, Criteria1:=\">=\" & dStart, Operator:=xlAnd, Criteria2:=\"<=\" & dEnd\n\n Set ws = Nothing\nEnd Sub\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
344,092
<p>I work for a large website. Our marketing department asks us to add ever more web ad tracking pixels to our pages. I have no problem with tracking the effectiveness of ad campaigns, but the servers serving those pixels can be unreliable. I'm sure most of you have seen web pages that refuse to finish loading because a pixel from yieldmanager.com won't finish downloading.</p> <p>If the pixel never finishes downloading, onLoad never fires, and, in our case, the page won't function without that. </p> <p>We have the additional problem of Gomez. As you may know they have bots all over the world that measure site speed, and it's important for us to look good in their measurements, despite flaws in their methodology. Their bots execute onLoad handlers. So even if I use a script that runs onLoad to add the pixels to the page after everything else finishes, we can still get crappy Gomez scores if the pixel takes 80 seconds to load. </p> <p>My solution was to add the pixels to the page via an onMouseMove handler, so only humans will trigger them. Do you guys have any better ideas ?</p>
[ { "answer_id": 344118, "author": "Stevo", "author_id": 1937, "author_profile": "https://Stackoverflow.com/users/1937", "pm_score": 4, "selected": true, "text": " $(document).ready(function(){\n // Your code here\n });\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43670/" ]
344,095
<p>Is that possible to have a single PHP SOAP server which will handle requests to several classes (services)?</p> <p>If yes, could you please show an example implementation?</p> <p>If not, could you please describe why?</p>
[ { "answer_id": 346571, "author": "gnud", "author_id": 27204, "author_profile": "https://Stackoverflow.com/users/27204", "pm_score": 0, "selected": false, "text": "class ServiceProxy {\n private $map = array();\n\n public function addMethod($name, $callback) {\n if(is_callable($callback)) {\n $this->map[$name] = $callback;\n return true;\n }\n return false;\n } \n\n function __call($name, $args) {\n if(isset($map[$name])) {\n return call_user_func_array($map[$name], $args);\n } else {\n return null;\n }\n }\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43668/" ]
344,098
<p>Consider the following table:</p> <pre><code>mysql&gt; select * from phone_numbers; +-------------+------+-----------+ | number | type | person_id | +-------------+------+-----------+ | 17182225465 | home | 1 | | 19172225465 | cell | 1 | | 12129876543 | home | 2 | | 13049876543 | cell | 2 | | 15064223454 | home | 3 | | 15064223454 | cell | 3 | | 18724356798 | home | 4 | | 19174335465 | cell | 5 | +-------------+------+-----------+ </code></pre> <p>I'm trying to find those people who have home phones but not cells. </p> <p>This query works:</p> <pre><code>mysql&gt; select h.* -&gt; from phone_numbers h -&gt; left join phone_numbers c -&gt; on h.person_id = c.person_id -&gt; and c.type = 'cell' -&gt; where h.type = 'home' -&gt; and c.number is null; +-------------+------+-----------+ | number | type | person_id | +-------------+------+-----------+ | 18724356798 | home | 4 | +-------------+------+-----------+ </code></pre> <p>but this one doesn't:</p> <pre><code>mysql&gt; select h.* -&gt; from phone_numbers h -&gt; left join phone_numbers c -&gt; on h.person_id = c.person_id -&gt; and h.type = 'home' -&gt; and c.type = 'cell' -&gt; where c.number is null; +-------------+------+-----------+ | number | type | person_id | +-------------+------+-----------+ | 19172225465 | cell | 1 | | 13049876543 | cell | 2 | | 15064223454 | cell | 3 | | 18724356798 | home | 4 | | 19174335465 | cell | 5 | +-------------+------+-----------+ </code></pre> <p>The only difference between the two is the location of the <code>h.type = 'home'</code> condition - in the first it's in the <code>where</code> clause and in the second it's part of the <code>on</code> clause.</p> <p>Why doesn't the second query return the same result as the first?</p>
[ { "answer_id": 344127, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 4, "selected": true, "text": "for each row in phone_numbers h /* Note this is ALL home AND cell phones */\n select c.number from phone_numbers c\n where h.person_id = c.person_id\n and h.type = 'home'\n and c.type = 'cell';\n if c.number is null (i.e. no row found)\n display h.*\n end if\nend loop;\n" }, { "answer_id": 30119476, "author": "Rohan Nayak", "author_id": 3890589, "author_profile": "https://Stackoverflow.com/users/3890589", "pm_score": 0, "selected": false, "text": "SEL * \nFROM phone_numbers T1\nWHERE typeS='home' AND person_id NOT IN\n(SELECT person_id FROM phone_numbers T2 WHERE T1.person_id=T2.person_id AND typeS='cell')\n" }, { "answer_id": 30162860, "author": "Naresh Chaudhary", "author_id": 4070498, "author_profile": "https://Stackoverflow.com/users/4070498", "pm_score": 0, "selected": false, "text": "select * from phone_numbers\nwhere person_id not in (select person_id from phone_numbers where type='cell')\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1094969/" ]
344,101
<p>Wish to simultaneously call a function multiple times. I wish to use threads to call a function which will utilize the machines capability to the fullest. This is a 8 core machine, and my requirement is to use the machine cpu from 10% to 100% or more. </p> <p>My requirement is to use the boost class. Is there any way I can accomplish this using the boost thread or threadpool library? Or some other way to do it?</p> <p>Also, if I have to call multiple functions with different parameters each time (with separate threads), what is the best way to do this? [using boost or not using boost] and how?</p> <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;string.h&gt; #include &lt;time.h&gt; #include &lt;boost/thread/mutex.hpp&gt; #include &lt;boost/bind.hpp&gt; using namespace std; using boost::mutex; using boost::thread; int threadedAPI1( ); int threadedAPI2( ); int threadedAPI3( ); int threadedAPI4( ); int threadedAPI1( ) { cout &lt;&lt; "Thread0" &lt;&lt; endl; } int threadedAPI2( ) { cout &lt;&lt; "Thread1" &lt;&lt; endl; } int threadedAPI3( ) { cout &lt;&lt; "Thread2" &lt;&lt; endl; } int threadedAPI4( ) { cout &lt;&lt; "Thread3" &lt;&lt; endl; } int main(int argc, char* argv[]) { boost::threadpool::thread_pool&lt;&gt; threads(4); // start a new thread that calls the "threadLockedAPI" function threads.schedule(boost::bind(&amp;threadedAPI1,0)); threads.schedule(boost::bind(&amp;threadedAPI2,1)); threads.schedule(boost::bind(&amp;threadedAPI3,2)); threads.schedule(boost::bind(&amp;threadedAPI4,3)); // wait for the thread to finish threads.wait(); return 0; } </code></pre> <p>The above is not working and I am not sure why? :-(</p>
[ { "answer_id": 344522, "author": "James Hopkin", "author_id": 11828, "author_profile": "https://Stackoverflow.com/users/11828", "pm_score": 2, "selected": false, "text": "int threadedAPI1( );\n\nboost::bind(&threadedAPI1,0)\n threads.schedule(&threadedAPI1)\n" }, { "answer_id": 344726, "author": "jalf", "author_id": 33213, "author_profile": "https://Stackoverflow.com/users/33213", "pm_score": 4, "selected": true, "text": "boost::bind(threadedAPI1, 0)() threadedAPI1(0) threadedAPI1(0) threadedAPI1() int threadedAPI1(int i);\n struct threadedAPI {\n threadedAPI(int i) : i(i) {} // A constructor taking the arguments you wish to pass to the thread, and saves them in the class instance.\n\n void operator()() { // The () operator is the function that is actually called when the thread starts, and because it is just a regular class member function, it can see the 'i' variable initialized by the constructor\n cout << \"Thread\" << i << endl; // No need to create 4 identical functions. We can just reuse this one, and pass a different `i` each time we call it.\n }\nprivate:\n int i;\n};\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35416/" ]
344,104
<p>I was wondering which was better:</p> <pre><code>$lookup = array( "a" =&gt; 1, "b" =&gt; 2, "c" =&gt; 3 ); return $lookup[$key]; </code></pre> <p>or</p> <pre><code>if ( $key == "a" ) return 1 else if ( $key == "b" ) return 2 else if ( $key == "c" ) return 3 </code></pre> <p>or maybe just a nice switch...</p> <pre><code>switch($key){ case "a": return 1; case "b": return 2; case "c": return 3; } </code></pre> <p>I always prefer the first method as I can separate the data from the code; At this scale it looks quite silly but on a larger scale with thousands of lines of lookup entries; How much longer is PHP going to take building an array and then only checking maybe 1 or 2 entries per request.</p> <p>I think it'd have to be tested and clocked, but I'd say the bigger and more complicated the array the slower it's going to become.</p> <p>PHP Should be able to handle lookups faster than I can in PHP-code, but building the array in the first place surely takes up a lot of time.</p>
[ { "answer_id": 344156, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "if()" }, { "answer_id": 344365, "author": "Christopher Lightfoot", "author_id": 24525, "author_profile": "https://Stackoverflow.com/users/24525", "pm_score": 1, "selected": false, "text": "emptyfunction: 0.00000087601416110992430969503855231472755349386716\nlookuparray: 0.00000136602194309234629100648257538086483009465155\nmakearrayonly: 0.00000156002373695373539708814922266633118397294311\nmakearray: 0.00000174602739810943597796187489595842734502184612\nifblock: 0.00000127001986503601083772739543942265072473674081\nswitchblock: 0.00000131001937389373773757957151314679222764425504\n" }, { "answer_id": 344760, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "{\n $x = 0;\n foreach ($test as $k => $v) {\n $x = sprintf(” % s=>%sn”,$k,$v);}\n}\n{\n $x = 0;\n reset($test);\n while (list($k, $v) = each($test)) {\n $x = sprintf(” % s=>%sn”,$k,$v);\n }\n}\n{\n $x = 0;\n $k = array_keys($test);\n $co = sizeof($k);\n for ($it = 0; $it < $co; $it++) {\n $x = sprintf(” % s=>%sn”,$k[$it],$test[$k[$it]]);\n }\n}\n{\n $x = 0;\n reset($test);\n while ($k = key($test)) {\n $x = sprintf(” % s=>%sn”,$k,current($test)); next($test);\n }\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24525/" ]
344,117
<p>Is there any way to get a String[] with the roles a user has in the JSP or Servlet?</p> <p>I know about request.isUserInRole("role1") but I also want to know all the roles of the user.</p> <p>I searched the servlet source and it seems this is not possible, but this seems odd to me.</p> <p>So... any ideas?</p>
[ { "answer_id": 344153, "author": "Steve McLeod", "author_id": 2959, "author_profile": "https://Stackoverflow.com/users/2959", "pm_score": 4, "selected": false, "text": " System.out.println(\"type = \" + request.getUserPrincipal().getClass());\n final Principal userPrincipal = request.getUserPrincipal();\n GenericPrincipal genericPrincipal = (GenericPrincipal) userPrincipal;\n final String[] roles = genericPrincipal.getRoles();\n" }, { "answer_id": 344223, "author": "Josh", "author_id": 2204759, "author_profile": "https://Stackoverflow.com/users/2204759", "pm_score": 4, "selected": true, "text": "String[] allRoles = {\"1\",\"2\",\"3\"};\nHttpServletRequest request = ... (or from method argument)\nList userRoles = new ArrayList(allRoles.length);\nfor(String role : allRoles) {\n if(request.isUserInRole(role)) { \n userRoles.add(role);\n }\n}\n\n// I forgot the exact syntax for list.toArray so this is prob wrong here\nreturn userRoles.toArray(String[].class);\n" }, { "answer_id": 37298248, "author": "SuperPiski", "author_id": 6350660, "author_profile": "https://Stackoverflow.com/users/6350660", "pm_score": 2, "selected": false, "text": "import weblogic.security.Security;\nimport weblogic.security.SubjectUtils;\n...\nprivate List<String> getUserRoles() {\n return Arrays.asList(SubjectUtils.getPrincipalNames(Security.getCurrentSubject()).split(\"/\"));\n}\n" }, { "answer_id": 48499806, "author": "Uux", "author_id": 3986374, "author_profile": "https://Stackoverflow.com/users/3986374", "pm_score": 2, "selected": false, "text": "Policy Policy#getPermissions(ProtectionDomain) getPermissions package com.example;\n\nimport java.security.CodeSource;\nimport java.security.Permission;\nimport java.security.PermissionCollection;\nimport java.security.Policy;\nimport java.security.Principal;\nimport java.security.ProtectionDomain;\nimport java.security.cert.Certificate;\nimport java.util.Collections;\nimport java.util.Enumeration;\nimport java.util.HashSet;\nimport java.util.Set;\n\nimport javax.security.auth.Subject;\nimport javax.security.jacc.PolicyContext;\nimport javax.security.jacc.PolicyContextException;\nimport javax.security.jacc.WebRoleRefPermission;\n\npublic final class Util {\n\n\n private static final Set<String> NO_ROLES = Collections.emptySet();\n private static final Permission DUMMY_WEB_ROLE_REF_PERM = new WebRoleRefPermission(\"\", \"dummy\");\n\n /**\n * Retrieves the declared Servlet security roles that have been mapped to the {@code Principal}s of\n * the currently authenticated {@code Subject}, optionally limited to the scope of the Servlet\n * referenced by {@code servletName}.\n * \n * @param servletName\n * The scope; {@code null} indicates Servlet-context-wide matching.\n * @return the roles; empty {@code Set} iff:\n * <ul>\n * <li>the remote user is unauthenticated</li>\n * <li>the remote user has not been associated with any roles declared within the search\n * scope</li>\n * <li>the method has not been called within a Servlet invocation context</li>\n * </ul>\n */\n public static Set<String> getCallerWebRoles(String servletName) {\n // get current subject\n Subject subject = getSubject();\n if (subject == null) {\n // unauthenticated\n return NO_ROLES;\n }\n Set<Principal> principals = subject.getPrincipals();\n if (principals.isEmpty()) {\n // unauthenticated?\n return NO_ROLES;\n }\n // construct a domain for querying the policy; the code source shouldn't matter, as far as\n // JACC permissions are concerned\n ProtectionDomain domain = new ProtectionDomain(new CodeSource(null, (Certificate[]) null), null, null,\n principals.toArray(new Principal[principals.size()]));\n // get all permissions accorded to those principals\n PermissionCollection pc = Policy.getPolicy().getPermissions(domain);\n // cause resolution of WebRoleRefPermissions, if any, in the collection, if still unresolved\n pc.implies(DUMMY_WEB_ROLE_REF_PERM);\n Enumeration<Permission> e = pc.elements();\n if (!e.hasMoreElements()) {\n // nothing granted, hence no roles\n return NO_ROLES;\n }\n Set<String> roleNames = NO_ROLES;\n // iterate over the collection and eliminate duplicates\n while (e.hasMoreElements()) {\n Permission p = e.nextElement();\n // only interested in Servlet container security-role(-ref) permissions\n if (p instanceof WebRoleRefPermission) {\n String candidateRoleName = p.getActions();\n // - ignore the \"any-authenticated-user\" role (only collect it if your\n // application has actually declared a role named \"**\")\n // - also restrict to the scope of the Servlet identified by the servletName\n // argument, unless null\n if (!\"**\".equals(candidateRoleName) && ((servletName == null) || servletName.equals(p.getName()))\n && ((roleNames == NO_ROLES) || !roleNames.contains(candidateRoleName))) {\n if (roleNames == NO_ROLES) {\n roleNames = new HashSet<>();\n }\n roleNames.add(candidateRoleName);\n }\n }\n }\n return roleNames;\n }\n\n private static Subject getSubject() {\n return getFromJaccPolicyContext(\"javax.security.auth.Subject.container\");\n }\n\n @SuppressWarnings(\"unchecked\")\n private static <T> T getFromJaccPolicyContext(String key) {\n try {\n return (T) PolicyContext.getContext(key);\n }\n catch (PolicyContextException | IllegalArgumentException e) {\n return null;\n }\n }\n\n private Util() {\n }\n\n}\n" }, { "answer_id": 74280772, "author": "Brian Akumah", "author_id": 9598447, "author_profile": "https://Stackoverflow.com/users/9598447", "pm_score": 0, "selected": false, "text": "import org.springframework.security.core.context.SecurityContextHolder; \n \n \n@GetMapping(\"/\")\npublic String someEndpoint() {\n System.out.println(SecurityContextHolder.getContext().getAuthentication().getAuthorities());\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43671/" ]
344,128
<p>I'm pulling back a Date and a Time from a database. They are stored in separate fields, but I would like to combine them into a java.util.Date object that reflects the date/time appropriately.</p> <p>Here is my original approach, but it is flawed. I always end up with a Date/Time that is 6 hours off what it should be. I think this is because the Time has a timezone offset as well as the Date, and I really only need one of them to have the timezone offset.</p> <p>Any suggestions on how to do this so that it will give me the correct Date/Time?</p> <pre><code>import java.sql.Time; import java.util.Calendar; import java.util.Date; import org.apache.commons.lang.time.DateUtils; public static Date combineDateTime(Date date, Time time) { if (date == null) return null; Date newDate = DateUtils.truncate(date, Calendar.DATE); if (time != null) { Date t = new Date(time.getTime()); newDate = new Date(newDate.getTime() + t.getTime()); } return newDate; } </code></pre>
[ { "answer_id": 344165, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 4, "selected": true, "text": " Calendar dCal = Calendar.getInstance();\n dCal.setTime(date);\n Calendar tCal = Calendar.getInstance();\n tCal.setTime(time);\n dCal.set(Calendar.HOUR_OF_DAY, tCal.get(Calendar.HOUR_OF_DAY));\n dCal.set(Calendar.MINUTE, tCal.get(Calendar.MINUTE));\n dCal.set(Calendar.SECOND, tCal.get(Calendar.SECOND));\n dCal.set(Calendar.MILLISECOND, tCal.get(Calendar.MILLISECOND));\n date = dCal.getTime();\n" }, { "answer_id": 344179, "author": "Nick Holt", "author_id": 41423, "author_profile": "https://Stackoverflow.com/users/41423", "pm_score": 1, "selected": false, "text": "ResultSet.getTime(String, Calendar) Calendar" }, { "answer_id": 344189, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 2, "selected": false, "text": "TimeZone TimeZone Date t = new Date(time.getTime());\n java.sql.Time newDate = new Date(newDate.getTime() + time.getTime());\n TimeZone java.sql.Time" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1310/" ]
344,161
<p>Using WMI VB scripting, I would like to create/attach multiple child processes to a parent process, such as the explorer process.</p> <p>When an app is started by clicking on it, it becomes a child process of the explorer process. The same is true for all apps that are loaded when Windows starts up.</p> <p>If you kill the explorer process using the "End Process Tree" context menu option in the task manager, it kills all child processes of the explorer process as well (a quick, brute force way to clean up memory without restarting).</p> <p>I have two scripts - one that kills a bunch of specific processes, and another that restarts those processes.</p> <p>Most of the processes/apps in my scripts are loaded at start-up thus they are children of the explorer process. When I kill the explorer process tree, all these process die, as explained earlier.</p> <p>When I restart these apps using a script, they are no longer children of the explorer process. When I kill the kill the explorer process tree, the apps started by the script do not die.</p> <p>Now, I know I can kill each process individually using a script. But it would be nice to just kill the explorer processes tree in a script without having to specify the individual apps I want to kill.</p> <p>So, if I have one script that can start my apps as children of the explorer process, my other script just has to kill the explorer processes tree.</p> <p>I have a script that does just that. It loops through and kills all the child processes of the explorer process. However it only works on apps that load at start up or are are clicked on.</p> <p>Also, by preventing these apps from loading at start-up, Windows loads MUCH faster. Later, I click on my script icon to load my apps when needed.</p> <p>That's why I want to create a script that can start apps as children of the explorer process.</p> <p>An interesting side note: I have to postpone killing any command/console processes, otherwise the script may kill itself before getting the rest of the processes.</p> <p>Any ideas how this can be done?</p> <p>Below is my code that fails.</p> <pre><code>Option Explicit dim wmi, rootProcessName, rootProcess, objStartup, objConfig, objProcess, strComputer, dropbox, itunes, skype strComputer = "." dropbox="C:\Program Files\Dropbox\Dropbox.exe" itunes="C:\Program Files\iTunes\iTunes.exe" skype="C:\Program Files\Skype\Phone\Skype.exe" Const NORMAL = 32 Set wmi = GetObject("winmgmts:\\" &amp; strComputer &amp; "\root\cimv2") Set objStartup = wmi.Get("Win32_ProcessStartup") Set objConfig = objStartup.SpawnInstance_ objConfig.PriorityClass = NORMAL rootProcessName = "'explorer.exe'" set rootProcess = wmi.ExecQuery("Select * from Win32_Process Where Name = " &amp; rootProcessName ) For Each objProcess in rootProcess objProcess.Create dropbox, null, objConfig objProcess.Create itunes, null, objConfig objProcess.Create skype, null, objConfig Next WScript.Quit </code></pre>
[ { "answer_id": 71476435, "author": "Spokes", "author_id": 3411895, "author_profile": "https://Stackoverflow.com/users/3411895", "pm_score": 0, "selected": false, "text": "dim shell = wscript.createObject(\"wscript.shell\")\nshell.run(<path-to-application>\\excel.exe)\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43244/" ]
344,162
<p>I have a bunch of old classic ASP pages, many of which show database data in tables. None of the pages have any sorting functionality built in: you are at the mercy of whatever ORDER BY clause the original developer saw fit to use.</p> <p>I'm working on a quick fix to tack on sorting via client-side javascript. I have a script already written that mostly does what I need. However, I still need to add one bit of functionality. The table rows in these pages will often have alternating row colors, and the mechanism used to achieve this varies among the pages. It might be as simple as changing a CSS class or the styles may have been rendered inline by the ASP code.</p> <p>Right now after sorting the table each row keeps the coloring scheme is was rendered with and so the alternating rows no longer alternate. I was hoping to fix it with something simple like this:</p> <pre><code>/* "table" is a var for the table element I'm sorting. I've already verified it exists, and that there are at least three rows. At this point the first row (index 0) is always the header row. */ // check for alternating row styles: var RowStyle = table.rows[1].style; var AltStyle = table.rows[2].style; // SORT HAPPENS HERE!! // snip // Apply alternating row styles if (RowStyle === AltStyle) return true; for (var i=1,il=table.rows.length;i&lt;il;i+=1) { if (i%2==0) table.rows[i].style=RowStyle; else table.rows[i].style=AltStyle; } </code></pre> <p>Unfortunately, you can't just set to an element's style property like this. It complains that the object has no setter. How else can I do this simply? No frameworks like jQuery allowed here- that's out of my hands.</p> <p><strong>Update:</strong><br> While it would be the best solution, it's just not practical to refactor 100+ pages to all use classes rather than inline style. Also, sometimes there's more involved than just the background color. For example, a row may be much darker or lighter than the alternating row, with one style having a different foreground color as well to accommodate. Or an alternating style may set borders differently. I really don't know what is used on all of these pages, so I need something that will generically apply <em>all</em> styles from one row to another.</p>
[ { "answer_id": 344204, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 6, "selected": true, "text": "cssText className var css1 = table.rows[1].style.cssText;\nvar css2 = table.rows[2].style.cssText;\nvar class1 = table.rows[1].className;\nvar class2 = table.rows[2].className;\n\n// sort\n\n// loop\n if (i%2==0) {\n table.rows[i].style.cssText = css1;\n table.rows[i].className = class1;\n } else {\n table.rows[i].style.cssText = css2;\n table.rows[i].className = class2;\n }\n cssText" }, { "answer_id": 344336, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 2, "selected": false, "text": "function transferAllStyles(elemFrom, elemTo)\n{\n var prop;\n for (prop in elemFrom.style)\n if (typeof prop == \"string\")\n try { elemTo.style[prop] = elemFrom.style[prop]; }\n catch (ex) { /* don't care */ }\n}\n" }, { "answer_id": 344427, "author": "scunliffe", "author_id": 6144, "author_profile": "https://Stackoverflow.com/users/6144", "pm_score": 5, "selected": false, "text": "//Standards base browsers\nelem.setAttribute('style', styleString);\n\n//Non Standards based IE browser\nelem.style.setAttribute('cssText', styleString);\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
344,168
<p>I have a page that allows users to enter a lot of information about them (metadata) they can then click on a icon which opens a modal window containing a googlemap which allows them to add locations, and a title for that location.</p> <p>Using mootools I can pass the value of a form field back to the original form, using onclose. The main page form then has a single hidden input field, which goes into the database as one field, serialised. </p> <p>The problem is a user can add as many locations as they want, there are also 3 types of location. Each with its own set of co-ordinates, which can be single or multiple!</p> <p>So I want to know the best way to handle all of this data, is it possible to load it into one form and then use Moo to submit that form to a single form field, or can I use moo to just append all the information into a single hidden input field, but if I do that, how does user input come into it. Im stumped and looking at some suggestions on how to set this up in the 'best' possible way.</p> <p>Currently I have a table, and each item is added as a new row, by JS when a user clicks on the map, it creates a new row with the details about the click, item and then a user input field.</p> <p>If its a single location then its added as 'placemark', a user input field for the name and then the co-ordinates go into a 3rd table cell. However if its a shape, then the first cell contains 'shape', user input field for name/description, and the third cell contains a list of co-ordinates one for each point, this is the same for lines.</p> <p>The problem I have is I could write it all to a single form field, but then how do I allow for user input of the titles, I need to use a form field for that? The other option is to take each row from a table and input it into the single form field, seperated by a pipe or similar, but then im not sure if I can read from other form fields.</p> <p>I hope the above makes some sense!! All feedback welcome!</p> <p>Im using mootools for this, but providing I can get my head around the layout then that should not really be an issue.</p>
[ { "answer_id": 344408, "author": "Elocution Safari", "author_id": 43670, "author_profile": "https://Stackoverflow.com/users/43670", "pm_score": 3, "selected": true, "text": "var usersLocations = {\"locations\": [\n {\"type\": \"point\", \"coords\": [100,200]},\n {\"type\": \"line\", \"coords\": [[200,300],[400,500]]},\n {\"type\": \"shape\", \"coords\": [[200,300],[400,500],[1000,1500]]}\n ]\n};\n usersLocations.locations[0][\"type\"] = \"<what the user typed>\";\n" }, { "answer_id": 822762, "author": "Barett", "author_id": 95674, "author_profile": "https://Stackoverflow.com/users/95674", "pm_score": 0, "selected": false, "text": "usersLocations.locations[0][\"name\"] = document.getElementById(\"location0name\").value;\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28241/" ]
344,171
<p>As we know that, with compute function of datatable we can get sum of columns. But I want to get sum of a row of datatable. I will explain with a example:</p> <p>I have a datatable like image below: With compute function we can get the sum of each column (product). Such as for product1, 2 + 12 + 50 + 13= 77.</p> <p>I want to get sum of company1 : 2 + 6 + 4 + 3 + 5 = 20</p> <p><a href="http://img123.imageshack.us/img123/1517/61519307xx5.jpg" rel="nofollow noreferrer">http://img123.imageshack.us/img123/1517/61519307xx5.jpg</a></p> <p>How can I do it with asp.net 1.1?</p>
[ { "answer_id": 344215, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 2, "selected": false, "text": "\"Quantity * UnitPrice\"" }, { "answer_id": 344279, "author": "Jason Jackson", "author_id": 13103, "author_profile": "https://Stackoverflow.com/users/13103", "pm_score": 3, "selected": true, "text": "DataTable dt = WhateverCreatesDataTable();\nDataRow dr = dt.Rows[0];\nint sum = dt.Columns.Cast<DataColumn>().Sum(dc=>(int)dr[dc]);\n DataTable dt = WhateverCreatesDataTable();\nDataRow dr = dt.Rows[0];\nint sum = 0;\n\nforeach(DataColumn dc in dt.Columns)\n sum += (int)dr[dc];\n" }, { "answer_id": 421194, "author": "Binoj Antony", "author_id": 33015, "author_profile": "https://Stackoverflow.com/users/33015", "pm_score": 2, "selected": false, "text": "DataColumn totalColumn = new DataColumn();\ntotalColumn.DataType = System.Type.GetType(\"System.Int32\");\ntotalColumn.ColumnName = \"Total\";\ntotalColumn.Expression = \"Product1 + Product2 + Product3 + Product4 + Product5\";\n\n// Populate and get the DataTable dt then add this computed column to this table\n\ndt.Columns.Add(totalColumn);\n//Now if you access the column \"Total\" of the table you will get the desired result.\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/439507/" ]
344,199
<p>I know how to do a regular php mysql search and display the results. However, because of the nature of what I'm trying to accomplish I need to be able to sort by relevancy. Let me explain this better:</p> <p>Normal Query "apple iphone applications" will search the database using %apple iphone application%, but if there aren't records which display that phrase in that exact order the search will produce nothing.</p> <p>What I basically need to do is search for 'apple', 'iphone' and 'applications' all separately and then merge the results into one, and then I need to grade the relevancy by how many instances of the word are found in the records. For example if I did what I wanted to do and it returned them following:</p> <pre><code>Iphone Applications From Apple Apple Make The Best Apple Iphone Applications Iphone Applications </code></pre> <p>They would rank as follows:</p> <pre><code>Apple Make The Best Apple Iphone Applications Iphone Applications From Apple Iphone Applications </code></pre> <p>Because of how many instances of the search terms are found. See highlighted:</p> <pre><code>[Apple] Make The Best [Apple] [Iphone] [Applications] [Iphone] [Applications] From [Apple] [Iphone] [Applications] </code></pre> <p>I hope I have explained this well enough and I would be extremely grateful if anyone could give me any pointers.</p>
[ { "answer_id": 344213, "author": "Filip Ekberg", "author_id": 39106, "author_profile": "https://Stackoverflow.com/users/39106", "pm_score": 3, "selected": false, "text": "select title, match (title,content) against (”internet”) as score \nfrom cont \nwhere match (title,content) against (”internet”) limit 10;\n" }, { "answer_id": 344283, "author": "Murat Ayfer", "author_id": 25910, "author_profile": "https://Stackoverflow.com/users/25910", "pm_score": 1, "selected": false, "text": "SELECT field2, field3, ..., MATCH(field1, field2) AGAINST (\"search string\") AS relevance WHERE MATCH(field1, field2) AGAINST \"search string\" ORDER BY relevance DESC LIMIT 0,10\n" }, { "answer_id": 28991545, "author": "Martijn H.", "author_id": 2449481, "author_profile": "https://Stackoverflow.com/users/2449481", "pm_score": 3, "selected": false, "text": "SELECT *, ( (value_column LIKE '%rusten%') + (value_column LIKE '%dagen%') + (value_column LIKE '%bezoek%') + (value_column LIKE '%moeten%') ) as count_words\nFROM data_table\nWHERE (value_column LIKE '%dagen%' OR value_column LIKE '%rusten%' OR value_column LIKE '%bezoek%' OR value_column LIKE '%moeten%')\nORDER BY count_words DESC\n SELECT * FROM data_table\nWHERE MATCH(value_column) AGAINST('+dagen +rusten +bezoek +moeten' IN BOOLEAN MODE)\nORDER BY MATCH(value_column) AGAINST('+dagen +rusten +bezoek +moeten' IN BOOLEAN MODE) DESC;\n" }, { "answer_id": 43289959, "author": "Rohit Kumar", "author_id": 7835649, "author_profile": "https://Stackoverflow.com/users/7835649", "pm_score": 0, "selected": false, "text": "SELECT (\"some text here\" or `column_name`) RLIKE \"Apple|Iphone|Application\" AS Result ORDER BY Result DESC;\n SELECT * FROM \"table_name\" WHERE `column_name` RLIKE \"Apple|Iphone|Application\";\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26823/" ]
344,203
<p>What is the maximum number of threads that can be created by a process under Linux?</p> <p>How (if possible) can this value be modified?</p>
[ { "answer_id": 344264, "author": "Vincent Van Den Berghe", "author_id": 39259, "author_profile": "https://Stackoverflow.com/users/39259", "pm_score": 4, "selected": false, "text": "cat /proc/sys/kernel/threads-max\n echo 123456789 | sudo tee -a /proc/sys/kernel/threads-max\n" }, { "answer_id": 344292, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 9, "selected": true, "text": "cat /proc/sys/kernel/threads-max\n echo 100000 > /proc/sys/kernel/threads-max\n ulimit/getrlimit" }, { "answer_id": 1743959, "author": "wefeqfw", "author_id": 212289, "author_profile": "https://Stackoverflow.com/users/212289", "pm_score": 2, "selected": false, "text": "nbio" }, { "answer_id": 9211891, "author": "codersofthedark", "author_id": 1060337, "author_profile": "https://Stackoverflow.com/users/1060337", "pm_score": 6, "selected": false, "text": "number of threads = total virtual memory / (stack size*1024*1024)\n ulimit -v ulimit -s ulimit -s newvalue\n\nulimit -v newvalue\n" }, { "answer_id": 19914078, "author": "c4f4t0r", "author_id": 2597174, "author_profile": "https://Stackoverflow.com/users/2597174", "pm_score": 4, "selected": false, "text": " max_threads = totalram_pages / (8 * 8192 / 4096);\n /* The default maximum number of threads is set to a safe\n * value: the thread structures can take up at most half\n * of memory.\n */\nmax_threads = mempages / (8 * THREAD_SIZE / PAGE_SIZE);\n" }, { "answer_id": 21926745, "author": "Albert Kong", "author_id": 2745009, "author_profile": "https://Stackoverflow.com/users/2745009", "pm_score": 3, "selected": false, "text": "$ cat /proc/sys/kernel/threads-max \n max_threads = mempages / (8 * THREAD_SIZE / PAGE_SIZE);\n cat /proc/zoneinfo | grep spanned | awk '{totalpages=totalpages+$2} END {print totalpages}';\n ulimit -s" }, { "answer_id": 26190804, "author": "Vladimir Kunschikov", "author_id": 2277408, "author_profile": "https://Stackoverflow.com/users/2277408", "pm_score": 5, "selected": false, "text": "ulimit -s 256\nulimit -i 120000\necho 120000 > /proc/sys/kernel/threads-max\necho 600000 > /proc/sys/vm/max_map_count\necho 200000 > /proc/sys/kernel/pid_max \n\n ./100k-pthread-create-app\n /etc/systemd/logind.conf: UserTasksMax=100000\n" }, { "answer_id": 40089863, "author": "Matteo Zocca", "author_id": 7001293, "author_profile": "https://Stackoverflow.com/users/7001293", "pm_score": 2, "selected": false, "text": "vim /etc/sysctl.conf\n kernel.threads-max = \"value\"\n" }, { "answer_id": 44156540, "author": "Axel Podehl", "author_id": 1338132, "author_profile": "https://Stackoverflow.com/users/1338132", "pm_score": 3, "selected": false, "text": " ulimit -a\n...\n stack size (kbytes, -s) 10240\n" }, { "answer_id": 66218324, "author": "wuchang", "author_id": 2256006, "author_profile": "https://Stackoverflow.com/users/2256006", "pm_score": 2, "selected": false, "text": "root@myhost:~# lsb_release -a\nNo LSB modules are available.\nDistributor ID: Ubuntu\nDescription: Ubuntu 16.04.7 LTS\nRelease: 16.04\nCodename: xenial\nroot@myhost:~# uname -a\nLinux myhost 4.4.0-190-generic #220-Ubuntu SMP Fri Aug 28 23:02:15 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux\n java/jstack/jstat ...\n#\n# There is insufficient memory for the Java Runtime Environment to continue.\n# Cannot create GC thread. Out of system resources.\n# An error report file with more information is saved as:\n# /root/hs_err_pid1390.log\n root@lascorehadoop-15a32:~# free -mh\n total used free shared buff/cache available\nMem: 125G 11G 41G 1.2G 72G 111G\nSwap: 0B 0B 0B\n ~# ps -eLf|wc -l\n31506\n root@myhost:~# ulimit -a\ncore file size (blocks, -c) 0\ndata seg size (kbytes, -d) unlimited\nscheduling priority (-e) 0\nfile size (blocks, -f) unlimited\npending signals (-i) 515471\nmax locked memory (kbytes, -l) 64\nmax memory size (kbytes, -m) unlimited\nopen files (-n) 98000\npipe size (512 bytes, -p) 8\nPOSIX message queues (bytes, -q) 819200\nreal-time priority (-r) 0\nstack size (kbytes, -s) 8192\ncpu time (seconds, -t) unlimited\nmax user processes (-u) 515471\nvirtual memory (kbytes, -v) unlimited\nfile locks (-x) unlimited\n kernel.pid_max" }, { "answer_id": 69264209, "author": "Mz A", "author_id": 5756620, "author_profile": "https://Stackoverflow.com/users/5756620", "pm_score": 0, "selected": false, "text": "/etc/systemd/system.conf\n DefaultTasksMax=Value\n /etc/systemd/system/sshd.service.d/override.conf\n TasksMax=Value\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
344,210
<p>I'm using the ASP.net cache in a web project, and I'm writing a "status" page for it which shows the items in the cache, and as many statistics about the cache as I can find. Is there any way that I can get the total size (in bytes) of the cached data? The size of each item would be even better. I want to display this on a web page, so I don't think I can use a performance counter.</p>
[ { "answer_id": 344329, "author": "Ryan Cook", "author_id": 43029, "author_profile": "https://Stackoverflow.com/users/43029", "pm_score": 5, "selected": true, "text": "Cache.EffectivePrivateBytesLimit" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16872/" ]
344,212
<p>Ok I need to change the value of a hidden field in a gridview and here is what I have so far:</p> <pre><code>for(var i = 0; i &lt; gv_Proofs.rows.length; i++) { var tbl_Cell = gv_Proofs.rows[i].cells[0]; var sdiFound = false; for(var x = 0; x &lt; tbl_Cell.childNodes.length; x++) { if(tbl_Cell.childNodes[x].id == "_ctl0_MasterContentPlaceHolder_gv_Proofs__ctl2_lbl_SDI") { if(tbl_Cell.childNodes[x].innerHTML == sdi) sdiFound = true; } if(tbl_Cell.childNodes[x].id == "_ctl0_MasterContentPlaceHolder_gv_Proofs__ctl2_lbl_Updated" &amp;&amp; sdiFound) tbl_Cell.childNodes[x].value = "true"; } } </code></pre> <p>can anyone tell me what I am doing wrong? Thank You!</p>
[ { "answer_id": 344266, "author": "Mike Robinson", "author_id": 43687, "author_profile": "https://Stackoverflow.com/users/43687", "pm_score": 0, "selected": false, "text": "<%= lbl_SDI.ClientID %>\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2486/" ]
344,236
<p>I have yet another managed C++ KeyValuePair question where I know what to do in C#, but am having a hard time translating to managed C++. Here is the code that does what I want to do in C#:</p> <pre><code>KeyValuePair&lt;String, String&gt; KVP = new KeyValuePair&lt;string, string&gt;("this", "that"); </code></pre> <p>I've reflected it into MC++ and get this:</p> <pre><code>KeyValuePair&lt;String __gc*, String __gc*&gt; __gc* KVP = (S"this", S"that"); </code></pre> <p>which I'm translating to:</p> <pre><code>KeyValuePair&lt;String ^, String ^&gt; KVP = (gcnew String("this"), gcnew String("that")); </code></pre> <p>I know from my <a href="https://stackoverflow.com/questions/341477/generic-generics-in-managed-c">previous question</a> that KeyValuePair is a value type; is the problem that it's a value type in C++ and a reference type in C#? Can anyone tell me how to set the key and value of a KeyValuePair from C++? </p>
[ { "answer_id": 344331, "author": "Excel Kobayashi", "author_id": 42911, "author_profile": "https://Stackoverflow.com/users/42911", "pm_score": 3, "selected": true, "text": "KeyValuePair< String ^, String ^> k(gcnew String(\"Foo\"), gcnew String(\"Bar\"));" }, { "answer_id": 344370, "author": "Aaron Fischer", "author_id": 5618, "author_profile": "https://Stackoverflow.com/users/5618", "pm_score": 1, "selected": false, "text": "System::Collections::Generic::KeyValuePair< System::String^, System::String^>^ k = gcnew System::Collections::Generic::KeyValuePair< System::String^, System::String^>(gcnew System::String(\"foo\") ,gcnew System::String(\"bar\")) ;\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2831/" ]
344,257
<p>I want to create tag in subversion. On the command line I have tried the following:</p> <p><strong>svn copy <a href="http://myserver.mycompany.com:8080/svn/SVN_Main/trunk" rel="nofollow noreferrer">http://myserver.mycompany.com:8080/svn/SVN_Main/trunk</a> <a href="http://myserver.mycompany.com:8080/svn/SVN_Main/tag/Build-5.4.3.2" rel="nofollow noreferrer">http://myserver.mycompany.com:8080/svn/SVN_Main/tag/Build-5.4.3.2</a> -m "Build 5.4.3.2 tag"</strong></p> <p>I get this error:</p> <p><strong>svn: Path '<a href="http://myserver.mycompany.com:8080/svn/SVN_Main/trunk" rel="nofollow noreferrer">http://myserver.mycompany.com:8080/svn/SVN_Main/trunk</a>' does not exist for revision 1234</strong></p> <p>The path <a href="http://myserver.mycompany.com:8080/svn/SVN_Main/trunk" rel="nofollow noreferrer">http://myserver.mycompany.com:8080/svn/SVN_Main/trunk</a> is exact same path that I have when I use the repro-browser on that folder. Any ideas on what may be causing this problem? I have also tried it w/wo username/password.</p>
[ { "answer_id": 344330, "author": "derobert", "author_id": 27727, "author_profile": "https://Stackoverflow.com/users/27727", "pm_score": 1, "selected": false, "text": "-r svn ls -r" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43688/" ]
344,263
<p>I want to pass the params collection from the controller to the model to parse filtering and sorting conditions. Does having a method in the model that takes the params from the controller break MVC?</p>
[ { "answer_id": 344483, "author": "Daniel Lucraft", "author_id": 11951, "author_profile": "https://Stackoverflow.com/users/11951", "pm_score": 2, "selected": false, "text": "class Model < ActiveRecord::Base\n def update_from_params(params)\n ....\n end\nend\n\nclass ModelsController < ActionController::Base\n def update\n ...\n @model.update_from_params(params)\n end\nend\n class Model < ActiveRecord::Base\n def update_from_update_params(params)\n # do stuff\n end\n\n def update_from_settings_params(params)\n # do different stuff\n end\n\nend\n\nclass ModelsController < ActionController::Base\n def update\n ...\n @model.update_from_update_params(params)\n end\n\n def change_settings\n ...\n @model.update_from_settings_params(params)\n end\nend\n class Model < ActiveRecord::Base\n def update_from_data(hash)\n validate_data!(hash)\n # do stuff\n end\nend\n\nclass ModelsController < ActionController::Base\n def update\n ...\n @model.update_from_data(translate_update_params)\n end\n\n def change_settings\n ...\n @model.update_from_data(translate_change_settings_params)\n end\nend\n" }, { "answer_id": 914642, "author": "Kris", "author_id": 22237, "author_profile": "https://Stackoverflow.com/users/22237", "pm_score": 1, "selected": false, "text": "# in controller\ndef search\n Model.search(params[:search][:options])\nend\n <!-- in view -->\n<input type='text' name='search[options][keywords]' />\n<input type='text' name='search[options][conditions]' />\n<input type='text' name='search[options][sort]' />\n def self.do_search(criteria)\n\n Rental.search(criteria[:keywords], \n :per_page => self.per_page,\n :page => page,\n :conditions => criteria[:conditions],\n :order => criteria[:sort])\n\nend\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
344,273
<p>I have a SQL Report that insists on printing an extra blank page at the end, even though all the report items should fit on one page. I tried shortening the elements on the page that is spilling over, but no matter how much I compress them, or how much blank space is left on the first page, SRS still thinks it needs to take up another page as well. This is annoying because it's such a common problem - all it takes is one mistake to make a report spill over. So I'm not asking how can I fix this on this one report, but how can I fix this on this and future reports: Is there a flag or setting I can set to tell SRS "No matter what, never print more than 1 page"? Or "Suppress blank pages = true"?</p>
[ { "answer_id": 28583841, "author": "Biruk Tilahun", "author_id": 4098056, "author_profile": "https://Stackoverflow.com/users/4098056", "pm_score": 0, "selected": false, "text": "ConsumeContainerWhitespace TRUE FALSE" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
344,280
<p>I'm currently writing an app for a Windows Mobile 5.0 app and it seems to possess some firewall-esqe feature where I need to permit the running of any deployed executable. Is there some kind of registry key I can use to turn this off during development as it's frustrating having to babysit the device.</p>
[ { "answer_id": 28583841, "author": "Biruk Tilahun", "author_id": 4098056, "author_profile": "https://Stackoverflow.com/users/4098056", "pm_score": 0, "selected": false, "text": "ConsumeContainerWhitespace TRUE FALSE" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1143/" ]
344,315
<p>I am trying to test a class that manages data access in the database (you know, CRUD, essentially). The DB library we're using happens to have an API wherein you first get the table object by a static call:</p> <pre><code>function getFoo($id) { $MyTableRepresentation = DB_DataObject::factory("mytable"); $MyTableRepresentation-&gt;get($id); ... do some stuff return $somedata } </code></pre> <p>...you get the idea.</p> <p>We're trying to test this method, but mocking the DataObject stuff so that (a) we don't need an actual db connection for the test, and (b) we don't even need to include the DB_DataObject lib for the test.</p> <p>However, in PHPUnit I can't seem to get $this->getMock() to appropriately set up a static call. I have...</p> <pre><code> $DB_DataObject = $this-&gt;getMock('DB_DataObject', array('factory')); </code></pre> <p>...but the test still says unknown method "factory". I know it's creating the object, because before it said it couldn't find DB_DataObject. Now it can. But, no method?</p> <p>What I really want to do is to have two mock objects, one for the table object returned as well. So, not only do I need to specify that factory is a static call, but also that it returns some specified other mock object that I've already set up.</p> <p>I should mention as a caveat that I did this in SimpleTest a while ago (can't find the code) and it worked fine.</p> <p>What gives?</p> <p>[UPDATE]</p> <p>I am starting to grasp that it has something to do with expects()</p>
[ { "answer_id": 344531, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 0, "selected": false, "text": " public function setUp() {\n $mockDb = new MockDb();\n DB_DataObject::setAdapter($mockDb);\n }\n" }, { "answer_id": 3285554, "author": "David Harkness", "author_id": 285873, "author_profile": "https://Stackoverflow.com/users/285873", "pm_score": 2, "selected": false, "text": "function getFoo($id) {\n $MyTableRepresentation = $this->getTable(\"mytable\");\n $MyTableRepresentation->get($id);\n ... do some stuff\n return $somedata\n}\n\nfunction getTable($table) {\n return DB_DataObject::factory($table);\n}\n function testMyTable() {\n $dao = $this->getMock('MyTableDao', array('getMock'));\n $table = $this->getMock('DB_DataObject', ...);\n $dao->expects($this->any())\n ->method('getTable')\n ->with('mytable')\n ->will($this->returnValue($table));\n $table->expects...\n ...test...\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/577/" ]
344,317
<p>On a Unix system, where does gcc look for header files?</p> <p>I spent a little time this morning looking for some system header files, so I thought this would be good information to have here.</p>
[ { "answer_id": 344321, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 4, "selected": false, "text": " /usr/local/include\n libdir/gcc/target/version/include\n /usr/target/include\n /usr/include\n" }, { "answer_id": 344347, "author": "robert", "author_id": 32805, "author_profile": "https://Stackoverflow.com/users/32805", "pm_score": 5, "selected": false, "text": "-I" }, { "answer_id": 344446, "author": "diciu", "author_id": 2811, "author_profile": "https://Stackoverflow.com/users/2811", "pm_score": 5, "selected": false, "text": "$ echo \"#include <bogus.h>\" > t.c; gcc -v t.c; rm t.c\n\n[..]\n\n#include \"...\" search starts here:\n#include <...> search starts here:\n /usr/local/include\n /usr/lib/gcc/i686-apple-darwin9/4.0.1/include\n /usr/include\n /System/Library/Frameworks (framework directory)\n /Library/Frameworks (framework directory)\nEnd of search list.\n\n[..]\n\nt.c:1:32: error: bogus.h: No such file or directory\n" }, { "answer_id": 344525, "author": "Drew Dormann", "author_id": 16287, "author_profile": "https://Stackoverflow.com/users/16287", "pm_score": 9, "selected": true, "text": "`gcc -print-prog-name=cc1plus` -v\n `gcc -print-prog-name=cpp` -v\n" }, { "answer_id": 19170533, "author": "user2844647", "author_id": 2844647, "author_profile": "https://Stackoverflow.com/users/2844647", "pm_score": 1, "selected": false, "text": "echo $C_INCLUDE_PATH\n export C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/include\n" }, { "answer_id": 33485647, "author": "zwol", "author_id": 388520, "author_profile": "https://Stackoverflow.com/users/388520", "pm_score": 4, "selected": false, "text": "$ LC_ALL=C gcc -v -E -xc - < /dev/null 2>&1 | \n LC_ALL=C sed -ne '/starts here/,/End of/p'\n #include \"...\" search starts here:\n#include <...> search starts here:\n /usr/lib/gcc/x86_64-linux-gnu/5/include\n /usr/local/include\n /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed\n /usr/include/x86_64-linux-gnu\n /usr/include\nEnd of search list.\n -I sed LC_ALL=C sed" }, { "answer_id": 41381666, "author": "user292283", "author_id": 7354409, "author_profile": "https://Stackoverflow.com/users/7354409", "pm_score": 4, "selected": false, "text": "g++ -print-search-dirs\ngcc -print-search-dirs\n" }, { "answer_id": 72762087, "author": "Rick", "author_id": 5983841, "author_profile": "https://Stackoverflow.com/users/5983841", "pm_score": 0, "selected": false, "text": "gcc -print-prog-name=cc1plus -v Configured with: /home/tian/playground/gcc_build_play/objdir/../gcc-12.1.0/configure --prefix=/home/tian/GCC-12.1.0 --disable-multilib\n mv ./gcc -print-prog-name=cc1plus -v tian@tian-B250M-Wind:~/GCC-12.1.0/bin$ `./gcc -print-prog-name=cc1plus` -v\nignoring nonexistent directory \"/home/tian/GCC-12.1.0/lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../x86_64-pc-linux-gnu/include\"\n#include \"...\" search starts here:\n#include <...> search starts here:\n /home/tian/GCC-12.1.0/lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0\n /home/tian/GCC-12.1.0/lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/x86_64-pc-linux-gnu\n /home/tian/GCC-12.1.0/lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/backward\n /home/tian/GCC-12.1.0/lib/gcc/x86_64-pc-linux-gnu/12.1.0/include\n /usr/local/include\n /home/tian/GCC-12.1.0/include\n /home/tian/GCC-12.1.0/lib/gcc/x86_64-pc-linux-gnu/12.1.0/include-fixed\n /usr/include\nEnd of search list.\n mv ~/Desktop/ tian@tian-B250M-Wind:~/Desktop/GCC-12.1.0/bin$ `./gcc -print-prog-name=cc1plus` -v\nignoring nonexistent directory \"/home/tian/GCC-12.1.0/include/c++/12.1.0\"\nignoring nonexistent directory \"/home/tian/GCC-12.1.0/include/c++/12.1.0/x86_64-pc-linux-gnu\"\nignoring nonexistent directory \"/home/tian/GCC-12.1.0/include/c++/12.1.0/backward\"\nignoring nonexistent directory \"/home/tian/GCC-12.1.0/lib/gcc/x86_64-pc-linux-gnu/12.1.0/include\"\nignoring nonexistent directory \"/home/tian/GCC-12.1.0/include\"\nignoring nonexistent directory \"/home/tian/GCC-12.1.0/lib/gcc/x86_64-pc-linux-gnu/12.1.0/include-fixed\"\nignoring nonexistent directory \"/home/tian/GCC-12.1.0/x86_64-pc-linux-gnu/include\"\n#include \"...\" search starts here:\n#include <...> search starts here:\n /usr/local/include\n /usr/include\nEnd of search list.\n ./g++ /usr/include /usr/local/include mv ./g++ /usr/include /usr/local/include ./g++ gcc g++ /path_to_gcc12/bin/gcc ./g++ -g -Wall --verbose -o test test.cpp tian@tian-B250M-Wind:~/Desktop/GCC-12.1.0/bin$ ./g++ -g -Wall --verbose -o test test.cpp\nUsing built-in specs.\nCOLLECT_GCC=./g++\nCOLLECT_LTO_WRAPPER=/home/tian/Desktop/GCC-12.1.0/bin/../libexec/gcc/x86_64-pc-linux-gnu/12.1.0/lto-wrapper\nTarget: x86_64-pc-linux-gnu\nConfigured with: /home/tian/playground/gcc_build_play/objdir/../gcc-12.1.0/configure --prefix=/home/tian/GCC-12.1.0 --disable-multilib\nThread model: posix\nSupported LTO compression algorithms: zlib\ngcc version 12.1.0 (GCC) \nCOLLECT_GCC_OPTIONS='-g' '-Wall' '-v' '-o' 'test' '-shared-libgcc' '-mtune=generic' '-march=x86-64'\n /home/tian/Desktop/GCC-12.1.0/bin/../libexec/gcc/x86_64-pc-linux-gnu/12.1.0/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -iprefix /home/tian/Desktop/GCC-12.1.0/bin/../lib/gcc/x86_64-pc-linux-gnu/12.1.0/ -D_GNU_SOURCE test.cpp -quiet -dumpbase test.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -g -Wall -version -o /tmp/ccrg0qhG.s\nGNU C++17 (GCC) version 12.1.0 (x86_64-pc-linux-gnu)\n compiled by GNU C version 12.1.0, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP\n\nGGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072\nignoring nonexistent directory \"/home/tian/Desktop/GCC-12.1.0/bin/../lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../x86_64-pc-linux-gnu/include\"\nignoring duplicate directory \"/home/tian/Desktop/GCC-12.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0\"\nignoring duplicate directory \"/home/tian/Desktop/GCC-12.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/x86_64-pc-linux-gnu\"\nignoring duplicate directory \"/home/tian/Desktop/GCC-12.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/backward\"\nignoring duplicate directory \"/home/tian/Desktop/GCC-12.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/12.1.0/include\"\nignoring nonexistent directory \"/usr/local/include/x86_64-linux-gnu\"\nignoring duplicate directory \"/home/tian/Desktop/GCC-12.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/12.1.0/include-fixed\"\nignoring nonexistent directory \"/home/tian/Desktop/GCC-12.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../x86_64-pc-linux-gnu/include\"\n#include \"...\" search starts here:\n#include <...> search starts here:\n /home/tian/Desktop/GCC-12.1.0/bin/../lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0\n /home/tian/Desktop/GCC-12.1.0/bin/../lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/x86_64-pc-linux-gnu\n /home/tian/Desktop/GCC-12.1.0/bin/../lib/gcc/x86_64-pc-linux-gnu/12.1.0/../../../../include/c++/12.1.0/backward\n /home/tian/Desktop/GCC-12.1.0/bin/../lib/gcc/x86_64-pc-linux-gnu/12.1.0/include\n /home/tian/Desktop/GCC-12.1.0/bin/../lib/gcc/x86_64-pc-linux-gnu/12.1.0/include-fixed\n /usr/local/include\n /home/tian/Desktop/GCC-12.1.0/bin/../lib/gcc/../../include\n /usr/include/x86_64-linux-gnu\n /usr/include\nEnd of search list.\n\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
344,325
<p>For testing purposes I need to get my Outlook 2003 addin (vb.net) disabled so that it can only be reactivated through the help menu or by deleting the resilency key from within the registry.</p> <p>I tried to achieve this by creating an unhandled invalid cast exception during the startup eventhandler but this does not help. Outlook only says that it could not load the addin but it does not disable it.</p> <p>How can I create a crash which does disable the addin?</p>
[ { "answer_id": 368884, "author": "user20389", "author_id": 20389, "author_profile": "https://Stackoverflow.com/users/20389", "pm_score": 0, "selected": false, "text": "System.Threading.Thread.Sleep(10000)" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25428/" ]
344,327
<p>I am doing some simple sanity validation on various types. The current test I'm working on is checking to make sure their properties are populated. In this case, populated is defined as not null, having a length greater than zero (if a string), or not equal to 0 (if an integer).</p> <p>The "tricky" part of this test is that some properties are immune to this check. Right now I use a giant if statement that weeds out properties that don't need to be checked.</p> <pre><code>//Gets all the properties of the currect feature. System.Reflection.PropertyInfo[] pi = t.GetProperties(); for(int i = 0; i &lt; pi.Length; i++) { if(!pi[i].Name.Equals("PropertyOne") &amp;&amp; !pi[i].Name.Equals("PropertyTwo") &amp;&amp; !pi[i].Name.Equals("PropertyThree") //... repeat a bunch more times &amp;&amp; !pi[i].Name.IndexOf("ValueOne") != -1 &amp;&amp; !pi[i].Name.IndexOf("ValueTwo") != -1 //... repeat a bunch more times { //Perform the validation check. } } </code></pre> <p>When profiling, I noticed the if statement is actually performing worse than the reflection (not that the reflection is blazing fast). Is there a more efficient way to filter the properties of several different types? </p> <p>I've thought about a massive regular expression but I'm unsure on how to format it, plus it would probably be unreadable given its size. I've also considered storing the values in a List and then using Linq but I'm not sure how to handle the cases that use String.IndexOf() to find if the property contains a certain value.</p> <p>Thanks in advance.</p>
[ { "answer_id": 344340, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "var matchingProperties = pi.Where(exactNames.Contains(pi.Name) ||\n partialNames.Any(name => pi.Name.Contains(name));\n\nforeach (PropertyInfo property in matchingProperties)\n{\n // Stuff\n}\n" }, { "answer_id": 344640, "author": "spasarto", "author_id": 43699, "author_profile": "https://Stackoverflow.com/users/43699", "pm_score": 0, "selected": false, "text": "List<System.Reflection.PropertyInfo> pi = type.GetProperties().ToList();\n\nvar matchingProperties = pi.Where( prop => !PropertyExclusionSet.Contains( prop.Name )\n&& !PropertiesPartialSet.Any( name => prop.Name.Contains( name ) ) );\n" }, { "answer_id": 344688, "author": "Ted Elliott", "author_id": 16501, "author_profile": "https://Stackoverflow.com/users/16501", "pm_score": 0, "selected": false, "text": "public class MyClass {\n\n [CheckMe]\n public int PropertyOne { get; set; }\n\n [DontCheckMe]\n public int PropertyTwo { get; set; }\n\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43699/" ]
344,343
<p>I'm looking for digital low pass filter code/library/class for a .net windows forms project, preferably written in c, c++ or c#. I probably need to set the number of poles, coefficients, windowing, that sort of thing. I can't use any of the gpl'd code that's available, and don't know what else is out there. Any suggestions appreciated. </p>
[ { "answer_id": 344362, "author": "Keith Sirmons", "author_id": 1048, "author_profile": "https://Stackoverflow.com/users/1048", "pm_score": 5, "selected": true, "text": "using System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace Filter\n{\npublic class ButterworthLowPassFilter\n{\n\n //filter fc = 2hz, fs = 10hz\n\n private const int LowPassOrder = 4;\n\n private double[] inputValueModifier;\n private double[] outputValueModifier;\n private double[] inputValue;\n private double[] outputValue;\n private int valuePosition;\n\n public ButterworthLowPassFilter()\n {\n inputValueModifier = new double[LowPassOrder];\n inputValueModifier[0] = 0.098531160923927;\n inputValueModifier[1] = 0.295593482771781;\n inputValueModifier[2] = 0.295593482771781;\n inputValueModifier[3] = 0.098531160923927;\n\n outputValueModifier = new double[LowPassOrder];\n outputValueModifier[0] = 1.0;\n outputValueModifier[1] = -0.577240524806303;\n outputValueModifier[2] = 0.421787048689562;\n outputValueModifier[3] = -0.0562972364918427;\n }\n\n public double Filter(double inputValue)\n {\n if (this.inputValue == null && this.outputValue == null)\n {\n this.inputValue = new double[LowPassOrder];\n this.outputValue = new double[LowPassOrder];\n\n valuePosition = -1;\n\n for (int i=0; i < LowPassOrder; i++)\n {\n this.inputValue[i] = inputValue;\n this.outputValue[i] = inputValue;\n }\n\n return inputValue;\n }\n else if (this.inputValue != null && this.outputValue != null)\n {\n valuePosition = IncrementLowOrderPosition(valuePosition);\n\n this.inputValue[valuePosition] = inputValue;\n this.outputValue[valuePosition] = 0;\n\n int j = valuePosition;\n\n for (int i = 0; i < LowPassOrder; i++)\n {\n this.outputValue[valuePosition] += inputValueModifier[i] * this.inputValue[j] -\n outputValueModifier[i] * this.outputValue[j];\n\n j = DecrementLowOrderPosition(j);\n }\n\n return this.outputValue[valuePosition];\n }\n else\n {\n throw new Exception(\"Both inputValue and outputValue should either be null or not null. This should never be thrown.\");\n }\n }\n\n private int DecrementLowOrderPosition(int j)\n {\n if (--j < 0)\n {\n j += LowPassOrder;\n }\n return j;\n }\n\n private int IncrementLowOrderPosition(int position)\n {\n return ((position + 1) % LowPassOrder);\n }\n\n}\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28343/" ]
344,350
<p>There is a column in a database that is of type INT (Sql server).</p> <p>This int value is used at a bit flag, so I will be AND'ing and OR'ing on it.</p> <p>I have to pass a parameter into my sproc, and that parameter will represent a specific flag item.</p> <p><b>I would normally use an enumeration and pass the int representation to the sproc</b>, but since many different modules will be accessing it it won't be practicial for them all to have my enum definition (if it is changed, it will be a headache to roll it out).</p> <p>So should I use a 'string' or a magic-number as the parameter value, then in my sproc I will do:</p> <pre><code>IF(@blah = 'approved') BEGIN // bit banging here END </code></pre>
[ { "answer_id": 344423, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 2, "selected": false, "text": "CREATE PROCEDURE BitBang(@Flag AS VARCHAR(50), @Id AS INT)\nAS\nBEGIN\n DECLARE @Bit INT\n\n SET @BIT = CASE @Flag\n WHEN 'approved' THEN 16\n WHEN 'noapproved' THEN 16\n WHEN 'fooflag' THEN 8\n WHEN 'nofooflag' THEN 8\n END\n\n IF @Bit IS NOT NULL\n BEGIN\n IF LEFT(@Flag, 2) = 'no' \n BEGIN\n UPDATE TheTable SET BitField = BitField & ~@Bit WHERE Id = @Id\n END\n ELSE\n BEGIN\n UPDATE TheTable SET BitField = BitField | @Bit WHERE Id = @Id\n END\n END\nEND\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
344,363
<p>I have a base class that has a private static member:</p> <pre><code>class Base { private static Base m_instance = new Base(); public static Base Instance { get { return m_instance; } } } </code></pre> <p>And I want to derive multiple classes from this:</p> <pre><code>class DerivedA : Base {} class DerivedB : Base {} class DerivedC : Base {} </code></pre> <p>However, at this point calling DerivedA::Instance will return the same exact object as will DerivedB::Instance and DerivedC::Instance. I can solve this by declaring the instance in the derived class, but then every single derived class will need to do that and that just seems like it should be unneccessary. So is there any way to put all this in the base class? Could a design pattern be applied?</p>
[ { "answer_id": 344376, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": false, "text": "private static Dictionary<Type, Base> instances = new Dictionary<Type, Base>();\npublic static T GetInstance<T>() where T : Base, new() {\n Type ty = typeof(T);\n T x;\n if (instances.TryGetValue(ty, out x)) return x;\n x = new T();\n instances[ty] = x;\n return x;\n}\n" }, { "answer_id": 344377, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "class Base\n{\n // Put common stuff in here...\n}\n\nclass Base<T> : Base where T : Base<T>, new()\n{\n private static T m_instance = new T();\n\n public static T Instance { get { return m_instance; } }\n}\n\nclass DerivedA : Base<DerivedA> {}\nclass DerivedB : Base<DerivedB> {}\nclass DerivedC : Base<DerivedC> {}\n List<string> List<int> Base<DerivedA>.Instance DerivedA.Instance DerivedA.Instance Base t = DerivedA.Instance;\nt = DerivedB.Instance;\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18202/" ]
344,372
<p>just now the dba let me connect to the database using Sql Server Management Studio, this is how i noticed that the default database for the tfs setup and service users is master, is this ok?, is this why I'm having this error?, Let me post part of the log and the properties of the Setup user to confirm that the users are configured correctly. </p> <p>Here is part of the log with the error: </p> <pre><code>Using workflow file from location exe. Executing workflow 'Quiesce ATDT'... Stopping Windows Service 'TFSServerScheduler'... Stopping Windows Service 'CoverAn'... Stopping Windows Service 'W3SVC'... Starting Windows Service 'W3SVC'... Disabling SQL Jobs for databases FSActivityLogging,TFSBuild,TFSIntegration,TFSVersionControl,TFSWorkItemTracking,TFSWorkItemTrackingAttachments,TFSWarehouse CREATE TABLE permission denied in database 'master'. Retrying... Disabling SQL Jobs for databases TFSActivityLogging,TFSBuild,TFSIntegration,TFSVersionControl,TFSWorkItemTracking,TFSWorkItemTrackingAttachments,TFSWarehouse CREATE TABLE permission denied in database 'master'. Retrying... Disabling SQL Jobs for databases TFSActivityLogging,TFSBuild,TFSIntegration,TFSVersionControl,TFSWorkItemTracking,TFSWorkItemTrackingAttachments,TFSWarehouse CREATE TABLE permission denied in database 'master'. Retrying... Disabling SQL Jobs for databases TFSActivityLogging,TFSBuild,TFSIntegration,TFSVersionControl,TFSWorkItemTracking,TFSWorkItemTrackingAttachments,TFSWarehouse CREATE TABLE permission denied in database 'master'. Retrying... Disabling SQL Jobs for databases TFSActivityLogging,TFSBuild,TFSIntegration,TFSVersionControl,TFSWorkItemTracking,TFSWorkItemTrackingAttachments,TFSWarehouse CREATE TABLE permission denied in database 'master'. Retrying... Disabling SQL Jobs for databases TFSActivityLogging,TFSBuild,TFSIntegration,TFSVersionControl,TFSWorkItemTracking,TFSWorkItemTrackingAttachments,TFSWarehouse SQL Error #1 SQL Message: CREATE TABLE permission denied in database 'master'. SQL LineNumber: 13 SQL Source: .Net SqlClient Data Provider SQL Procedure: System.Data.SqlClient.SqlException: CREATE TABLE permission denied in database 'master'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.TeamFoundation.Admin.TFSQuiesce.Quiescer.DisableJobs(XPathNavigator workflow) at Microsoft.TeamFoundation.Admin.TFSQuiesce.Quiescer.ProcessSqlDatabaseElement(XPathNavigator workflow, String action, String dbName) at Microsoft.TeamFoundation.Admin.TFSQuiesce.Quiescer.ExecuteWorkflowStep(XPathNavigator workflow, String action, String nameAttribute) at Microsoft.TeamFoundation.Admin.TFSQuiesce.Quiescer.ExecuteWorkflowStepWithRetry(XPathNavigator workflow, String action, String nameAttribute) at Microsoft.TeamFoundation.Admin.TFSQuiesce.Quiescer.RunWorkflow(String workflowName) Exception Data: Key: HelpLink.ProdName, Value: Microsoft SQL Server Key: HelpLink.ProdVer, Value: 09.00.3054 Key: HelpLink.EvtSrc, Value: MSSQLServer Key: HelpLink.EvtID, Value: 262 Key: HelpLink.BaseHelpUrl, Value: http://go.microsoft.com/fwlink Key: HelpLink.LinkId, Value: 20476 Executing workflow 'Unquiesce ATDT'... Enabling SQL Jobs. Unblocking service account from accessing database TFSActivityLogging Unblocking service account from accessing database TFSBuild Unblocking service account from accessing database TFSIntegration Unblocking service account from accessing database TFSVersionControl Unblocking service account from accessing database TFSWorkItemTracking Unblocking service account from accessing database TFSWorkItemTrackingAttachments Unblocking service account from accessing database TFSWarehouse Stopping Windows Service 'W3SVC'... Starting Windows Service 'W3SVC'... Starting Windows Service 'TFSServerScheduler'... Starting Windows Service 'CoverAn'... Workflow 'Quiesce ATDT' failed! ExitCode = 9000. 12/03/08 16:29:03 DDSet_Status: Process returned 9000 12/03/08 16:29:03 DDSet_Status: Found the matching error code for return value '9000' and it is: '29207' 12/03/08 16:29:03 DDSet_Error: 9000 12/03/08 16:29:03 DDSet_CARetVal: 29207 12/03/08 16:29:03 DDSet_Status: QuietExec returned 29207 12/03/08 16:29:03 DDSet_Exit: QuietExec ended MSI (s) (44:18) [16:29:03:812]: User policy value 'DisableRollback' is 0 MSI (s) (44:18) [16:29:03:812]: Machine policy value 'DisableRollback' is 0 Action ended 16:29:03: InstallFinalize. Return value 3. </code></pre> <p>Here are the properties of the setup user in SQL:</p> <p><strong>General</strong><br> Login Name: CNBYV\SRVSTFTN<br> Windows Authentication<br> Default database: master<br> Default Language: English </p> <p><strong>Server Roles</strong><br> dbcreator<br> public<br> sercurityadmin </p> <p><strong>User Mapping</strong><br> Map Database User DefaultSchema Default Role<br> Checked master CNBYV\SRVSTFTN ... public<br> Checked TfsActivityLogging dbo dbo dbo_owner, public<br> Checked TfsBuild dbo dbo dbo_owner, public<br> Checked TfsIntegration dbo dbo dbo_owner, public<br> Checked TfsVersionControl dbo dbo dbo_owner, public<br> Checked TfsWarehouse dbo dbo dbo_owner, public<br> Checked TfsWorkItemTracking dbo dbo dbo_owner, public<br> Checked TfsWorkItemTrackingAttachments dbo dbo dbo_owner, public </p> <p>Those are the settings that i found more important, if you need more information let me know. </p> <p>Thanks a lot.</p> <p>PS: It was just a f<em>ck</em> pain to post the table above, i don't know why people like Markdown, if someone know how to fix it so it appears like a table please edit the question.</p> <p>Juan Zamudio</p>
[ { "answer_id": 344376, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": false, "text": "private static Dictionary<Type, Base> instances = new Dictionary<Type, Base>();\npublic static T GetInstance<T>() where T : Base, new() {\n Type ty = typeof(T);\n T x;\n if (instances.TryGetValue(ty, out x)) return x;\n x = new T();\n instances[ty] = x;\n return x;\n}\n" }, { "answer_id": 344377, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "class Base\n{\n // Put common stuff in here...\n}\n\nclass Base<T> : Base where T : Base<T>, new()\n{\n private static T m_instance = new T();\n\n public static T Instance { get { return m_instance; } }\n}\n\nclass DerivedA : Base<DerivedA> {}\nclass DerivedB : Base<DerivedB> {}\nclass DerivedC : Base<DerivedC> {}\n List<string> List<int> Base<DerivedA>.Instance DerivedA.Instance DerivedA.Instance Base t = DerivedA.Instance;\nt = DerivedB.Instance;\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15058/" ]
344,380
<p>In <code>java.util.Calendar</code>, January is defined as month 0, not month 1. Is there any specific reason to that ?</p> <p>I have seen many people getting confused about that...</p>
[ { "answer_id": 344393, "author": "Powerlord", "author_id": 15880, "author_profile": "https://Stackoverflow.com/users/15880", "pm_score": -1, "selected": false, "text": "Calendar.JANUARY" }, { "answer_id": 344400, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 9, "selected": true, "text": "java.util.Calendar // I \"know\" there are 12 months\nString[] monthNames = new String[12]; // and populate...\nString name = monthNames[calendar.get(Calendar.MONTH)];\n Date Calendar Date.toString()" }, { "answer_id": 344424, "author": "stesch", "author_id": 41860, "author_profile": "https://Stackoverflow.com/users/41860", "pm_score": 5, "selected": false, "text": "tm time.h tm_mon tm_mon" }, { "answer_id": 344545, "author": "Paul Brinkley", "author_id": 18160, "author_profile": "https://Stackoverflow.com/users/18160", "pm_score": 2, "selected": false, "text": "if (date.getMonth() == 3) out.print(\"March\");\n\nif (date.getMonth() == Calendar.MARCH) out.print(\"March\");\n" }, { "answer_id": 7179337, "author": "piksel bitworks", "author_id": 910069, "author_profile": "https://Stackoverflow.com/users/910069", "pm_score": 5, "selected": false, "text": "time.h monthname[JANUARY] \"January\" day+1" }, { "answer_id": 10372869, "author": "Edwin Dalorzo", "author_id": 697630, "author_profile": "https://Stackoverflow.com/users/697630", "pm_score": 2, "selected": false, "text": "java.util.GregorianCalendar old java.util.Date GregorianCalendar GregorianCalendar gc = new GregorianCalendar();\ngc.setLenient( false );\n/* Bug only manifests if lenient set false */\ngc.set( 2001, 1, 1, 1, 0, 0 );\nint year = gc.get ( Calendar.YEAR );\n/* throws exception */\n GregorianCalendar GregorianCalendar. get(Calendar.MONTH)); GregorianCalendar GregorianCalendar.get(Calendar.ZONE_OFFSET) GregorianCalendar. get( Calendar. DST_OFFSET) GregorianCalendar.set( year, month, day, hour, minute) DateFormat GregorianCalendar" }, { "answer_id": 18002968, "author": "arucker", "author_id": 2643398, "author_profile": "https://Stackoverflow.com/users/2643398", "pm_score": 6, "selected": false, "text": "12 + 1 = 13 // What month is 13?\n (12 + 1) % 12 = 1\n (11 + 1) % 12 = 0 // What month is 0?\n ((11 - 1 + 1) % 12) + 1 = 12 // Lots of magical numbers!\n (0 + 1) % 12 = 1 // February\n(1 + 1) % 12 = 2 // March\n(2 + 1) % 12 = 3 // April\n(3 + 1) % 12 = 4 // May\n(4 + 1) % 12 = 5 // June\n(5 + 1) % 12 = 6 // July\n(6 + 1) % 12 = 7 // August\n(7 + 1) % 12 = 8 // September\n(8 + 1) % 12 = 9 // October\n(9 + 1) % 12 = 10 // November\n(10 + 1) % 12 = 11 // December\n(11 + 1) % 12 = 0 // January\n" }, { "answer_id": 38066676, "author": "Digital_Reality", "author_id": 2648826, "author_profile": "https://Stackoverflow.com/users/2648826", "pm_score": 2, "selected": false, "text": "java.time.Month java.time.Month getValue Month.JULY Calendar.JULY (import java.time.*;)\n" }, { "answer_id": 39219595, "author": "Basil Bourque", "author_id": 642706, "author_profile": "https://Stackoverflow.com/users/642706", "pm_score": 2, "selected": false, "text": "Month.FEBRUARY.getValue() // February → 2.\n java.time.Month Month Month JANUARY FEBRUARY MARCH static final public someMethod( Month.AUGUST ) Month Month month = Month.of( 2 ); // 2 → February.\n Month int monthNumber = Month.FEBRUARY.getValue(); // February → 2.\n String output = \n Month.FEBRUARY.getDisplayName( \n TextStyle.FULL , \n Locale.CANADA_FRENCH \n );\n Year YearMonth java.util.Date .Calendar java.text.SimpleDateFormat Interval YearWeek YearQuarter" }, { "answer_id": 66682080, "author": "Ole V.V.", "author_id": 5772882, "author_profile": "https://Stackoverflow.com/users/5772882", "pm_score": 2, "selected": false, "text": "Calendar Calendar ZonedDateTime Calendar GregorianCalendar Calendar Calendar oldfashionedCalendarObject = Calendar.getInstance();\n ZonedDateTime zdt\n = ((GregorianCalendar) oldfashionedCalendarObject).toZonedDateTime();\n \n System.out.println(zdt);\n System.out.format(\"Month is %d or %s%n\", zdt.getMonthValue(), zdt.getMonth());\n 2021-03-17T23:18:47.761+01:00[Europe/Copenhagen]\nMonth is 3 or MARCH\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11618/" ]
344,419
<p>In HTML, I can find a file starting from the <strong>web server's</strong> root folder by beginning the filepath with &quot;/&quot;. Like:</p> <pre><code>/images/some_image.jpg </code></pre> <p>I can put that path in any file in any subdirectory, and it will point to the right image.</p> <p>With PHP, I tried something similar:</p> <pre><code>include(&quot;/includes/header.php&quot;); </code></pre> <p>...but that doesn't work.</p> <p>I think that that <a href="http://us2.php.net/manual/en/ini.core.php#ini.include-path" rel="noreferrer">this page</a> is saying that I can set <code>include_path</code> once and after that, it will be assumed. But I don't quite get the syntax. Both examples start with a period, and it says:</p> <blockquote>Using a . in the include path allows for relative includes as it means the current directory.</blockquote> <p>Relative includes are exactly what I <strong>don't</strong> want.</p> <p><strong>How do I make sure that all my includes point to the <code>root/includes</code> folder?</strong> (Bonus: what if I want to place that folder outside the public directory?)</p> <h2>Clarification</h2> <p>My development files are currently being served by XAMPP/Apache. Does that affect the absolute path? (I'm not sure yet what the production server will be.)</p> <h2>Update</h2> <p>I don't know what my problem was here. The <code>include_path</code> thing I referenced above was exactly what I was looking for, and the syntax isn't really confusing. I just tried it and it works great.</p> <p>One thing that occurs to me is that some people may have thought that &quot;/some/path&quot; was an &quot;absolute path&quot; because they assumed the OS was Linux. This server is Windows, so an absolute path would have to start with the drive name.</p> <p>Anyway, problem solved! :)</p>
[ { "answer_id": 344445, "author": "Rob Prouse", "author_id": 30827, "author_profile": "https://Stackoverflow.com/users/30827", "pm_score": 7, "selected": true, "text": "define( 'ROOT_DIR', dirname(__FILE__) );\n require_once( ROOT_DIR.'/include/functions.php' );\n" }, { "answer_id": 344464, "author": "gnud", "author_id": 27204, "author_profile": "https://Stackoverflow.com/users/27204", "pm_score": 3, "selected": false, "text": "ini_set(\"include_path\", \"/your_include_path:\".ini_get(\"include_path\"));\n" }, { "answer_id": 344471, "author": "Jacco", "author_id": 22674, "author_profile": "https://Stackoverflow.com/users/22674", "pm_score": 3, "selected": false, "text": "include('/includes/header.php'); \n '.' require_once(__DIR__ . '/Factories/ViewFactory.php');\n require_once()" }, { "answer_id": 344594, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<?php\n$path = getcwd(); \n$myfile = \"/test.inc.php\";\n\n/* \n echo ($path.$myfile);\nwould return...\n\n/usr/srv/apache/htdocs/myworkingdir/test.inc.php\n\naccess outside your working directory is not allowed.\n*/\n\n\ninclud_once ($path.$myfile);\n\n//some code\n\n?>\n" }, { "answer_id": 344636, "author": "Nathan Long", "author_id": 4376, "author_profile": "https://Stackoverflow.com/users/4376", "pm_score": 5, "selected": false, "text": "$root = $_SERVER['DOCUMENT_ROOT'];\ninclude($root.\"/path/to/file.php\");\n" }, { "answer_id": 11855222, "author": "nishluck", "author_id": 1583215, "author_profile": "https://Stackoverflow.com/users/1583215", "pm_score": 0, "selected": false, "text": "<?php if(!$root) for($i=count(explode(\"/\",$_SERVER[\"PHP_SELF\"]));$i>2;$i--) $root .= \"../\"; ?>\n <?php include($root.\"some/include/directory/file.php\"); ?>\n ../ $root $root.\"../external/file.txt\"" }, { "answer_id": 18344667, "author": "kunde", "author_id": 2361278, "author_profile": "https://Stackoverflow.com/users/2361278", "pm_score": 2, "selected": false, "text": "$_SERVER['DOCUMENT_ROOT'] $_SERVER['DOCUMENT_ROOT'] C:\\wamp\\www\\\n my_paths.php <?php if(!defined('MY_ABS_PATH')) define('MY_ABS_PATH',$_SERVER['DOCUMENT_ROOT'].'MyProyect/')\n my_paths.php MY_ABS_PATH" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4376/" ]
344,421
<p>Some people have suggested that when doing an estimate one should make a lower and upper range on the expected time to delivery. The few project tools I have seen, seem to demand one fixed date. Are there any tools that support this concept of a estimation range?</p>
[ { "answer_id": 344680, "author": "BIBD", "author_id": 685, "author_profile": "https://Stackoverflow.com/users/685", "pm_score": 2, "selected": false, "text": "computed_result = (b + 4e + w)/6\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7734/" ]
344,428
<p>How do I access 'a' below?</p> <pre><code>var test = function () { return { 'a' : 1, 'b' : this.a + 1 //doesn't work }; }; </code></pre>
[ { "answer_id": 344453, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": false, "text": "var test = function () {\n var o = {};\n o['a'] = 1;\n o['b'] = o['a'] + 1;\n return o;\n};\n" }, { "answer_id": 344475, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 2, "selected": false, "text": "var t = function () \n {\n return new x();\n };\n\nvar x = function ()\n {\n this.a = 1;\n this.b = this.a + 1; //works\n }\n" }, { "answer_id": 344507, "author": "Chris MacDonald", "author_id": 18146, "author_profile": "https://Stackoverflow.com/users/18146", "pm_score": 0, "selected": false, "text": "var test = function () {\n //private members\n var a = 1;\n var b = a + 1;\n //public interface\n return {\n geta : function () {\n return a;\n },\n getb : function () {\n return b;\n }\n }\n}();\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
344,430
<p>I have an aspx page where i am Processing a large number of records from a table and doing some manipulation.after each manipuation,(each record),I have a Response.Write("Record : "+rec); Response.Flush()</p> <p>I have set Response.Buffer property to false. It is working fine But If i want to render the output as a table row,its not working as of Response.Write After fininshing all the records in the loop only , the table is getting printed</p> <p>How to solve this ?</p>
[ { "answer_id": 344456, "author": "Timothy Lee Russell", "author_id": 12919, "author_profile": "https://Stackoverflow.com/users/12919", "pm_score": 0, "selected": false, "text": ".column1 { width: 40px; }\n.column2 { width: 40px; }\n\nResponse.Write(\"<div id=\\\"column1\\\">some text</div><div id=\\\"column2\\\">some text</div>\");\nResponse.Flush();\n Response.Write(\"<table><tr><td>some text</td></tr></table>\");\nResponse.Flush();\n" }, { "answer_id": 2677321, "author": "Glen Little", "author_id": 32429, "author_profile": "https://Stackoverflow.com/users/32429", "pm_score": 4, "selected": false, "text": "Response.Flush" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40521/" ]
344,440
<p>I have a general exception handler, Application_error in my global.asax where I'm trying to isolate all the uncaught exceptions on all my many pages. I don't want to use Page_error to catch exception because it's inefficient to call that on so many pages. So where in the exception can I find what page actually caused the exception?</p>
[ { "answer_id": 344463, "author": "jlew", "author_id": 7450, "author_profile": "https://Stackoverflow.com/users/7450", "pm_score": 6, "selected": true, "text": "HttpContext con = HttpContext.Current;\ncon.Request.Url.ToString()\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8456/" ]
344,451
<p>I'm using jQuery in conjunction with the <a href="http://malsup.com/jquery/form/" rel="nofollow noreferrer">form plugin</a> and I'd like to intercept the form data before submission and make changes. </p> <p>The form plugin has a property called beforeSubmit that should do this, but I seem to be having trouble getting the function I specify to run.</p> <p>Here's the markup for the form (some style details omitted):</p> <pre><code>&lt;form id="form1"&gt; &lt;fieldset id="login"&gt; &lt;legend&gt;Please Log In&lt;/legend&gt; &lt;label for="txtLogin"&gt;Login&lt;/label&gt; &lt;input id="txtLogin" type="text" /&gt; &lt;label for="txtPassword"&gt;Password&lt;/label&gt; &lt;input id="txtPassword" type="password" /&gt; &lt;button type="submit" id="btnLogin"&gt;Log In&lt;/button&gt; &lt;/fieldset&gt; &lt;/form&gt; </code></pre> <p>And here's the javascript that I have so far:</p> <pre><code>$(document).ready(function() { var options = { method: 'post', url: 'Login.aspx', beforeSubmit: function(formData, form, options) { $.each(formData, function() { log.info(this.value); }); return true; } }; $('form#form1').ajaxForm(options); }); </code></pre> <p>(log.info() is from the <a href="http://www.gscottolson.com/blackbirdjs/" rel="nofollow noreferrer">Blackbird</a> debugger library I'm using)</p> <p>When I click the submit button, rather than the POST verb I specified it uses a GET instead, and nothing is logged from my beforeSubmit function. It seems that the ajaxForm plugin is not being applied to the form at all, but I don't see why. Can anybody help with this?</p>
[ { "answer_id": 344918, "author": "Ariel", "author_id": 24654, "author_profile": "https://Stackoverflow.com/users/24654", "pm_score": 3, "selected": true, "text": "<script type=\"text/javascript\">\n $(document).ready(function() {\n var options = {\n beforeSubmit: showData\n };\n $('form#form1').ajaxForm(options);\n });\n function showData(formData, form, options) {\n //var formData = [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ];\n $.each(formData, function(i, obj) { log.info(obj.name + \" | \" + obj.value); });\n return true;\n }\n</script>\n\n<form id=\"form1\" action=\"Login.aspx\" method=\"post\">\n<fieldset id=\"login\">\n <legend>Please Log In</legend>\n <label for=\"txtLogin\">Login</label>\n <input id=\"txtLogin\" type=\"text\" name=\"User\" />\n <label for=\"txtPassword\">Password</label>\n <input id=\"txtPassword\" type=\"password\" name=\"Pass\" />\n <button type=\"submit\" id=\"btnLogin\">Log In</button>\n</fieldset>\n</form>\n" }, { "answer_id": 344937, "author": "J Cooper", "author_id": 38803, "author_profile": "https://Stackoverflow.com/users/38803", "pm_score": 1, "selected": false, "text": "type method $(document).ready(function... $(function... $.each(formData, function... $(formData).each(function..." } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1249/" ]
344,460
<p>I am trying to put the stuff within parentheses into the value of a src attribute in an img tag:</p> <pre><code>while(&lt;TOCFILE&gt;) { $toc_line = $_; $toc_line =~ s/&lt;inlineFig.*?(\.\.\/pics\/ch09_inline99_*?\.jpg)*?&lt;\/inlineFig&gt;/&lt;img src="${1}" alt="" \/\&gt;/g; $new_toc_file .= $toc_line; } </code></pre> <p>So I expected to see tags like this in the output:</p> <pre><code>&lt;img src="../pics/ch09_inline99_00" alt="" /&gt; </code></pre> <p>But instead I'm getting:</p> <pre><code>&lt;img src="" alt="" /&gt; </code></pre>
[ { "answer_id": 344577, "author": "bart", "author_id": 19966, "author_profile": "https://Stackoverflow.com/users/19966", "pm_score": 4, "selected": false, "text": "inline99_*?\\.jpg\n ^^^ \n \\d *? ($PATTERN)*?\n $_ = 'one two three';\ns/(\\w+\\s*)*/$1/;\nprint;\n" }, { "answer_id": 344650, "author": "Ape-inago", "author_id": 42082, "author_profile": "https://Stackoverflow.com/users/42082", "pm_score": 2, "selected": false, "text": "while(<TOCFILE>)\n{\n $toc_line = $_;\n $toc_line =~ \n s/ # replace the follwoing \n\n <inlineFig # match this text \n .*? # then any characters until the next sequence matches\n ( # throw the match into $1\n \\.\\.\\/pics\\/ch09_inline99_ # ..\\pics\\cho9_inline99_\n \\d*?\\.jpg # folowed by 0 or more numbers\n )*? # keeping doing that until the next sequence matches\n <\\/inlineFig> # match this text\n\n / # with the follwoing\n\n\n <img src=\"${1}\" alt=\"\" \\/\\> # some text and the result of $1 above.\n\n /xg; # <- the x makes it ignore whitespace and #comments\n $new_toc_file .= $toc_line;\n}\n" }, { "answer_id": 344687, "author": "converter42", "author_id": 28974, "author_profile": "https://Stackoverflow.com/users/28974", "pm_score": 1, "selected": false, "text": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $new_toc_file;\n\n{\n # localizing $_ protects any existing value in the global $_\n # you should localize $_ even if you choose to assign it to a variable\n\n local $_;\n\n while(<DATA>) { \n # in the absence of the bind operator =~, s/// operates against $_\n s!<inlineFig.*?(\\.\\./pics/ch09_inline99_.*?\\.jpg)</inlineFig>!<img src=\"$1\" alt=\"\" />!g;\n $new_toc_file .= $_;\n }\n}\n\nprint $new_toc_file, \"\\n\";\n\n__END__\n<inlineFig>../pics/ch09_inline99_00.jpg</inlineFig>\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
344,468
<p>When I get a vanilla Windows system, there's a bunch of stuff I change to make it more developer-friendly.</p> <p>Some of it I remember every time, other stuff I only do as and when.</p> <p>Examples:</p> <ul> <li>Show extensions of all file types</li> <li>Make hidden and system file visible</li> <li>Turn off Windows Defender</li> </ul> <p>I seem to remember a blog post from Jeff on this topic, but can't locate it!</p> <p>What else do you do, and do you have any tools that automate this process?</p>
[ { "answer_id": 344506, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 5, "selected": false, "text": "regsvr32 /u zipfldr.dll" }, { "answer_id": 344767, "author": "Sam Hasler", "author_id": 2541, "author_profile": "https://Stackoverflow.com/users/2541", "pm_score": 3, "selected": false, "text": "Command Line Scripts @echo off\nsetlocal\n\nset UTILPATH=C:\\Program Files\\System Tools\\Command Line Utilities\n\nif not \"x%1\"==\"x\" (\n\nstart \"\" \"notepad\" \"%UTILPATH%\\%1.bat\"\n\n) else (\n\ndir /b \"%UTILPATH%\" | grep -v com.bat | grep -P \"(exe|bat|cmd)\" | sed \"s/\\.\\(exe\\|bat\\|cmd\\)//\"\necho.\n\n)\n com com script-name com new-script-name com com Program Files Win key cmd Ctrl+Shift+Enter Alt+C Command Line Scripts Task Scheduler Task @setlocal\n@set _MYDOCS_=%USERPROFILE%\\Documents\n\n@REM Note: first delete the drives so I can run script again\n@REM to fix drives that failed to get mapped\n\nsubst /d W:\nsubst /d T:\nsubst /d S:\nsubst /d R:\nsubst /d N:\nsubst /d L:\nsubst /d H:\nsubst W: \"%_MYDOCS_%\\Work\\SVN Working Copy\\Website\\trunk\\www\"\nsubst T: \"%_MYDOCS_%\\Work\\SVN Working Copy\\project 1\\trunk\"\nsubst S: \"%_MYDOCS_%\\Work\\SVN Working Copy\"\nsubst R: \"%_MYDOCS_%\\Work\\SVN Working Copy\\project 2\\branches\\12.50\"\nsubst N: \"%_MYDOCS_%\\Work\\SVN Working Copy\\project 2\\trunk\"\nsubst L: \"%_MYDOCS_%\\Work\\\"\nsubst H: \"%_MYDOCS_%\\My Projects\\Haslers.info\\Working Copy\"\n" }, { "answer_id": 344949, "author": "Rob Hruska", "author_id": 29995, "author_profile": "https://Stackoverflow.com/users/29995", "pm_score": 2, "selected": false, "text": "p [putty-session-name]" }, { "answer_id": 358374, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 3, "selected": false, "text": "ls dir grep" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1737/" ]
344,478
<p>Can LINQ to SQL query using <strong>NOT IN</strong>? </p> <p>e.g., SELECT au_lname, state FROM authors WHERE state NOT IN ('CA', 'IN', 'MD')</p>
[ { "answer_id": 344498, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 3, "selected": false, "text": "NorthwindDataContext dc = new NorthwindDataContext();\ndc.Log = Console.Out;\nvar query =\n from c in dc.Customers\n where !(from o in dc.Orders\n select o.CustomerID)\n .Contains(c.CustomerID)\n select c;\nforeach (var c in query) Console.WriteLine( c );\n" }, { "answer_id": 344500, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 7, "selected": true, "text": " List<string> states = new List<string> { \"CA\", \"IN\", \"MD\" };\n var q = from a in authors\n where !states.Contains(a.state)\n select new { a.au_lname, a.state };\n var q = authors.Where( a => !states.Contains( a.state ) )\n .Select( a => new { a.au_lname, a.state } );\n" }, { "answer_id": 344510, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 3, "selected": false, "text": " var states = new[] {\"CA\", \"IN\", \"MD\"};\n var query = db.Authors.Where(x => !states.Contains(x.state));\n" }, { "answer_id": 344526, "author": "Rob", "author_id": 34224, "author_profile": "https://Stackoverflow.com/users/34224", "pm_score": 2, "selected": false, "text": "\n List<long> badUserIDs = new List { 10039309, 38300590, 500170561 };\n BTDataContext dc = new BTDataContext();\n var items = from u in dc.Users\n where !badUserIDs.Contains(u.FbUserID)\n select u;\n \n{SELECT [t0].[UserID], [t0].[FbUserID], [t0].[FbNetworkID], [t0].[Name], \nFROM [dbo].[Users] AS [t0]\nWHERE NOT ([t0].[FbUserID] IN (@p0, @p1, @p2))\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1316/" ]
344,479
<p>Is it possible to get the expiry <code>DateTime</code> of an <code>HttpRuntime.Cache</code> object?</p> <p>If so, what would be the best approach?</p>
[ { "answer_id": 350374, "author": "Tom Jelen", "author_id": 28399, "author_profile": "https://Stackoverflow.com/users/28399", "pm_score": 6, "selected": true, "text": "private DateTime GetCacheUtcExpiryDateTime(string cacheKey)\n{\n object cacheEntry = Cache.GetType().GetMethod(\"Get\", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(Cache, new object[] { cacheKey, 1 });\n PropertyInfo utcExpiresProperty = cacheEntry.GetType().GetProperty(\"UtcExpires\", BindingFlags.NonPublic | BindingFlags.Instance);\n DateTime utcExpiresValue = (DateTime)utcExpiresProperty.GetValue(cacheEntry, null);\n\n return utcExpiresValue;\n}\n HttpRuntime.Cache object cacheEntry = Cache.GetType().GetMethod(\"Get\").Invoke(null, new object[] { cacheKey, 1 });\n" }, { "answer_id": 52931609, "author": "Sahil Shah", "author_id": 1075251, "author_profile": "https://Stackoverflow.com/users/1075251", "pm_score": 2, "selected": false, "text": "private DateTime GetCacheUtcExpiryDateTime(string cacheKey)\n{\n var aspnetcachestoreprovider = System.Web.HttpRuntime.Cache.GetType().GetProperty(\"InternalCache\", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(System.Web.HttpRuntime.Cache, null);\n var intenralcachestore = aspnetcachestoreprovider.GetType().GetField(\"_cacheInternal\", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(aspnetcachestoreprovider);\n Type TEnumCacheGetOptions = System.Web.HttpRuntime.Cache.GetType().Assembly.GetTypes().Where(d => d.Name == \"CacheGetOptions\").FirstOrDefault();\n object cacheEntry = intenralcachestore.GetType().GetMethod(\"DoGet\", BindingFlags.NonPublic | BindingFlags.Instance, null, CallingConventions.Any, new[] { typeof(bool), typeof(string), TEnumCacheGetOptions }, null).Invoke(intenralcachestore, new Object[] { true, cacheKey, 1 }); ;\n PropertyInfo utcExpiresProperty = cacheEntry.GetType().GetProperty(\"UtcExpires\", BindingFlags.NonPublic | BindingFlags.Instance);\n DateTime utcExpiresValue = (DateTime)utcExpiresProperty.GetValue(cacheEntry, null);\n\n return utcExpiresValue;\n}\n private DateTime GetCacheUtcExpiryDateTime(string cacheKey)\n{\n MethodInfo GetCacheEntryMethod = null;\n Object CacheStore = null;\n bool GetterFound = true;\n\n GetCacheEntryMethod = System.Web.HttpRuntime.Cache.GetType().GetMethod(\"Get\", BindingFlags.Instance | BindingFlags.NonPublic);\n if (GetCacheEntryMethod != null)\n {\n GetterFound = true;\n CacheStore = System.Web.HttpRuntime.Cache;\n }\n else\n {\n var aspnetcachestoreprovider = System.Web.HttpRuntime.Cache.GetType().GetProperty(\"InternalCache\", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(System.Web.HttpRuntime.Cache, null);\n var intenralcachestore = aspnetcachestoreprovider.GetType().GetField(\"_cacheInternal\", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(aspnetcachestoreprovider);\n Type TEnumCacheGetOptions = System.Web.HttpRuntime.Cache.GetType().Assembly.GetTypes().Where(d => d.Name == \"CacheGetOptions\").FirstOrDefault();\n GetCacheEntryMethod = intenralcachestore.GetType().GetMethod(\"DoGet\", BindingFlags.NonPublic | BindingFlags.Instance, null, CallingConventions.Any, new[] { typeof(bool), typeof(string), TEnumCacheGetOptions }, null);\n GetterFound = false;\n CacheStore = intenralcachestore;\n }\n\n dynamic cacheEntry;\n if (GetterFound)\n cacheEntry = GetCacheEntryMethod.Invoke(CacheStore, new Object[] { cacheKey, 1 });\n else\n cacheEntry = GetCacheEntryMethod.Invoke(CacheStore, new Object[] { true, cacheKey, 1 });\n\n PropertyInfo utcExpiresProperty = cacheEntry.GetType().GetProperty(\"UtcExpires\", BindingFlags.NonPublic | BindingFlags.Instance);\n DateTime utcExpiresValue = (DateTime)utcExpiresProperty.GetValue(cacheEntry, null);\n\n return utcExpiresValue;\n}\n" }, { "answer_id": 73265313, "author": "Aashutosh", "author_id": 19709646, "author_profile": "https://Stackoverflow.com/users/19709646", "pm_score": 0, "selected": false, "text": "var expiry = DateTime.UtcNow.AddMinutes(10);\nHttpRuntime.Cache.Insert(\"key\", new { Value = \"Value\", Expiry = expiry }, null, expiry, Cache.NoSlidingExpiration);\n dynamic cachedData = HttpRuntime.Cache.Get(\"key\");\nDateTime cacheExpiry = cachedData.Expiry;\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/343/" ]
344,503
<pre><code>class MyBase { protected object PropertyOfBase { get; set; } } class MyType : MyBase { void MyMethod(MyBase parameter) { // I am looking for: object p = parameter.PropertyOfBase; // error CS1540: Cannot access protected member 'MyBase.PropertyOfBase' via a qualifier of type 'MyBase'; the qualifier must be of type 'MyType' (or derived from it) } } </code></pre> <p>Is there a way to get a protected property of a parameter of a type from an extending type without reflection? Since the extending class knows of the property through its base type, it would make sense if possible.</p>
[ { "answer_id": 344668, "author": "Jay Bazuzi", "author_id": 5314, "author_profile": "https://Stackoverflow.com/users/5314", "pm_score": 3, "selected": false, "text": "class Other : MyBase { }\n\nnew MyType().MyMethod(new Other());\n Other PropertyOfBase" }, { "answer_id": 11028991, "author": "Medinoc", "author_id": 1455631, "author_profile": "https://Stackoverflow.com/users/1455631", "pm_score": 4, "selected": false, "text": "class MyBase\n{\n protected object PropertyOfBase { get; set; }\n\n protected static object GetPropertyOfBaseOf(MyBase obj) \n {\n return obj.PropertyOfBase;\n }\n}\n\nclass MyType : MyBase\n{\n void MyMethod(MyBase parameter)\n {\n object p = GetPropertyOfBaseOf(parameter);\n }\n}\n" }, { "answer_id": 49060056, "author": "jrivam", "author_id": 1649086, "author_profile": "https://Stackoverflow.com/users/1649086", "pm_score": 0, "selected": false, "text": "public class MyBase\n{\n protected object PropertyOfBase { get; set; }\n}\n\npublic class MyType : MyBase\n{\n void MyMethod()\n {\n object p = base.PropertyOfBase;\n }\n}\n" }, { "answer_id": 49139540, "author": "jrivam", "author_id": 1649086, "author_profile": "https://Stackoverflow.com/users/1649086", "pm_score": 0, "selected": false, "text": "public class MyBase\n{\n protected object PropertyOfBase { get; set; }\n\n public class MyType\n {\n public void MyMethod(MyBase parameter)\n {\n object p = parameter.PropertyOfBase; \n }\n }\n}\n var t = new MyBase.MyType();\nt.MyMethod(new MyBase());\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
344,509
<p>Trying to get this example working from <a href="http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx" rel="nofollow noreferrer">http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx</a></p> <p>However, I can't seem to get the namespace or syntax right for "Process" below.</p> <pre><code>&lt;Border x:Name="panelDialog" Visibility="Collapsed"&gt; &lt;Grid&gt; &lt;Border Background="Black" Opacity="0.49"&gt;&lt;/Border&gt; &lt;!--While Xmal Content of the dialog will go here--&gt; &lt;/Grid&gt; &lt;/Border&gt; </code></pre> <p>The blog post goes on to say.....</p> <p>Just put two function for hide and display the dialog. Total Code is given bellow. In bellow code I have Displayed a loading screen with light box effect. When displaying modal dialog just invoke show and hide wait screen methods. Its good to send your cpu expansive jobs to background thread and use dispatcher to update UI while you are in background thread.</p> <pre><code>&lt;Page x:Class="Home"&gt; &lt;Grid&gt; &lt;ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"&gt; &lt;!--All the contents will go here--&gt; &lt;/ScrollViewer&gt; &lt;Border x:Name="panelLoading" Visibility="Collapsed"&gt; &lt;Grid&gt; &lt;Border Background="Black" Opacity="0.49"&gt;&lt;/Border&gt; &lt;local:TMEWaitScreen&gt;&lt;/local:TMEWaitScreen&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;/Grid&gt; &lt;/Page&gt; </code></pre> <p>Here is the codebehind</p> <pre><code>#region About Wait Screen /// &lt;summary&gt; /// Show wait screen before a web request /// &lt;/summary&gt; public void ShowWaitScreen() { Process del = new Process(ShowWaitScreenUI); Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, del); } private void ShowWaitScreenUI() { panelLoading.Visibility = Visibility.Visible; } /// &lt;summary&gt; /// Hide a wait screen after a web request /// &lt;/summary&gt; public void HideWaitScreen() { Process del = new Process(HideWaitScreenUI); Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, del); } private void HideWaitScreenUI() { panelLoading.Visibility = Visibility.Collapsed; } #endregion </code></pre> <p>I'm having issues with this lines specifically:</p> <pre><code>Process del = new Process(ShowWaitScreenUI); </code></pre> <p>The only Process I can find is in System.Diagnostics, and takes no arguments. Is the blog post I'm trying to learn from off,or am I just in the wrong place?</p>
[ { "answer_id": 344610, "author": "John Z", "author_id": 43430, "author_profile": "https://Stackoverflow.com/users/43430", "pm_score": 2, "selected": false, "text": "private delegate void Process();\n private delegate void HideWaitScreenHandler();\nprivate delegate void ShowWaitScreenHandler();\n private delegate void ShowWaitScreenUIHandler(bool show);\n\nvoid ShowWaitScreenUIThreaded(bool show)\n{\n Process del = new ShowWaitScreenHandler(OnShowWaitScreenUI);\n Dispatcher.Invoke(DispatcherPriority.Normal, del, show);\n}\n\nvoid OnShowWaitScreenUI(bool show)\n{\n panelLoading.Visibility = show ? Visibility.Visible : Visibility.Collapsed;\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22451/" ]
344,519
<p>I am trying to filter an IEnumerable object of the duplicate values, so I would like to get the distinct values from it, for example, lets say that it holds days:</p> <p>monday tuesday wednesday wednesday</p> <p>I would like to filter it and return:</p> <p>monday tuesday wednesday</p> <p>What is the most efficient way to do this in .net 2.0?</p>
[ { "answer_id": 344536, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": true, "text": "Dictionary<object, object> list = new Dictionary<object, object>();\nforeach (object o in enumerable)\n if (!list.ContainsKey(o))\n {\n // Do the actual work.\n list[o] = null;\n }\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7952/" ]
344,533
<p>I'm struggling to understand Dependency Properties in Silverlight 2. Does anybody have a good explanation or link that clearly explains the DependencyObject and/or DependencyProperty?</p>
[ { "answer_id": 344536, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": true, "text": "Dictionary<object, object> list = new Dictionary<object, object>();\nforeach (object o in enumerable)\n if (!list.ContainsKey(o))\n {\n // Do the actual work.\n list[o] = null;\n }\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
344,557
<p>Why is garbage collection required for tail call optimization? Is it because if you allocate memory in a function which you then want to do a tail call on, there'd be no way to do the tail call and regain that memory? (So the stack would have to be saved so that, after the tail call, the memory could be reclaimed.)</p>
[ { "answer_id": 346761, "author": "Claudiu", "author_id": 15055, "author_profile": "https://Stackoverflow.com/users/15055", "pm_score": 2, "selected": false, "text": "list *result = filter(make900MBlist(), funcptr);\n list *srclist = make900MBlist();\nlist *result = filter(srclist, funcptr);\nfreelist(srclist);\n list *result = filter_reclaim(make900MBlist(), funcptr);\n" }, { "answer_id": 363702, "author": "dsimcha", "author_id": 23903, "author_profile": "https://Stackoverflow.com/users/23903", "pm_score": 4, "selected": true, "text": "int foo(int arg) {\n // Base case.\n\n vector<double> bar(10);\n // Populate bar, do other stuff.\n\n return foo(someNumber);\n}\n ret = foo(someNumber);\nfree(bar);\nreturn ret;\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
344,559
<p>I have a directory full (~10<sup>3</sup>, 10<sup>4</sup>) of XML files from which I need to extract the contents of several fields. I've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go through the files, one by one to extract the data. </p> <ol> <li>Is there a more efficient way? (simple text matching doesn't work)</li> <li>Do I need to issue a new ParserCreate() for each new file (or string) or can I reuse the same one for every file?</li> <li>Any caveats?</li> </ol> <p>Thanks!</p>
[ { "answer_id": 349472, "author": "Torsten Marek", "author_id": 9567, "author_profile": "https://Stackoverflow.com/users/9567", "pm_score": 2, "selected": false, "text": "iterparse iterparse import xml.etree.cElementTree as ET\nxml_it = ET.iterparse(\"some.xml\")\nevent, elem = xml_it.next()\n event \"end\"" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/280/" ]
344,588
<p>The title pretty much says it all. :-) I have lots of virtual hosts and I want to put a single rewriting block at the top of the httpd.conf file that rewrites URLs no matter which virtual host the request might be directed to. How the heck do I do this?</p> <p>I found <a href="http://www.webmasterworld.com/forum92/1359.htm" rel="noreferrer">this</a> but my question is the same: how can I do this without resorting to .htaccess files and performing some other action for each virtual host?</p> <p>OMGTIA!</p>
[ { "answer_id": 378802, "author": "Jeremy Bourque", "author_id": 2192597, "author_profile": "https://Stackoverflow.com/users/2192597", "pm_score": 3, "selected": false, "text": "include" }, { "answer_id": 1772829, "author": "Travis Wilson", "author_id": 8735, "author_profile": "https://Stackoverflow.com/users/8735", "pm_score": 3, "selected": false, "text": "RewriteOptions inherit\n" }, { "answer_id": 3213665, "author": "Chad A. Davis", "author_id": 256856, "author_profile": "https://Stackoverflow.com/users/256856", "pm_score": 2, "selected": false, "text": "Options +Indexes +FollowSymLinks\nRewriteEngine on\n# If it begins with only domain.com, prepend www and send to www.domain.com\nRewriteCond %{HTTP_HOST} ^domain [NC]\nRewriteRule ^(.*) http://www.domain.com$1 [L,R=301]\n\n# Correct misspelling in the domain name, applies to any VirtualHost in the domain\n# Requires a subdomain, i.e. (serviceXXX.)domain.com, or the prepended www. from above\nRewriteCond %{HTTP_HOST} ^([^.]+\\.)dommmmmain\\.com\\.?(:[0-9]*)?$ [NC]\nRewriteRule ^(.*) %{HTTP_HOST}$1 [C]\nRewriteRule ^([^.]+\\.)?domain.com(.*) http://$1domain.com$2 [L,R=301]\n\n# No-name virtual host to catch all invalid hostnames and mod_rewrite and redirect them\n<VirtualHost *>\n RewriteEngine on\n RewriteOptions inherit\n</VirtualHost>\n" }, { "answer_id": 6481731, "author": "Alex Gray", "author_id": 547214, "author_profile": "https://Stackoverflow.com/users/547214", "pm_score": 0, "selected": false, "text": "Listen 80\nNameVirtualHost *:80\n\n<VirtualHost *:80>\nErrorLog \"/var/log/apache2/error_log\"\n</VirtualHost>\n\n<VirtualHost *:80>\nServerName alloftherestoftheVHosts.com\nDocumentRoot \"/ServiceData/.........\n............ \n" }, { "answer_id": 8470055, "author": "Zava", "author_id": 746276, "author_profile": "https://Stackoverflow.com/users/746276", "pm_score": 4, "selected": false, "text": "<VirtualHost> RewriteEngine On\nRewriteOptions Inherit \n" }, { "answer_id": 31112734, "author": "Matej Snoha", "author_id": 3522053, "author_profile": "https://Stackoverflow.com/users/3522053", "pm_score": 5, "selected": true, "text": "RewriteOptions InheritDown RewriteEngine on RewriteOptions" }, { "answer_id": 50652344, "author": "nyet", "author_id": 4108263, "author_profile": "https://Stackoverflow.com/users/4108263", "pm_score": 1, "selected": false, "text": "# letsencrypt\n<IfModule alias_module>\n Alias /.well-known/ /var/www/html/.well-known/\n</IfModule>\n<IfModule mod_rewrite.c>\n # prevent vhost rewrites from killing the alias\n RewriteEngine On\n RewriteOptions InheritDownBefore\n RewriteCond %{REQUEST_URI} ^/\\.well\\-known\n RewriteRule . - [L,PT]\n</IfModule>\n <VirtualHost *:80>\n ....\n <IfModule mod_rewrite.c>\n RewriteEngine On\n RewriteRule ^/.* /index.php [L,PT]\n </IfModule>\n</VirtualHost>\n" }, { "answer_id": 60104733, "author": "Maciek Semik", "author_id": 2024493, "author_profile": "https://Stackoverflow.com/users/2024493", "pm_score": 1, "selected": false, "text": "Apache HTTP Server 2.4.8 Apache/2.4.25 (Debian) Apache/2.4.25 RewriteOptions InheritDown\nRewriteCond %{HTTP_HOST} ^www\\. [NC,OR]\nRewriteCond %{HTTP_HOST} !\\.co$ [NC]\nRewriteCond %{HTTP_HOST} ^(?:www\\.)?(.+)\\.[^.]+$ [NC]\nRewriteRule ^ https://%1.co%{REQUEST_URI} [L,NE,R=301]\n<VirtualHost *:80>\n RewriteEngine On\n ServerAlias *.*\n</VirtualHost>\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16609/" ]
344,590
<p>I am creating a WCF service hosted within IIS7 on Windows Vista SP1. I am getting the following error:</p> <p>The certificate 'CN=SignedByLocalHost' must have a private key that is capable of key exchange. The process must have access rights for the private key. </p> <p>It looks like I would need to give the host process assess to the certificate which was done in the past with winhttpcertcfg which has been deprecated for Vista. The article I found indicates to use the certificate console, but I am missing somethign because I don't see any capability to edit my cert. </p> <p>Any help would be great!</p> <p>Thanks</p>
[ { "answer_id": 344643, "author": "JoshBerke", "author_id": 26160, "author_profile": "https://Stackoverflow.com/users/26160", "pm_score": 3, "selected": false, "text": "All Tasks / Manage Private Keys" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26160/" ]
344,591
<p>I have build server inside our domain (and it needs to be because it also talks to other boxes in the domain), and a webserver that is in the DMZ.</p> <p>As part of our build scripts, I would like to deploy websites to the webserver in the DMZ, using the Nant copy task. The problem is, that Nant is invoked from TeamCity which runs under the System account on the build server, and there is no way that I can find to give the build server system account access to the DMZ webserver directories. (It probably isn't a good idea anyway).</p> <p>Is there anyway to tell Nant to run a specific task under a different windows user, or is there another solution to my problem?</p> <p><strong>Edit:</strong> One other restriction I am running under is that I can't create new domain accounts (well, at least not without going through an approval process). I can create local machine accounts, but in that case, it doesn't seem that runas will work across the DMZ.</p>
[ { "answer_id": 347775, "author": "Scott Saad", "author_id": 4916, "author_profile": "https://Stackoverflow.com/users/4916", "pm_score": 3, "selected": true, "text": "<scp <exec" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24954/" ]
344,607
<p>I have recently started working with Unified Communication Managed API 2.0 (UCMA) and Office Communication Server(OCS) 2007. I have a need in my app that I have to create custom presence for my users? Has anyone of you guys done this before and can point me in right direction?</p> <p>There is not much documentation out there regarding this, so I am struggling here.</p> <p>Thanks</p>
[ { "answer_id": 347775, "author": "Scott Saad", "author_id": 4916, "author_profile": "https://Stackoverflow.com/users/4916", "pm_score": 3, "selected": true, "text": "<scp <exec" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43007/" ]
344,608
<p>This question relates to an ASP.NET website, originally developed in VS 2005 and now in VS 2008.</p> <p>This website uses two unmanaged external DLLs which are not .NET and I do not have the source code to compile them and have to use them as is.</p> <p>This website runs fine from within Visual Studio, locating and accessing these external DLLs correctly. However, when the website is published on a webserver (runnning IIS6 and ASP.NET 2.0) rather than the development PC it cannot locate and access these external DLLs, and I get the following error:</p> <p><code>Unable to load DLL 'XYZ.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)</code></p> <p>The external DLLs are located in the bin directory of the website, along with the managed DLLs that wrap them and all the other DLLs for the website.</p> <p>Searching this problem reveals that many other people seem to have the same problem accessing external non.NET DLLs from ASP.NET websites, but I haven't found a solution that works.</p> <p>I have tried the following:</p> <ul> <li>Running DEPENDS to check the dependencies to establish that the first three are in System32 directory in the path, the last is in the .NET 2 framework.</li> <li>I put the two DLLs and their dependencies in System32 and rebooted the server, but website still couldn't load these external DLLs.</li> <li>Gave full rights to ASPNET, IIS_WPG and IUSR (for that server) to the website bin directory and rebooted, but website still couldn't load these external DLLs.</li> <li>Added the external DLLs as existing items to the projects and set their "Copy to Output" property to "Copy Always", and website still can't find the DLLs.</li> <li>Also set their "Build Action" property to "Embedded resource" and website still can't find the DLLs.</li> </ul> <p>Any assistance with this problem would be greatly appreciated!</p>
[ { "answer_id": 4598747, "author": "Matt Woodard", "author_id": 179187, "author_profile": "https://Stackoverflow.com/users/179187", "pm_score": 5, "selected": false, "text": "System.Environment.SetEnvironmentVariable(\"Path\", searchPath + \";\" + oldPath)\n" }, { "answer_id": 34238335, "author": "Mad Dog", "author_id": 5084556, "author_profile": "https://Stackoverflow.com/users/5084556", "pm_score": 2, "selected": false, "text": "namespace TestDetNet\n{\n static class NativeMethods\n {\n [DllImport(\"kernel32.dll\")]\n public static extern IntPtr LoadLibrary(string dllToLoad);\n\n [DllImport(\"kernel32.dll\")]\n public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);\n\n\n [DllImport(\"kernel32.dll\")]\n public static extern bool FreeLibrary(IntPtr hModule);\n }\n\n public partial class _Default : System.Web.UI.Page\n {\n [UnmanagedFunctionPointer(CallingConvention.StdCall)]\n private delegate int GetRandom();\n\n protected System.Web.UI.WebControls.Label Label1;\n protected void Page_Load(object sender, EventArgs e)\n {\n Label1.Text = \"Hell'ou\";\n Label1.Font.Italic = true;\n }\n\n protected void Button1_Click(object sender, EventArgs e)\n {\n if (File.Exists(System.Web.HttpContext.Current.Server.MapPath(\"html/bin\")+\"\\\\DelphiLibrary.dll\")) {\n IntPtr pDll = NativeMethods.LoadLibrary(System.Web.HttpContext.Current.Server.MapPath(\"html/bin\")+\"\\\\DelphiLibrary.dll\");\n if (pDll == IntPtr.Zero) { Label1.Text = \"pDll is zero\"; }\n else\n {\n IntPtr pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pDll, \"GetRandom\");\n if (pAddressOfFunctionToCall == IntPtr.Zero) { Label1.Text += \"IntPtr is zero\"; }\n else\n {\n GetRandom _getRandom = (GetRandom)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall,typeof(GetRandom));\n\n int theResult = _getRandom();\n\n bool result = NativeMethods.FreeLibrary(pDll);\n Label1.Text = theResult.ToString();\n }\n }\n }\n }\n }\n}\n" }, { "answer_id": 51118520, "author": "Ers", "author_id": 205743, "author_profile": "https://Stackoverflow.com/users/205743", "pm_score": 0, "selected": false, "text": "String _path = String.Concat(System.Environment.GetEnvironmentVariable(\"PATH\")\n ,\";\"\n , System.Web.Hosting.HostingEnvironment.MapPath(\"~/bin/x64\")\n ,\";\"\n , System.Web.Hosting.HostingEnvironment.MapPath(\"~/bin/dll/x64\")\n ,\";\"\n );\n System.Environment.SetEnvironmentVariable(\"PATH\", _path, EnvironmentVariableTarget.Process);\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27569/" ]
344,630
<p>I have an enumeration value marked with the following attribute. The second parameter instructs the compiler to error whenever the value is used. I want this behavior for anyone that implements my library, but I need to use this enumeration value within my library. How do I tell the compiler to ignore the Obsolete error for the couple of uses in my library.</p> <pre><code>public enum Choices { One, Two, [ObsoleteAttribute("don't use me", true)] Three, Four } </code></pre> <hr> <p>Solution (Thanks everyone)</p> <pre><code>public class EnumHack { static EnumHack() { // Safety check if (Choices!= (Choices)Enum.Parse(typeof(Choices), "Three")) throw new Exception("Choices.Three != 3; Who changed my Enum!"); } [Obsolete("Backwards compatible Choices.Three", false)] public const Choices ChoicesThree = (Choices)3; } </code></pre>
[ { "answer_id": 344635, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "private const Choices BackwardsCompatibleThree = (Choices) 3;\n" }, { "answer_id": 344666, "author": "Ryan Cook", "author_id": 43029, "author_profile": "https://Stackoverflow.com/users/43029", "pm_score": 1, "selected": false, "text": "namespace ConsoleApplication\n{\n class Program\n {\n static void Main(string[] args)\n {\n TestMethod((Choices)3);\n }\n\n private static int TestMethod(Choices choice) {\n return 1;\n }\n }\n\n public enum Choices\n {\n One = 1,\n Two = 2,\n [ObsoleteAttribute(\"don't use me\", true)]\n Three = 3,\n Four = 4\n }\n}\n (Choices)Enum.Parse(typeof(Choices), \"Choices.Three\")\n" }, { "answer_id": 381015, "author": "Nick Bolton", "author_id": 47775, "author_profile": "https://Stackoverflow.com/users/47775", "pm_score": 2, "selected": false, "text": "#pragma warning disable 0612\n // Call obsolete type/enum member here\n#pragma warning restore 0612\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28736/" ]
344,657
<p>I'm trying to learn about trees by implementing one from scratch. In this case I'd like to do it in C# Java or C++. (without using built in methods)</p> <p>So each node will store a character and there will be a maximum of 26 nodes per node.</p> <p>What data structure would I use to contain the pointers to each of the nodes?</p> <p>Basically I'm trying to implement a radix tree from scratch.</p> <p>Thanks,</p>
[ { "answer_id": 344827, "author": "Bill K", "author_id": 12943, "author_profile": "https://Stackoverflow.com/users/12943", "pm_score": 1, "selected": false, "text": "nextNode=nodes[c-'a'];\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43734/" ]
344,665
<p>I have a table like this:</p> <pre><code> Column | Type | Modifiers ---------+------+----------- country | text | food_id | int | eaten | date | </code></pre> <p>And for each country, I want to get the food that is eaten most often. The best I can think of (I'm using postgres) is:</p> <pre><code>CREATE TEMP TABLE counts AS SELECT country, food_id, count(*) as count FROM munch GROUP BY country, food_id; CREATE TEMP TABLE max_counts AS SELECT country, max(count) as max_count FROM counts GROUP BY country; SELECT country, max(food_id) FROM counts WHERE (country, count) IN (SELECT * from max_counts) GROUP BY country; </code></pre> <p>In that last statement, the GROUP BY and max() are needed to break ties, where two different foods have the same count.</p> <p>This seems like a lot of work for something conceptually simple. Is there a more straight forward way to do it?</p>
[ { "answer_id": 344713, "author": "John MacIntyre", "author_id": 29043, "author_profile": "https://Stackoverflow.com/users/29043", "pm_score": 2, "selected": false, "text": "select country, food_id, count(*) cnt \ninto #tempTbl \nfrom mytable \ngroup by country, food_id\n\nselect country, food_id\nfrom #tempTbl as x\nwhere cnt = \n (select max(cnt) \n from mytable \n where country=x.country \n and food_id=x.food_id)\n" }, { "answer_id": 344728, "author": "JosephStyons", "author_id": 672, "author_profile": "https://Stackoverflow.com/users/672", "pm_score": 2, "selected": false, "text": "select nf.country, nf.food_id as most_frequent_food_id\nfrom national_foods nf\ngroup by country, food_id \nhaving\n (country,count(*)) in ( \n select country, max(cnt)\n from\n (\n select country, food_id, count(*) as cnt\n from national_foods nf1\n group by country, food_id\n )\n group by country\n having country = nf.country\n )\n" }, { "answer_id": 344772, "author": "jkramer", "author_id": 12523, "author_profile": "https://Stackoverflow.com/users/12523", "pm_score": 3, "selected": false, "text": "SELECT DISTINCT\n\"F1\".\"food\",\n\"F1\".\"country\"\nFROM \"foo\" \"F1\"\nWHERE\n\"F1\".\"food\" =\n (SELECT \"food\" FROM\n (\n SELECT \"food\", COUNT(*) AS \"count\"\n FROM \"foo\" \"F2\" \n WHERE \"F2\".\"country\" = \"F1\".\"country\" \n GROUP BY \"F2\".\"food\" \n ORDER BY \"count\" DESC\n ) AS \"F5\"\n LIMIT 1\n )\n food | country \n-----------+------------\n Bratwurst | Germany\n Fisch | Frankreich\n" }, { "answer_id": 345088, "author": "Matt Rogish", "author_id": 2590, "author_profile": "https://Stackoverflow.com/users/2590", "pm_score": 2, "selected": false, "text": "SELECT country, MAX( food_id )\n FROM( SELECT m1.country, m1.food_id\n FROM munch m1\n INNER JOIN ( SELECT country\n , food_id\n , COUNT(*) as food_counts\n FROM munch m2\n GROUP BY country, food_id ) as m3\n ON m1.country = m3.country\n GROUP BY m1.country, m1.food_id \n HAVING COUNT(*) / COUNT(DISTINCT m3.food_id) = MAX(food_counts) ) AS max_foods\n GROUP BY country\n" }, { "answer_id": 345221, "author": "Theo", "author_id": 43402, "author_profile": "https://Stackoverflow.com/users/43402", "pm_score": 2, "selected": false, "text": "select country,food_id, count(*) ne \nfrom food f1 \ngroup by country,food_id \nhaving count(*) = (select max(count(*)) \n from food f2 \n where country = f1.country \n group by food_id) \n" }, { "answer_id": 346656, "author": "Jamal Hansen", "author_id": 2035722, "author_profile": "https://Stackoverflow.com/users/2035722", "pm_score": 3, "selected": false, "text": "Select Country, Food_id\nFrom Munch T1\nWhere Food_id= \n (Select Food_id\n from Munch T2\n where T1.Country= T2.Country\n group by Food_id\n order by count(Food_id) desc\n limit 1)\ngroup by Country, Food_id\n" }, { "answer_id": 12448971, "author": "pilcrow", "author_id": 132382, "author_profile": "https://Stackoverflow.com/users/132382", "pm_score": 4, "selected": false, "text": "SELECT country, food_id\n FROM (SELECT country, food_id, ROW_NUMBER() OVER (PARTITION BY country ORDER BY freq DESC) AS rn\n FROM ( SELECT country, food_id, COUNT('x') AS freq\n FROM country_foods\n GROUP BY 1, 2) food_freq) ranked_food_req\n WHERE rn = 1;\n" }, { "answer_id": 36603115, "author": "JCF", "author_id": 2247323, "author_profile": "https://Stackoverflow.com/users/2247323", "pm_score": 2, "selected": false, "text": "select distinct on (country) country, food_id\nfrom munch\ngroup by country, food_id\norder by country, count(*) desc\n country | food_id | eaten\nUS 1 2017-1-1\nUS 1 2017-1-1\nUS 2 2017-1-1\nUS 3 2017-1-1\nGB 3 2017-1-1\nGB 3 2017-1-1\nGB 2 2017-1-1\n country | food_id\nUS 1\nGB 3\n" }, { "answer_id": 43613779, "author": "jrouquie", "author_id": 1315131, "author_profile": "https://Stackoverflow.com/users/1315131", "pm_score": 5, "selected": false, "text": "mode() select mode() within group (order by food_id)\nfrom munch\ngroup by country\n country | mode\n--------------\nGB | 3\nUS | 1\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34382/" ]
344,672
<p>What is the algorithm for storing the pixels in a spiral in JS?</p>
[ { "answer_id": 344945, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 4, "selected": true, "text": "var Spiral = function(a) {\n this.initialize(a);\n}\n\nSpiral.prototype = {\n _a: 0.5,\n\n constructor: Spiral,\n\n initialize: function( a ) {\n if (a != null) this._a = a;\n },\n\n\n /* specify the increment in radians */\n points: function( rotations, increment ) {\n var maxAngle = Math.PI * 2 * rotations;\n var points = new Array();\n\n for (var angle = 0; angle <= maxAngle; angle = angle + increment)\n {\n points.push( this._point( angle ) );\n }\n\n return points;\n },\n\n _point: function( t ) {\n var x = this._a * t * Math.cos(t);\n var y = this._a * t * Math.sin(t);\n return { X: x, Y: y };\n }\n}\n\n\nvar spiral = new Spiral(0.3);\nvar points = spiral.points( 2, 0.01 );\n\nplot(points);\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18149/" ]
344,697
<p>I have a site with the following robots.txt in the root:</p> <pre><code>User-agent: * Disabled: / User-agent: Googlebot Disabled: / User-agent: Googlebot-Image Disallow: / </code></pre> <p>And pages within this site are getting scanned by Googlebots all day long. Is there something wrong with my file or with Google?</p>
[ { "answer_id": 344700, "author": "Sean Carpenter", "author_id": 729, "author_profile": "https://Stackoverflow.com/users/729", "pm_score": 6, "selected": true, "text": "Disallow: Disabled:" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29493/" ]
344,705
<p>I'm thinking of choosing Adobe AIR as the client-side implementation technology for an upcoming project. (The previous choice was C# and WPF, but I've been really impressed with Flash/Flex/AIR lately.)</p> <p>But one of the most important features of my product will be its plugin architecture, allowing third party developers to extend the functionality and GUI in interesting ways.</p> <p>I know how I'd design the architecture in C#: A plug-in loader would enumerate all of the assemblies in the local "app/plugins/" directory. For each assembly, it'd enumerate all of the classes, looking for implementations of the "IPluginFactory" interface. For each plugin created by the factory, I'd ask it for its MVC classes, and snap its GUI elements (menu items, panels, etc) into the appropriate slots in the existing GUI layout.</p> <p>I'd like to accomplish the same thing within AIR (loading plugins from the local filesystem, not from the web). After reading <a href="http://www.adobe.com/devnet/air/articles/introduction_to_air_security.html" rel="noreferrer">this article</a>, my understanding is that it's possible, and that the basic architecture (loading SWFs into sandboxed ApplicationDomains, etc) is very similar to the way you'd do it in .NET.</p> <p>But I'm curious about the gotchas.</p> <p>If any of you have done any dynamic classloading with the flash player (preferably in mixed flash/flex apps, and ESPECIALLY within the AIR host), I'd love to hear about your experiences building your plugin framework and where you ran into tricky situations with the flash player, and with the flash, flex, and AIR APIs.</p> <p>For example, if someone asked me this same question, but with the Java platform in mind, I'd definitely mention that the JVM has no notion of "modules" or "assemblies". The highest level of aggregation is the "class", so it can be difficult to create organizational structures within a plugin system for managing large projects. I'd also talk about issues with multiple classloaders and how each maintains its own separate instance of a loaded class (with its own separate static vars).</p> <hr> <p>Here are a few specific questions still unanswered for me:</p> <p>1) The actionscript "Loader" class can load an SWF into an ApplicationDomain. But what exactly does that appdomain contain? Modules? Classes? How are MXML components represented? How do I find all of the classes that implement my plugin interface?</p> <p>2) If you've loaded a plugin into a separate ApplicationDomain from the main application, is it substantially more complicated to call code from within that other appdomain? Are there any important limitations about the kinds of data that can pass through the inter-appdomain marshalling layer? Is marshalling prohibitively expensive?</p> <p>3) Ideally, I'd like to develop the majority of my own main code as a plugin (with the main application being little more than a plugin-loading shell) and use the plugin architecture to hoist that functionality into the app. Does that strike fear in your heart?</p>
[ { "answer_id": 349767, "author": "hasseg", "author_id": 4111, "author_profile": "https://Stackoverflow.com/users/4111", "pm_score": 4, "selected": true, "text": "ModuleManager mx.modules ModuleBase ModuleManager IMyAppPlugin MyAppFacade implements IMyAppFacade" }, { "answer_id": 476125, "author": "RogerV", "author_id": 48048, "author_profile": "https://Stackoverflow.com/users/48048", "pm_score": 0, "selected": false, "text": "<mx:Module/>" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22979/" ]
344,714
<p>!!! This is not a duplicate question since the solutions offered in the other topics didn't work for me.</p> <p>When I try to commit:</p> <p>Error: Working copy 'D:\Webs\Drupal 6' locked<br> Error: Please execute the "Cleanup" command.</p> <p>When I try to do a cleanup:</p> <p>Cleanup failed to process the following paths: D:\Webs\Drupal 6</p> <p>Does anyone know how I can solve this problem?</p>
[ { "answer_id": 344745, "author": "derobert", "author_id": 27727, "author_profile": "https://Stackoverflow.com/users/27727", "pm_score": 2, "selected": false, "text": "D:\\Webs\\Drupal 6 .svn" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344714", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
344,715
<p>I'm writing some code that id like to be able to work with any window, such as a window created through the windows API, MFC, wxWidgets, etc.</p> <p>The problem is that for some things I need to use the same thread that created the window, which in many cases is just sat in a message loop.</p> <p>My first thought was to post a callback message to the window, which would then call a function in my code when it recieves the message using one of the params and a function pointer of some sorts. However there doesnt seem to be a standard windows message to do this, and I cant create my own message since I dont control the windows code, so cant add the needed code to the message handler to implement the callback...</p> <p>Is there some other way to get the thread that created the window to enter my function?</p> <p>EDIT: John Z sugessted that I hooked the windows messages. If I do that is there some way to get "ids" for custom messages without the risk of conflicting with any custom messages the window already has?</p> <p>eg I might do</p> <pre><code>WM_CALLBACK = WM_APP+1 </code></pre> <p>But if the window I'm hooking has already done something with WM_APP+1 I'm gonna run into problems.</p> <p>EDIT2: just found RegisterWindowMessage :)</p>
[ { "answer_id": 344738, "author": "John Z", "author_id": 43430, "author_profile": "https://Stackoverflow.com/users/43430", "pm_score": 3, "selected": true, "text": "// Subclass the edit control. \nwpOrigEditProc = (WNDPROC) SetWindowLong(hwndEdit, GWL_WNDPROC, (LONG)EditSubclassProc); \n\n// Remove the subclass from the edit control. \nSetWindowLong(hwndEdit, GWL_WNDPROC, (LONG)wpOrigEditProc); \n" }, { "answer_id": 344959, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 0, "selected": false, "text": "VOID CALLBACK Function( \nHWND hwnd,\nUINT uMsg,\nUINT_PTR idEvent,\nDWORD dwTime\n)\n{\n // stuff\n}\n\nSetTimer(hWnd, event, 0, Function);\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6266/" ]
344,737
<p>I have a XML Structure that looks like this.</p> <pre><code>&lt;sales&gt; &lt;item name="Games" sku="MIC28306200" iCat="28" sTime="11/26/2008 8:41:12 AM" price="1.00" desc="Item Name" /&gt; &lt;item name="Games" sku="MIC28307100" iCat="28" sTime="11/26/2008 8:42:12 AM" price="1.00" desc="Item Name" /&gt; ... &lt;/sales&gt; </code></pre> <p>I am trying to find a way to SORT the nodes based on the sTime attribute which is a DateTime.ToString() value. The trick is I need to keep the Nodes in tact and for some reason I can't find a way to do that. I'm fairly certain that LINQ and XPath have a way to do it, but I'm stuck because I can't seem to sort based on DateTime.ToString() value.</p> <pre><code>XPathDocument saleResults = new XPathDocument(@"temp/salesData.xml"); XPathNavigator navigator = saleResults.CreateNavigator(); XPathExpression selectExpression = navigator.Compile("sales/item/@sTime"); selectExpression.AddSort("@sTime", XmlSortOrder.Descending, XmlCaseOrder.None, "", XmlDataType.Number); XPathNodeIterator nodeIterator = navigator.Select(selectExpression); while( nodeIterator.MoveNext() ) { string checkMe = nodeIterator.Current.Value; } </code></pre> <p>I also need to maintain a pointer to the NODE to retrieve the values of the other attributes. </p> <p>Perhaps this isn't a simple as I thought it would be.</p> <p>Thanks.</p> <p><strong>Solution</strong>: Here's what I ended up using. Taking the selected answer and the IComparable class this is how I get the XML nodes sorted based on the sTime attribute and then get the all the attributes into the appropriate Arrays to be used later.</p> <pre><code> XPathDocument saleResults = new XPathDocument(@"temp/salesData.xml"); XPathNavigator navigator = saleResults.CreateNavigator(); XPathExpression selectExpression = navigator.Compile("sales/item"); XPathExpression sortExpr = navigator.Compile("@sTime"); selectExpression.AddSort(sortExpr, new DateTimeComparer()); XPathNodeIterator nodeIterator = navigator.Select(selectExpression); int i = 0; while (nodeIterator.MoveNext()) { if (nodeIterator.Current.MoveToFirstAttribute()) { _iNameList.SetValue(nodeIterator.Current.Value, i); } if (nodeIterator.Current.MoveToNextAttribute()) { _iSkuList.SetValue(nodeIterator.Current.Value, i); } ... nodeIterator.Current.MoveToParent(); i++; } </code></pre>
[ { "answer_id": 344764, "author": "jlew", "author_id": 7450, "author_profile": "https://Stackoverflow.com/users/7450", "pm_score": 3, "selected": true, "text": " class Program\n {\n static void Main(string[] args)\n {\n XPathDocument saleResults = new XPathDocument( @\"salesData.xml\" );\n XPathNavigator navigator = saleResults.CreateNavigator( );\n XPathExpression selectExpression = navigator.Compile( \"sales/item\" );\n XPathExpression sortExpr = navigator.Compile(\"@sTime\");\n selectExpression.AddSort(sortExpr, new DateTimeComparer());\n XPathNodeIterator nodeIterator = navigator.Select( selectExpression ); \n while ( nodeIterator.MoveNext( ) )\n {\n string checkMe = nodeIterator.Current.Value;\n }\n }\n public class DateTimeComparer : IComparer\n {\n public int Compare(object x, object y)\n {\n DateTime dt1 = DateTime.Parse( x.ToString( ) );\n DateTime dt2 = DateTime.Parse( y.ToString( ) );\n return dt1.CompareTo( dt2 );\n }\n }\n }\n" }, { "answer_id": 344792, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": 3, "selected": false, "text": "XmlDocument myDoc = new XmlDocument();\n\nmyDoc.LoadXml(@\"\n<sales>\n<item name=\"\"Games\"\"\n sku=\"\"MIC28306200\"\"\n iCat=\"\"28\"\"\n sTime=\"\"11/26/2008 8:41:12 AM\"\"\n price=\"\"1.00\"\"\n desc=\"\"Item Name\"\" />\n<item name=\"\"Games\"\"\n sku=\"\"MIC28307100\"\"\n iCat=\"\"28\"\"\n sTime=\"\"11/26/2008 8:42:12 AM\"\"\n price=\"\"1.00\"\"\n desc=\"\"Item Name\"\" />\n</sales>\n\");\n\nvar sortedItems = myDoc.GetElementsByTagName(\"item\").OfType<XmlElement>()\n .OrderBy(item => DateTime.ParseExact(item.GetAttribute(\"sTime\"), \"MM/dd/yyyy h:mm:ss tt\", null));\n\nforeach (var item in sortedItems)\n{\n Console.WriteLine(item.OuterXml);\n}\n" }, { "answer_id": 344875, "author": "Robert Rossney", "author_id": 19403, "author_profile": "https://Stackoverflow.com/users/19403", "pm_score": 1, "selected": false, "text": "CCCC-MM-DD HH:MM:SS" }, { "answer_id": 46402777, "author": "Chetan Mehra", "author_id": 1725131, "author_profile": "https://Stackoverflow.com/users/1725131", "pm_score": 0, "selected": false, "text": " private static void SortElementAttributesBasis(XmlNode rootNode)\n {\n\n\n\n for (int j = 0; j < rootNode.ChildNodes.Count; j++)\n {\n for (int i = 1; i < rootNode.ChildNodes.Count; i++)\n {\n Console.WriteLine(rootNode.OuterXml);\n DateTime dt1 = DateTime.ParseExact(rootNode.ChildNodes[i].Attributes[\"sTime\"].Value, \"M/d/yyyy h:mm:ss tt\", System.Globalization.CultureInfo.InvariantCulture);\n DateTime dt2 = DateTime.ParseExact(rootNode.ChildNodes[i-1].Attributes[\"sTime\"].Value, \"M/d/yyyy h:mm:ss tt\", System.Globalization.CultureInfo.InvariantCulture);\n int compare = DateTime.Compare(dt1,dt2);\n if (compare < 0)\n {\n rootNode.InsertBefore(rootNode.ChildNodes[i], rootNode.ChildNodes[i - 1]);\n Console.WriteLine(rootNode.OuterXml);\n }\n\n // Provide the name of Attribute in .Attribute[\"Name\"] based on value you want to sort.\n\n //if (String.Compare(rootNode.ChildNodes[i].Attributes[\"sTime\"].Value, rootNode.ChildNodes[1 - 1].Attributes[\"sTime\"].Value) < 0)\n //{\n // rootNode.InsertBefore(rootNode.ChildNodes[i], rootNode.ChildNodes[i - 1]);\n\n //}\n }\n }\n }\n <sales>\n<item name=\"Games\" sku=\"MIC28306200\" iCat=\"28\"\n sTime=\"11/26/2008 8:41:12 PM\"\n price=\"1.00\" desc=\"Item Name\" />\n<item name=\"Games\" sku=\"MIC28307100\" iCat=\"28\"\n sTime=\"11/26/2008 8:42:12 AM\"\n price=\"1.00\" desc=\"Item Name\" />\n<item name=\"Games\" sku=\"MIC28307100\" iCat=\"28\"\n sTime=\"11/26/2008 11:42:12 AM\"\n price=\"1.00\" desc=\"Item Name\" />\n<item name=\"Games\" sku=\"MIC28306200\" iCat=\"28\"\n sTime=\"12/23/2008 8:41:12 PM\"\n price=\"1.00\" desc=\"Item Name\" />\n<item name=\"Games\" sku=\"MIC28307100\" iCat=\"28\"\n sTime=\"12/23/2008 8:42:12 AM\"\n price=\"1.00\" desc=\"Item Name\" />\n <item name=\"Games\" sku=\"MIC28307100\" iCat=\"28\" sTime=\"11/26/2008 8:42:12 AM\" price=\"1.00\" desc=\"Item Name\" /><item name=\"Games\" sku=\"MIC28307100\" iCat=\"28\" sTime=\"11/26/2008 11:42:12 AM\" price=\"1.00\" desc=\"Item Name\" /><item name=\"Games\" sku=\"MIC28306200\" iCat=\"28\" sTime=\"11/26/2008 8:41:12 PM\" price=\"1.00\" desc=\"Item Name\" /><item name=\"Games\" sku=\"MIC28307100\" iCat=\"28\" sTime=\"12/23/2008 8:42:12 AM\" price=\"1.00\" desc=\"Item Name\" />\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30408/" ]
344,741
<p>I am looking to create an expression tree by parsing xml using C#. The xml would be like the following:</p> <pre><code>&lt;Expression&gt; &lt;If&gt; &lt;Condition&gt; &lt;GreaterThan&gt; &lt;X&gt; &lt;Y&gt; &lt;/GreaterThan&gt; &lt;/Condition&gt; &lt;Expression /&gt; &lt;If&gt; &lt;Else&gt; &lt;Expression /&gt; &lt;/Else&gt; &lt;Expression&gt; </code></pre> <p>or another example...</p> <pre><code>&lt;Expression&gt; &lt;Add&gt; &lt;X&gt; &lt;Expression&gt; &lt;Y&gt; &lt;Z&gt; &lt;/Expression&gt; &lt;/Add&gt; &lt;/Expression&gt; </code></pre> <p>...any pointers on where to start would be helpful.</p> <p>Kind regards,</p>
[ { "answer_id": 344811, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 4, "selected": true, "text": "using System.Linq.Expressions; //in System.Core.dll\n\nExpression BuildExpr(XmlNode xmlNode)\n { switch(xmlNode.Name)\n { case \"Add\":\n { return Expression.Add( BuildExpr(xmlNode.ChildNodes[0])\n ,BuildExpr(xmlNode.ChilNodes[1]));\n } \n\n /* ... */\n\n }\n }\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21586/" ]
344,744
<p>The DB load on my site is getting really high so it is time for me to cache common queries that are being called 1000s of times an hour where the results are not changing. So for instance on my city model I do the following: </p> <pre><code>def self.fetch(id) Rails.cache.fetch("city_#{id}") { City.find(id) } end def after_save Rails.cache.delete("city_#{self.id}") end def after_destroy Rails.cache.delete("city_#{self.id}") end </code></pre> <p>So now when I can City.find(1) the first time I hit the DB but the next 1000 times I get the result from memory. Great. But most of the calls to city are not City.find(1) but @user.city.name where Rails does not use the fetch but queries the DB again... which makes sense but not exactly what I want it to do. </p> <p>I can do City.find(@user.city_id) but that is ugly. </p> <p>So my question to you guys. What are the smart people doing? What is the right way to do this? </p>
[ { "answer_id": 344854, "author": "mwilliams", "author_id": 23909, "author_profile": "https://Stackoverflow.com/users/23909", "pm_score": 0, "selected": false, "text": "class Product < ActiveRecord::Base\n extend ActiveSupport::Memoizable\n\n belongs_to :category\n\n def filesize(num = 1)\n # some expensive operation\n sleep 2\n 12345789 * num\n end\n memoize :filesize\nend\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43744/" ]
344,748
<p>I'm trying to do something like </p> <pre><code>URL clientks = com.messaging.SubscriptionManager.class.getResource( "client.ks" ); String path = clientks.toURI().getPath(); System.setProperty( "javax.net.ssl.keyStore", path); </code></pre> <p>Where client.ks is a file stored in com/messaging in the jar file that I'm running.</p> <p>The thing that reads the javax.net.ssl.keyStore is expecting a path to the client.ks file which is in the jar. I'd rather not extract the file and put in on the client's machine if possible. So is it possible to reference a file in a jar?</p> <p>This doesn't work as getPath() returns null. Is there another way to do this?</p>
[ { "answer_id": 344782, "author": "Jason Day", "author_id": 737, "author_profile": "https://Stackoverflow.com/users/737", "pm_score": 3, "selected": false, "text": "InputStream File File" }, { "answer_id": 17352927, "author": "user2529737", "author_id": 2529737, "author_profile": "https://Stackoverflow.com/users/2529737", "pm_score": 6, "selected": true, "text": "InputStream keystoreInput = Thread.currentThread().getContextClassLoader()\n .getResourceAsStream(<path in jar>/client.ks\");\nInputStream truststoreInput = Thread.currentThread().getContextClassLoader()\n .getResourceAsStream(<path in jar>/client.ts\");\nsetSSLFactories(keystoreInput, \"password\", truststoreInput);\nkeystoreInput.close();\ntruststoreInput.close();\n\nprivate static void setSSLFactories(InputStream keyStream, String keyStorePassword, \n InputStream trustStream) throws Exception\n{ \n // Get keyStore\n KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); \n\n // if your store is password protected then declare it (it can be null however)\n char[] keyPassword = keyStorePassword.toCharArray();\n\n // load the stream to your store\n keyStore.load(keyStream, keyPassword);\n\n // initialize a key manager factory with the key store\n KeyManagerFactory keyFactory = \n KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); \n keyFactory.init(keyStore, keyPassword);\n\n // get the key managers from the factory\n KeyManager[] keyManagers = keyFactory.getKeyManagers();\n\n // Now get trustStore\n KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); \n\n // if your store is password protected then declare it (it can be null however)\n //char[] trustPassword = password.toCharArray();\n\n // load the stream to your store\n trustStore.load(trustStream, null);\n\n // initialize a trust manager factory with the trusted store\n TrustManagerFactory trustFactory = \n TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); \n trustFactory.init(trustStore);\n\n // get the trust managers from the factory\n TrustManager[] trustManagers = trustFactory.getTrustManagers();\n\n // initialize an ssl context to use these managers and set as default\n SSLContext sslContext = SSLContext.getInstance(\"SSL\");\n sslContext.init(keyManagers, trustManagers, null);\n SSLContext.setDefault(sslContext); \n}\n" }, { "answer_id": 45606296, "author": "eis", "author_id": 365237, "author_profile": "https://Stackoverflow.com/users/365237", "pm_score": 3, "selected": false, "text": "import javax.net.ssl.HttpsURLConnection;\nimport javax.net.ssl.KeyManager;\nimport javax.net.ssl.KeyManagerFactory;\nimport javax.net.ssl.SSLContext;\nimport java.io.BufferedReader;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.net.URL;\nimport java.security.KeyStore;\n\npublic class PlainJavaHTTPS2Test {\n\n public void setUp() throws Exception {\n final String KEYSTOREPATH = \"clientkeystore.p12\"; // or .jks\n\n // store password can be null if there is no password\n final char[] KEYSTOREPASS = \"keystorepass\".toCharArray();\n\n // key password can be null if there is no password\n final char[] KEYPASS = \"keypass\".toCharArray();\n\n try (InputStream storeStream = this.getClass().getResourceAsStream(KEYSTOREPATH)) {\n setSSLFactories(storeStream, \"PKCS12\", KEYSTOREPASS, KEYPASS);\n }\n }\n private static void setSSLFactories(InputStream keyStream, String keystoreType, char[] keyStorePassword, char[] keyPassword) throws Exception\n {\n KeyStore keyStore = KeyStore.getInstance(keystoreType);\n\n keyStore.load(keyStream, keyStorePassword);\n\n KeyManagerFactory keyFactory =\n KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());\n\n keyFactory.init(keyStore, keyPassword);\n\n KeyManager[] keyManagers = keyFactory.getKeyManagers();\n\n SSLContext sslContext = SSLContext.getInstance(\"SSL\");\n sslContext.init(keyManagers, null, null);\n SSLContext.setDefault(sslContext);\n }\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7949/" ]
344,753
<p>i am trying to do something with the PIL Image library in django, but i experience some problems.</p> <p>I do like this:</p> <p><code> import Image </code></p> <p>And then I do like this</p> <p><code> images = map(Image.open, glob.glob(os.path.join(dirpath, '*.thumb.jpg'))) </code></p> <p>But when i try to run this i get an error and it leeds me to think that its not imported correctly, anybody know?</p> <p><code> type object 'Image' has no attribute 'open' </code></p>
[ { "answer_id": 344791, "author": "Manuel Ceron", "author_id": 23657, "author_profile": "https://Stackoverflow.com/users/23657", "pm_score": 0, "selected": false, "text": "from PIL import Image\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42546/" ]
344,777
<p>I'm trying to add two folders to my eclipse project's classpath, let's say Folder A and Folder B. B is inside A. Whenever I add A to the classpath</p> <pre><code>&lt;classpathentry kind="lib" path="/A"/&gt; </code></pre> <p>it works just fine, but I need to be able to access the files in B as well. Whenever I try to add</p> <pre><code>&lt;classpathentry kind="lib" path="/A/B"/&gt; </code></pre> <p>to the classpath, it says </p> <blockquote> <p>Cannot nest 'A/B inside library A'</p> </blockquote> <p>I'm a newbie when it comes to editing the classpath, so I'm wondering, is there is anyway to add a folder in the eclipse classpath that is nested in another folder that is also in the eclipse classpath?</p>
[ { "answer_id": 8398181, "author": "michaelliu", "author_id": 726894, "author_profile": "https://Stackoverflow.com/users/726894", "pm_score": 2, "selected": false, "text": "<classpathentry kind=\"lib\" path=\"/A\" excluding=\"B/\"/>\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1459442/" ]
344,784
<p>I have some library code which is used from my application and is also used by a .NET custom action in a Visual Studio installer project. The library code in turn uses the Enterprise Library logging block to do its logging. How can I get configuration information to the Enterprise Library in the context of my custom action running inside msiexec? Is it possible to bootstrap the config mechanism in code before I make any calls to the EntLib?</p> <p>Update: I've produced a hack that seems like it will work but relies on setting a non-public static field using reflection. It's a shame that EntLib is so tightly coupled to the .NET ConfigurationManager.</p> <pre><code>var factory = new LogWriterFactory( new FakeConfigSource( "foo.config" ) ); var field = typeof ( Logger ).GetField( "factory", BindingFlags.Static | BindingFlags.NonPublic ); field.SetValue( null, factory ); Logger.Write( "Test" ); </code></pre> <p>Update 2: Although that hack works in a testbed, when run in the context of msiexec, the assembly loader does not find the assemblies referenced in the config file. Fuslogvw indicates that AppBase is the windows system32 directory, which makes some sense. What I don't understand is why the custom action assembly's manifest dependencies (which are in the [TargetDir] directory alongside the custom action assembly) are found, but dynamically-loaded assemblies called out in the config file are not. Can't see any way around this.</p>
[ { "answer_id": 362029, "author": "w4g3n3r", "author_id": 36745, "author_profile": "https://Stackoverflow.com/users/36745", "pm_score": 0, "selected": false, "text": "Const msiMessageTypeInfo = &H04000000\nConst msiMessageTypeFatalExit = &H00000000\nConst msiMessageTypeError = &H01000000\nConst msiMessageTypeWarning = &H02000000\nConst msiMessageTypeUser = &H03000000 \n\nDim rec : Set rec = Session.Installer.CreateRecord(1)\nrec.StringData(1) = \"Your log message.\"\n\nSession.Message msiMessageTypeInfo, rec\n" }, { "answer_id": 582165, "author": "John Hunter", "author_id": 2253, "author_profile": "https://Stackoverflow.com/users/2253", "pm_score": 0, "selected": false, "text": "string installDir = System.IO.Path.GetDirectoryName(\n System.Reflection.Assembly.GetExecutingAssembly().Location);\nSystem.IO.File.Copy(\n System.IO.Path.Combine(installDir, \"<Insert Assembly Name>.dll\"),\n System.IO.Path.Combine(Environment.SystemDirectory, \"<Insert Assembly Name>.dll\"),\n true);\n" }, { "answer_id": 604604, "author": "Jeffrey Hantin", "author_id": 55637, "author_profile": "https://Stackoverflow.com/users/55637", "pm_score": 1, "selected": false, "text": "LoadFrom AppDomain App.config" }, { "answer_id": 48997009, "author": "Paul", "author_id": 63209, "author_profile": "https://Stackoverflow.com/users/63209", "pm_score": 0, "selected": false, "text": "AppDomain.AssemblyResolve Install internal class MyInstaller : Installer\n{\n public override void Install(IDictionary stateSaver)\n {\n base.Install(stateSaver);\n\n AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>\n {\n // Resolve assemblies here, e.g.:\n return\n args.Name == \"My.Assembly\"\n ? Assembly.LoadFrom(this.Context.Parameters[\"TARGETDIR\"] + \"\\\\My.Assembly.dll\")\n : null;\n };\n\n // Continue install...\n }\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7450/" ]
344,789
<p>I want to install PEAR on PHP 5, so I can use Spreadsheet_Excel_Writer.</p> <p>I don`t know how to install it on my ISP nor my personal MacBook.</p> <p>Thoughts for both?</p>
[ { "answer_id": 344830, "author": "jlleblanc", "author_id": 586, "author_profile": "https://Stackoverflow.com/users/586", "pm_score": 2, "selected": false, "text": "pear install Spreadsheet_Excel_Writer\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
344,797
<p>What is the best solution to build several CDT C++ projects from the command line? The projects have references and so it is not possible to just build single projects.</p>
[ { "answer_id": 962610, "author": "James Blackburn", "author_id": 115144, "author_profile": "https://Stackoverflow.com/users/115144", "pm_score": 6, "selected": false, "text": "eclipse -nosplash \n -application org.eclipse.cdt.managedbuilder.core.headlessbuild \n -import {[uri:/]/path/to/project} \n -build {project_name | all} \n -cleanBuild {projec_name | all}\n eclipsec.exe eclipse.exe" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
344,801
<p>Deletion operations seems to be the slowest in a YUI datatable. I have a datatable with > 300 rows. I need to delete selected rows. I tried removing the selected records from the <code>recordset</code> and then calling <code>table.render()</code> .. While this is okay, can it be made better?</p>
[ { "answer_id": 346747, "author": "Evan Anderson", "author_id": 40764, "author_profile": "https://Stackoverflow.com/users/40764", "pm_score": 2, "selected": false, "text": "var selected = theDataTable.getSelectedRows();\nvar rset = theDataTable.getRecordSet();\n\nfor (var x = 0; x < selected.length; x++) {\n theDataTable.deleteRow(rset.getRecordIndex(rset.getRecord(selected[x]))\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
344,823
<p>On various pages throughout my PHP web site and in various nested directories I want to include a specific file at a path relative to the root.</p> <p>What single command can I put on both of these pages...</p> <pre>http://www.example.com/pageone.php</pre> <pre>http://www.example.com/somedirectory/pagetwo.php</pre> <p>...to include this page:</p> <pre>http://www.example.com/includes/analytics.php</pre> <p>This does not work:</p> <pre><code>&lt;?php include('/includes/analytics.php'); ?&gt; </code></pre> <p>Does it matter that this is hosted in IIS on Windows?</p>
[ { "answer_id": 344831, "author": "Stefan Mai", "author_id": 13257, "author_profile": "https://Stackoverflow.com/users/13257", "pm_score": 1, "selected": false, "text": "include 'includes/analytics.php';\n include '../includes/analytics.php';\n" }, { "answer_id": 344848, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 3, "selected": false, "text": "define('ROOT', dirname(__FILE__));\n" }, { "answer_id": 344853, "author": "J Cooper", "author_id": 38803, "author_profile": "https://Stackoverflow.com/users/38803", "pm_score": 5, "selected": false, "text": "include $_SERVER['DOCUMENT_ROOT'] . \"/includes/analytics.php\";" }, { "answer_id": 344858, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "getenv() $HOME" }, { "answer_id": 344870, "author": "Zack Peterson", "author_id": 83, "author_profile": "https://Stackoverflow.com/users/83", "pm_score": 1, "selected": false, "text": "<?php include('c:/inetpub/example.com/includes/analytics.php'); ?>\n c:/inetpub/example.com/" }, { "answer_id": 344877, "author": "Zoredache", "author_id": 20267, "author_profile": "https://Stackoverflow.com/users/20267", "pm_score": 3, "selected": false, "text": "require_once realpath(dirname(__FILE__).'/config.php');\nrequire_once realpath(dirname(__FILE__).'/lib/Database.php');\n" }, { "answer_id": 4426192, "author": "Reggie Z. Banal", "author_id": 540136, "author_profile": "https://Stackoverflow.com/users/540136", "pm_score": 3, "selected": false, "text": "config.php define('ROOT', $_SERVER['DOCUMENT_ROOT']); include_once(ROOT.\"/someFile.php\"); include_once(ROOT.\"/includes/someFile.php\");" }, { "answer_id": 18706342, "author": "Santiago", "author_id": 1067170, "author_profile": "https://Stackoverflow.com/users/1067170", "pm_score": 0, "selected": false, "text": "<?php include $_SERVER['DOCUMENT_ROOT'].'\\\\Your\\\\Site\\\\Path.php' ?>\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
344,826
<p>Today I'm starting a little project to create a Django based school administration program. I'm currently designing the models and their corresponding relationships. Being rather new to Django and relational databases in general, I would like some input.</p> <p>Before I show you the current model layout, you need to have an idea of what the program is meant to do. Keep in mind that it is my goal for the software to be usable by both individual schools and entire school systems.</p> <p>Features: - Create multiple schools<br> - Track student population per school<br> - Track student demographics, parent contact info, etc.<br> - Grade books<br> - Transcripts<br> - Track disciplinary record.<br> - Fees schedules and payment tracking<br> - Generate reports (student activity, student transcripts, class progress, progress by demographic, payment reports, disciplinary report by student class and demographic)<br> -- Automated PDF report email to parents for student reports.</p> <p>Given those feature requirements, here is the model layout that I currently have: Models</p> <pre><code>* Person o ID: char or int o FirstName: char o MiddleName: char o FamilyName: char o Sex: multiple choice o Ethnicity: multiple choice o BirthDate: date o Email: char o HomePhone: char o WordPhone: char o CellPhone: char o Address: one-to-one with Location * Student (inherent Person) o Classes: one-to-many with Class o Parents: one-to-many with Parent o Account: one-to-one with PaymentSchedule o Tasks: one-to-many with Tasks o Diciplin: one-to-many with Discipline * Parent (inherent Person) o Children: one-to-many with Student * Teacher (inherent Person) o Classes: one-to-many with Class * Location o Address: char o Address2: char o Address3: char o City: char o StateProvince: char o PostalCode: char o Country: multiple choice * Course o Name: char o Description: text field o Grade: int * Class o School: one-to-one with School o Course: one-to-one with Course o Teacher: one-to-one with Teacher o Students: one-to-many with Student * School o ID: char or int o Name: char o Location: one-to-one with location * Tasks o ID: auto increment o Type: multiple choice (assignment, test, etc.) o DateAssigned: date o DateCompleted: date o Score: real o Weight: real o Class: one-to-one with class o Student: one-to-one with Student * Discipline o ID: auto-increment o Discription: text-field o Reaction: text-field o Students: one-to-many with Student * PaymentSchedule o ID: auto-increment o YearlyCost: real o PaymentSchedule: multiple choice o ScholarshipType: multiple choice, None if N/A o ScholarshipAmount: real, 0 if N/A o Transactions: one-to-many with Payments * Payments o auto-increment o Amount: real o Date: date </code></pre> <p>If you have ideas on how this could be improved upon, I'd love to year them!</p> <h1>Update</h1> <p>I've written the initial models.py code, which is probably in need of much love. If you would like to take a look, or even join the project, check out the link.<br> <a href="http://bazaar.launchpad.net/~djangoschools/djangoschools/trunk/files" rel="nofollow noreferrer"><a href="http://bazaar.launchpad.net/~djangoschools/djangoschools/trunk/files" rel="nofollow noreferrer">http://bazaar.launchpad.net/~djangoschools/djangoschools/trunk/files</a></a></p>
[ { "answer_id": 345403, "author": "Justin Voss", "author_id": 5616, "author_profile": "https://Stackoverflow.com/users/5616", "pm_score": 0, "selected": false, "text": "from django.db import models\n\nSEX_CHOICES = (\n ('M', 'Male'),\n ('F', 'Female')\n)\n\nETHNICITY_CHOICES = (\n # follow the same format as SEX_CHOICES:\n # (database_value, human_friendly_name)\n)\n\nclass Person(models.Model):\n first_name = models.CharField(max_length=200)\n middle_name = models.CharField(max_length=200)\n familiy_name = models.CharField(max_length=200) \n\n sex = models.CharField(max_length=1, choices=SEX_CHOICES)\n ethnicity = models.CharField(max_length=1, choices=ETHNICITY_CHOICES)\n birth_date = models.DateField()\n\n email = models.EmailField()\n home_phone = models.CharField(max_length=10) # USA phone numbers\n work_phone = models.CharField(max_length=10)\n cell_phone = models.CharField(max_length=10)\n address = models.ForeignKey(Location)\n\nclass Location(models.Model):\n # left as an exercise for the reader\n\n# more classes...\n" }, { "answer_id": 2135038, "author": "orokusaki", "author_id": 128463, "author_profile": "https://Stackoverflow.com/users/128463", "pm_score": 0, "selected": false, "text": "class SchoolClass(models.Model):\n teacher = models.ManyToManyField(Teacher, related_name='teachers')\n student = models.ManyToManyField(Student, related_name='students')\n prerequisites = models.ForeignKey('self')\n startdate = models.DateField()\n enddate = models.DateField()\n ... and so on ...\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33383/" ]
344,828
<p>Basically I am trying to retrieve a list of stored procedure parameters using Linq to SQL? Is there a way to do this?</p>
[ { "answer_id": 345403, "author": "Justin Voss", "author_id": 5616, "author_profile": "https://Stackoverflow.com/users/5616", "pm_score": 0, "selected": false, "text": "from django.db import models\n\nSEX_CHOICES = (\n ('M', 'Male'),\n ('F', 'Female')\n)\n\nETHNICITY_CHOICES = (\n # follow the same format as SEX_CHOICES:\n # (database_value, human_friendly_name)\n)\n\nclass Person(models.Model):\n first_name = models.CharField(max_length=200)\n middle_name = models.CharField(max_length=200)\n familiy_name = models.CharField(max_length=200) \n\n sex = models.CharField(max_length=1, choices=SEX_CHOICES)\n ethnicity = models.CharField(max_length=1, choices=ETHNICITY_CHOICES)\n birth_date = models.DateField()\n\n email = models.EmailField()\n home_phone = models.CharField(max_length=10) # USA phone numbers\n work_phone = models.CharField(max_length=10)\n cell_phone = models.CharField(max_length=10)\n address = models.ForeignKey(Location)\n\nclass Location(models.Model):\n # left as an exercise for the reader\n\n# more classes...\n" }, { "answer_id": 2135038, "author": "orokusaki", "author_id": 128463, "author_profile": "https://Stackoverflow.com/users/128463", "pm_score": 0, "selected": false, "text": "class SchoolClass(models.Model):\n teacher = models.ManyToManyField(Teacher, related_name='teachers')\n student = models.ManyToManyField(Student, related_name='students')\n prerequisites = models.ForeignKey('self')\n startdate = models.DateField()\n enddate = models.DateField()\n ... and so on ...\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9382/" ]
344,829
<p>I got a core that looks very different from the ones I usually get - most of the threads are in __kernel_vsyscall() :</p> <pre><code> 9 process 11334 0xffffe410 in __kernel_vsyscall () 8 process 11453 0xffffe410 in __kernel_vsyscall () 7 process 11454 0xffffe410 in __kernel_vsyscall () 6 process 11455 0xffffe410 in __kernel_vsyscall () 5 process 11474 0xffffe410 in __kernel_vsyscall () 4 process 11475 0xffffe410 in __kernel_vsyscall () 3 process 11476 0xffffe410 in __kernel_vsyscall () 2 process 11477 0xffffe410 in __kernel_vsyscall () 1 process 11323 0x08220782 in MyClass::myfunc () </code></pre> <p>What does that mean?</p> <p>EDIT: In particular, I usually see a lot of threads in "pthread_cond_wait" and "___newselect_nocancel" and now those are on the second frame in each thread - why is this core different?</p>
[ { "answer_id": 344841, "author": "coppro", "author_id": 16855, "author_profile": "https://Stackoverflow.com/users/16855", "pm_score": 6, "selected": true, "text": "__kernel_vsyscal sysenter" }, { "answer_id": 347355, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "linux-gate.so linux-gate.so.1 __kernel_vsyscall()" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/779/" ]
344,845
<p>I am regularly required to compare data sent to me in Excel spreadsheets with data that lives in SQL Server. I know that you can connect SQL Server to spreadsheets but it always seemed clunky</p> <p>This is really a post to show off my solution but I would love to hear other peoples ideas.</p>
[ { "answer_id": 344846, "author": "wcm", "author_id": 2173, "author_profile": "https://Stackoverflow.com/users/2173", "pm_score": 3, "selected": true, "text": "Sub CreateOpenXML()\n\n Dim cols, rows As Long\n cols = Selection.Columns.Count\n rows = Selection.rows.Count\n Dim Header() As String\n ReDim Preserve Header(cols)\n For i = 1 To cols '''Each Column In Selection.Rows(0).Columns\n Header(i) = CleanHeader(Selection.Cells(1, i).Value)\n 'Header(i) = Application.WorksheetFunction.Substitute(CleanString(Selection.Cells(1, i).Value), \" \", \"_\")\n 'Header(i) = Application.WorksheetFunction.Substitute(Header(i), \"(\", \"_\")\n 'Header(i) = Application.WorksheetFunction.Substitute(Header(i), \")\", \"_\")\n 'i = i + 1\n Next\n Dim theXML As String, tmpXML As String, counter As Integer\n\n theXML = \"DECLARE @DocHandle int\" & vbCrLf\n theXML = theXML & \"DECLARE @XmlDocument varchar(8000)\" & vbCrLf\n theXML = theXML & \"EXEC sp_xml_preparedocument @DocHandle OUTPUT, N'<theRange>\" & vbCrLf\n tmpXML = \"\"\n counter = 0\n For i = 2 To rows\n tmpXML = tmpXML & vbTab & \"<theRow>\"\n For j = 1 To cols\n If Selection.Cells(i, j).Text <> \"NULL\" And Selection.Cells(i, j).Text <> \"\" Then\n tmpXML = tmpXML & \"<\" & Header(j) & \">\" & CleanString(Selection.Cells(i, j).Text) & \"</\" & Header(j) & \">\"\n 'tmpXML = tmpXML & CleanString(Selection.Cells(i, j).Text)\n 'tmpXML = tmpXML & \"</\" & Header(j) & \">\"\n End If\n Next j\n tmpXML = tmpXML & \"</theRow>\" & vbCrLf\n counter = counter + 1\n If counter = 200 Then\n theXML = theXML & tmpXML\n tmpXML = \"\"\n counter = 0\n End If\n Next i\n theXML = theXML & tmpXML\n theXML = theXML & \"</theRange>'\" & vbCrLf & vbCrLf\n '''theXML = theXML & \"EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument\" & vbCrLf\n theXML = theXML & \"SELECT \"\n For i = 1 To cols\n theXML = theXML & \"[\" & Header(i) & \"]\"\n If i <> cols Then theXML = theXML & \", \"\n Next\n theXML = theXML & vbCrLf\n theXML = theXML & \"INTO #tmp\"\n theXML = theXML & vbCrLf\n theXML = theXML & \"FROM OPENXML (@DocHandle, '/theRange/theRow',2) WITH (\" & vbCrLf\n For i = 1 To cols\n theXML = theXML & vbTab & \"[\" & Header(i) & \"] varchar(100)\"\n If i <> cols Then theXML = theXML & \",\"\n theXML = theXML & vbCrLf\n Next\n theXML = theXML & \")\" & vbCrLf\n theXML = theXML & \"EXEC sp_xml_removedocument @DocHandle\" & vbCrLf\n theXML = theXML & vbCrLf\n theXML = theXML & \"Select * from #tmp\" & vbCrLf\n theXML = theXML & vbCrLf\n theXML = theXML & \"--DROP TABLE #tmp\"\n theXML = theXML & vbCrLf\n MsgBox \"The XML has been copied to the clipboard\"\n Dim dob As New DataObject\n dob.SetText (theXML)\n dob.PutInClipboard\n\nEnd Sub\n\nFunction CleanString(orig As String)\n Dim tmp As String\n tmp = orig\n '''MsgBox InStr(orig, \"&\")\n If InStr(orig, \"&\") > 0 Or InStr(orig, \"'\") > 0 Or InStr(orig, \"<\") > 0 Or InStr(orig, \">\") > 0 Or InStr(orig, \"\"\"\") > 0 Then\n tmp = Application.WorksheetFunction.Substitute(tmp, \"&\", \"&amp;\")\n tmp = Application.WorksheetFunction.Substitute(tmp, \"'\", \"&apos;\")\n tmp = Application.WorksheetFunction.Substitute(tmp, \"<\", \"&lt;\")\n tmp = Application.WorksheetFunction.Substitute(tmp, \">\", \"&gt;\")\n tmp = Application.WorksheetFunction.Substitute(tmp, \"\"\"\", \"&quot;\")\n End If\n CleanString = tmp\n\nEnd Function\n\nFunction CleanHeader(orig As String)\n Dim tmp As String\n tmp = Trim(orig)\n If InStr(orig, \" \") > 0 Or InStr(orig, \"(\") > 0 Or InStr(orig, \")\") > 0 Or InStr(orig, \"$\") > 0 Or InStr(orig, \"/\") > 0 Or InStr(orig, \"?\") > 0 Or InStr(orig, \"&\") > 0 Or InStr(orig, \"'\") > 0 Or InStr(orig, \"<\") > 0 Or InStr(orig, \">\") > 0 Or InStr(orig, \"\"\"\") > 0 Then\n tmp = Application.WorksheetFunction.Substitute(tmp, \"&\", \"And\")\n tmp = Application.WorksheetFunction.Substitute(tmp, \"'\", \"_\")\n tmp = Application.WorksheetFunction.Substitute(tmp, \"<\", \"\")\n tmp = Application.WorksheetFunction.Substitute(tmp, \">\", \"\")\n tmp = Application.WorksheetFunction.Substitute(tmp, \"\"\"\", \"\")\n tmp = Application.WorksheetFunction.Substitute(tmp, \" \", \"_\")\n tmp = Application.WorksheetFunction.Substitute(tmp, \"(\", \"_\")\n tmp = Application.WorksheetFunction.Substitute(tmp, \")\", \"_\")\n tmp = Application.WorksheetFunction.Substitute(tmp, \"$\", \"\")\n tmp = Application.WorksheetFunction.Substitute(tmp, \"/\", \"\")\n tmp = Application.WorksheetFunction.Substitute(tmp, \"?\", \"\")\n End If\n CleanHeader = tmp\n\nEnd Function\n\nSub MakeText()\n\n ActiveCell.CurrentRegion.Select\n Dim rng As Range\n Set rng = Selection\n\n Dim str As String\n For i = 1 To rng.rows.Count\n For j = 1 To rng.Columns.Count\n str = Application.WorksheetFunction.Text(rng.Cells(i, j).Value, \"#\")\n rng.Cells(i, j).NumberFormat = \"@\"\n rng.Cells(i, j).Value = str\n Next j\n Next i\n\nEnd Sub\n Name DOB Score Comment\nJohn Smith 7/1/1990 93 Great effort\nSue Jones 1/1/1989 95 Super achievement\nRobin Sixpack 12/1/1985 100 OK\n DECLARE @DocHandle int\nDECLARE @XmlDocument varchar(8000)\nEXEC sp_xml_preparedocument @DocHandle OUTPUT, N'<theRange>\n <theRow><Name>John Smith</Name><DOB>7/1/1990</DOB><Score>93</Score><Comment>Great effort</Comment></theRow>\n <theRow><Name>Sue Jones</Name><DOB>1/1/1989</DOB><Score>95</Score><Comment>Super achievement</Comment></theRow>\n <theRow><Name>Robin Sixpack</Name><DOB>12/1/1985</DOB><Score>100</Score><Comment>OK</Comment></theRow>\n</theRange>'\n\nSELECT [Name], [DOB], [Score], [Comment]\nINTO #tmp\nFROM OPENXML (@DocHandle, '/theRange/theRow',2) WITH (\n [Name] varchar(100),\n [DOB] varchar(100),\n [Score] varchar(100),\n [Comment] varchar(100)\n)\nEXEC sp_xml_removedocument @DocHandle\n\nSelect * from #tmp\n\n--DROP TABLE #tmp\n" }, { "answer_id": 345192, "author": "Mike Woodhouse", "author_id": 1060, "author_profile": "https://Stackoverflow.com/users/1060", "pm_score": 1, "selected": false, "text": "Application.WorksheetFunction.Substitute Replace Application Workbook/Worksheets Range Variant Dim values as Variant\nvalues = Selection.Values\n .Cells theXML = theXML & theXML = theXML & \"INTO #tmp\"\n sb.Add \"INTO #tmp\"\n & vbCrLf" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2173/" ]
344,851
<p>I added a <code>get_absolute_url</code> function to one of my models.</p> <pre><code>def get_absolute_url(self): return '/foo/bar' </code></pre> <p>The admin site picks it up and adds a "view on site" link to the detail page for that object (when I put a real URL there instead of "/foo/bar").</p> <p>The problem is instead of going to <code>http://localhost:8000/foo/bar</code>, it goes to <code>http://example.com/foo/bar</code>.</p> <p>What am I doing wrong?</p>
[ { "answer_id": 11420955, "author": "supervacuo", "author_id": 399367, "author_profile": "https://Stackoverflow.com/users/399367", "pm_score": 2, "selected": false, "text": "sites from south.v2 import DataMigration\nfrom django.conf import settings\n\nclass Migration(DataMigration):\n\n def forwards(self, orm):\n Site = orm['sites.Site']\n site = Site.objects.get(id=settings.SITE_ID)\n site.domain = 'yoursite.com'\n site.name = 'yoursite'\n site.save()\n" }, { "answer_id": 54986923, "author": "Xerion", "author_id": 92436, "author_profile": "https://Stackoverflow.com/users/92436", "pm_score": 2, "selected": false, "text": "from django.conf import settings\nfrom django.db import migrations\n\ndef change_site_name(apps, schema_editor):\n Site = apps.get_model('sites', 'Site')\n site = Site.objects.get(id=settings.SITE_ID)\n site.domain = 'yourdomain.com'\n site.name = 'Your Site'\n site.save()\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('app', '0001_initial'),\n ]\n\n operations = [\n migrations.RunPython(change_site_name),\n ]\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437/" ]
344,856
<p>I have a form action that needs to have its value set from a variable. I need to set the variable once and it will be reflected many times throughout the DOM.</p> <p>So:</p> <p>variable = "somthing.html"; ... </p>
[ { "answer_id": 344869, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 2, "selected": false, "text": "var variableName = \"myform.htm\";\n\nthis.form.action = variableName;\n" }, { "answer_id": 344885, "author": "Scott Evernden", "author_id": 11397, "author_profile": "https://Stackoverflow.com/users/11397", "pm_score": 2, "selected": true, "text": "<script src=\"jquery-1.2.6.pack.js\"></script>\n<script>\n$(document).ready(function() {\n var variable = \"something.html\";\n $('form').attr(\"action\", variable);\n});\n</script>\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4444/" ]
344,860
<p>Let's say I have the three following lists</p> <p>A1<br> A2<br> A3 </p> <p>B1<br> B2</p> <p>C1<br> C2<br> C3<br> C4<br> C5 </p> <p>I'd like to combine them into a single list, with the items from each list as evenly distributed as possible sorta like this:</p> <p>C1<br> A1<br> C2<br> B1<br> C3<br> A2<br> C4<br> B2<br> A3<br> C5</p> <p>I'm using .NET 3.5/C# but I'm looking more for how to approach it then specific code.</p> <p>EDIT: I need to keep the order of elements from the original lists.</p>
[ { "answer_id": 344896, "author": "nlucaroni", "author_id": 157, "author_profile": "https://Stackoverflow.com/users/157", "pm_score": 1, "selected": false, "text": "- filter lists into three categories\n - lists of length 1\n - first half of the elements of lists with > 1 elements\n - second half of the elements of lists with > 1 elements\n- recurse on the first and second half of the lists if they have > 1 element\n - combine results of above computation in order\n- randomly combine the list of singletons into returned list \n" }, { "answer_id": 344900, "author": "gnud", "author_id": 27204, "author_profile": "https://Stackoverflow.com/users/27204", "pm_score": -1, "selected": false, "text": "merge = list()\nlists = list(list_a, list_b, list_c)\nlists.sort_by(length, descending)\n\nwhile lists is not empty:\n l = lists.remove_first()\n merge.append(l.remove_first())\n if l is not empty:\n next = lists.remove_first()\n lists.append(l)\n lists.sort_by(length, descending)\n lists.prepend(next)\n" }, { "answer_id": 345370, "author": "Svante", "author_id": 31615, "author_profile": "https://Stackoverflow.com/users/31615", "pm_score": 1, "selected": false, "text": "(/ n (+ (length list) 1))" }, { "answer_id": 31064201, "author": "I_AM_PANDA", "author_id": 4971878, "author_profile": "https://Stackoverflow.com/users/4971878", "pm_score": 2, "selected": false, "text": "public List<String> equimix(List<List<String>> input) {\n\n // sort biggest list to smallest list\n Collections.sort(input, new Comparator<List<String>>() {\n public int compare(List<String> a1, List<String> a2) {\n return a2.size() - a1.size();\n }\n });\n\n List<String> output = input.get(0);\n\n for (int i = 1; i < input.size(); i++) {\n output = equimix(output, input.get(i));\n }\n\n return output;\n}\n\npublic List<String> equimix(List<String> listA, List<String> listB) {\n\n if (listB.size() > listA.size()) {\n List<String> temp;\n temp = listB;\n listB = listA;\n listA = temp;\n }\n\n List<String> output = listA;\n\n double shiftCoeff = (double) listA.size() / listB.size();\n double floatCounter = shiftCoeff;\n\n for (String item : listB) {\n int insertionIndex = (int) Math.round(floatCounter);\n output.add(insertionIndex, item);\n floatCounter += (1+shiftCoeff);\n }\n\n return output;\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1786/" ]
344,881
<p>I'm doing some straight up asynchronous calls from javascript using the XMLHTTPRequest object. On success, with certain return values, I would like to do an asynchonous post back on an update panel and run some server side methods. This is about how I'm implementing it now:</p> <pre><code>&lt;script language="javascript"&gt; function AjaxCallback_Success(objAjax) { if (objAjax.responseText == "refresh") { document.getElementById('&lt;%= btnHidden.ClientID %&gt;').click(); } } &lt;/script&gt; &lt;asp:UpdatePanel ID="upStatus" runat="server"&gt; &lt;ContentTemplate&gt; &lt;asp:Button ID="btnHidden" runat="server" style="display: none;" OnClick="SomeMethod" /&gt; &lt;asp:DropDownList ID="ddlStatus" field="Orders_Status" parent="Orders" runat="server"&gt; &lt;/asp:DropDownList&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p>This has to do with work flow. If while you are working on an order, someone invoices it, then the options available in the status drop down actually changes. So a timed even checks for changes and if there is a change, which wouldn't normally happen, the update panel posts back and the drop down list gets re-bound to a new data table based on various return values from the ajax response text. </p> <p>My original code is actually much more complicated than this, but I've abstracted just enough to make my concept clearer. Is there a better, cleaner way to do this by dropping the hidden button and making a straight javascript call that will cause an update panel to asynchonously postback and run a server side method?</p>
[ { "answer_id": 344903, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 3, "selected": true, "text": "__doPostBack('eventTarget','eventArguments');\n __doPostBack('<%= btnHidden.ClientID %>','');\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18893/" ]
344,906
<p>I thought it is a very simple task to export data in a view from SQL Server 2005 to a fixed width text file. But the wizard is a pain. The format is not correct. Does anybody know how to deal with it? or any better way to do that?</p>
[ { "answer_id": 345058, "author": "jerryhung", "author_id": 37568, "author_profile": "https://Stackoverflow.com/users/37568", "pm_score": 4, "selected": true, "text": "bcp \"SELECT * FROM AdventureWorks.Person.Contact\" queryout Contacts.txt -c -T\n" }, { "answer_id": 345542, "author": "Sam", "author_id": 37379, "author_profile": "https://Stackoverflow.com/users/37379", "pm_score": 0, "selected": false, "text": "usage: Sqlcmd [-U login id] [-P password]\n [-S server] [-H hostname] [-E trusted connection]\n [-d use database name] [-l login timeout] [-t query timeout]\n [-h headers] [-s colseparator] [-w screen width]\n [-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]\n [-c cmdend] [-L[c] list servers[clean output]]\n [-q \"cmdline query\"] [-Q \"cmdline query\" and exit]\n [-m errorlevel] [-V severitylevel] [-W remove trailing spaces]\n [-u unicode output] [-r[0|1] msgs to stderr]\n [-i inputfile] [-o outputfile] [-z new password]\n [-f <codepage> | i:<codepage>[,o:<codepage>]] [-Z new password and exit]\n [-k[1|2] remove[replace] control characters]\n [-y variable length type display width]\n [-Y fixed length type display width]\n [-p[1] print statistics[colon format]]\n [-R use client regional setting]\n [-b On error batch abort]\n [-v var = \"value\"...] [-A dedicated admin connection]\n [-X[1] disable commands, startup script, enviroment variables [and exit]]\n [-x disable variable substitution]\n [-? show syntax summary]\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31689/" ]
344,908
<p>In a web-based application that uses the Model-View-Controller design pattern, the logic relating to processing form submissions seems to belong somewhere in between the Model layer and the Controller layer. This is especially true in the case of a complex form (i.e. where form processing goes well beyond simple CRUD operations).</p> <p>What's the best way to conceptualize this? Are forms simply a kind of glue between models and controllers? Or does form logic belong squarely in the M or C camp?</p> <p>EDIT: I understand the basic flow of information in an MVC application (see chills42's answer for a summary). My question is where the form processing logic belongs - in the controller, in the model, or somewhere else?</p>
[ { "answer_id": 2635553, "author": "Samnan", "author_id": 296542, "author_profile": "https://Stackoverflow.com/users/296542", "pm_score": 2, "selected": false, "text": "class User_controller\n{\n\n function login()\n {\n $form = new LoginForm(); // this is the class you would create\n if ($form->validate())\n {\n $data = $this->user_model->getUserData( $form->userid );\n // form processing complete, use the main \"user\" model to fetch userdata for display,\n // or redirect user to another page, update your session, anything you like\n } else {\n $form->display();\n }\n }\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1103/" ]
344,924
<p>I did this in the past, and can't remember the correct command (I think I was using instring or soemthign?)</p> <p>I want to list all the windows services running that have the word 'sql' in them.</p> <p>Listing all the windows services is:</p> <pre><code>Get-Service </code></pre> <p>Is there a instring function that does this?</p>
[ { "answer_id": 344933, "author": "Steven Murawski", "author_id": 1233, "author_profile": "https://Stackoverflow.com/users/1233", "pm_score": 6, "selected": true, "text": "Get-Service -Name *sql*\n Get-Service | where-object {$_.name -like '*sql*'}\n -name <string[]>\n Specifies the service names of services to be retrieved. Wildcards are\n permitted. By default, Get-Service gets all of the services on the comp\n uter.\n\n Required? false\n Position? 1\n Default value *\n Accept pipeline input? true (ByValue, ByPropertyName)\n Accept wildcard characters? true\n" }, { "answer_id": 11266713, "author": "Nisanth.KV", "author_id": 1456981, "author_profile": "https://Stackoverflow.com/users/1456981", "pm_score": 3, "selected": false, "text": " Get-Service | Where-Object {$_.Status -eq \"Running\"} | Where-Object {$_.Name -like \"*sql*\"}\n" }, { "answer_id": 43773341, "author": "Prasanth...", "author_id": 7960830, "author_profile": "https://Stackoverflow.com/users/7960830", "pm_score": 2, "selected": false, "text": "Get-Service -Name '*<search string>*'\n" }, { "answer_id": 57927680, "author": "UnhandledExcepSean", "author_id": 1007019, "author_profile": "https://Stackoverflow.com/users/1007019", "pm_score": 0, "selected": false, "text": "Get-WmiObject -ComputerName <INSERT COMPUTER NAME> -Class Win32_Service | where-object {$_.name -like '*sql*'}\n" }, { "answer_id": 62483496, "author": "Kristen", "author_id": 65703, "author_profile": "https://Stackoverflow.com/users/65703", "pm_score": 0, "selected": false, "text": "\"*SQL*\" get-service | Where-Object {$_.DisplayName -like \"*MySearchString*\" -or $_.ServiceName -like \"*MySearchString*\"}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
344,928
<p>I am working on an ASP.NET web application that is required to bring up a popup on a roolover. I am using the "OnMouseOver" event and it works as expected. The problem is that the event is on a "hair trigger"; even a casual passage of the mouse over the control brings up the popup (which then must be manually dismissed). I want to add a delay so that a rapid pass over the control in question does not trigger the event. Is there a way to set such a delay or is there a different event that I could use to get the same "trigger event on a slow rollover"? </p>
[ { "answer_id": 344940, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "onmouseover setTimeout onmouseout setTimeout" }, { "answer_id": 345022, "author": "JonStonecash", "author_id": 23862, "author_profile": "https://Stackoverflow.com/users/23862", "pm_score": 0, "selected": false, "text": "function ItemMouseOver(oRow, \"parameters for the popup\") \n{\n oRow.showTimer = window.setTimeout(function() \n { \n alert('popup');\n }, 1000);\n}\nfunction ItemMouseOut(oRow)\n{\n if (oRow.showTimer)\n window.clearTimeout(oRow.showTimer);\n protected void ReportGridView_RowDataBound(object sender, GridViewRowEventArgs e)\n{\n if (e.Row.RowType == DataControlRowType.DataRow && (\n e.Row.RowState == DataControlRowState.Normal \n || e.Row.RowState == DataControlRowState.Alternate))\n {\n // get the input values for the popup for the row (stuff deleted)\n e.Row.Attributes[\"onmouseover\"] = \"javascript:ItemMouseOver(this,\n \"parameters for the popup\");\";\n e.Row.Attributes[\"onmouseout\"] = \"javascript:ItemMouseOut(this);\";\n } \n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23862/" ]
344,934
<p>I'd like one of my table rows to be a button that takes up an entire row of my UITableView. I figured the best way to go about this is to instantiate a UIButton, and give it the same frame size as an instance of UITableViewCell, and add that as a subview to the cell. I'm almost there, but quite a few pixels off to not get that perfect touch to it. Is there a better approach to this, or perhapsps can my placement accuracy be fixed up to get that perfect alignment?</p> <pre><code>cell = [tv dequeueReusableCellWithIdentifier:CellIdentifier]; if(cell == nil) { cell = [self tableviewCellWithReuseIdentifier:CellIdentifier]; } UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button setFrame:CGRectMake(0.0f, 5.0f, 320.0f, 44.0f)]; [button setTitle:@"Do Stuff" forState:UIControlStateNormal]; [button addTarget:self action:@selector(doStuff:) forControlEvents:UIControlEventTouchUpInside]; [cell addSubview:button]; </code></pre>
[ { "answer_id": 345062, "author": "Ryan Townshend", "author_id": 24707, "author_profile": "https://Stackoverflow.com/users/24707", "pm_score": 4, "selected": false, "text": "[[[self tableView] cellForRowAtIndexPath:indexPath] setSelected:YES animated:YES];\n[self doStuff];\n[[[self tableView] cellForRowAtIndexPath:indexPath] setSelected:NO animated:YES];\n setSelected: animated:" }, { "answer_id": 938910, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {\n ・・・\n UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];\n btn.frame = CGRectMake(230.0f, 4.0f, 60.0f, 36.0f);\n [btn setTitle:@\"OK\" forState:UIControlStateNormal];\n [btn setTitle:@\"OK\" forState:UIControlStateSelected];\n [btn addTarget:self action:@selector(onClickRename:) forControlEvents:UIControlEventTouchUpInside];\n [cell.contentView addSubview:btn];\n ・・・\n return cell;\n}\n" }, { "answer_id": 2543635, "author": "Taras Kalapun", "author_id": 206723, "author_profile": "https://Stackoverflow.com/users/206723", "pm_score": 0, "selected": false, "text": "UIButton *btnView = [[UIButton alloc] init];\nbtnView.frame = CGRectMake(52.0f, 2.0f, 215.0f, 38.0f);\n[btnView setImage:[UIImage imageNamed:@\"invite.png\"] forState:UIControlStateNormal];\n[btnView addTarget:self action:@selector(showInviteByMail) forControlEvents:UIControlEventTouchUpInside];\n[cell.contentView addSubview:btnView];\n[btnView release];\n" }, { "answer_id": 2581626, "author": "Cord LaBarre", "author_id": 309581, "author_profile": "https://Stackoverflow.com/users/309581", "pm_score": 2, "selected": false, "text": "button.frame = cell.bounds;\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40882/" ]
344,961
<p>I'm trying to remember how the math is worked out to compute the remainder of an XOR algorithm in Cyclical Redundancy Checks to verify the remainder bits of a network message.</p> <p>I shouldn't have tossed that text book.</p> <p>This is easily done in code, but how is it worked out by hand?</p> <p>I know it looks something like a standard division algorithm, but I can't remember where to go from there to get the remainder. </p> <pre><code> ___________ 1010 | 101101000 </code></pre> <p><strong>Note:</strong> I did google it, but wasn't able to find a place where they mapped the steps in figuring the remainder.</p>
[ { "answer_id": 5977379, "author": "Anant Rao", "author_id": 750480, "author_profile": "https://Stackoverflow.com/users/750480", "pm_score": 3, "selected": false, "text": "1010 | 101101000\n 1010\n 0001 this result is 1011 XOR 1010 = 0001\n 1010\n 1010\n 0000 thus no remainder. \n" }, { "answer_id": 20948016, "author": "Marcus", "author_id": 839086, "author_profile": "https://Stackoverflow.com/users/839086", "pm_score": 2, "selected": false, "text": "1010 = 1*x^3 + 0*x^2 + 1*x^1 + 0*x^0 = x^3 + x = x3 + x\n101101000 = x8 + x6 + x5 + x3\n\n -------------------\nx3 + x ) x8 + x6 + x5 + x3\n x^8 x^3 x^5 x5\n -------------------\nx3 + x ) x8 + x6 + x5 + x3\n x8 + x6\n x5 + x3 x5\n -------------------\nx3 + x ) x8 + x6 + x5 + x3\n x8 + x6\n -------------------\n x5 + x3\n x5 + x2\n -------------------\nx3 + x ) x8 + x6 + x5 + x3\n x8 + x6\n -------------------\n x5 + x3\n x5 + x3\n -------------------\n 0\n x^y xy (P(x) + a*C(x)) / C(x) = P(x)/C(x) + a*C(x)/C(x) P(x)/C(x) a*C(x)/C(x)" }, { "answer_id": 70643213, "author": "Elvis23", "author_id": 14908131, "author_profile": "https://Stackoverflow.com/users/14908131", "pm_score": 0, "selected": false, "text": "101110000\n1001\n--------- XOR the 1011 and 1001\n0010\n 101110000\n1001\n--------- \n 1010\n 101110000\n1001\n--------- \n 1010\n 1001\n---------\n 0011\n--------- Remove zeros at the beginning\n 1100\n 1001\n---------\n 0101\n--------- Remove zeros at the beginning\n 1010\n 1001\n---------\n 0011\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34183/" ]
344,963
<p>I'm trying to use the freeware <a href="http://www.nontube.com/products/multiple-find-and-replace/" rel="nofollow noreferrer">Multiple Find And Replace 1.00</a> suggested in <a href="https://stackoverflow.com/questions/268045/multi-line-search-and-replace-tool#272325">this question</a>.</p> <p><a href="http://www.nontube.com/images/screenshot-mfar.png" rel="nofollow noreferrer">Multiple Find And Replace 1.00 http://www.nontube.com/images/screenshot-mfar.png</a></p> <p>Unfortunately it requires that I explicitly select each file I'd like it to search.</p> <p>But, it does allow me to load in a text file of the file paths.</p> <pre>C:\one.txt C:\two.txt C:\somedirectory\three.txt</pre> <p><strong>I'd like a text file of paths to all files with extension .php within a certain directory and all its subdirectories (recursive).</strong></p> <p>Does anyone know of a ready-made tool I can use to quickly generate such a list of files?</p>
[ { "answer_id": 344974, "author": "Cory Foy", "author_id": 4083, "author_profile": "https://Stackoverflow.com/users/4083", "pm_score": 2, "selected": false, "text": "dir /S /B *.php" }, { "answer_id": 344980, "author": "Brett", "author_id": 43778, "author_profile": "https://Stackoverflow.com/users/43778", "pm_score": 3, "selected": true, "text": "cd /d \"[base-directory]\" && dir /s /b *.php > [list file]\n cd /d \"c:\\my files\" && dir /s /b *.php > c:\\list.txt\n" }, { "answer_id": 344983, "author": "Drejc", "author_id": 6482, "author_profile": "https://Stackoverflow.com/users/6482", "pm_score": 1, "selected": false, "text": "dir /S /B *.php > output.txt\n" }, { "answer_id": 344988, "author": "benlumley", "author_id": 39161, "author_profile": "https://Stackoverflow.com/users/39161", "pm_score": 1, "selected": false, "text": "dir *.html /B /S > somefile.txt\n" }, { "answer_id": 344999, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 1, "selected": false, "text": "find basedir -name \\*.php -exec sed -i 's/text-to-find/text-to-replace/g' '{}' '+'\n sed" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
344,964
<p>I have a binary field in my database that is hard to describe in a UI using a single "Is XXXX?"-type checkbox. I'd rather use a pair of radio buttons (e.g. "Do it the Foo way" and "Do it the Bar way"), but right now all the other fields on my form are data-bound to a business object. I'd like to data-bind the pair of radio buttons to the business object as well, but haven't come up with a good way to do it yet. I can bind one of the buttons to the field, such that the field is set "true" if the button is selected, but while selecting the other button does de-select the first one (that is, the two radio buttons are properly paired), the value of the field does not update to reflect this.</p> <p>I'd like to be able to say</p> <pre><code>button1.DataBindings.Add(new Binding("checked", source, "useFoo")); button2.DataBindings.Add(new Binding("checked", source, "!useFoo")); </code></pre> <p>but I'm pretty sure that will throw when it runs. Is there an easier way, or should I just put more thought into how to word a single checkbox? I don't want to add extra functions to handle something this trivial...</p> <p>ETA: A commenter has suggested considering a dropdown (ComboBox). I had thought about this, but how would I data-bind that to a boolean field in a database/Property in a business object? If I bind the SelectedItem to the useFoo property, what would go in the Items collection? Would I have to add just "True" and "False", or could I somehow add a key/value pair object that ties a displayed item ("Use Foo" / "Do Not Use Foo") to the boolean value behind it? I'm having trouble finding docs on this.</p> <hr> <p>About the answer: the solution I wound up using involved modifying the business object -- the basic idea is very similar to the one posted by Gurge, but I came up with it separately before I read his response. In short, I added a separate property that simply returns <code>!useFoo</code>. One radio button is bound to <code>source.UseFoo</code>, and the other is bound to <code>source.UseBar</code> (the name of the new property). It's important to make sure the new property has both getters and setters, or you'll wind up with really odd behavior.</p>
[ { "answer_id": 345568, "author": "Guge", "author_id": 37771, "author_profile": "https://Stackoverflow.com/users/37771", "pm_score": 2, "selected": true, "text": "IIF(Foo=true, false, true) Bar Bar RadioButton.Checked Foo Bar Bar Foo [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\npublic bool Bar {\n get {\n try {\n return ((bool)(this[this.tableradio.BarColumn]));\n }\n catch (global::System.InvalidCastException e) {\n throw new global::System.Data.StrongTypingException(\"The value for column \\'Bar\\' in table \\'radio\\' is DBNull.\", e);\n }\n }\n set {\n this[this.tableradio.BarColumn] = value;\n this[this.tableradio.FooColumn] = !value;\n }\n}\n" }, { "answer_id": 378662, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "BO BO.Value Public Property NotValue() As Boolean\n Get\n Return Not BO.Value\n End Get\n Set(ByVal value As Boolean)\n BO.Value = Not value\n RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(\"NotValue\"))\n End Set\nEnd Property\n\n\nPrivate Sub BO_PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Handles BO.PropertyChanged\n If e.PropertyName = \"Value\" Then\n RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(\"NotValue\"))\n End If\nEnd Sub\n RBTrue.DataBindings.Add(New Binding(\"Checked\", Me.BO, \"Value\", False, DataSourceUpdateMode.OnPropertyChanged))\nRBFalse.DataBindings.Add(New Binding(\"Checked\", Me, \"NotValue\", False, DataSourceUpdateMode.OnPropertyChanged))\n" }, { "answer_id": 1432075, "author": "Mac", "author_id": 8696, "author_profile": "https://Stackoverflow.com/users/8696", "pm_score": 3, "selected": false, "text": "RadioButton true CheckedChanged RadioButton private void radioButton_CheckedChanged(object sender, EventArgs e)\n{\n foreach (Binding b in ((Control)sender).DataBindings)\n b.WriteValue();\n}\n" }, { "answer_id": 36334763, "author": "vi3x", "author_id": 3328062, "author_profile": "https://Stackoverflow.com/users/3328062", "pm_score": 1, "selected": false, "text": "button1.DataBindings.Add(new Binding(\"checked\", source, \"useFoo\", false, DataSourceUpdateMode.OnPropertyChanged);\n// no need to databind button 2, since button1.checked \n// is set to false when button2 is checked\n DataSourceUpdateMode OnValidation OnPropertyChanged INotifyPropertyChanged OnPropertyChanged button2 button1.CausesValidation = false;\nbutton2.CausesValidation = false;\n" }, { "answer_id": 44134014, "author": "Pete", "author_id": 462781, "author_profile": "https://Stackoverflow.com/users/462781", "pm_score": 1, "selected": false, "text": " // Load radio state\n radioButton1.Checked = ((myModel)myBindingSource.DataSource).boolOption1;\n radioButton2.Checked = ((myModel)myBindingSource.DataSource).boolOption2;\n // Save radio state\n ((myModel)myBindingSource.DataSource).boolOption1 = radioButton1.Checked;\n ((myModel)myBindingSource.DataSource).boolOption2 = radioButton2.Checked;\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26286/" ]
344,966
<p>I want to override the bad default tabbing scheme in emacs so that it will work like most other editors (eclipse, notepad++). I want to set it so that regardless of mode, tab will insert a tab, and pressing enter will keep me at my current tab depth.</p> <p>I tried this, but it does nothing:</p> <pre><code>(global-set-key (kbd "TAB") 'tab-to-tab-stop) (setq default-tab-width 4) ;; 8 is way too many </code></pre>
[ { "answer_id": 344970, "author": "J Cooper", "author_id": 38803, "author_profile": "https://Stackoverflow.com/users/38803", "pm_score": 1, "selected": false, "text": "C-j" }, { "answer_id": 345291, "author": "ShreevatsaR", "author_id": 4958, "author_profile": "https://Stackoverflow.com/users/4958", "pm_score": 4, "selected": true, "text": "(global-set-key (kbd \"RET\") 'newline-and-indent)\n .emacs C-j (global-set-key (kbd \"TAB\") 'tab-to-tab-stop)" }, { "answer_id": 345384, "author": "Trey Jackson", "author_id": 6148, "author_profile": "https://Stackoverflow.com/users/6148", "pm_score": 3, "selected": false, "text": "TAB TAB 'c-indent-to-column 'global-set-key TAB 'pabbrev TAB (defvar just-tab-keymap (make-sparse-keymap) \"Keymap for just-tab-mode\")\n(define-minor-mode just-tab-mode\n \"Just want the TAB key to be a TAB\"\n :global t :lighter \" TAB\" :init-value 0 :keymap just-tab-keymap\n (define-key just-tab-keymap (kbd \"TAB\") 'indent-for-tab-command))\n TAB TAB" }, { "answer_id": 386587, "author": "Joe Casadonte", "author_id": 45978, "author_profile": "https://Stackoverflow.com/users/45978", "pm_score": 2, "selected": false, "text": "<tab>; M-i tab-to-tab-stop" }, { "answer_id": 813540, "author": "quodlibetor", "author_id": 25616, "author_profile": "https://Stackoverflow.com/users/25616", "pm_score": 2, "selected": false, "text": "'self-insert-command 'indent-for-tab-command self-insert-command" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40397/" ]
344,969
<p>I have a JQueryDialog with a text field, an OK button and a cancel button.</p> <p>I want to be able to hit the enter key after filling in the text fields and have it do the same action as when I click the OK button.</p>
[ { "answer_id": 345005, "author": "Jason Day", "author_id": 737, "author_profile": "https://Stackoverflow.com/users/737", "pm_score": 6, "selected": true, "text": "getRootPane().setDefaultButton(okButton)" }, { "answer_id": 1308758, "author": "John Yeary", "author_id": 160361, "author_profile": "https://Stackoverflow.com/users/160361", "pm_score": 1, "selected": false, "text": "if (KeyEvent.VK_ENTER == event.getKeyCode()) {\n yourButton.doClick();\n }\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32899/" ]
344,973
<p>I would like to have alternate behavior during a print stylesheet on a web page. Something along the lines of:</p> <blockquote> <p>If this page is being printed, don't bother calling SWFObject to summon an .swf into existence. Just leave the HTML that the Flash will replace.</p> </blockquote> <p>I've tried things like setting a known element to a known style that exists for the screen but not for the print stylesheet. But getting a "style" via Javascript doesn't get a <em>computed</em> style.</p> <p>Summary: In a cross-browser way, is it possible to tell which stylesheet is in effect?</p>
[ { "answer_id": 345011, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 4, "selected": true, "text": "display:none;" }, { "answer_id": 345012, "author": "Victor", "author_id": 42518, "author_profile": "https://Stackoverflow.com/users/42518", "pm_score": 1, "selected": false, "text": "getActiveStyleSheet function getActiveStyleSheet() \n{\n var i, a;\n\n for (i = 0; (a = document.getElementsByTagName(\"link\")[i]); i++) \n {\n if (a.getAttribute(\"rel\").indexOf(\"style\") != -1\n && a.getAttribute(\"title\")\n && !a.disabled) \n return a.getAttribute(\"title\");\n }\n\n return null;\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12694/" ]
344,987
<p>In VisualBasic.Net When I activate a picture box and then draw something on it, it draws and then immediately goes blank. Works fine when I re-draw it, but almost always messes up the first time I draw on it. This has happenned with several different programs, and the help file is no help.</p>
[ { "answer_id": 344995, "author": "Andrew Rollings", "author_id": 40410, "author_profile": "https://Stackoverflow.com/users/40410", "pm_score": 1, "selected": false, "text": "DoubleBuffered" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
344,998
<p>Can we access div tags of user control in Master page? I am trying to change the background color for each one of the div tags on some event.</p>
[ { "answer_id": 345193, "author": "Jared", "author_id": 3442, "author_profile": "https://Stackoverflow.com/users/3442", "pm_score": 1, "selected": false, "text": "Control myControl = this.Page.Master.FindControl(\"[Your name here]\");\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/344998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21918/" ]
345,003
<p>I know that new-ing something in one module and delete-ing it in another can often cause problems in VC++. Problems with different runtimes. Mixing modules with staticly linked runtimes and/or dynamically linked versioning mismatches both can screw stuff up if I recall correctly.</p> <p><strong>However, is it safe to use VC++ 2008's std::tr1::shared_ptr across modules?</strong></p> <p>Since there is only one version of the runtime that even knows what what a shared_ptr is, static linking is my only danger (for now...). I thought I've read that boost's version of a shared_ptr was safe to use like this, but I'm using Redmond's version...</p> <p>I'm trying to avoid having a special call to free objects in the allocating module. (or something like a "delete this" in the class itself). If this all seems a little hacky, I'm using this for unit testing. If you've ever tried to unit test existing C++ code you can understand how <strong><em>creative</em></strong> you need to be at times. My memory is allocated by an EXE, but ultimately will be freed in a DLL (if the reference counting works the way I think it does).</p>
[ { "answer_id": 345079, "author": "dalle", "author_id": 19100, "author_profile": "https://Stackoverflow.com/users/19100", "pm_score": 2, "selected": false, "text": "std" }, { "answer_id": 345474, "author": "Tim Lesher", "author_id": 14942, "author_profile": "https://Stackoverflow.com/users/14942", "pm_score": 5, "selected": true, "text": "FreeLibrary()" }, { "answer_id": 5835036, "author": "Marc Mutz - mmutz", "author_id": 134841, "author_profile": "https://Stackoverflow.com/users/134841", "pm_score": 4, "selected": false, "text": "shared_ptr shared_ptr shared_ptr template <typename T>\nstruct default_deleter {\n void operator()( T * t ) { delete t; }\n};\n shared_ptr<Foo> foo( new Bar );\n shared_ptr<Foo> foo( new Bar, default_deleter<Bar>() );\n shared_ptr delete shared_ptr shared_ptr shared_ptr shared_ptr auto_ptr delete delete auto_ptr shared_ptr shared_ptr" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/345003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3655/" ]
345,009
<p>I'm building a demo app in WPF, which is new to me. I'm currently displaying text in a FlowDocument, and need to print it.</p> <p>The code I'm using looks like this:</p> <pre><code> PrintDialog pd = new PrintDialog(); fd.PageHeight = pd.PrintableAreaHeight; fd.PageWidth = pd.PrintableAreaWidth; fd.PagePadding = new Thickness(50); fd.ColumnGap = 0; fd.ColumnWidth = pd.PrintableAreaWidth; IDocumentPaginatorSource dps = fd; pd.PrintDocument(dps.DocumentPaginator, "flow doc"); </code></pre> <p>fd is my FlowDocument, and for now I'm using the default printer instead of allowing the user to specify print options. It works OK, except that after the document prints, the FlowDocument displayed on screen has changed to to use the settings I specified for printing. </p> <p>I can fix this by manually resetting everything after I print, but is this the best way? Should I make a copy of the FlowDocument before I print it? Or is there another approach I should consider?</p>
[ { "answer_id": 853461, "author": "Cheeso", "author_id": 48082, "author_profile": "https://Stackoverflow.com/users/48082", "pm_score": 6, "selected": true, "text": " private void DoThePrint(System.Windows.Documents.FlowDocument document)\n {\n // Clone the source document's content into a new FlowDocument.\n // This is because the pagination for the printer needs to be\n // done differently than the pagination for the displayed page.\n // We print the copy, rather that the original FlowDocument.\n System.IO.MemoryStream s = new System.IO.MemoryStream();\n TextRange source = new TextRange(document.ContentStart, document.ContentEnd);\n source.Save(s, DataFormats.Xaml);\n FlowDocument copy = new FlowDocument();\n TextRange dest = new TextRange(copy.ContentStart, copy.ContentEnd);\n dest.Load(s, DataFormats.Xaml);\n\n // Create a XpsDocumentWriter object, implicitly opening a Windows common print dialog,\n // and allowing the user to select a printer.\n\n // get information about the dimensions of the seleted printer+media.\n System.Printing.PrintDocumentImageableArea ia = null;\n System.Windows.Xps.XpsDocumentWriter docWriter = System.Printing.PrintQueue.CreateXpsDocumentWriter(ref ia);\n\n if (docWriter != null && ia != null)\n {\n DocumentPaginator paginator = ((IDocumentPaginatorSource)copy).DocumentPaginator;\n\n // Change the PageSize and PagePadding for the document to match the CanvasSize for the printer device.\n paginator.PageSize = new Size(ia.MediaSizeWidth, ia.MediaSizeHeight);\n Thickness t = new Thickness(72); // copy.PagePadding;\n copy.PagePadding = new Thickness(\n Math.Max(ia.OriginWidth, t.Left),\n Math.Max(ia.OriginHeight, t.Top),\n Math.Max(ia.MediaSizeWidth - (ia.OriginWidth + ia.ExtentWidth), t.Right),\n Math.Max(ia.MediaSizeHeight - (ia.OriginHeight + ia.ExtentHeight), t.Bottom));\n\n copy.ColumnWidth = double.PositiveInfinity;\n //copy.PageWidth = 528; // allow the page to be the natural with of the output device\n\n // Send content to the printer.\n docWriter.Write(paginator);\n }\n\n }\n" }, { "answer_id": 40745687, "author": "dotNET", "author_id": 1137199, "author_profile": "https://Stackoverflow.com/users/1137199", "pm_score": 2, "selected": false, "text": "//Clone the source document\nvar str = XamlWriter.Save(FlowDoc);\nvar stringReader = new System.IO.StringReader(str);\nvar xmlReader = XmlReader.Create(stringReader);\nvar CloneDoc = XamlReader.Load(xmlReader) as FlowDocument;\n\n//Now print using PrintDialog\nvar pd = new PrintDialog();\n\nif (pd.ShowDialog().Value)\n{\n CloneDoc.PageHeight = pd.PrintableAreaHeight;\n CloneDoc.PageWidth = pd.PrintableAreaWidth;\n IDocumentPaginatorSource idocument = CloneDoc as IDocumentPaginatorSource;\n\n pd.PrintDocument(idocument.DocumentPaginator, \"Printing FlowDocument\");\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/345009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1338/" ]
345,010
<p>Does combining an Enterprise Messaging solution with Web Services result in a real performance gain over simple HTTP requests over sockets?</p> <p>(if implementation details will help, interested in JMS with a SOAP webservice)</p>
[ { "answer_id": 853461, "author": "Cheeso", "author_id": 48082, "author_profile": "https://Stackoverflow.com/users/48082", "pm_score": 6, "selected": true, "text": " private void DoThePrint(System.Windows.Documents.FlowDocument document)\n {\n // Clone the source document's content into a new FlowDocument.\n // This is because the pagination for the printer needs to be\n // done differently than the pagination for the displayed page.\n // We print the copy, rather that the original FlowDocument.\n System.IO.MemoryStream s = new System.IO.MemoryStream();\n TextRange source = new TextRange(document.ContentStart, document.ContentEnd);\n source.Save(s, DataFormats.Xaml);\n FlowDocument copy = new FlowDocument();\n TextRange dest = new TextRange(copy.ContentStart, copy.ContentEnd);\n dest.Load(s, DataFormats.Xaml);\n\n // Create a XpsDocumentWriter object, implicitly opening a Windows common print dialog,\n // and allowing the user to select a printer.\n\n // get information about the dimensions of the seleted printer+media.\n System.Printing.PrintDocumentImageableArea ia = null;\n System.Windows.Xps.XpsDocumentWriter docWriter = System.Printing.PrintQueue.CreateXpsDocumentWriter(ref ia);\n\n if (docWriter != null && ia != null)\n {\n DocumentPaginator paginator = ((IDocumentPaginatorSource)copy).DocumentPaginator;\n\n // Change the PageSize and PagePadding for the document to match the CanvasSize for the printer device.\n paginator.PageSize = new Size(ia.MediaSizeWidth, ia.MediaSizeHeight);\n Thickness t = new Thickness(72); // copy.PagePadding;\n copy.PagePadding = new Thickness(\n Math.Max(ia.OriginWidth, t.Left),\n Math.Max(ia.OriginHeight, t.Top),\n Math.Max(ia.MediaSizeWidth - (ia.OriginWidth + ia.ExtentWidth), t.Right),\n Math.Max(ia.MediaSizeHeight - (ia.OriginHeight + ia.ExtentHeight), t.Bottom));\n\n copy.ColumnWidth = double.PositiveInfinity;\n //copy.PageWidth = 528; // allow the page to be the natural with of the output device\n\n // Send content to the printer.\n docWriter.Write(paginator);\n }\n\n }\n" }, { "answer_id": 40745687, "author": "dotNET", "author_id": 1137199, "author_profile": "https://Stackoverflow.com/users/1137199", "pm_score": 2, "selected": false, "text": "//Clone the source document\nvar str = XamlWriter.Save(FlowDoc);\nvar stringReader = new System.IO.StringReader(str);\nvar xmlReader = XmlReader.Create(stringReader);\nvar CloneDoc = XamlReader.Load(xmlReader) as FlowDocument;\n\n//Now print using PrintDialog\nvar pd = new PrintDialog();\n\nif (pd.ShowDialog().Value)\n{\n CloneDoc.PageHeight = pd.PrintableAreaHeight;\n CloneDoc.PageWidth = pd.PrintableAreaWidth;\n IDocumentPaginatorSource idocument = CloneDoc as IDocumentPaginatorSource;\n\n pd.PrintDocument(idocument.DocumentPaginator, \"Printing FlowDocument\");\n}\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/345010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2362/" ]
345,021
<p>Our organization provides a variety of services to our clients (e.g., web hosting, tech support, custom programming, etc...). There's a page on our website that lists all available services and their corresponding prices. This was static data, but my boss wants it all pulled from a database instead.</p> <p>There are about 100 services listed. Only two of them, however, have a non numeric value for "price" (specifically, the strings "ISA" and "cost + 8%" - I really don't know what they're supposed to mean, so don't ask me). </p> <p>I'd hate to make the "price" column a varchar just because of these two listings. My current approach is to create a special "price_display" field, which is either blank or contains the text to display in place of the price. This solution feels too much like a dirty hack though (it would needlessly complicate the queries), so is there a better solution?</p>
[ { "answer_id": 1155482, "author": "HLGEM", "author_id": 9034, "author_profile": "https://Stackoverflow.com/users/9034", "pm_score": 2, "selected": false, "text": "Price Unit Display\n10.00 item null\n100.00 box null\nnull null \"Call for Pricing\"\n" } ]
2008/12/05
[ "https://Stackoverflow.com/questions/345021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32998/" ]