qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
298,011 | <p>I have seen posts that show three ways to reset the DMV views:</p>
<ol>
<li>Reset the SQL Service</li>
<li>Detatch the database</li>
<li>Close the database</li>
</ol>
<p>All of these methods seem to require taking the system off-line for a few moments. Is there a way to reset the statistics on demand without interrupting use of the database? When we have odd performance issues come up in production it is useful to limit the data in the dmv views to data collected during the duration of the performance issue to help describe the state of the system during the performance issue.</p>
| [
{
"answer_id": 362243,
"author": "gbn",
"author_id": 27535,
"author_profile": "https://Stackoverflow.com/users/27535",
"pm_score": 2,
"selected": true,
"text": "sys.dm_os_latch_stats\nsys.dm_os_wait_stats\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32992/"
] |
298,013 | <p>Say I have entities organized in a hierarchy with <code>Parent</code> being the root entity and <code>Child</code> being a subclass of <code>Parent</code>. I'd like to setup an <code>NSArrayController</code> to fetch only entities of <code>Parent</code>, but not <code>Child</code>.</p>
<p>If you set the Entity Name of the array controller in Interface Builder to <code>Parent</code>, it fetches all <code>Parent</code> and <code>Child</code> entities. I originally tried setting the array controller's fetch predicate in Interface Builder to:</p>
<pre><code>entity.name == "Parent"
</code></pre>
<p>This worked for an XML store, but when I switched to a SQLite store, it no longer worked. I get the following error:</p>
<pre><code>keypath entity.name not found in entity <NSSQLEntity xxx>
</code></pre>
<p>As a work around, I am setting up a filter predicate (with the same <code>entity.name</code> predicate as above) in my <code>awakeFromNib</code> to filter only Parent entities. Apparently, that predicate is valid once the entities are in memory, but you can't use it in a SQL-backed fetch predicate.</p>
<p>Is there a way to fetch only <code>Parent</code> entities, but not <code>Child</code> entities using a fetch predicate that works with a SQLite store? It seems wasteful to pull in entities that you're only going to ignore with the filter predicate.</p>
| [
{
"answer_id": 298119,
"author": "Chris Hanson",
"author_id": 714,
"author_profile": "https://Stackoverflow.com/users/714",
"pm_score": 3,
"selected": false,
"text": "includesSubentities defaultFetchRequest -fetchWithRequest:..."
},
{
"answer_id": 304208,
"author": "Dave Dribin",
"author_id": 26825,
"author_profile": "https://Stackoverflow.com/users/26825",
"pm_score": 3,
"selected": true,
"text": "includesSubentities setContent:"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26825/"
] |
298,015 | <p>Do developers have to put certain/extra elements in the feed's XML file or attributes in the hyperlink for the browser to recognize that it's a feed that can be subscribed to? Or do browsers do that automatically as long as the XML validates?</p>
<p>(showing users that "Subscribe to this feed using..." interface in Firefox or "You are viewing a feed that contains frequently updated content. When you subscribe to a feed, ..." interface on Internet Explorer, etc.) </p>
| [
{
"answer_id": 302646,
"author": "Oppositional",
"author_id": 2029,
"author_profile": "https://Stackoverflow.com/users/2029",
"pm_score": 3,
"selected": true,
"text": "<html>\n <head>\n <title>My Web Site</title>\n <link rel=\"alternate\" type=\"application/atom+xml\" title=\"My Feed (Atom)\" href=\"/feed.aspx?format=atom\" />\n <link rel=\"alternate\" type=\"application/rss+xml\" title=\"My Feed (RSS)\" href=\"/feed.aspx?format=rss\" />\n </head>\n <body>\n <!-- page content -->\n </body>\n</html>\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57936/"
] |
298,016 | <p>What are all the problem that you foresee in doing that.</p>
| [
{
"answer_id": 314663,
"author": "John Dibling",
"author_id": 241536,
"author_profile": "https://Stackoverflow.com/users/241536",
"pm_score": 4,
"selected": true,
"text": "for( int n = 0; n < someMax; ++n )\n{\n // do stuff\n}\n\nprintf(\"Did %d stuffs\", n);\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22076/"
] |
298,024 | <p>Boost is a great set of libraries and it really <em>boosts</em> productivity. But debugging code that uses it is a total nightmare. Sure, stepping through twenty thousand header files can be a valuable intellectual exercise, but what if you need to do it over and over again?</p>
<p>Is there a developer-friendly way of just skipping the boost portion and having the debugger go straight to my code?</p>
<p>Visual Studio has a <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.debuggerstepthroughattribute.aspx" rel="noreferrer">DebuggerStepThroughAttribute</a> for .NET framework. Is there anything similar for native C++?</p>
| [
{
"answer_id": 298038,
"author": "Alastair",
"author_id": 31038,
"author_profile": "https://Stackoverflow.com/users/31038",
"pm_score": 4,
"selected": true,
"text": "boost\\:\\:.*=NoStepInto boost::function"
},
{
"answer_id": 298054,
"author": "Andreas Magnusson",
"author_id": 5811,
"author_profile": "https://Stackoverflow.com/users/5811",
"pm_score": 4,
"selected": false,
"text": "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\NativeDE\\StepOver] [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\NativeDE\\StepOver]\n\"10\"=\"boost\\:\\:.*=NoStepInto\"\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21704/"
] |
298,031 | <p>If it does, then how do you justify the overheads incurred (journaling etc.)?
If it does not, then how come the pagefile gets fragmented?
Additionally, would increasing the cluster size improve pagefile performance (cluster slack space is a non-issue)?</p>
| [
{
"answer_id": 298038,
"author": "Alastair",
"author_id": 31038,
"author_profile": "https://Stackoverflow.com/users/31038",
"pm_score": 4,
"selected": true,
"text": "boost\\:\\:.*=NoStepInto boost::function"
},
{
"answer_id": 298054,
"author": "Andreas Magnusson",
"author_id": 5811,
"author_profile": "https://Stackoverflow.com/users/5811",
"pm_score": 4,
"selected": false,
"text": "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\NativeDE\\StepOver] [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\NativeDE\\StepOver]\n\"10\"=\"boost\\:\\:.*=NoStepInto\"\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,039 | <p>I have a custom control that I need to use in another custom control. I have written all code at server side (no HTML). Can anyone tell me how to write below line of code in code behind using <code>htmlTextWriter</code> and how to register this control or how to write custom control within another where html is written from code behind?</p>
<pre><code><cc2:test id="test1" runat="server" marqueedirection="left" marqueeheight="25"
marqueewidth="725" ShowImage="False" ShowTitle="False" ShowUrlUnderLine="True"></cc2:test
</code></pre>
| [
{
"answer_id": 298061,
"author": "Chris Fulstow",
"author_id": 38126,
"author_profile": "https://Stackoverflow.com/users/38126",
"pm_score": 2,
"selected": false,
"text": "namespace My.Controls\n{\n public class InnerControl : Control\n {\n protected override void Render(HtmlTextWriter writer)\n {\n writer.WriteLine(\"<h1>Inner Control</h1>\");\n }\n }\n}\n namespace My.Controls\n{\n public class OuterControl : Control\n {\n protected override void Render(HtmlTextWriter writer)\n {\n writer.WriteLine(\"<h1>Outer Control</h1>\");\n InnerControl innerControl = new InnerControl();\n innerControl.RenderControl(writer);\n }\n }\n}\n <%@ Register TagPrefix=\"c\" Namespace=\"My.Controls\" %>\n<c:OuterControl runat=\"server\" />\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,048 | <p><a href="http://mumble.net/~campbell/emacs/paredit.el" rel="noreferrer">paredit</a> binds <code>M-<up></code> and <code>M-<down></code>, but I want <a href="http://www.emacswiki.org/emacs/WindMove" rel="noreferrer">windmove</a> to own those keybindings. I have paredit-mode set to activate in certain modes only, but windmove is set to run globally. I want windmove to win, but paredit steals those keybindings when it loads.</p>
<p>How can I easily stop paredit from stomping on windmove's keybindings? I have been going into <code>paredit.el</code> and commenting out the lines which set the keybinding, but this is far from ideal (I have to remember to do this every time I update paredit).</p>
<p>More generally, can I load an elisp file while "protecting" certain keybindings from being changed?</p>
| [
{
"answer_id": 298685,
"author": "Emerick Rogul",
"author_id": 33837,
"author_profile": "https://Stackoverflow.com/users/33837",
"pm_score": 5,
"selected": true,
"text": "eval-after-load ;;; Customize paredit using `eval-after-load':\n;;;\n;;; (eval-after-load 'paredit\n;;; '(progn ...redefine keys, &c....))\n (eval-after-load 'paredit\n '(progn\n (define-key paredit-mode-map (kbd \"<M-up>\") nil)\n (define-key paredit-mode-map (kbd \"<M-down>\") nil)))\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23070/"
] |
298,049 | <p>I want to, from JavaScript, access as a variable the file that is loaded as an image in an img tag. </p>
<h2>I don't want to access its name, but the actual data.</h2>
<p>The reason for this is that I want to be able to copy it to and from variables so that I can , among other things, change the image without reloading it.</p>
<p>Can this be done? If so, how?</p>
<p>Note: I'm slightly more interested in <em>reading</em> the data than writing it.</p>
| [
{
"answer_id": 298050,
"author": "Falco Foxburr",
"author_id": 37266,
"author_profile": "https://Stackoverflow.com/users/37266",
"pm_score": -1,
"selected": false,
"text": "img = new Image(); \nimg.src = \"imagefile.jpg\";\n"
},
{
"answer_id": 298101,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 1,
"selected": false,
"text": "<img src=\"data:image/gif;base64,R0lGODl......j5+g4JADs=\">\n"
},
{
"answer_id": 298200,
"author": "Chris Fulstow",
"author_id": 38126,
"author_profile": "https://Stackoverflow.com/users/38126",
"pm_score": 4,
"selected": true,
"text": "// Download the image data using AJAX, I'm using jQuery\nvar imageData = $.ajax({ url: \"MyImage.gif\", async: false }).responseText;\n\n// Image data updating magic\nimageDataChanged = ChangeImage(imageData);\n\n// Encode to base64, maybe try the webtoolkit.base64.js library\nimageDataEncoded = Base64Encode(imageDataChanged);\n\n// Write image data out to browser (FF seems to support this)\ndocument.write('<img src=\"data:image/gif;base64,' + imageDataEncoded + '\">');\n"
},
{
"answer_id": 300120,
"author": "Matthew Crumley",
"author_id": 2214,
"author_profile": "https://Stackoverflow.com/users/2214",
"pm_score": 2,
"selected": false,
"text": "var img = document.getElementById(\"img_id\");\nvar canvas = document.getElementById(\"canvas_id\");\nvar context = canvas.getContext(\"2d\");\n\nvar imageData = context.getImageData(0, 0, context.width, context.height);\n\n// Now imageData is an object with width, height, and data properties.\n// imageData.data is an array of pixel values (4 values per pixel in RGBA order)\n\n// Change the top left pixel to red\nimageData.data[0] = 255; // red\nimageData.data[1] = 0; // green\nimageData.data[2] = 0; // blue\nimageData.data[3] = 255; // alpha\n\n// Update the canvas\ncontext.putPixelData(imageData, 0, 0);\n var index = (y * imageData.width + x) * 4;\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] |
298,057 | <p>I want to access a MySQL database directly from JavaScript code in an HTML page in Firefox.</p>
<p>Does such a library exist?</p>
<p>To be very clear, <strong>CGI+Ajax will not work</strong></p>
<p>Some background: I want to create something like a GUI front end for a MySQL database (that's not what it is, but it's close enough). I'm thinking about doing this as a local HTML page using JavaScript but for that to work I would need MySQL bindings for JavaScript under Firefox. I already have a working prototype in under 100 LOC, but it requires a web server, and for reasons that are beyond this question, that won't work.</p>
<p>NOTE: both the database and the JavaScript code will be running locally and are not intended as a public page. In fact the HTML file will loaded as a file://// file. The only reason I'm using JavaScript is that it's the only available system for doing GUI stuff where I need it.</p>
<p>I'm willing to install plugins, DLL's, Windows dependent stuff or what not to make this work.</p>
<hr>
<p>Edit: It looks like the answer is, "It can be done, but it's going to be painful". As one of my options is to just spew out all the data as files (ugly, and not too flexible, but it would work) I think I'm not going to pursue this.</p>
| [
{
"answer_id": 298296,
"author": "Lukman",
"author_id": 34586,
"author_profile": "https://Stackoverflow.com/users/34586",
"pm_score": 0,
"selected": false,
"text": "var myshell = new ActiveXObject( \"WScript.shell\" );\nmyshell.run( program names );\n mysql.exe mysql.exe -h localhost -u root dbo < script.sql > output.txt\n mysql.exe"
},
{
"answer_id": 300300,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "var DATABASE = {\n\n database: 'blog_development',\n host: 'localhost',\n username: 'dbuser',\n password: 'dbpass'\n\n};\n\nfunction ArticleModel(properties) {\n for (var p in properties) {\n this[p] = properties[p];\n }\n}\n\nArticleModel.findAll = function() {\n var results = [];\n\n var jsConnectionObj = new Packages.MysqlConnection();\n c = jsConnectionObj.open(DATABASE.host,\n DATABASE.database,\n DATABASE.username,\n DATABASE.password);\n\n if (c) {\n var s = c.createStatement();\n s.executeQuery(\"SELECT * FROM articles;\");\n var rs = s.getResultSet();\n while (rs.next()) {\n results.push(new ArticleModel({\n id: rs.getInt(\"id\"),\n title: rs.getString(\"title\"),\n body: rs.getString(\"body\")\n }));\n }\n rs.close();\n c.close(); \n return results;\n }\n\n throw new Error('could not connect to database'); \n};\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] |
298,063 | <p>I have got a table in MS Access 2007 with 4 fields.</p>
<ul>
<li>Labour Cost</li>
<li>Labour Hours</li>
<li>Vat</li>
<li>Total</li>
</ul>
<p>How do I multiply 'Labour Hours' by 'Labour Cost' add the 'VAT' and display the answer in 'Total'</p>
<p>Where would I put any formulas?, in a form or query or table ?</p>
| [
{
"answer_id": 298072,
"author": "Phil.Wheeler",
"author_id": 15609,
"author_profile": "https://Stackoverflow.com/users/15609",
"pm_score": 2,
"selected": false,
"text": "SELECT [Total] = [Labour Cost] * [Labour Hours] + [VAT]\n"
},
{
"answer_id": 298093,
"author": "Cybis",
"author_id": 32998,
"author_profile": "https://Stackoverflow.com/users/32998",
"pm_score": 1,
"selected": false,
"text": "UPDATE YourTableName SET [Total] = [Labour Hours] * [Labour Cost] + [VAT]\n SELECT [Labour Cost], \n [Labour Hours], \n [VAT], \n [Labour Hours] * [Labour Cost] + [VAT] AS [Total]\nFROM YourTableName\n"
},
{
"answer_id": 298719,
"author": "wakingrufus",
"author_id": 37847,
"author_profile": "https://Stackoverflow.com/users/37847",
"pm_score": 0,
"selected": false,
"text": "total: [VAT] + [Labour Hours] * [Labour Cost]\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,069 | <p>I'm tasked with automating the retrieval of a couple of <a href="http://www.businessobjects.com/product/catalog/web_intelligence/" rel="nofollow noreferrer">BusinessObjects Web Intelligence</a> reports and further processing thereof.</p>
<p>I have no other means of access to this data (this was the first avenue I followed), so I <em>will</em> have to do some screen scraping. Alas, the interface seems <em>user-only</em>. Grr!</p>
<p>Has anyone done this before? Like to share?</p>
<p>Also, does anyone know of a good library for automating the web browser? I know there is a python thingy out there that can be used for testing web applications - I need something in .NET though... What is your favorite?</p>
<p>PS: I have also checked this <a href="https://stackoverflow.com/questions/189288/automate-getting-report-from-webpage">thread (automate getting report from webpage)</a>, but am hoping for a Web Intelligence specific sollution.</p>
| [
{
"answer_id": 548870,
"author": "Shift8",
"author_id": 46323,
"author_profile": "https://Stackoverflow.com/users/46323",
"pm_score": 2,
"selected": false,
"text": "c:\\curl\\bin\\curl -X POST -F File=@[filename] -F \"title=[title]\" -F \"notes=[notes]\" \"http://xxx/AddScannedImage?debtref=[filename]\"\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2260/"
] |
298,074 | <p>I would like to add a method to a built-in type (e.g. Double), so that I can use an <code>infix</code> operator. Is that possible?</p>
| [
{
"answer_id": 298087,
"author": "Daniel Spiewak",
"author_id": 9815,
"author_profile": "https://Stackoverflow.com/users/9815",
"pm_score": 5,
"selected": true,
"text": "double class MyRichDouble(d: Double) {\n def <>(other: Double) = d != other\n}\n\nimplicit def doubleToSyntax(d: Double) = new MyRichDouble(d)\n <> Double doubleToSyntax 3.1415 <> 2.68 // => true\n Double Double doubleToSyntax import Predef._ class MyStuff extends PredefTrait <> Stream take Int Stream val str: Stream[Int] = ...\nval subStream = str take 5\n str take 5 str.take(5)"
},
{
"answer_id": 298140,
"author": "namin",
"author_id": 34596,
"author_profile": "https://Stackoverflow.com/users/34596",
"pm_score": 2,
"selected": false,
"text": "object errorEstimation {\n class Estimate(val x: Double, val e: Double) {\n def + (that: Estimate) =\n new Estimate(this.x + that.x, this.e + that.e)\n def - (that: Estimate) =\n new Estimate(this.x - that.x, this.e + that.e)\n def * (that: Estimate) =\n new Estimate(this.x * that.x,\n this.x.abs*that.e+that.x.abs*this.e+this.e*that.e)\n def / (that: Estimate) =\n new Estimate(this.x/that.x,\n (this.x.abs*that.e+that.x.abs*this.e)/(that.x.abs*(that.x.abs-that.e)))\n def +- (e2: Double) =\n new Estimate(x,e+e2)\n override def toString =\n x + \" +- \" + e\n }\n implicit def double2estimate(x: Double): Estimate = new Estimate(x,0)\n implicit def int2estimate(x: Int): Estimate = new Estimate(x,0)\n\n def main(args: Array[String]) = {\n println(((x: Estimate) => x+2*x+3*x*x)(1 +- 0.1))\n // 6.0 +- 0.93\n println(((x: Estimate) => (((y: Estimate) => y*y + 2)(x+x)))(1 +- 0.1))\n // 6.0 +- 0.84\n def poly(x: Estimate) = x+2*x+3/(x*x)\n println(poly(3.0 +- 0.1))\n // 9.33333 +- 0.3242352\n println(poly(30271.3 +- 0.0001))\n // 90813.9 +- 0.0003\n println(((x: Estimate) => poly(x*x))(3 +- 1.0))\n // 27.037 +- 20.931\n }\n}\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34596/"
] |
298,116 | <p>In a JSF dataTable I want to display the row index next to the rows... like:</p>
<pre><code>Column A Column B
1 xxx
2 yyy
</code></pre>
<p>I thought that I could use an implicit el variable like #{rowIndex} but this is not working.</p>
<p>A solution I found is to create a binding for the data table and use the binding like:</p>
<pre><code><h:dataTable var="item" value="#{controller.items}" binding="#{controller.dataTable}">
<h:column>#{controller.dataTable.rowIndex}</h:column>
<h:column>value</h:column>
</h:dataTable>
</code></pre>
<p>but this solution is complex and doesn't work well when I have many nested dataTables in a page.</p>
<p>Any ideas on how to solve this in a better way?</p>
| [
{
"answer_id": 298612,
"author": "McDowell",
"author_id": 304,
"author_profile": "https://Stackoverflow.com/users/304",
"pm_score": 5,
"selected": true,
"text": " <h:dataTable border=\"1\" value=\"#{nestedDataModel}\" var=\"nested\">\n <h:column>\n <h:dataTable border=\"1\" value=\"#{nested}\" var=\"item\">\n <h:column>\n <h:outputText value=\"#{nested.rowIndex}\" />\n </h:column>\n <h:column>\n <h:outputText value=\"#{item}\" />\n </h:column>\n </h:dataTable>\n </h:column>\n </h:dataTable>\n public class NestedDataModel extends DataModel implements Serializable {\n\n private List<List<String>> nestedDataModel = populateModel();\n private int index;\n\n private List<List<String>> populateModel() {\n List<List<String>> list = new ArrayList<List<String>>();\n for(int x=0; x<3; x++) {\n List<String> nestedTableData = new ArrayList<String>();\n for(int y=0; y<3; y++) {\n nestedTableData.add(\"Foo x=\"+x+\" y=\"+y);\n }\n list.add(nestedTableData);\n }\n return list;\n }\n\n @Override\n public int getRowCount() {\n return nestedDataModel.size();\n }\n\n @Override\n public Object getRowData() {\n List<String> list = nestedDataModel.get(index);\n return new ListDataModel(list);\n }\n\n @Override\n public int getRowIndex() {\n return index;\n }\n\n @Override\n public Object getWrappedData() {\n return nestedDataModel;\n }\n\n @Override\n public boolean isRowAvailable() {\n return index >= 0 && index < nestedDataModel.size();\n }\n\n @Override\n public void setRowIndex(int arg0) {\n index = arg0;\n }\n\n @Override\n public void setWrappedData(Object arg0) {\n throw new UnsupportedOperationException();\n }\n\n}\n public class RowCounter implements Serializable {\n\n private transient int row = 0;\n\n public int getRow() {\n return ++row;\n }\n\n}\n <managed-bean>\n <managed-bean-name>rowCounter</managed-bean-name>\n <managed-bean-class>tablerows.RowCounter</managed-bean-class>\n <managed-bean-scope>request</managed-bean-scope>\n</managed-bean>\n <f:view>\n <h:dataTable border=\"1\" value=\"#{tableDataBean.tableDataModel}\"\n var=\"rowBean\">\n <h:column>\n <h:outputText value=\"#{rowCounter.row}\" />\n </h:column>\n <h:column>\n <h:outputText value=\"#{rowBean}\" />\n </h:column>\n </h:dataTable>\n</f:view>\n"
},
{
"answer_id": 6776363,
"author": "Brent Clay",
"author_id": 489133,
"author_profile": "https://Stackoverflow.com/users/489133",
"pm_score": 5,
"selected": false,
"text": "<t:dataTable rowIndexVar=\"row\" value=\"#{someBean.value}\"> \n <h:column> \n <h:outputText value=\"#{row + 1}\"/> \n </h:column> \n</t:dataTable>\n"
},
{
"answer_id": 24326261,
"author": "Yuri",
"author_id": 2460038,
"author_profile": "https://Stackoverflow.com/users/2460038",
"pm_score": 3,
"selected": false,
"text": "<rich:dataTable value=\"#{backingBean.list}\" var=\"v\" rowKeyVar=\"index\">\n <rich:column>\n <f:facet name=\"header\">Index</f:facet>\n <h:outputText value=\"#{index + 1}\" />\n </rich:column>\n <rich:column>\n <f:facet name=\"header\">Name</f:facet>\n <h:outputText value=\"#{v.name}\" />\n </rich:column>\n</rich:dataTable>\n"
},
{
"answer_id": 36864954,
"author": "Gonçalo Alberto",
"author_id": 2553260,
"author_profile": "https://Stackoverflow.com/users/2553260",
"pm_score": 2,
"selected": false,
"text": "<h:dataTable var=\"item\" value=\"#{controller.items}\">\n <h:column>#{controller.items.indexOf(item)}</h:column>\n <h:column>value</h:column>\n</h:dataTable>\n"
},
{
"answer_id": 45167296,
"author": "Youans",
"author_id": 1460591,
"author_profile": "https://Stackoverflow.com/users/1460591",
"pm_score": 2,
"selected": false,
"text": "<h:column>\n <f:facet name=\"header\">#</f:facet>\n #{bean.listValue.indexOf(varObject)+1}\n</h:column>\n"
},
{
"answer_id": 69902425,
"author": "BalusC",
"author_id": 157882,
"author_profile": "https://Stackoverflow.com/users/157882",
"pm_score": 1,
"selected": false,
"text": "UIComponent #{component} <h:dataTable> UIData NamingContainer #{component.namingContainer} <h:dataTable> UIData HtmlDataTable <h:dataTable value=\"#{['one', 'two', 'three']}\" var=\"item\">\n <h:column>This is the `UIData` component: #{component.namingContainer}</h:column>\n</h:dataTable>\n UIData getRowIndex() <h:dataTable value=\"#{['one', 'two', 'three']}\" var=\"item\">\n <h:column>Row index: #{component.namingContainer.rowIndex + 1}</h:column>\n</h:dataTable>\n + 1 binding"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19331/"
] |
298,139 | <p>I'm passing a reference of a form to a class. Within this class I believed I could use <code>formRef->Controls["controlName"]</code> to access properties on the control.</p>
<p>This works for a few labels, but on a button I receive a "Object reference not set to an instance of an object." when I try to change the Text property.</p>
<p>Help or explanation appreciated...</p>
| [
{
"answer_id": 298268,
"author": "rozon",
"author_id": 37583,
"author_profile": "https://Stackoverflow.com/users/37583",
"pm_score": 1,
"selected": true,
"text": "array<Control^>^ id = myForm->Controls->Find(\"myButton\", true);\nid[0]->Text = \"new text\";\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37583/"
] |
298,162 | <p>Ok well I've been trying to convert my model to use LINQ but didn't want to throw away my current DTO's and their interfaces which are scattered through the domain.</p>
<p>I managed to find this blog post which has outlined the process quite nicely:</p>
<p><a href="http://www.sidarok.com/web/blog/content/2008/10/14/achieving-poco-s-in-linq-to-sql.html" rel="noreferrer">Achieving POCOs in LINQ To SQL</a></p>
<p>I have the managed to get the retrieval of records to objects working properly, however, due to the nested nature of my my model, I can't seem to get addition working for the child objects. That is, if I create a child object, and set the reference to the desired parents object, LINQ to SQL still throws an exception stating the child's reference to the parent is null. If I attempt to add a plain old parent object, it succeeds, but adding child objects directly fails</p>
<p>Here is my failing test:</p>
<pre><code> [Test]
public void AddSelectionShouldAddSelectionToMarket()
{
Market market = (Market) new Repository().GetMarket(1);
Selection selection = new Selection();
selection.Market = market;
new Repository().AddSelection(selection);
Assert.IsTrue(selection.SID > 0);
}
</code></pre>
<p>Here is the error message:</p>
<p>System.InvalidOperationException: An attempt was made to remove a relationship between a Market and a Selection. However, one of the relationship's foreign keys (Selection.MID) cannot be set to null.</p>
<p>The relevant parts of the 2 objects:</p>
<pre><code>[DataContract]
public class Selection : ISelection
{
private int mID;
[DataMember]
public int MID
{
get { return this.mID; }
set { this.mID = value; }
}
private Market market;
[DataMember]
public Market Market
{
get { return this.market; }
set
{
this.market = value;
this.mID = value.MID;
}
}
}
[DataContract]
public class Market : IMarket
{
private int mID;
[DataMember]
public int MID
{
get { return this.mID; }
protected set { this.mID = value; }
}
private List<Selection> selections;
[DataMember]
public List<Selection> Selections
{
get { return this.selections; }
set
{
this.selections = value;
// For LINQ
foreach (Selection selection in selections)
{
selection.MID = mID;
selection.Market = this;
}
}
}
}
</code></pre>
<p>My DA code:</p>
<pre><code> MarketsDataContext context = new MarketsDataContext();
DataLoadOptions options = new DataLoadOptions();
options.LoadWith<Selection>(s => s.Prices);
options.LoadWith<Market>(m => m.Selections);
context.LoadOptions = options;
return context;
</code></pre>
<p>and;</p>
<pre><code> public void AddSelection(ISelection selection)
{
using (MarketsDataContext context = MarketsDataContext.GetContext())
{
context.Selections.InsertOnSubmit((Selection) selection);
context.SubmitChanges();
}
}
</code></pre>
<p>And finally my XML mapping:</p>
<pre><code> <Table Name="dbo.Markets" Member="Markets">
<Type Name="Market">
<Column Name="MID" Member="MID" Storage="mID" DbType="Int NOT NULL" IsPrimaryKey="true" IsDbGenerated="true" AutoSync="OnInsert" />
<Association Name="FK_Market-Selections" Member="Selections" Storage="selections" ThisKey="MID" OtherKey="MID" DeleteRule="NO ACTION" />
</Type>
</Table>
<Table Name="dbo.Selections" Member="Selections">
<Type Name="Selection">
<Column Name="SID" Member="SID" Storage="sID" DbType="Int NOT NULL" IsPrimaryKey="true" IsDbGenerated="true" AutoSync="OnInsert" />
<Column Name="MID" Member="MID" Storage="mID" DbType="Int NOT NULL" />
<Association Name="FK_Market-Selections" Member="Market" Storage="market" ThisKey="MID" OtherKey="MID" IsForeignKey="true" />
</Type>
</Table>
</code></pre>
<p>So, can anyone point me in the right direction? I've been searching for hours...</p>
<p>Edit:</p>
<p>Here's my stacktrace for my test failure:</p>
<pre><code>at System.Data.Linq.ChangeTracker.StandardChangeTracker.StandardTrackedObject.SynchDependentData()
at System.Data.Linq.ChangeProcessor.ValidateAll(IEnumerable`1 list)
at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges()
at BetMax.DataModel.Repository.AddSelection(ISelection selection) in Repository.cs: line 68
at BetMax.DataModel.Test.ModelTest.AddSelectionShouldAddSelectionToMarket() in ModelTest.cs: line 65
</code></pre>
<p>And my GetMarket method:</p>
<pre><code> public IMarket GetMarket(int MID)
{
Market market;
using (MarketsDataContext context = MarketsDataContext.GetContext())
{
market = context.Markets.Single(m => m.MID == MID);
}
return market;
}
</code></pre>
<p>Edit 2:</p>
<p>Well, adding </p>
<pre><code>DeleteOnNull="true"
</code></pre>
<p>to Selections foreign key in the XML mapping has removed the foreign key error, but now I'm getting a null reference on one of Selections's child objects, saying its reference to Selection is null even though Selection is being initialised with none of its variables set (outside the foreign keys). I even tried creating a child object, and set its references correctly but am still getting this error:</p>
<pre><code>System.NullReferenceException: Object reference not set to an instance of an object.
at BetMax.DTO.Price.set_Selection(Selection value) in Price.cs: line 25
at System.Data.Linq.Mapping.PropertyAccessor.Accessor`3.SetValue(ref T instance, V value)
at System.Data.Linq.Mapping.MetaAccessor`2.SetBoxedValue(ref Object instance, Object value)
at System.Data.Linq.ChangeProcessor.ClearForeignKeysHelper(MetaAssociation assoc, Object trackedInstance)
at System.Data.Linq.ChangeProcessor.ClearForeignKeyReferences(TrackedObject to)
at System.Data.Linq.ChangeProcessor.PostProcessUpdates(List`1 insertedItems, List`1 deletedItems)
at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges()
at BetMax.DataModel.Repository.AddSelection(ISelection selection) in Repository.cs: line 68
at BetMax.DataModel.Test.ModelTest.AddSelectionShouldAddSelectionToMarket() in ModelTest.cs: line 69
</code></pre>
<p>Price is another object, constructed in the same that that Selection is related to Market (1 selection has many prices, 1 market has many selections) etc etc.</p>
| [
{
"answer_id": 298250,
"author": "Ali Ersöz",
"author_id": 4215,
"author_profile": "https://Stackoverflow.com/users/4215",
"pm_score": 2,
"selected": false,
"text": "[Test]\npublic void AddSelectionShouldAddSelectionToMarket()\n{\n Market market = (Market) new Repository().GetMarket(1);\n\n Selection selection = new Selection();\n selection.Market = market;\n\n new Repository().AddSelection(selection);\n\n Assert.IsTrue(selection.SID > 0);\n}\n [Test]\npublic void AddSelectionShouldAddSelectionToMarket()\n{\n Repository repository = new Repository();\n Market market = (Market) repository.GetMarket(1);\n\n Selection selection = new Selection();\n selection.Market = market;\n\n repository.AddSelection(selection);\n\n Assert.IsTrue(selection.SID > 0);\n}\n"
},
{
"answer_id": 298256,
"author": "GeekyMonkey",
"author_id": 29900,
"author_profile": "https://Stackoverflow.com/users/29900",
"pm_score": 2,
"selected": false,
"text": "public Market Market\n{\n get { return this.market; }\n set\n {\n this.market = value;\n this.mID = value.MID;\n }\n}\n set\n {\n this.market = value;\n this.mID = (value == null) ? null : value.MID;\n }\n int? MID\n"
},
{
"answer_id": 298657,
"author": "Ali Ersöz",
"author_id": 4215,
"author_profile": "https://Stackoverflow.com/users/4215",
"pm_score": 2,
"selected": false,
"text": "private List<Price> prices\n[DataMember]\npublic List<Price> Prices\n{\n get { return this.prices; }\n set\n {\n if(value != null)\n {\n this.pricess = value;\n // For LINQ \n foreach (Price price in prices)\n {\n price.MID = mID;\n price.Selection = this;\n }\n }\n }\n}\n"
},
{
"answer_id": 2204059,
"author": "Neil T.",
"author_id": 235288,
"author_profile": "https://Stackoverflow.com/users/235288",
"pm_score": 2,
"selected": false,
"text": "Market\n======\nMarket_ID int not null identity (1, 1)\n\n\nSelection\n=========\nSelection_ID int not null identity (1, 1)\nMarket_ID int (FK to Market)\nSelection_Name varchar(50)\n Selection selection = new Selection();\nMarket market = new Market();\n\nmarket.Selections.Add(selection);\nDataContext.Markets.InsertOnSubmit(market);\nDataContext.SubmitChanges();\n Selection selection = new Selection();\nMarket market = DataContext.Markets.Where(a => a.Market_ID == 7).Single();\n\nmarket.Selections.Add(selection);\nDataContext.SubmitChanges();\n Selection selection = DataContext.Markets.Where(a => a.Market_ID == 7).Selections.First();\n\nselection.Selection_Name = \"New Name\";\nDataContext.SubmitChanges();\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12948/"
] |
298,167 | <p>Instead of writing</p>
<pre><code>((x: Double) => (((y: Double) => y*y))(x+x))(3)
</code></pre>
<p>I would like to write something like</p>
<pre><code>((x: Double) => let y=x+x in y*y)(3)
</code></pre>
<p>Is there anything like this sort of syntactic sugar in Scala?</p>
| [
{
"answer_id": 299310,
"author": "Daniel Spiewak",
"author_id": 9815,
"author_profile": "https://Stackoverflow.com/users/9815",
"pm_score": 5,
"selected": true,
"text": "val ({ x: Double =>\n val y = x + x\n y * y\n})(3)\n val var"
},
{
"answer_id": 300866,
"author": "Germán",
"author_id": 17138,
"author_profile": "https://Stackoverflow.com/users/17138",
"pm_score": 3,
"selected": false,
"text": " ({ x:Double => val y = x + x; y * y })(3)\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34596/"
] |
298,169 | <p>Ok guys any idea how i may go about creating an answers file for an unattended install for say WinAmp?</p>
<p>So far all my research points to is doing an unattended install for windows or some other OS. What I want to do is create an unattended install for a 3rd party software. Are there tools to do this? Or is unattended install for 3rd party software just a pipe dream?</p>
| [
{
"answer_id": 300760,
"author": "saschabeaumont",
"author_id": 592,
"author_profile": "https://Stackoverflow.com/users/592",
"pm_score": 2,
"selected": true,
"text": "MSIEXEC /I file.msi /QUIET\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38210/"
] |
298,183 | <p>Is it better to initialize class member variables on declaration</p>
<pre><code>private List<Thing> _things = new List<Thing>();
private int _arb = 99;
</code></pre>
<p>or in the default constructor?</p>
<pre><code>private List<Thing> _things;
private int _arb;
public TheClass()
{
_things = new List<Thing>();
_arb = 99;
}
</code></pre>
<p>Is it simply a matter of style or are there performance trade-offs, one way or the other?</p>
| [
{
"answer_id": 298208,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 7,
"selected": true,
"text": "[DefaultValue(\"\")]\npublic string Foo {get;set;}\npublic Bar() { // ctor\n Foo = \"\";\n}\n private readonly List<SomeClass> items = new List<SomeClass>();\npublic List<SomeClass> Items {get {return items;}}\n public Bar() : this(\"\") {}\npublic Bar(string foo) {Foo = foo;}\n base(...) public Bar(string foo) this(...)"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1535/"
] |
298,187 | <p>I have a small program that is installed in a custom folder in the program files, but when I tried to read or write to files that are needed to operate, the program raises an Access Denied Exeption. How can I elevte the program, with the user's permission of course.</p>
| [
{
"answer_id": 13526576,
"author": "Marimuthu",
"author_id": 1847154,
"author_profile": "https://Stackoverflow.com/users/1847154",
"pm_score": 1,
"selected": false,
"text": "e.g. fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35984/"
] |
298,190 | <p>On input validation, I'm using balloon tips instead of message boxes.
My problem is that on Vista, they have the old XP style with the rounded corners, not the newer more rectangle like appearance.</p>
<p>I've tried creating them using CreateWindowEx and <code>tooltips_class32</code> or showing the Edit's associated balloontip using SendMessageW and <code>EM_SHOWBALLOONTIP</code>, the result is the same.
Doing the same thing in Visual Studio and C# results in a Vista style balloon tip.</p>
<p>You can see an example of the balloon hint I need, when you toggle Caps Lock while in a password edit, like the one on the Windows Logon.</p>
| [
{
"answer_id": 299343,
"author": "Jim McKeeth",
"author_id": 255,
"author_profile": "https://Stackoverflow.com/users/255",
"pm_score": 2,
"selected": false,
"text": "procedure ShowHint; overload;\nprocedure ShowHint(Point: TPoint); overload;\nprocedure ShowHint(Rect: TRect); overload;\nprocedure ShowHint(Control: TControl); overload;\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15089/"
] |
298,194 | <p>I develop one application using VB.net (200%) that connects to MS-Access Database, I use TableAdapter and Dataset for connection to the Access DB file.</p>
<p>I need to implement a simple transaction method (commit, rollback) in saving to the DB?</p>
<p>Is there a way to do that without the need to use inline SQL statement?</p>
<p>Thanks,</p>
| [
{
"answer_id": 298253,
"author": "artur02",
"author_id": 13937,
"author_profile": "https://Stackoverflow.com/users/13937",
"pm_score": 4,
"selected": false,
"text": " SqlConnection db = new SqlConnection(\"connstringhere\");\n SqlTransaction transaction;\n\n db.Open();\n transaction = db.BeginTransaction();\n try \n {\n new SqlCommand(\"INSERT INTO TransactionDemo \" +\n \"(Text) VALUES ('Row1');\", db, transaction)\n .ExecuteNonQuery();\n new SqlCommand(\"INSERT INTO TransactionDemo \" +\n \"(Text) VALUES ('Row2');\", db, transaction)\n .ExecuteNonQuery();\n new SqlCommand(\"INSERT INTO CrashMeNow VALUES \" +\n \"('Die', 'Die', 'Die');\", db, transaction)\n .ExecuteNonQuery();\n transaction.Commit();\n } \n catch (SqlException sqlError) \n {\n transaction.Rollback();\n }\n db.Close();\n bool IsConsistent = false;\n\nusing (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope())\n\n{\n\n SqlConnection cn = newSqlConnection(CONNECTION_STRING );\n\n string sql = \"DELETE Categories\";\n\n SqlCommand cmd = newSqlCommand(sql, cn);\n\n cn.Open();\n\n cmd.ExecuteNonQuery();\n\n cn.Close();\n\n //Based on this property the transaction will commit if\n\n //successful. If it fails however, this property will\n\n //not be set and the transaction will not commit.\n\n ts.Consistent = IsConsistent;\n\n}\n conn = new SqlConnection(Properties.Settings.Default.NorthwindConnectionString);\nconn.Open();\ntrans = conn.BeginTransaction();\n1. \npublic SqlDataAdapter GetAdapter(object tableAdapter)\n{\n Type tableAdapterType = tableAdapter.GetType();\n SqlDataAdapter adapter = (SqlDataAdapter)tableAdapterType.GetProperty(\"Adapter\", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(tableAdapter, null);\n return adapter;\n}\n2.\nadapter.InsertCommand.Connection = trans.Connection;\nadapter.UpdateCommand.Connection = trans.Connection;\nadapter.DeleteCommand.Connection = trans.Connection;\n\n3.\nadapter.InsertCommand.Transaction = trans;\nadapter.UpdateCommand.Transaction = trans;\nadapter.DeleteCommand.Transaction = trans;\n\n4. \n-\n\n5. \ntrans.commit();\n CustomersDataSet.CustomersDataTable customers = new CustomersDataSet.CustomersDataTable();\n CustomersDataSetTableAdapters.CustomersTableAdapter tblAdap = new \n CustomersDataSetTableAdapters.CustomersTableAdapter();\n using (TransactionScope txScope = new TransactionScope())\n {\n tblAdap.Fill(customers);\n customers.Rows[0][\"ContactName\"] = \"Maria Velasquez\";\n tblAdap.Update(customers);\n txScope.Complete();\n }\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,218 | <p>In XHTML Strict, it seems that you're not allowed to use the <code><u></code> tag any more. Is there a semantic equivalent like there is for <code><b></code> and <code><i></code>? If not, is there any convention for how to markup underlined text in XHTML?</p>
<p>Thanks.</p>
| [
{
"answer_id": 298247,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 3,
"selected": false,
"text": "<span class=\"highlight\"> <em>"
},
{
"answer_id": 507976,
"author": "vartec",
"author_id": 60711,
"author_profile": "https://Stackoverflow.com/users/60711",
"pm_score": 2,
"selected": false,
"text": "<em style=\"text-decoration: underline\">\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21709/"
] |
298,219 | <p>I'm looking to find a way to access the .net query string contained in the standard ASP.NET request object inside a web service. In other words if I set a SOAP web service to this url:</p>
<p><a href="http://localhost/service.asmx?id=2" rel="noreferrer">http://localhost/service.asmx?id=2</a></p>
<p>Can I access the ID Get variable?</p>
| [
{
"answer_id": 298229,
"author": "Ali Ersöz",
"author_id": 4215,
"author_profile": "https://Stackoverflow.com/users/4215",
"pm_score": 5,
"selected": true,
"text": "this.Context.Request.QueryString[\"id\"];\n"
},
{
"answer_id": 1297948,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "Uri myRef = new Uri(stringMyWindowLocationParameter);\nSystem.Collections.Specialized.NameValueCollection mojQuery = HttpUtility.ParseQueryString(myRef.Query);\n // Instead trying to request query string like this\nstring myId = HttpContext.Current.Request.QueryString[\"id\"];\n\n// ... I called it like this\nstring myId = myRef[\"id\"];\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32582/"
] |
298,228 | <p>This led on from the question about asking if Apache Maven and IBM Rational ClearCase integrated well. Thought I should write up what I found out - will require various edits, but I shall eventually get round to adding it all I hope.</p>
<h2>Environment</h2>
<p><strong>ClearCase</strong> - Version 7.0.1.2 of ClearCase.</p>
<p><strong>Maven</strong> - All of them, from the <a href="http://maven.apache.org" rel="nofollow noreferrer">Maven website</a>.</p>
<p><strong>Hudson</strong> - Version 1.307 downloaded straight from the <a href="http://hudson-ci.org/" rel="nofollow noreferrer">Hudson website</a></p>
<hr />
<h2>Questions</h2>
<ul>
<li>Does Maven run from a VOB?</li>
</ul>
<p>I installed all the versions of Maven2 into a VOB 'stacked', i.e. I added Version 2.0 - labelled it, locked the label - then added 2.0.1 on top.</p>
<p>To prevent there being extraneous files, I used the -rnname flag in clearfsimport.</p>
<p>This way, I could simply use a label to specify the version of Maven I wanted access to in my configuration spec, but still keep the same path for the maven executable - <em>/maven/bin/mvn.</em></p>
<p>Once all the versions were installed, I had no problem running Maven from there via a <em>Dynamic</em> View. Repositories are downloaded from an internal installation of Nexus to the users home directory as normal - and this saves any problems with checking in and out.</p>
<p>A benefit of keeping the tool in source control is that you can set company-wide settings (such as pointing to a internal repository) - then run that single instance of Maven from the VOB on any platform, which retains the settings you originally set!</p>
<p>In Maven projects, I only kept the src directory and the pom.xml in source control, as everything else can be auto-generated afterwards.</p>
<ul>
<li>Does Hudson work with ClearCase?</li>
</ul>
<p>I had no problem setting up Hudson to run with ClearCase Dynamic Views. All it took was a symlink from the working directory for Hudson to the root of the view (in this case /view/xxx). The ClearCase plugin successfully ran <strong>ct lshistory</strong> to find if there had been any changes in the integration branch that developers merge into.</p>
<p>I did write a small script to set-up the initial environment for a job - just the config.xml and dynamic view symlink - so that the correct view was listed in the job and the initial settings were correct. Any enhancements by the users afterwards were then changes to the default template, rather than them setting it up themselves.</p>
<p>In the overall settings of Hudson, I used the $CLEARCASE_VIEW environment variable to set the path to the Maven executable. That way, the version of Maven depended on the version set in the configuration specification - rather than the one they selected within Hudson.</p>
<p>This saves extra administration on both the part of me (the admin) and my users.</p>
<ul>
<li>What Internal Repository Manager did you use?</li>
</ul>
<p>I set up Sonatype Nexus to be the Internal Repository Manager - primarily because I read in the <a href="http://www.sonatype.com/people/?s=hudson+build+farm" rel="nofollow noreferrer">Sonatype blog</a> that Hudson was going to get more integrated with Nexus, and we may as well be prepared for new enhancements in the future. I also believed, when I got it set up and tried it, that it was more prepared for a large commercial environment because you could tune the groups within the repository manager to be more flexible - useful for a great number of projects.</p>
| [
{
"answer_id": 298306,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 2,
"selected": false,
"text": "INFO Checking out file: /opt/viewstore/common/maven/my_lf_ss/vobs/test_alm/LF_Build/pom.xml\nINFO ERROR BUILD FAILURE\nINFO INFO Unable to enable editing on the POM\nProvider message:\nThe cleartool command failed.\nCommand output:\ncleartool: Error: Element \"/opt/viewstore/common/maven/my_lf_ss/vobs/test_alm/LF_Build/pom.xml\" is already checked out to view \"my_lf_ss\".\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31161/"
] |
298,231 | <p>I have following string</p>
<pre><code>String str = "replace :) :) with some other string";
</code></pre>
<p>And I want to replace first occurance of <code>:)</code> with some other string</p>
<p>And I used <code>str.replaceFirst(":)","hi");</code></p>
<p>it gives following exception</p>
<blockquote>
<p>"Unmatched closing ')'"</p>
</blockquote>
<p>I tried using <code>replace</code> function but it replaced all occurance of <code>:)</code>.</p>
| [
{
"answer_id": 298240,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "replaceFirst ) str.replaceFirst(\":\\\\)\", \"hi\");\n"
},
{
"answer_id": 298242,
"author": "Tor Haugen",
"author_id": 32050,
"author_profile": "https://Stackoverflow.com/users/32050",
"pm_score": 3,
"selected": false,
"text": "str = str.replaceFirst(\":\\\\)\", \"hi\");\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25778/"
] |
298,235 | <p>I'm having some doubts on how to set up my SVN stuff. </p>
<p>First my situation:
Programmer working alone on most stuff, outside access not needed (yet).</p>
<p>I want:<ul>
<li>A speedy SVN, preferably free.
<li>Private
<li>Backup friendly
<li>Somewhat hassle free
<li>A lot of storage.
</ul>
I don't want:<ul>
<li>To have problems transfering my data to another comp / svn install.
</ul>
I tried:
Assembla free hosted solution and some other free hosted solutions, these won't work for me because of storage / project limitations. </p>
<p>So now I have the options:<ul>
<li>Get a shared host with a large amount of space for SVN.
<li>Just install it on one of my comps (running windows)
<li>Install it on a vmware image which would make it easier to copy and maybe ease the backup process.
</ul></p>
<p>What would you do in my situation and why?</p>
<p>Edit:</p>
<p>Or is GIT a better option in this situation, and if so why?
(keeping in mind that I have no experience with this technology)</p>
| [
{
"answer_id": 298371,
"author": "Tader",
"author_id": 30700,
"author_profile": "https://Stackoverflow.com/users/30700",
"pm_score": 0,
"selected": false,
"text": "git init"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30600/"
] |
298,257 | <p>Parts of my application are in C++ under windows. I need the process id for the current process. Any thoughts? </p>
| [
{
"answer_id": 298262,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 7,
"selected": true,
"text": "GetCurrentProcessId"
},
{
"answer_id": 28183927,
"author": "David A. Gray",
"author_id": 3079037,
"author_profile": "https://Stackoverflow.com/users/3079037",
"pm_score": 3,
"selected": false,
"text": "GetCurrentProcessId DllMain mov eax,fs:[00000018]\nmov eax,dword ptr [eax+20h]\nret\n GetLastError SetLastError"
},
{
"answer_id": 63767351,
"author": "Muhammed_G",
"author_id": 10935450,
"author_profile": "https://Stackoverflow.com/users/10935450",
"pm_score": 2,
"selected": false,
"text": "getpid() _getpid() <process.h>"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21634/"
] |
298,261 | <p>If I have the following code:</p>
<pre><code>MyClass pClass = new MyClass();
pClass.MyEvent += MyFunction;
pClass = null;
</code></pre>
<p>Will pClass be garbage collected? Or will it hang around still firing its events whenever they occur? Will I need to do the following in order to allow garbage collection?</p>
<pre><code>MyClass pClass = new MyClass();
pClass.MyEvent += MyFunction;
pClass.MyEvent -= MyFunction;
pClass = null;
</code></pre>
| [
{
"answer_id": 298276,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 9,
"selected": true,
"text": "publisher.SomeEvent += target.SomeHandler;\n"
},
{
"answer_id": 298284,
"author": "Tor Haugen",
"author_id": 32050,
"author_profile": "https://Stackoverflow.com/users/32050",
"pm_score": 3,
"selected": false,
"text": "pClass pClass pClass"
},
{
"answer_id": 10932867,
"author": "Arav",
"author_id": 1442337,
"author_profile": "https://Stackoverflow.com/users/1442337",
"pm_score": 0,
"selected": false,
"text": "pClass pClass null"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/986/"
] |
298,277 | <p>When C# 4.0 comes out and we have the dynamic keyword as described in this <a href="http://channel9.msdn.com/pdc2008/TL16/" rel="noreferrer">excellent presentation by Anders Hejlsberg</a>, (C# is evolving faster than I can keep up.. I didn't have much time to acquaint myself with the var keyword)</p>
<p>Would I still need the var keyword ? Is there anything that var can do.. that dynamic can't?</p>
<pre><code>var x = SomeFunctionThatIKnowReturnsSomeKindOfList();
// do something with x
dynamic x = SomeFunctionThatIKnowReturnsSomeKindOfList();
// do something with x
</code></pre>
| [
{
"answer_id": 298287,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": true,
"text": "var dynamic dynamic var"
},
{
"answer_id": 298290,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 4,
"selected": false,
"text": "var a = \"foo\";\nstring a = \"foo\";\n dynamic d = SomeOperation();\nd.Foo(); // Will this fail or not? Won't know until you run the program\n"
},
{
"answer_id": 298298,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 1,
"selected": false,
"text": "Var i = \"Hello World\"\n i.Split(\"/\")\n dynamic i = \"Hello World\"\n i.Split(\"/\")\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695/"
] |
298,281 | <p>Is it possible to create a list that can be access by either an index or a key?</p>
<p><em>I am looking for a Collection type that already exists but has this facility, I want to avoid redefining the indexers</em> </p>
| [
{
"answer_id": 298295,
"author": "Robert Wagner",
"author_id": 10784,
"author_profile": "https://Stackoverflow.com/users/10784",
"pm_score": 0,
"selected": false,
"text": "public object this[int index]\n{\n get { /* return the specified index here */ }\n set { /* set the specified index to value here */ }\n}\n"
},
{
"answer_id": 298300,
"author": "Mark Ingram",
"author_id": 986,
"author_profile": "https://Stackoverflow.com/users/986",
"pm_score": 1,
"selected": false,
"text": "public object this[int index]\n{\n get { ... }\n set { ... }\n}\n public object this[String key]\n{\n get { ... }\n set { ... }\n}\n List<T> List<T>"
},
{
"answer_id": 298324,
"author": "Martin Brown",
"author_id": 20553,
"author_profile": "https://Stackoverflow.com/users/20553",
"pm_score": 3,
"selected": true,
"text": " System.Collections.Specialized.NameValueCollection k = \n new System.Collections.Specialized.NameValueCollection();\n\n k.Add(\"B\", \"Brown\");\n k.Add(\"G\", \"Green\");\n\n Console.WriteLine(k[0]); // Writes Brown\n Console.WriteLine(k[\"G\"]); // Writes Green\n"
},
{
"answer_id": 298327,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "SortedList<,> Dictionary<,> Collection<> List<> IList IList<T> public SomeType this[int someId] {...}\n IList[<T>]"
},
{
"answer_id": 298954,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 2,
"selected": false,
"text": "class IndexableDictionary<TKey, TItem> : KeyedCollection<TKey, TItem>\n { Dictionary<TItem, TKey> keys = new Dictionary<TItem, TKey>();\n\n protected override TKey GetKeyForItem(TItem item) { return keys[item];}\n\n public void Add(TKey key, TItem item) \n { keys[item] = key;\n this.Add(item);\n }\n }\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] |
298,288 | <p>I have the following code</p>
<pre><code><html>
<head>
<title>Test</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-color: #000000;
}
#Pictures {
position:absolute;
width:591px;
height:214px;
z-index:1;
left: 17%;
top: 30%;
text-align:center;
}
#Links {
width:600px;
height:30px;
z-index:2;
top: 184px;
font-family: "Broadway", Broadway, monospace;
font-size: 14px;
color: #FFFFFF;
text-align: center;
}
.links2 {
font-family: Broadway;
color: #FFFFFF;
text-decoration: none;
}
a:links2, a:visited {
color: #ffffff;
}
a:hover, a:active {
color: #333333;
}
#Main {
position:absolute;
width:800px;
height:600px;
z-index:2;
left: 15%;
top: 10%;
right: 15%;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
}
#Logo {
position:absolute;
float: left;
width:104px;
height:100px;
z-index:2;
}
</style>
</head>
<body>
<div id="Main">
<div id="Pictures">
<div>
<a href="1.html" ><img src="1.gif" alt="x" width="181" height="173" border="0" /></a>
<a href="1.html" class="links2">1</a>
</div>
<div>
<a href="2.html" class="links2"><img src="2.gif" alt="x" width="181" height="173" border="0" align="top" /></a>
<a href="2.html" class="links2">2</a>
</div>
<div>
<a href="3.html" class="links2"><img src="3.gif" alt="3" width="181" height="173" border="0" /></a>
<a href="3.html" class="links2">3</a>
</div>
</div>
</div>
<div id="Logo"><img src="logo.gif" alt="x" width="104" height="100" border="0"/></div>
</div>
</body>
</html>
</code></pre>
<p>Which is displaying the picture layers vertically.</p>
<p>I am trying to make it o the 3 images are aligned horizontally with the text centered underneath them. Why are they defaulting to vertical, and can I change this behavior?</p>
| [
{
"answer_id": 298318,
"author": "Phil Jenkins",
"author_id": 35496,
"author_profile": "https://Stackoverflow.com/users/35496",
"pm_score": 1,
"selected": true,
"text": "display: block; links2 <span> <div> #Pictures span\n{\n float: left;\n margin-right: 5px;\n}\n"
},
{
"answer_id": 298381,
"author": "Ola Tuvesson",
"author_id": 6903,
"author_profile": "https://Stackoverflow.com/users/6903",
"pm_score": 1,
"selected": false,
"text": "<style>\nbody {\nbackground-color: #000;\ncolor: #FFF;\n}\na {\nfont-family: \"Broadway\", Broadway, monospace;\nfont-size: 14px;\ncolor: #FFF;\n}\n#images a {\nwidth: 24.99%;\ndisplay: block;\nfloat: left;\ntext-align: center;\n}\n</style>\n\n<div id=\"images\">\n<a href=\"1.html\" >\n <img src=\"1.gif\" alt=\"x\" width=\"181\" height=\"173\" border=\"0\" /><br />\n One\n</a>\n<a href=\"2.html\" >\n <img src=\"2.gif\" alt=\"x\" width=\"181\" height=\"173\" border=\"0\" /><br />\n Two\n</a>\n<a href=\"3.html\" >\n <img src=\"3.gif\" alt=\"x\" width=\"181\" height=\"173\" border=\"0\" /><br />\n Three\n</a>\n<a href=\"4.html\" >\n <img src=\"4.gif\" alt=\"x\" width=\"181\" height=\"173\" border=\"0\" /><br />\n Four\n</a>\n</div>\n"
},
{
"answer_id": 298390,
"author": "alexmeia",
"author_id": 36587,
"author_profile": "https://Stackoverflow.com/users/36587",
"pm_score": 1,
"selected": false,
"text": "div.imageBox {\n float: left;\n margin-right: 10px;\n }\n\ndiv.imageBox p {\n text-align: center;\n }\n <div class=\"imageBox\">\n <a href=\"#\">\n <img src=\"image1.gif\" width=\"100\" height=\"100\"\n alt=\"image 1\" /></a>\n <p><a href=\"#\">1</a></p>\n</div>\n\n<div class=\"imageBox\">\n <a href=\"#\">\n <img src=\"image2.gif\" width=\"100\" height=\"100\"\n alt=\"image 1\" /></a>\n <p><a href=\"#\">2</a></p>\n</div>\n\n<div class=\"imageBox\">\n <a href=\"#\">\n <img src=\"image3.gif\" width=\"100\" height=\"100\"\n alt=\"image 1\" /></a>\n <p><a href=\"#\">3</a></p>\n</div>\n div#Pictures div\n\n {\n float: left;\n margin-right: 5px;\n }\n a:links2\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
298,289 | <p>I have the following code that I need to add an additonal object to after the results have been retrieved from the databse. Any Ideas on how I might to this ?</p>
<pre><code> public IEnumerable<ProdPriceDisplay> GetShopProductsPrices()
{
//ProdPriceDisplay ProdPrice = new ProdPriceDisplay();
var Products = from shop in db.SHOPs
select new ProdPriceDisplay
{
ProdPrice = shop.S_NAME + " - £" + shop.S_PRICE
};
// *** Want to add something like this:-
// Products.Add new ProdPriceDisplay { ProdPrice = "some additional text"; }
return Products;
}
</code></pre>
| [
{
"answer_id": 298304,
"author": "Ali Ersöz",
"author_id": 4215,
"author_profile": "https://Stackoverflow.com/users/4215",
"pm_score": 0,
"selected": false,
"text": "var productsAsList = Products.ToList();\nproductsAsList.Add(new ProdPriceDisplay { ProdPrice = \"some additional text\"; });\n\nreturn productsAsList; // As your return type is IEnumarable, that won't be a problem;\n"
},
{
"answer_id": 298313,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": true,
"text": "Enumerable.Concat public IEnumerable<ProdPriceDisplay> GetShopProductsPrices()\n{\n var products = from shop in db.SHOPs\n select new ProdPriceDisplay\n {\n ProdPrice = shop.S_NAME + \" - £\" + shop.S_PRICE\n };\n\n return products.AsEnumerable()\n .Concat(new [] { new ProdPriceDisplay \n { ProdPrice = \"some additional text\"; });\n}\n Enumerable.Repeat (new ProdPriceDisplay { ... }, 1) AsEnumerable()"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26809/"
] |
298,292 | <p>I'm trying to read a value from a file and use it in a subsequent command.</p>
<p>I have a file called <code>AppServer.pid</code> which contains the process id of my app server (just the number, it's not a properties file or anything like that).</p>
<p>The app server is hanging, so I want to take this value and pass it to the kill command. So my script will be something like</p>
<pre><code>SET VALUE_FROM_FILE=AppServer.pid # or something
taskkill /pid %VALUE_FROM_FILE% /f
</code></pre>
<p>Is there a convenient way to do this in Windows scripting?</p>
| [
{
"answer_id": 298374,
"author": "RuntimeException",
"author_id": 15789,
"author_profile": "https://Stackoverflow.com/users/15789",
"pm_score": 1,
"selected": false,
"text": "for /f %%G in (appid.txt) do (SET PID=%%G)\necho %PID%\ntaskkill etc here... \n"
},
{
"answer_id": 298409,
"author": "Cocowalla",
"author_id": 25758,
"author_profile": "https://Stackoverflow.com/users/25758",
"pm_score": 5,
"selected": true,
"text": "SET /P VALUE_FROM_FILE= < AppServer.pid\ntaskkill /pid %VALUE_FROM_FILE% /f\n"
},
{
"answer_id": 38447908,
"author": "isapir",
"author_id": 968244,
"author_profile": "https://Stackoverflow.com/users/968244",
"pm_score": 1,
"selected": false,
"text": "tasklist taskkill /FI IMAGENAME eq %process_name% nginx.exe taskkill /F /FI \"IMAGENAME eq nginx.exe\"\n /F /FI"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21590/"
] |
298,301 | <p>Can anyone provide some pseudo code for a roulette selection function? How would I implement this: I don't really understand how to read this math notation.I want General algorithm to this.</p>
| [
{
"answer_id": 298315,
"author": "Bork Blatt",
"author_id": 5381,
"author_profile": "https://Stackoverflow.com/users/5381",
"pm_score": 2,
"selected": false,
"text": "VBScript RND() Math.random()"
},
{
"answer_id": 320788,
"author": "Dan Dyer",
"author_id": 5171,
"author_profile": "https://Stackoverflow.com/users/5171",
"pm_score": 6,
"selected": false,
"text": "0 - 0.3 is item 1\n0.3 - 0.4 is item 2\n0.4 - 0.5 is item 3\n0.5 - 0.57 is item 4\n0.57 - 0.63 is item 5\n0.63 - 0.68 is item 6\n0.68 - 0.8 is item 7\n0.8 - 0.85 is item 8\n0.85 - 0.98 is item 9\n0.98 - 1 is item 10\n"
},
{
"answer_id": 1892335,
"author": "gray",
"author_id": 75010,
"author_profile": "https://Stackoverflow.com/users/75010",
"pm_score": 3,
"selected": false,
"text": "p[1..n] r local c = 0\nfor i = 1,n do\n c = c + p[i]\n if r <= c then\n return i\n end\nend\n"
},
{
"answer_id": 2787451,
"author": "Paul",
"author_id": 335272,
"author_profile": "https://Stackoverflow.com/users/335272",
"pm_score": 1,
"selected": false,
"text": "public static List<Classifier> rouletteSelection(int classifiers) {\n List<Classifier> classifierList = new LinkedList<Classifier>();\n double strengthSum = 0.0;\n double probabilitySum = 0.0;\n\n // add up the strengths of the map\n Set<String> keySet = ClassifierMap.CLASSIFIER_MAP.keySet();\n for (String key : keySet) {\n /* used for debug to make sure wheel is working.\n if (strengthSum == 0.0) {\n ClassifierMap.CLASSIFIER_MAP.get(key).setStrength(8000.0);\n }\n */\n Classifier classifier = ClassifierMap.CLASSIFIER_MAP.get(key);\n double strength = classifier.getStrength();\n strengthSum = strengthSum + strength;\n }\n System.out.println(\"strengthSum: \" + strengthSum);\n\n // compute the total probability. this will be 1.00 or close to it.\n for (String key : keySet) {\n Classifier classifier = ClassifierMap.CLASSIFIER_MAP.get(key);\n double probability = (classifier.getStrength() / strengthSum);\n probabilitySum = probabilitySum + probability;\n }\n System.out.println(\"probabilitySum: \" + probabilitySum);\n\n while (classifierList.size() < classifiers) {\n boolean winnerFound = false;\n double rouletteRandom = random.nextDouble();\n double rouletteSum = 0.0;\n\n for (String key : keySet) {\n Classifier classifier = ClassifierMap.CLASSIFIER_MAP.get(key);\n double probability = (classifier.getStrength() / strengthSum);\n rouletteSum = rouletteSum + probability;\n if (rouletteSum > rouletteRandom && (winnerFound == false)) {\n System.out.println(\"Winner found: \" + probability);\n classifierList.add(classifier);\n winnerFound = true;\n }\n }\n }\n return classifierList;\n}\n"
},
{
"answer_id": 5315679,
"author": "noio",
"author_id": 224949,
"author_profile": "https://Stackoverflow.com/users/224949",
"pm_score": 3,
"selected": false,
"text": "def roulette_select(population, fitnesses, num):\n \"\"\" Roulette selection, implemented according to:\n <http://stackoverflow.com/questions/177271/roulette\n -selection-in-genetic-algorithms/177278#177278>\n \"\"\"\n total_fitness = float(sum(fitnesses))\n rel_fitness = [f/total_fitness for f in fitnesses]\n # Generate probability intervals for each individual\n probs = [sum(rel_fitness[:i+1]) for i in range(len(rel_fitness))]\n # Draw new population\n new_population = []\n for n in xrange(num):\n r = rand()\n for (i, individual) in enumerate(population):\n if r <= probs[i]:\n new_population.append(individual)\n break\n return new_population\n"
},
{
"answer_id": 11984609,
"author": "d9daniel",
"author_id": 1601544,
"author_profile": "https://Stackoverflow.com/users/1601544",
"pm_score": 1,
"selected": false,
"text": "Map<A, B> roulette_wheel_schema = new LinkedHashMap<A, B>()\n private Map<Integer, Integer> getRouletteWheel(\n ArrayList<Chromosome_fitnessProportionate> chromosomes,\n int precision) {\n\n /*\n * The number of pockets on the wheel\n * \n * number of pockets in roulette_wheel_schema = probability ·\n * (10^precision)\n */\n Map<Integer, Integer> roulette_wheel_schema = new LinkedHashMap<Integer, Integer>();\n double fitness_proportionate = 0.0D;\n double pockets = 0.0D;\n int key_counter = -1;\n double scale_factor = Math\n .pow(new Double(10.0D), new Double(precision));\n for (int index_cromosome = 0; index_cromosome < chromosomes.size(); index_cromosome++){\n\n Chromosome_fitnessProportionate chromosome = chromosomes\n .get(index_cromosome);\n fitness_proportionate = chromosome.getFitness_proportionate();\n fitness_proportionate *= scale_factor;\n pockets = Math.rint(fitness_proportionate);\n System.out.println(\"... \" + index_cromosome + \" : \" + pockets);\n\n for (int j = 0; j < pockets; j++) {\n roulette_wheel_schema.put(Integer.valueOf(++key_counter),\n Integer.valueOf(index_cromosome));\n }\n }\n\n return roulette_wheel_schema;\n}\n"
},
{
"answer_id": 15582810,
"author": "Dan W",
"author_id": 848344,
"author_profile": "https://Stackoverflow.com/users/848344",
"pm_score": 2,
"selected": false,
"text": "class Roulette\n{\n double[] c;\n double total;\n Random random;\n\n public Roulette(double[] n) {\n random = new Random();\n total = 0;\n c = new double[n.Length+1];\n c[0] = 0;\n // Create cumulative values for later:\n for (int i = 0; i < n.Length; i++) {\n c[i+1] = c[i] + n[i];\n total += n[i];\n }\n }\n\n public int spin() {\n double r = random.NextDouble() * total; // Create a random number between 0 and 1 and times by the total we calculated earlier.\n //int j; for (j = 0; j < c.Length; j++) if (c[j] > r) break; return j-1; // Don't use this - it's slower than the binary search below.\n\n //// Binary search for efficiency. Objective is to find index of the number just above r:\n int a = 0;\n int b = c.Length - 1;\n while (b - a > 1) {\n int mid = (a + b) / 2;\n if (c[mid] > r) b = mid;\n else a = mid;\n }\n return a;\n }\n}\n"
},
{
"answer_id": 15582983,
"author": "Andrew Mao",
"author_id": 586086,
"author_profile": "https://Stackoverflow.com/users/586086",
"pm_score": 2,
"selected": false,
"text": "static int selectRandomWeighted(double[] wts, Random rnd) {\n int selected = 0;\n double total = wts[0];\n\n for( int i = 1; i < wts.length; i++ ) {\n total += wts[i]; \n if( rnd.nextDouble() <= (wts[i] / total)) selected = i;\n }\n\n return selected; \n}\n"
},
{
"answer_id": 33223286,
"author": "hmitcs",
"author_id": 2545547,
"author_profile": "https://Stackoverflow.com/users/2545547",
"pm_score": 0,
"selected": false,
"text": "import java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Random;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;\n\n/**\n * Roulette-wheel Test version.\n * Features a probability vector input with possibly null probability values.\n * Appropriate for adaptive operator selection such as Probability Matching \n * or Adaptive Pursuit, (Dynamic) Multi-armed Bandit.\n * @version October 2015.\n * @author Hakim Mitiche\n */\npublic class RouletteWheel {\n\n/**\n * Selects an element probabilistically. \n * @param wheelProbabilities elements probability vector.\n * @param rng random generator object\n * @return selected element index\n * @throws java.lang.Exception \n */\npublic int select(List<Double> wheelProbabilities, Random rng) \n throws Exception{\n\n double[] cumulativeProba = new double[wheelProbabilities.size()];\n cumulativeProba[0] = wheelProbabilities.get(0);\n for (int i = 1; i < wheelProbabilities.size(); i++)\n {\n double proba = wheelProbabilities.get(i);\n cumulativeProba[i] = cumulativeProba[i - 1] + proba;\n }\n int last = wheelProbabilities.size()-1;\n if (cumulativeProba[last] != 1.0)\n {\n throw new Exception(\"The probabilities does not sum up to one (\"\n + \"sum=\"+cumulativeProba[last]);\n }\n double r = rng.nextDouble();\n int selected = Arrays.binarySearch(cumulativeProba, r);\n if (selected < 0)\n {\n /* Convert negative insertion point to array index.\n to find the correct cumulative proba range index.\n */\n selected = Math.abs(selected + 1);\n }\n /* skip indexes of elements with Zero probability, \n go backward to matching index*/ \n int i = selected; \n while (wheelProbabilities.get(i) == 0.0){\n System.out.print(i+\" selected, correction\");\n i--;\n if (i<0) i=last;\n }\n selected = i;\n return selected;\n}\n\n\n\n public static void main(String[] args){\n\n RouletteWheel rw = new RouletteWheel();\n int rept = 20;\n List<Double> P = new ArrayList<>(4);\n P.add(0.2);\n P.add(0.1);\n P.add(0.6);\n P.add(0.1);\n Random rng = new Random();\n for (int i = 0 ; i < rept; i++){\n try {\n int s = rw.select(P, rng);\n System.out.println(\"Element selected \"+s+ \", P(s)=\"+P.get(s));\n } catch (Exception ex) {\n Logger.getLogger(RouletteWheel.class.getName()).log(Level.SEVERE, null, ex);\n }\n }\n P.clear();\n P.add(0.2);\n P.add(0.0);\n P.add(0.5);\n P.add(0.0);\n P.add(0.1);\n P.add(0.2);\n //rng = new Random();\n for (int i = 0 ; i < rept; i++){\n try {\n int s = rw.select(P, rng);\n System.out.println(\"Element selected \"+s+ \", P(s)=\"+P.get(s));\n } catch (Exception ex) {\n Logger.getLogger(RouletteWheel.class.getName()).log(Level.SEVERE, null, ex);\n }\n }\n}\n\n /**\n * {@inheritDoc}\n * @return \n */\n @Override\n public String toString()\n {\n return \"Roulette Wheel Selection\";\n }\n}\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,305 | <p>How to do this in Java - passing a collection of subtype to a method requiring a collection of base type?</p>
<p>The example below gives:</p>
<pre><code>The method foo(Map<String,List>) is not applicable for the arguments (Map<String,MyList>)
</code></pre>
<p>I can implement by creating a class hierarchy for the typed collections - but is it possible otherwise?</p>
<pre><code>public void testStackOverflow() {
class MyList extends AbstractList {
public Object get(int index) {
return null;
}
public int size() {
return 0;
}
};
Map <String, List> baseColl = null;
Map <String, MyList> subColl = null;
foo (subColl);
}
private void foo (Map <String, List> in) {
}
</code></pre>
<p>EDIT: Turns out from the answers that this requires "bounded wildcard" so adding this text for searchability</p>
| [
{
"answer_id": 298332,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "foo private void foo(Map <String, ? extends List> in) {\n}\n foo"
},
{
"answer_id": 298354,
"author": "Ray Tayek",
"author_id": 51292,
"author_profile": "https://Stackoverflow.com/users/51292",
"pm_score": 2,
"selected": false,
"text": "private void foo (Map <String, ? extends List> in { ... }\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2887/"
] |
298,312 | <p>Staring JBoss server from within Eclipse Ganymede gives me the following problem:
"Server JBoss v4.0 at localhost was unable to start within 120 seconds. If the server requires more time, try increasing the timeout in the server editor."</p>
<p>The console shows JBoss has started in so and so minutes but soon after, there is a pop up if the above message.
I can also start the JBoss externally. </p>
| [
{
"answer_id": 341001,
"author": "Mg.",
"author_id": 314728,
"author_profile": "https://Stackoverflow.com/users/314728",
"pm_score": 0,
"selected": false,
"text": "-Djava.io.tmpdir=yourTempDirectory\n"
},
{
"answer_id": 1703737,
"author": "Aboubacar Toure",
"author_id": 207286,
"author_profile": "https://Stackoverflow.com/users/207286",
"pm_score": 4,
"selected": false,
"text": "8080 8180"
},
{
"answer_id": 6532208,
"author": "Miroslav Beranič",
"author_id": 822662,
"author_profile": "https://Stackoverflow.com/users/822662",
"pm_score": 2,
"selected": false,
"text": "Djboss.service.binding.set=ports-01"
},
{
"answer_id": 9210283,
"author": "pkm1986",
"author_id": 1164686,
"author_profile": "https://Stackoverflow.com/users/1164686",
"pm_score": 0,
"selected": false,
"text": "10.168.2.11 host Name: localhost\nServer Name:localhost\n"
},
{
"answer_id": 17587087,
"author": "Plink",
"author_id": 2571501,
"author_profile": "https://Stackoverflow.com/users/2571501",
"pm_score": 1,
"selected": false,
"text": "I modified '<Connector port=\"8080\"' by '<Connector port=\"server port defined in Eclipse\"'\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,314 | <p>I have a Git repository I store random things in. Mostly random scripts, text files, websites I've designed and so on.</p>
<p>There are some large binary files I have deleted over time (generally 1-5MB), which are sitting around increasing the size of the repository, which I don't need in the revision history.</p>
<p>Basically I want to be able to do..</p>
<pre><code>me@host:~$ [magic command or script]
aad29819a908cc1c05c3b1102862746ba29bafc0 : example/blah.psd : 3.8MB : 130 days old
6e73ca29c379b71b4ff8c6b6a5df9c7f0f1f5627 : another/big.file : 1.12MB : 214 days old
</code></pre>
<p>..then be able to go though each result, checking if it's no longer required then removing it (probably using <code>filter-branch</code>)</p>
| [
{
"answer_id": 298888,
"author": "Aristotle Pagaltzis",
"author_id": 9410,
"author_profile": "https://Stackoverflow.com/users/9410",
"pm_score": 7,
"selected": true,
"text": "git-find-blob #!/usr/bin/perl\nuse 5.008;\nuse strict;\nuse Memoize;\n\nsub usage { die \"usage: git-large-blob <size[b|k|m]> [<git-log arguments ...>]\\n\" }\n\n@ARGV or usage();\nmy ( $max_size, $unit ) = ( shift =~ /^(\\d+)([bkm]?)\\z/ ) ? ( $1, $2 ) : usage();\n\nmy $exp = 10 * ( $unit eq 'b' ? 0 : $unit eq 'k' ? 1 : 2 );\nmy $cutoff = $max_size * 2**$exp; \n\nsub walk_tree {\n my ( $tree, @path ) = @_;\n my @subtree;\n my @r;\n\n {\n open my $ls_tree, '-|', git => 'ls-tree' => -l => $tree\n or die \"Couldn't open pipe to git-ls-tree: $!\\n\";\n\n while ( <$ls_tree> ) {\n my ( $type, $sha1, $size, $name ) = /\\A[0-7]{6} (\\S+) (\\S+) +(\\S+)\\t(.*)/;\n if ( $type eq 'tree' ) {\n push @subtree, [ $sha1, $name ];\n }\n elsif ( $type eq 'blob' and $size >= $cutoff ) {\n push @r, [ $size, @path, $name ];\n }\n }\n }\n\n push @r, walk_tree( $_->[0], @path, $_->[1] )\n for @subtree;\n\n return @r;\n}\n\nmemoize 'walk_tree';\n\nopen my $log, '-|', git => log => @ARGV, '--pretty=format:%T %h %cr'\n or die \"Couldn't open pipe to git-log: $!\\n\";\n\nmy %seen;\nwhile ( <$log> ) {\n chomp;\n my ( $tree, $commit, $age ) = split \" \", $_, 3;\n my $is_header_printed;\n for ( walk_tree( $tree ) ) {\n my ( $size, @path ) = @$_;\n my $path = join '/', @path;\n next if $seen{ $path }++;\n print \"$commit $age\\n\" if not $is_header_printed++;\n print \"\\t$size\\t$path\\n\";\n }\n}\n"
},
{
"answer_id": 300415,
"author": "Paul",
"author_id": 23356,
"author_profile": "https://Stackoverflow.com/users/23356",
"pm_score": 2,
"selected": false,
"text": "$ git reflog expire --expire=1.minute refs/heads/master\n # all deletions up to 1 minute ago available to be garbage-collected\n$ git fsck --unreachable \n # lists all the blobs(file contents) that will be garbage-collected \n$ git prune \n$ git gc\n"
},
{
"answer_id": 7945209,
"author": "mislav",
"author_id": 11687,
"author_profile": "https://Stackoverflow.com/users/11687",
"pm_score": 5,
"selected": false,
"text": "#!/usr/bin/env ruby -w\nhead, treshold = ARGV\nhead ||= 'HEAD'\nMegabyte = 1000 ** 2\ntreshold = (treshold || 0.1).to_f * Megabyte\n\nbig_files = {}\n\nIO.popen(\"git rev-list #{head}\", 'r') do |rev_list|\n rev_list.each_line do |commit|\n commit.chomp!\n for object in `git ls-tree -zrl #{commit}`.split(\"\\0\")\n bits, type, sha, size, path = object.split(/\\s+/, 5)\n size = size.to_i\n big_files[sha] = [path, size, commit] if size >= treshold\n end\n end\nend\n\nbig_files.each do |sha, (path, size, commit)|\n where = `git show -s #{commit} --format='%h: %cr'`.chomp\n puts \"%4.1fM\\t%s\\t(%s)\" % [size.to_f / Megabyte, path, where]\nend\n ruby big_file.rb [rev] [size in MB]\n$ ruby big_file.rb master 0.3\n3.8M example/blah.psd (aad2981: 4 months ago)\n1.1M another/big.file (6e73ca2: 2 weeks ago)\n"
},
{
"answer_id": 8854398,
"author": "Sitaram Chamarty",
"author_id": 1148156,
"author_profile": "https://Stackoverflow.com/users/1148156",
"pm_score": 3,
"selected": false,
"text": "#!/usr/bin/perl\nuse 5.10.0;\nuse strict;\nuse warnings;\n\nuse File::Temp qw(tempdir);\nEND { chdir( $ENV{HOME} ); }\nmy $tempdir = tempdir( \"git-files_tempdir.XXXXXXXXXX\", TMPDIR => 1, CLEANUP => 1 );\n\nmy $min = shift;\n$min =~ /^\\d+$/ or die \"need a number\";\n\n# ----------------------------------------------------------------------\n\nmy @refs =qw(HEAD);\n@refs = @ARGV if @ARGV;\n\n# first, find blob SHAs and names (no sizes here)\nopen( my $objects, \"-|\", \"git\", \"rev-list\", \"--objects\", @refs) or die \"rev-list: $!\";\nopen( my $blobfile, \">\", \"$tempdir/blobs\" ) or die \"blobs out: $!\";\n\nmy ( $blob, $name );\nmy %name;\nmy %size;\nwhile (<$objects>) {\n next unless / ./; # no commits or top level trees\n ( $blob, $name ) = split;\n $name{$blob} = $name;\n say $blobfile $blob;\n}\nclose($blobfile);\n\n# next, use cat-file --batch-check on the blob SHAs to get sizes\nopen( my $sizes, \"-|\", \"< $tempdir/blobs git cat-file --batch-check | grep blob\" ) or die \"cat-file: $!\";\n\nmy ( $dummy, $size );\nwhile (<$sizes>) {\n ( $blob, $dummy, $size ) = split;\n next if $size < $min;\n $size{ $name{$blob} } = $size if ( $size{ $name{$blob} } || 0 ) < $size;\n}\n\nmy @names_by_size = sort { $size{$b} <=> $size{$a} } keys %size;\n\nsay \"\nThe size shown is the largest that file has ever attained. But note\nthat it may not be that big at the commit shown, which is merely the\nmost recent commit affecting that file.\n\";\n\n# finally, for each name being printed, find when it was last updated on each\n# branch that we're concerned about and print stuff out\nfor my $name (@names_by_size) {\n say \"$size{$name}\\t$name\";\n\n for my $r (@refs) {\n system(\"git --no-pager log -1 --format='%x09%h%x09%x09%ar%x09$r' $r -- $name\");\n }\n print \"\\n\";\n}\nprint \"\\n\";\n"
},
{
"answer_id": 10099633,
"author": "SigTerm",
"author_id": 271376,
"author_profile": "https://Stackoverflow.com/users/271376",
"pm_score": 4,
"selected": false,
"text": "#!/usr/bin/env python\n\nimport os, sys\n\ndef getOutput(cmd):\n return os.popen(cmd).read()\n\nif (len(sys.argv) <> 2):\n print \"usage: %s size_in_bytes\" % sys.argv[0]\nelse:\n maxSize = int(sys.argv[1])\n\n revisions = getOutput(\"git rev-list HEAD\").split()\n\n bigfiles = set()\n for revision in revisions:\n files = getOutput(\"git ls-tree -zrl %s\" % revision).split('\\0')\n for file in files:\n if file == \"\":\n continue\n splitdata = file.split()\n commit = splitdata[2]\n if splitdata[3] == \"-\":\n continue\n size = int(splitdata[3])\n path = splitdata[4]\n if (size > maxSize):\n bigfiles.add(\"%10d %s %s\" % (size, commit, path))\n\n bigfiles = sorted(bigfiles, reverse=True)\n\n for f in bigfiles:\n print f\n"
},
{
"answer_id": 10343251,
"author": "Collin Anderson",
"author_id": 131881,
"author_profile": "https://Stackoverflow.com/users/131881",
"pm_score": 1,
"selected": false,
"text": "#!/usr/bin/env python\nimport os, sys\n\nbigfiles = []\nfor revision in os.popen('git rev-list HEAD'):\n for f in os.popen('git ls-tree -zrl %s' % revision).read().split('\\0'):\n if f:\n mode, type, commit, size, path = f.split(None, 4)\n if int(size) > int(sys.argv[1]):\n bigfiles.append((int(size), commit, path))\n\nfor f in sorted(set(bigfiles)):\n print f\n"
},
{
"answer_id": 10625163,
"author": "Zombo",
"author_id": 1002260,
"author_profile": "https://Stackoverflow.com/users/1002260",
"pm_score": 2,
"selected": false,
"text": "#!/bin/bash\nif [ \"$#\" != 1 ]\nthen\n echo 'git large.sh [size]'\n exit\nfi\n\ndeclare -A big_files\nbig_files=()\necho printing results\n\nwhile read commit\ndo\n while read bits type sha size path\n do\n if [ \"$size\" -gt \"$1\" ]\n then\n big_files[$sha]=\"$sha $size $path\"\n fi\n done < <(git ls-tree --abbrev -rl $commit)\ndone < <(git rev-list HEAD)\n\nfor file in \"${big_files[@]}\"\ndo\n read sha size path <<< \"$file\"\n if git ls-tree -r HEAD | grep -q $sha\n then\n echo $file\n fi\ndone\n"
},
{
"answer_id": 15842667,
"author": "Roberto Tyley",
"author_id": 438886,
"author_profile": "https://Stackoverflow.com/users/438886",
"pm_score": 3,
"selected": false,
"text": "git-filter-branch $ java -jar bfg.jar --strip-blobs-bigger-than 1M my-repo.git\n git gc $ git gc --prune=now --aggressive\n git-filter-branch"
},
{
"answer_id": 25795863,
"author": "Caustic",
"author_id": 1998564,
"author_profile": "https://Stackoverflow.com/users/1998564",
"pm_score": 0,
"selected": false,
"text": "git fat -a find 100000"
},
{
"answer_id": 46084767,
"author": "raphinesse",
"author_id": 380229,
"author_profile": "https://Stackoverflow.com/users/380229",
"pm_score": 2,
"selected": false,
"text": "HEAD git rev-list --objects --all \\\n| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \\\n| awk -v min_mb=10 '/^blob/ && $3 >= min_mb*2^20 {print substr($0,6)}' \\\n| grep -vFf <(git ls-tree -r HEAD | awk '{print $3}') \\\n| sort --numeric-sort --key=2 \\\n| cut -c 1-12,41- \\\n| $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest\n 2ba44098e28f 12MiB path/to/hires-image.png\nbd1741ddce0d 63MiB path/to/some-video-1080p.mp4\n numfmt brew install coreutils"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] |
298,319 | <p>I have a list of tables i.e. student, teacher, staff, dept. and so on and each of these tables have comments specific to them. Now one record in a table can have one or many comments that shows it's a one to many relation from any table to comments table. I don't know what the best way is to relate comments table to each of these. If I put foreign key from comments table to each of these tables, it will be like 40-50 fields depending on no. of tables. Secondly if I add foreign key from each of these tables to remarks table, it will be like repeating whole row just for the second remarks foreign key? Similarly if I use just one field in each table as comments, I will be actually storing rows in just one text field. Any suggestions on how to achieve efficient solution?</p>
| [
{
"answer_id": 298336,
"author": "Zoredache",
"author_id": 20267,
"author_profile": "https://Stackoverflow.com/users/20267",
"pm_score": 4,
"selected": true,
"text": "Id int\nCommentType enum (student, teacher, staff, dept)\nLinkId int\nComment\n 1,'Student',347,'text'\n"
},
{
"answer_id": 298367,
"author": "user38516",
"author_id": 38516,
"author_profile": "https://Stackoverflow.com/users/38516",
"pm_score": 2,
"selected": false,
"text": "+----------+------------+\n| student | student_id |\n+----------+------------+\n| Steve | 12 |\n| Larry | 57 |\n| Sunshine | 88 |\n+----------+------------+\n\n+--------+---------+\n| dept | dept_id |\n+--------+---------+\n| Math | 2 |\n| P.E. | 5 |\n| Drama | 12 |\n+--------+---------+\n +-----------------------+------------+\n| comment | comment_id |\n+-----------------------+------------+\n| I love Math! | 3 |\n| Larry is my hero... | 5 |\n| Sunshine <3 Me! | 6 |\n+-----------------------+------------+\n +------------+------------+\n| student_id | comment_id |\n+------------+------------+\n| 57 | 5 |\n| 57 | 6 |\n+------------+------------+\n\n+---------+------------+\n| dept_id | comment_id |\n+---------+------------+\n| 2 | 3 |\n+---------+------------+\n +-----------+------------+---------+\n| entity_id | comment_id | entity |\n+-----------+------------+---------+\n| 57 | 5 | student |\n| 57 | 6 | student |\n| 2 | 3 | dept |\n+-----------+------------+---------+\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29656/"
] |
298,326 | <p>When we use getstring to get data from a recordset (ADO) then it returns all the columns.</p>
<p>If only certain columns are required, how do we modify the getstring statement?</p>
| [
{
"answer_id": 298526,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 3,
"selected": true,
"text": "strSQL=\"SELECT ID, FName, SName FROM Members\"\nrs.Open strSQL, cn\n\na=rs.GetString\n"
},
{
"answer_id": 299161,
"author": "Philippe Grondier",
"author_id": 11436,
"author_profile": "https://Stackoverflow.com/users/11436",
"pm_score": -1,
"selected": false,
"text": "myString = join(rs.getrows( , , myColumn),\";\")\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31132/"
] |
298,342 | <p>I have a Flash movie embedded in some DIV. The trouble is that when I change any property of the enclosing DIV dynamically, Firefox (not other browsers) restarts/reinitializes Flash movie effectively resetting the whole progress (eg: file selection for upload, etc.).</p>
<p>Is there some sort of a workaround for this?</p>
| [
{
"answer_id": 315332,
"author": "Kornel",
"author_id": 27009,
"author_profile": "https://Stackoverflow.com/users/27009",
"pm_score": 3,
"selected": true,
"text": "visibility:hidden position:absolute;left:-9999px"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38511/"
] |
298,346 | <p>I have written C# code for ascx. I am trying to send an email on click of image button which works in Mozilla Firefox but not in Internet Explorer.</p>
<p>This function is called on button click:</p>
<pre><code><%@ Control Language="C#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Globalization" %>
<script language="c#" runat="server">
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string from = "manoj.singh@espireinfo.com";
string to = "manoj.singh@espireinfo.com";
string subject = "Keep me Updated";
string sendguide = "";
if (optsendguide.Checked)
{
sendguide = "Yes Please send me";
}
else
{
sendguide = "No Please don't send me";
}
// build up the body text
string body = "<html><body>";
body += String.Format("<div>Title: {0} </div>", title.Text);
body += String.Format("<div>First Name: {0} </div>",firstname.Value);
body += String.Format("<div>Sur Name: {0} </div>", surname.Value);
body += String.Format("<div>Email address: {0} </div>", email.Value);
body += String.Format("<div>Break Type: {0} </div>", breakTypeDescription.Text);
body += String.Format("<div>Big weekends guide: {0} </div>", sendguide);
body += "</body></html>";
string error = Utilities.SendEmail(to, from, subject, body);
if (error == "") // success
{
Response.Redirect("index.aspx");
}
else // error
{
Response.Write(error);
}
}
}
</script>
</code></pre>
<p>Markup:</p>
<pre><code><div class="form_elm_button">
<asp:ImageButton ID="SubmitButton"
runat="server"
Text="Submit"
ImageUrl="/images/17-6164button_submit.png"
OnClick="btnSubmit_Click"
CausesValidation="true"/>
</div>
</code></pre>
| [
{
"answer_id": 1919950,
"author": "subha",
"author_id": 233568,
"author_profile": "https://Stackoverflow.com/users/233568",
"pm_score": 1,
"selected": true,
"text": " var KeyID = (window.event) ? event.keyCode : e.keyCode;\n if (KeyID == 0) {\n var image = document.getElementById(\"<%= imagetirukural.ClientID%>\");\n var label = document.getElementById(\"<%= lbltirukural.ClientID%>\");\n if (image != null) {\n\n document.getElementById(\"<%= imagetirukural.ClientID%>\").style.display = \"block\";\n InitializeTimer();\n }\n else {\n document.getElementById(\"<%= lbltirukural.ClientID%>\").style.display = \"block\";\n InitializeTimer();\n }\n }\n else if (KeyID != 0) {\n\n\n if (image != null) {\n document.getElementById(\"<%= imagetirukural.ClientID%>\").style.display = \"block\";\n }\n else {\n document.getElementById(\"<%= lbltirukural.ClientID%>\").style.display = \"block\";\n }\n\n }\n }\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30394/"
] |
298,347 | <p>I have a flash file that loads an XML file at runtime. When the <code>.swf</code> file is run locally or on an Apache server it works fine but when hosted on an IIS6 based server the file won't load. </p>
<p>Can anyone help with this?</p>
| [
{
"answer_id": 1919950,
"author": "subha",
"author_id": 233568,
"author_profile": "https://Stackoverflow.com/users/233568",
"pm_score": 1,
"selected": true,
"text": " var KeyID = (window.event) ? event.keyCode : e.keyCode;\n if (KeyID == 0) {\n var image = document.getElementById(\"<%= imagetirukural.ClientID%>\");\n var label = document.getElementById(\"<%= lbltirukural.ClientID%>\");\n if (image != null) {\n\n document.getElementById(\"<%= imagetirukural.ClientID%>\").style.display = \"block\";\n InitializeTimer();\n }\n else {\n document.getElementById(\"<%= lbltirukural.ClientID%>\").style.display = \"block\";\n InitializeTimer();\n }\n }\n else if (KeyID != 0) {\n\n\n if (image != null) {\n document.getElementById(\"<%= imagetirukural.ClientID%>\").style.display = \"block\";\n }\n else {\n document.getElementById(\"<%= lbltirukural.ClientID%>\").style.display = \"block\";\n }\n\n }\n }\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,359 | <p>Currently I have a ListView (using the Details View). I would like to implement the behaviour whereby when a user selects a single item (log entry) the log entry expands (from one line to multiple lines) to provide more detailed information about the error that occured.</p>
<p>My question is this: Is this possible? If so, is there a good resource that I can use to help me?</p>
<p>EDIT:</p>
<p>If I <em>HAVE</em> to use WPF, then I guess Ill use the ElementHost with the control. However, I have absolutely no idea as to how about designing/coding/using WPF components. Any suggestions?</p>
| [
{
"answer_id": 298710,
"author": "buggs",
"author_id": 33647,
"author_profile": "https://Stackoverflow.com/users/33647",
"pm_score": 4,
"selected": true,
"text": " <ListBox ItemsSource=\"{Binding}\">\n <ListBox.ItemTemplate>\n <DataTemplate>\n <Grid>\n <Grid.RowDefinitions>\n <RowDefinition></RowDefinition>\n <RowDefinition></RowDefinition>\n </Grid.RowDefinitions>\n\n <Grid Grid.Row=\"0\" Height=\"20\" >\n <TextBlock Text=\"Not Selected\"></TextBlock>\n </Grid>\n <Grid x:Name=\"selectedOnlyGrid\" Grid.Row=\"1\" Visibility=\"Collapsed\">\n <TextBlock Text=\"Selected\"></TextBlock>\n </Grid>\n\n </Grid>\n\n <DataTemplate.Triggers>\n <DataTrigger Binding=\"{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}, AncestorLevel=1}, Path=IsSelected}\" Value=\"True\">\n <Setter Property=\"Visibility\" Value=\"Visible\" TargetName=\"selectedOnlyGrid\" />\n </DataTrigger>\n </DataTemplate.Triggers>\n </DataTemplate>\n </ListBox.ItemTemplate>\n </ListBox>\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1816/"
] |
298,361 | <p>In previous releases there were 3 ways to pass data from controller to view AFAIK (shown below). </p>
<p>I want to use method (2) with MVC Beta 1, but I can't find the renderView method. So what's the new syntax (if it's still possible)? Thanks in advance.</p>
<p>Ben.</p>
<p>Syntax #1: Old-school dictionary</p>
<pre><code>ViewData["Name"] = "Moo-moo";
ViewData["Age"] = 6;
ViewData["HasFunnyFace"] = true;
RenderView("ShowCat");
</code></pre>
<p>Syntax #2: Explicitly-typed ViewData object</p>
<pre><code>RenderView("ShowCat", new ShowCatViewData {
Name = "Moo-moo",
Age = 6,
HasFunnyFace = true
});
</code></pre>
<p>Syntax #3: Anonymously-typed object</p>
<pre><code>RenderView("ShowCat", new {
Name = "Moo-moo",
Age = 6,
HasFunnyFace = true
});
</code></pre>
| [
{
"answer_id": 298383,
"author": "Kieron",
"author_id": 5791,
"author_profile": "https://Stackoverflow.com/users/5791",
"pm_score": 3,
"selected": true,
"text": "return View (\"ShowCat\", <TYPED_DATA_SET_OR_OTHER_MODEL>);\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38522/"
] |
298,363 | <p>I create new ASP.NET web application that use SMTP to send message. The problem is the smtp was not authenticated from who send the message. </p>
<p>How can I make SMTP authenticated in my program? does C# have a class that have attribute for enter username and password?</p>
| [
{
"answer_id": 298379,
"author": "Arief",
"author_id": 34096,
"author_profile": "https://Stackoverflow.com/users/34096",
"pm_score": 8,
"selected": true,
"text": "using System.Net;\nusing System.Net.Mail;\n\nusing(SmtpClient smtpClient = new SmtpClient())\n{\n var basicCredential = new NetworkCredential(\"username\", \"password\"); \n using(MailMessage message = new MailMessage())\n {\n MailAddress fromAddress = new MailAddress(\"from@yourdomain.com\"); \n\n smtpClient.Host = \"mail.mydomain.com\";\n smtpClient.UseDefaultCredentials = false;\n smtpClient.Credentials = basicCredential;\n\n message.From = fromAddress;\n message.Subject = \"your subject\";\n // Set IsBodyHtml to true means you can send HTML email.\n message.IsBodyHtml = true;\n message.Body = \"<h1>your message body</h1>\";\n message.To.Add(\"to@anydomain.com\"); \n\n try\n {\n smtpClient.Send(message);\n }\n catch(Exception ex)\n {\n //Error, could not send the message\n Response.Write(ex.Message);\n }\n }\n}\n"
},
{
"answer_id": 298382,
"author": "Tor Haugen",
"author_id": 32050,
"author_profile": "https://Stackoverflow.com/users/32050",
"pm_score": 1,
"selected": false,
"text": "System.Net.Mail SmtpClient.Credentials"
},
{
"answer_id": 27896967,
"author": "Joseph King",
"author_id": 946265,
"author_profile": "https://Stackoverflow.com/users/946265",
"pm_score": 7,
"selected": false,
"text": "SmtpClient.Credentials SmtpClient.UseDefaultCredentials = false SmtpClient.UseDefaultCredentials = false SmtpClient.Credentials"
},
{
"answer_id": 47051556,
"author": "Jason Dang",
"author_id": 5307488,
"author_profile": "https://Stackoverflow.com/users/5307488",
"pm_score": 2,
"selected": false,
"text": "string to = \"jane@contoso.com\";\nstring from = \"ben@contoso.com\";\nMailMessage message = new MailMessage(from, to);\nmessage.Subject = \"Using the new SMTP client.\";\nmessage.Body = @\"Using this new feature, you can send an e-mail message from an application very easily.\";\nSmtpClient client = new SmtpClient(server);\n// Credentials are necessary if the server requires the client \n// to authenticate before it will send e-mail on the client's behalf.\nclient.UseDefaultCredentials = true;\nclient.EnableSsl = true;\nclient.Send(message);\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36446/"
] |
298,370 | <p>Is it possible to change java lookandfeel without modifying the program in a real-world environment?</p>
<p>I know that theoretically the answer is yes. I also created demo applications and changed the lookandfeel even at runtime and it worked. But when I created a real application with lots of controls lookandfeel change was not really working:</p>
<ul>
<li>Different lookandfeels have different bugs (or strange features). For instance some of them creates the same style for JTextField and JFormattedTextField, some of them uses different styles. This change can be quite annoying for users.</li>
<li>Control sizes are not the same (using different fonts, different borders), so sometimes the window looks ugly after change.</li>
<li>Keyboard shortcuts can also be different.</li>
<li>...</li>
</ul>
<p>In my applications after lookandfeel change (actually instead of changing the lookandfeel I tried using the same lookandfeel with different skins) I always have to modify the application. Not a very big modification, but lots of small modifications which makes lookandfeel change difficult.</p>
<p>Am I just very unlucky with the lookandfeels I tried (currently using <a href="http://www.l2fprod.com/skinlf/" rel="nofollow noreferrer">skinlf</a>), or lookandfeel change is not that easy as in small demo applications?</p>
<p>UPDATE: I'm using Swing and changing to other GUI library is not possible for me right now.</p>
<p><strong>UPDATE2</strong>: It seems to me the question was not clear. I do know how to change the lookandfeel. My questions is: Is it possible to create a real application where changing lookandfeel (or the skin of the lookandfeel) is an easy task? Currently if I change the lookandfeel it is not enough to change 2 or 3 lines, I have to review the whole application and fix quite a few problems caused by the lookandfeel change. dhiller suggested replacing skinlf with a better lookandfeel. Can you show me a skinable lookandfeel where skin replacement works better?</p>
| [
{
"answer_id": 298438,
"author": "reallyinsane",
"author_id": 35407,
"author_profile": "https://Stackoverflow.com/users/35407",
"pm_score": 2,
"selected": false,
"text": "java -jar yourapp.jar\n java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -jar yourapp.jar\n"
},
{
"answer_id": 298522,
"author": "Daniel Hiller",
"author_id": 16193,
"author_profile": "https://Stackoverflow.com/users/16193",
"pm_score": 1,
"selected": false,
"text": " UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21348/"
] |
298,373 | <p>Normally, in Delphi one would declare a function with a variable number of arguments using the 'array of const' method. However, for compatibility with code written in C, there's an much-unknown 'varargs' directive that can be added to a function declaration (I learned this while reading Rudy's excellent '<a href="http://rvelthuis.de/articles/articles-convert.html#varargs" rel="noreferrer">Pitfalls of convering</a>' document).</p>
<p>As an example, one could have a function in C, declared like this :</p>
<pre><code>void printf(const char *fmt, ...)
</code></pre>
<p>In Delphi, this would become :</p>
<pre><code>procedure printf(const fmt: PChar); varargs;
</code></pre>
<p>My question is : How can I get to the contents of the stack when implementing a method which is defined with the 'varargs' directive?</p>
<p>I would expect that some tooling for this exists, like Dephi translations of the va_start(), va_arg() and va_end() functions, but I can't find this anywhere.</p>
<p>Please help!</p>
<p>PS: Please don't drift off in discussions about the 'why' or the 'array of const' alternative - I need this to write C-like patches for functions inside Xbox games (see the Delphi Xbox emulator project 'Dxbx' on sourceforge for details).</p>
| [
{
"answer_id": 298603,
"author": "Barry Kelly",
"author_id": 3712,
"author_profile": "https://Stackoverflow.com/users/3712",
"pm_score": 5,
"selected": true,
"text": "{$apptype console}\n\ntype \n TArgPtr = record\n private\n FArgPtr: PByte;\n class function Align(Ptr: Pointer; Align: Integer): Pointer; static;\n public\n constructor Create(LastArg: Pointer; Size: Integer);\n // Read bytes, signed words etc. using Int32\n // Make an unsigned version if necessary.\n function ReadInt32: Integer;\n // Exact floating-point semantics depend on C compiler.\n // Delphi compiler passes Extended as 10-byte float; most C\n // compilers pass all floating-point values as 8-byte floats.\n function ReadDouble: Double;\n function ReadExtended: Extended;\n function ReadPChar: PChar;\n procedure ReadArg(var Arg; Size: Integer);\n end;\n\nconstructor TArgPtr.Create(LastArg: Pointer; Size: Integer);\nbegin\n FArgPtr := LastArg;\n // 32-bit x86 stack is generally 4-byte aligned\n FArgPtr := Align(FArgPtr + Size, 4);\nend;\n\nclass function TArgPtr.Align(Ptr: Pointer; Align: Integer): Pointer;\nbegin\n Integer(Result) := (Integer(Ptr) + Align - 1) and not (Align - 1);\nend;\n\nfunction TArgPtr.ReadInt32: Integer;\nbegin\n ReadArg(Result, SizeOf(Integer));\nend;\n\nfunction TArgPtr.ReadDouble: Double;\nbegin\n ReadArg(Result, SizeOf(Double));\nend;\n\nfunction TArgPtr.ReadExtended: Extended;\nbegin\n ReadArg(Result, SizeOf(Extended));\nend;\n\nfunction TArgPtr.ReadPChar: PChar;\nbegin\n ReadArg(Result, SizeOf(PChar));\nend;\n\nprocedure TArgPtr.ReadArg(var Arg; Size: Integer);\nbegin\n Move(FArgPtr^, Arg, Size);\n FArgPtr := Align(FArgPtr + Size, 4);\nend;\n\nprocedure Dump(const types: string); cdecl;\nvar\n ap: TArgPtr;\n cp: PChar;\nbegin\n cp := PChar(types);\n ap := TArgPtr.Create(@types, SizeOf(string));\n while True do\n begin\n case cp^ of\n #0: \n begin\n Writeln;\n Exit;\n end;\n\n 'i': Write(ap.ReadInt32, ' ');\n 'd': Write(ap.ReadDouble, ' ');\n 'e': Write(ap.ReadExtended, ' ');\n 's': Write(ap.ReadPChar, ' ');\n else\n Writeln('Unknown format');\n Exit;\n end;\n Inc(cp);\n end;\nend;\n\ntype\n PDump = procedure(const types: string) cdecl varargs;\nvar\n MyDump: PDump;\n\nfunction AsDouble(e: Extended): Double;\nbegin\n Result := e;\nend;\n\nfunction AsSingle(e: Extended): Single;\nbegin\n Result := e;\nend;\n\nprocedure Go;\nbegin\n MyDump := @Dump;\n\n MyDump('iii', 10, 20, 30);\n MyDump('sss', 'foo', 'bar', 'baz');\n\n // Looks like Delphi passes Extended in byte-aligned\n // stack offset, very strange; thus this doesn't work.\n MyDump('e', 2.0);\n // These two are more reliable.\n MyDump('d', AsDouble(2));\n // Singles passed as 8-byte floats.\n MyDump('d', AsSingle(2));\nend;\n\nbegin\n Go;\nend.\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12170/"
] |
298,385 | <p>Is it possible to get a list of all instances with a name in a flash movie using actionscript 2. Like an array containing all named text areas, or all movieClip instances etc. I would like to get this so the designer can add or remove text areas etc. and the actionscript can dynamically find these and get the texts from a separate datasource. </p>
<p>I guess what I want is something like a DOM tree or even better something like how getElementByName() works in JavaScript. And allso get the string value of the instance name so I can find it's text value in an xml.</p>
<p>Let's say the designer add a new text area with the name "copyright" and my code should (without having to change the script) find the data with the id "copyright" in an XML file if it is there, and add the value to the text area.</p>
| [
{
"answer_id": 299578,
"author": "defmeta",
"author_id": 10875,
"author_profile": "https://Stackoverflow.com/users/10875",
"pm_score": 0,
"selected": false,
"text": "for (var i in this) {\n if (typeof (this[i]) == \"movieclip\") {\n trace(\"movie clip '\"+this[i]._name+\"' is at depth \"+this[i].getDepth());\n }\n}\n"
},
{
"answer_id": 300905,
"author": "fenomas",
"author_id": 10651,
"author_profile": "https://Stackoverflow.com/users/10651",
"pm_score": 1,
"selected": false,
"text": "_root _name"
},
{
"answer_id": 312826,
"author": "defmeta",
"author_id": 10875,
"author_profile": "https://Stackoverflow.com/users/10875",
"pm_score": 3,
"selected": true,
"text": "private function traceAllChildren(rootContainer:DisplayObjectContainer):void {\n for(var i=0; i < rootContainer.numChildren; i++) {\n var item:* = rootContainer.getChildAt(i);\n try {\n traceAllChildren(item);\n } catch (e:Error) {\n trace(e.toString());\n }\n trace(item.toString());\n // This is the block where you can affect\n // an 'item' depending on it's type, name, etc..\n // eg: \n // if (item.toString() == '[object TextField]') {\n // item.text = \"The text I want to insert\";\n // }\n // or\n // if (item.name == myTextFieldNameVar) {\n // item.text = \"The text I want to insert\";\n // }\n }\n}\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26115/"
] |
298,391 | <p>I'm a little bit stuck with a asp.net project that i'm doing! I have got a class that is called from the code behind and many of its function have no return type ie, being void. How does one do exception handling then??? Also, if the function within the class does have a return type of, for instance, a dataset how would one then return an exception or indicate that an exception had occured? I have attached the following code from my class which is referenced from the code behind.</p>
<pre><code>public void fnRecord(string []varList, string fnName)
{
try
{
String x;
StringBuilder SQLParameters = new StringBuilder();
SQLParameters.AppendLine("SELECT #{Function}(");
{
SQLParameters.Replace("#{Function}", fnName);
}
for (int i = 0; i < varList.Length; i++)
{
x = varList[i].ToString();
SQLParameters.Append("'" + x + "',");
}
SQLParameters.Remove((SQLParameters.Length - 1), 1);
SQLParameters.Append(")");
string SQLCMD = SQLParameters.ToString();
conn.Open();
NpgsqlCommand command = new NpgsqlCommand(SQLCMD, conn);
Object result = command.ExecuteScalar();
}
catch (NpgsqlException ne)
{
//return ne;
}
catch (Exception x)
{
//error code
}
finally
{
conn.Close();
}
}
</code></pre>
<p>Any help would be appreciated!</p>
<p>Thanks</p>
| [
{
"answer_id": 298413,
"author": "Tor Haugen",
"author_id": 32050,
"author_profile": "https://Stackoverflow.com/users/32050",
"pm_score": 0,
"selected": false,
"text": "catch (NpgsqlException ne)\n{\n throw new Exception(\"Your explanatory message here\", ne);\n}\nfinally\n{\n ...\n}\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,432 | <p>I have a really simple ASP.NET web application and a web setup project that deploys the project output and content files to a virtual directory in IIS.</p>
<p>What I want is for the MSI to automatically disable Anonymouse Access for that virtual folder in IIS. </p>
<p>I suspect it can probably be done by writing some code in a custom action DLL, that would be acceptable, but is there any way to do it within the the settings of the web setup project?</p>
| [
{
"answer_id": 314042,
"author": "Ian G",
"author_id": 31765,
"author_profile": "https://Stackoverflow.com/users/31765",
"pm_score": 3,
"selected": false,
"text": "web.config <system.web>\n<authentication mode=\"Windows\"/>\n<authorization>\n <deny users=\"?\"/> \n</authorization>\n</system.web>\n"
},
{
"answer_id": 35159899,
"author": "Rae Lee",
"author_id": 5113582,
"author_profile": "https://Stackoverflow.com/users/5113582",
"pm_score": 0,
"selected": false,
"text": "<configuration>\n <system.web>\n <compilation debug=\"true\" targetFramework=\"4.0\" />\n <authentication mode=\"Forms\">\n <forms loginUrl=\"SignIn.aspx\" defaultUrl=\"Welcome.aspx\" protection=\"All\">\n <credentials passwordFormat=\"Clear\">\n <user name=\"lee\" password=\"lee12345\"/>\n <user name=\"add\" password=\"add12345\"/>\n </credentials>\n </forms>\n </authentication>\n\n <authorization>\n <deny users=\"?\" /> //deny acces to anonymous users\n </authorization>\n </system.web>\n\n</configuration>\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1039/"
] |
298,446 | <p>I've just started building a prototype application in Django. I started out by working through the <a href="http://docs.djangoproject.com/en/dev/intro/tutorial01/" rel="nofollow noreferrer">Django app tutorial on the Django site</a> which was pretty helpful, and gave me what I needed to get started. Now I have a couple of what I hope are very simple questions:</p>
<p>I want to put a loop into views.py, looping over a set of variables that have been passed in from a form. So I have a load of items in the HTML form, each of which has a SELECT drop-down list for people to select a score from 0-10, like this:</p>
<pre><code><select name="score1">
<option value=0 SELECTED>No score</option>
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
<option value=7>7</option>
<option value=8>8</option>
<option value=9>9</option>
<option value=10>10</option>
</select>
</code></pre>
<p>So I have, let's say, 100 of these variables, score1, score2, score3, ..., score99, score100. When the form is submitted, I want to loop through each of these variables and see if it's been set (i.e. is not 0) and if so, I want to store that value in a suitable place in the database. My problem is that I can't figure out how to loop through those variables.
I'm guessing that I want something like this:</p>
<pre><code>for o in request.POST.all
endfor
</code></pre>
<p>but then I'm really not sure what to do with that.</p>
<p>I'm not looking for someone to write the code for me, really: I just would like some guidance on how to write a loop like this in python / Django, and also maybe some pointers as to a good reference guide I can either see online or buy that will give me access to this kind of thing.</p>
<p>Also, the select object above I created pretty much by hand, and I'd really like to be able to ue a loop to generate it in the template in the first place. My template currently has this:</p>
<pre><code><table>
{% for movie in movie_list %}
<tr>
<td> {{ movie }} </td>
<td>
<select name="score{{ movie.id }}">
<option value=0 SELECTED>No score</option>
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
<option value=7>7</option>
<option value=8>8</option>
<option value=9>9</option>
<option value=10>10</option>
</select>
</td></tr>
{% endfor %}
</table>
</code></pre>
<p>I feel like there must be a way to create a simple loop that counts from 1 to 10 that would generate most of those options for me, but I can't figure out how to do that...</p>
| [
{
"answer_id": 298489,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 4,
"selected": true,
"text": "{{form}}"
},
{
"answer_id": 298499,
"author": "Alexander Kojevnikov",
"author_id": 712,
"author_profile": "https://Stackoverflow.com/users/712",
"pm_score": 1,
"selected": false,
"text": "{% for %}"
},
{
"answer_id": 300462,
"author": "EoghanM",
"author_id": 6691,
"author_profile": "https://Stackoverflow.com/users/6691",
"pm_score": 1,
"selected": false,
"text": "<select name=\"score{{ movie.id }}\">\n <option value=0 SELECTED>No score</option>\n {% for i in range(1, 11) %}\n <option value={{ i }}>{{ i }}</option>\n {% endfor %}\n</select>\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11522/"
] |
298,449 | <p>I have the following code for my masterpage:</p>
<pre><code><%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server" style="position:relative">
<title>Masterpage</title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="main" runat="server" style="position:relative">
<div>
<asp:ContentPlaceHolder id="MainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
<br style="clear:both" />
<form id="footer" style="position:relative">
<div>
<center style="font-size:small">Footer content</center>
</div>
</form>
</body>
</html>
</code></pre>
<p>My problem is that when the MainContent isn't filling up the page the footer is not at the bottom of the page. Is there a way to force the footer to stay on the bottom of the page if the main content isn't pushing it all the way down? When the main content is "big" enough it pushes the footer down with the content and displays on the bottom when scrolling down, but not if it is to small.</p>
<p>Anybody know how to fix this?</p>
| [
{
"answer_id": 463265,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "bottom:0px;\nposition:absolute;\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,456 | <p>I just want to create a C# program which will read a word template and create n number of copies of it with mail merge feature.The data to replace is Name and Address the rest of the things in the template should remains the same. Can any one tell me how to do this ?</p>
| [
{
"answer_id": 303367,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 0,
"selected": false,
"text": " strDir = CurrentProject.Path \n\n strMailmergeDataFilename = strDir & Format(Now, \"yymmdd_hhnnss\") & \".txt\"\n\n' Create CSV from database for use with mailmerge '\n' This is a separate function that simply exports the sql '\n' ExportSQLToCSV SQL, strMailmergeDataFilename '\n\n'Open merge template '\nSet objWordDoc = GetObject(strDir & MergeDocumentFilename, \"Word.Document\")\n\nobjWordDoc.Application.Visible = True \n\n'Format:=0 ''0 = wdOpenFormatAuto'\n'Add the data source '\nobjWordDoc.MailMerge.OpenDataSource _\n Name:=strMailmergeDataFilename, ConfirmConversions:=False, _\n ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _\n PasswordDocument:=\"\", PasswordTemplate:=\"\", WritePasswordDocument:=\"\", _\n WritePasswordTemplate:=\"\", Revert:=False, Format:=0, _\n Connection:=\"\", SQLStatement:=\"\", SQLStatement1:=\"\"\n\n'Type some text at a bookmark, you could use .range property ' \nSelection.Goto What:=wdGoToBookmark, Name:=\"signaturetext\"\nSelection.TypeText Text:=\"You are here\"\n\n'Run mailmerge '\nobjWordDoc.MailMerge.Destination = 0 '0 = wdSendToNewDocument'\n\nobjWordDoc.MailMerge.Execute\n\nobjWordDoc.Application.ActiveDocument.PrintPreview\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,460 | <p>I'm working on a <a href="http://userstyles.org/styles/12154" rel="nofollow noreferrer">Youtube userstyle script</a> that displays comments side by side with the video so you can watch the video and read the comments at the same time (what a marvelous idea - duh). You can see in the screenshots how far I've got. That means I only care about Firefox, and that CSS3 goes.</p>
<p>The problem I have is that I want to make a fully fluid layout and have the "other videos" div float to the right, while the middle div (the comments) stretches to fill the remaining space between the left div (the video played) and the right div (the "other videos").</p>
<p>Translated to CSS, the problem is: given divs "main", "rightnav" and "footer", in this fixed order in the document, how can I make the rightnav div float to the right, and the footer BELOW it? The best I managed to do was to absolutely position "rightnav" (right: 0), but then the footer goes below the "main" div, not below both of them. I've looked at <a href="https://stackoverflow.com/questions/220273/css-positioning-div-above-another-div-when-not-in-that-order-in-the-html">Use CSS to reorder DIVs</a> already. Negative 'top' values are out, as they depend on the content of the 'main' div.</p>
<p>Here's the source code:</p>
<pre><code><html lang="en-US">
<head>
<style type="text/css">
#main {
border: 1px solid;
float: left;
margin-right: 410px;
}
#rightnav {
background-color: yellow;
opacity: 0.5;
border: 1px dotted;
width: 400px;
float: right;
position: absolute;
right: 0;
}
#footer {
clear: both;
}
</style>
</head>
<body>
<div id="baseDiv" style="width: 100%">
<div id="main">
<script>for (var i=1; i<100; i++) document.write('main ');</script>
</div>
<div id="rightnav">
<script>for (var i=1; i<200; i++) document.write('rightnav ');</script>
</div>
<div id="footer">
<script>for (var i=1; i<100; i++) document.write('footer ');</script>
</div>
</div>
</body>
</html>
</code></pre>
<p>Hopefully it's clear what I want to achieve: the "footer" below the two divs, and the "main" div fluid.</p>
<p>Thanks for any ideas.</p>
| [
{
"answer_id": 298541,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 2,
"selected": false,
"text": "#main {\n border: 1px solid;\n width: 50%;\n float: left;\n}\n\n#rightnav {\n background-color: yellow;\n opacity: 0.5;\n border: 1px dotted;\n width: 48%;\n float: right;\n}\n\n#footer {\n clear: both;\n} \n"
},
{
"answer_id": 2039317,
"author": "Shawn",
"author_id": 247713,
"author_profile": "https://Stackoverflow.com/users/247713",
"pm_score": 1,
"selected": false,
"text": " <!--BEGIN HEADER-->\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"ltr\" lang=\"en-US\">\n\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n\n <title>float3col demo</title>\n\n <style>\n #tub_con{\n display:block;\n position:relative;\n text-align:center;\n width:500px;\n height:auto;\n margin-left:auto;\n margin-right:auto;\n border: solid #000000;\n }\n\n #left_nav{\n display:block;\n position:relative;\n float:left;\n height:80px;\n width:30%;\n\n max-width:30%;\n border: solid #000000;\n }\n #right_nav{\n display:block;\n position:relative;\n float:right;\n height:80px;\n width:30%;\n border: solid #000000;\n }\n #mid_cont{\n display:block;\n position:relative;\n padding-top:5px;\n margin-left:auto;\n margin-right:auto;\n height:auto;\n width:35%;\n border: solid #f86fff;\n }\n *html #mid_cont{\n display:block;\n position:relative;\n padding-top:5px;\n margin-left:auto;\n margin-right:auto;\n height:auto;\n width:100%;\n border: solid #f86fff;\n }\n\n </style>\n</head>\n\n<body style=\"text-align:center;\">\n<div id=\"tub_con\">\n<div id=\"left_nav\"></div>\n<div id=\"right_nav\">\n</div>\n<div id=\"mid_cont\">\nx x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x \n</div>\n\n<!--Test the stacking problem\n <div id=\"mid_cont\">\nx x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x \n</div>-->\n\n<div style=\"clear:both;\"></div>\n</div>\n\n<p style=\"width:100px; border:solid #000000; margin-left:auto; margin-right:auto;\">\nx x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x\n</p>\n</body>\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1269037/"
] |
298,463 | <p>This is the HTML:</p>
<pre><code><div id="testBlue">
<span>hello</span>
<span id="testGreen" class="testGreen">hello2</span>
</div>
</code></pre>
<p>If I have set in CSS:</p>
<pre><code>#testBlue span { color:Blue; }
.testGreen, #testGreen { color:Green; }
</code></pre>
<p>How can I override the general style in the second SPAN?</p>
<p>I have tried both id and class selectors but it doesnt override it.</p>
| [
{
"answer_id": 298468,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 2,
"selected": false,
"text": "#testGreen { color: red !important;}\n .testGreen { color: red !important;}\n !important"
},
{
"answer_id": 298472,
"author": "Allen Hardy",
"author_id": 11394,
"author_profile": "https://Stackoverflow.com/users/11394",
"pm_score": 3,
"selected": false,
"text": "#testBlue span { color:Blue; } \n#testblue #testgreen{color:Red}\n"
},
{
"answer_id": 298475,
"author": "pbrodka",
"author_id": 33093,
"author_profile": "https://Stackoverflow.com/users/33093",
"pm_score": 0,
"selected": false,
"text": "#testBlue * { color:Blue; } \n"
},
{
"answer_id": 298477,
"author": "alexmeia",
"author_id": 36587,
"author_profile": "https://Stackoverflow.com/users/36587",
"pm_score": 4,
"selected": true,
"text": "#testBlue span.testGreen {\n color: green;\n}\n"
},
{
"answer_id": 298542,
"author": "Nakul Chaudhary",
"author_id": 34588,
"author_profile": "https://Stackoverflow.com/users/34588",
"pm_score": 1,
"selected": false,
"text": "span#testGreen\n{\n color: green;\n}\n"
},
{
"answer_id": 6896714,
"author": "Paul Sullivan",
"author_id": 697060,
"author_profile": "https://Stackoverflow.com/users/697060",
"pm_score": 0,
"selected": false,
"text": "#testblue > span:first-child + span{}\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4264/"
] |
298,466 | <p>[This code is called from within the <code>Inspector.Activate</code> event handler (first call), i.e. right before the inspector window is actually shown.]</p>
<p>For "native" mail inspectors I can simply QI the <code>Inspector</code> interface to <code>IOleWindow</code> and call its <code>GetWindow</code> method. However, this will not work for Word inspectors which are in fact instances of Word with a special toolbar and do not implement <code>IOleWindow</code>.</p>
<p>(Temporarily) setting <code>Inspector.Caption</code> to some unique value and then looking for a window with that caption also does not work as accessing most properties of the <code>Inspector</code> simply has no (immediate) effect on the actual inspector window when using the WordMail option. Neither does calling <code>Activate</code> and then immediately querying <code>GetForegroundWindow</code> work reliably: when there are multiple inspectors already open or when actual Word windows are present this will often just return the "oldest" instance instead of the most recent one.</p>
<p>I have tried a number of other approaches over the years but they all eventually turned out to be flawed in some way or another. Is there a moderately simple solution to this at all or will I have to go for a much more elaborate approach like keeping my own list of known window handles via a system hook and trying to match them up against the known inspectors somehow? (hat tip to <a href="https://stackoverflow.com/questions/295996/is-the-order-in-which-handles-are-returned-by-enumwindows-meaningful#296014">P Daddy</a> for the hint about using CBT hooks)</p>
| [
{
"answer_id": 5181280,
"author": "Oliver Giesen",
"author_id": 9784,
"author_profile": "https://Stackoverflow.com/users/9784",
"pm_score": 2,
"selected": true,
"text": "EnumWindows IsWindowVisible False Inspector.Activate function GetWindowClassName(const AHandle: HWND): String;\nvar\n lClass: array[0..255] of Char;\nbegin\n if GetClassName(AHandle, lClass, SizeOf(lClass)) > 0 then\n Result := lClass\n else\n Result := '';\nend;\n\ntype\n TWordSearchInfo = record\n Result: HWND;\n end;\n PWordSearchInfo = ^TWordSearchInfo;\n\nfunction CheckWnd(AWnd: HWND; ASearchInfo: PWordSearchInfo): Boolean; stdcall;\nbegin\n Result := True;\n try\n if GetWindowClassName(AWnd) = 'OpusApp' then\n if not IsWindowVisible(AWnd) then\n begin\n ASearchInfo.Result := AWnd;\n Exit(False);\n end;\n except\n //plop!\n end;\nend;\n\nfunction GetNewestWordHandle: Cardinal;\nvar\n lSearchInfo: TWordSearchInfo;\nbegin\n lSearchInfo.Result := 0;\n EnumWindows(@CheckWnd, Integer(@lSearchInfo));\n Result := lSearchInfo.Result;\nend;\n Activate IsWordMail True"
},
{
"answer_id": 5298819,
"author": "Moox",
"author_id": 356437,
"author_profile": "https://Stackoverflow.com/users/356437",
"pm_score": 0,
"selected": false,
"text": "\ninspectorWindow = Win32.FindWindowEx(IntPtr.Zero, IntPtr.Zero, \"OpusApp\", \"Microsoft Word\");\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9784/"
] |
298,491 | <p>I want to close a System.Windows.Forms.Form if the user clicks anywhere outside it. I've tried using IMessageFilter, but even then none of the messages are passed to PreFilterMessage. How do I receive clicks outside a form's window?</p>
| [
{
"answer_id": 298512,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 3,
"selected": false,
"text": "public void SetVolume(int volume)\n{\n // do something with the volume - whatever you did before with it\n}\n VolumeSlider slider = new VolumeSlider();\nslider.Show(this); // the \"this\" is needed for the next step\n MainForm owner = (MainForm)this.Owner;\nowner.SetVolume(scrollbar.Value);\n"
},
{
"answer_id": 301341,
"author": "Simon",
"author_id": 15371,
"author_profile": "https://Stackoverflow.com/users/15371",
"pm_score": 4,
"selected": true,
"text": "protected override void OnShown(EventArgs e)\n{\n base.OnShown(e);\n this.Capture = true;\n}\n\nprotected override void OnCaptureChanged(EventArgs e)\n{\n if (!this.Capture)\n {\n if (!this.RectangleToScreen(this.DisplayRectangle).Contains(Cursor.Position))\n {\n this.Close();\n }\n else\n {\n this.Capture = true;\n }\n }\n\n base.OnCaptureChanged(e);\n}\n"
},
{
"answer_id": 11743238,
"author": "rkraen",
"author_id": 1566133,
"author_profile": "https://Stackoverflow.com/users/1566133",
"pm_score": 2,
"selected": false,
"text": "protected override void WndProc(ref Message m)\n{ \n base.WndProc(ref m);\n\n // if click outside dialog -> Close Dlg\n if (m.Msg == NativeConstants.WM_NCACTIVATE) //0x86\n {\n if (this.Visible)\n {\n if (!this.RectangleToScreen(this.DisplayRectangle).Contains(Cursor.Position))\n this.Close();\n }\n }\n}\n"
},
{
"answer_id": 41190484,
"author": "Sharif Lotfi",
"author_id": 5848472,
"author_profile": "https://Stackoverflow.com/users/5848472",
"pm_score": 0,
"selected": false,
"text": "Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click\n Form2.Owner = Me\n Form2.Show()\nEnd Sub\n Private Sub Form1_MouseClick(sender As Object, e As MouseEventArgs) Handles Me.MouseClick\n If Form2.IsHandleCreated = True Then\n Form2.Close()\n End If\nEnd Sub\n"
},
{
"answer_id": 42856041,
"author": "Hiep Nguyen",
"author_id": 6448792,
"author_profile": "https://Stackoverflow.com/users/6448792",
"pm_score": 0,
"selected": false,
"text": "private void button1_Click(object sender, EventArgs e)\n {\n Form f = new Form();\n f.LostFocus +=new EventHandler(f_LostFocus);\n f.Show();\n }\n\n void f_LostFocus(object sender, EventArgs e)\n {\n Form f = sender as Form;\n f.Close();\n f.Dispose();\n }\n"
},
{
"answer_id": 63608379,
"author": "Vương Hữu Thiện",
"author_id": 12569619,
"author_profile": "https://Stackoverflow.com/users/12569619",
"pm_score": 1,
"selected": false,
"text": "private void Form2_Deactivate(object sender, EventArgs e)\n{\n this.Close();\n}\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] |
298,494 | <p>I have many jobs that have a step to send 1 specific email out to a list of people. That list of reciepients is hardcoded in the step command and I need to remove one person from that list, in all jobs.</p>
<p>How do I loop through ALL the jobs in the Sql Server Agent and modify the command text to find+replace a specific piece of text. </p>
<p>I am using sql server 2005 and have already looked at sp_update_jobStep but doesn't appear to be exactly what i want.</p>
<p>Cheers.</p>
| [
{
"answer_id": 298792,
"author": "Tim C",
"author_id": 7585,
"author_profile": "https://Stackoverflow.com/users/7585",
"pm_score": 4,
"selected": true,
"text": "msdb.dbo.SysJobs\nmsdb.dbo.SysJobSteps\n UPDATE SJS SET\n Command = REPLACE(Command, 'EmailAddress&TestDomain.Com', '')\nFROM msdb.dbo.SysJobs SJ\nINNER JOIN msdb.dbo.SysJobSteps SJS\n ON SJS.Job_Id = SJ.Job_Id\nWHERE SJ.Originating_server = ..... -- Your server here\n AND SJS.Command LIKE '%EmailAddress@TestDomain.Com%'\n"
},
{
"answer_id": 29417264,
"author": "Kartar Rana",
"author_id": 4743160,
"author_profile": "https://Stackoverflow.com/users/4743160",
"pm_score": 0,
"selected": false,
"text": "/*\nReplace the below statement with the actual keyword to be replaced:\nINSERT INTO SP_Keyword VALUES\n('sys.databases3', 'sys.databases5')\n,('sysjobs3', 'sysjobs5')\n\nHere we are replacing sys.databases3 and sysjobs3 \nwith sys.databases5 and sysjobs5 respectively.\n\nScript only searches in 'TSQL', 'Powershell', 'CMDEXEC' job type.\n*/\n\nSET NOCOUNT ON\n\nuse msdb\nGO\n\nDECLARE @OldV VARCHAR(max) \nDECLARE @NEWV VARCHAR(max)\nDECLARE @job_id2 varchar(max)\nDECLARE @step_id2 varchar(10)\nDECLARE @command2 varchar(max)\nDECLARE @command3 varchar(300)\n\n--CLEANUP TASKS\nIF EXISTS(SELECT * FROM sys.tables where name = 'SP_Keyword')\n DROP TABLE SP_Keyword\n\nCREATE TABLE SP_Keyword\n(\nold_keyword varchar(200),\nnew_keyword varchar(200)\n)\n\n--DEBUG STATEMENT\n--PRINT 'SP_Keyword TABLE CREATED'\n\nINSERT INTO SP_Keyword VALUES\n('sys.databases3', 'sys.databases5')\n,('sysjobs3', 'sysjobs5')\n\n--DEBUG STATEMENT\n--PRINT 'VALUES INSERTED FOR KEYWORD'\n\nCREATE TABLE #jobs(\n [name] [sysname] ,\n [step_name] [sysname] ,\n [subsystem] [varchar](40) ,\n [command] [varchar](max) ,\n [keyword] [varchar](200) ,\n [database_name] [sysname] ,\n [enabled] [tinyint] ,\n [description] [varchar](512) ,\n [date_created] [datetime] ,\n [job_id] [uniqueidentifier] ,\n [step_id] [int] \n)\n\nDECLARE db_cursor3 CURSOR FOR \nSELECT old_keyword FROM SP_Keyword\n OPEN db_cursor3 \n FETCH NEXT FROM db_cursor3 INTO @OldV\n\n WHILE @@FETCH_STATUS = 0 \n BEGIN \n INSERT INTO #jobs\n SELECT a.name as job_name, b.step_name, b.subsystem, \n b.command, @OldV as 'keyword', b.database_name, a.enabled, \n a.description, a.date_created, b.job_id, b.step_id\n FROM [dbo].[sysjobsteps] as b\n INNER JOIN sysjobs as a\n ON a.job_id = b.job_id\n WHERE [command] LIKE '%'+@OldV+'%'\n AND [subsystem] IN ('TSQL', 'Powershell', 'CMDEXEC')\n\n FETCH NEXT FROM db_cursor3 INTO @OldV\n END \n\n CLOSE db_cursor3 \n DEALLOCATE db_cursor3\n\nIF NOT EXISTS(SELECT * FROM #jobs)\n BEGIN\n PRINT 'NO JOBS FOUND TO BE REPLACED'\n GOTO SKIPPER\n END\n--SELECT name as job_name, step_name, command, keyword, database_name, enabled, description, date_created FROM #jobs\n\n DECLARE db_cursor3 CURSOR FOR \n SELECT * FROM SP_Keyword\n\n OPEN db_cursor3 \n FETCH NEXT FROM db_cursor3 INTO @OldV,@newV\n\n WHILE @@FETCH_STATUS = 0 \n BEGIN \n UPDATE #jobs SET command=REPLACE(command,@oldV,@NewV)\n WHERE command LIKE '%'+@OldV+'%'\n FETCH NEXT FROM db_cursor3 INTO @oldV,@NewV\n END \n\n CLOSE db_cursor3 \n DEALLOCATE db_cursor3\n\n print 'COMMAND TO REPLACE JOB STEPS IS BEING EXECUTED'\n\n DECLARE db_cursor3 CURSOR FOR \n SELECT job_id, step_id, command FROM #jobs\n\n OPEN db_cursor3 \n FETCH NEXT FROM db_cursor3 INTO @job_id2,@step_id2, @command2\n\n WHILE @@FETCH_STATUS = 0 \n BEGIN \n SET @command3 = 'sp_update_jobstep @job_id = '''+@job_id2+''' ,@step_id = '+@step_id2+', @command = '''+@command2+''''\n PRINT @command3\n EXEC(@command3)\n FETCH NEXT FROM db_cursor3 INTO @job_id2,@step_id2, @command2\n END \n\n CLOSE db_cursor3 \n DEALLOCATE db_cursor3\n\nSKIPPER:\nDROP TABLE #jobs\nDROP TABLE SP_Keyword\nPRINT 'CLEANUP DONE'\nPRINT 'PROGRAM COMPLETE'\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11989/"
] |
298,503 | <p>I have some jQuery/JavaScript code that I want to run only when there is a hash (<code>#</code>) anchor link in a URL. How can you check for this character using JavaScript? I need a simple catch-all test that would detect URLs like these:</p>
<ul>
<li><code>example.com/page.html#anchor</code></li>
<li><code>example.com/page.html#anotheranchor</code></li>
</ul>
<p>Basically something along the lines of:</p>
<pre><code>if (thereIsAHashInTheUrl) {
do this;
} else {
do this;
}
</code></pre>
| [
{
"answer_id": 298513,
"author": "Gareth",
"author_id": 31582,
"author_profile": "https://Stackoverflow.com/users/31582",
"pm_score": 12,
"selected": true,
"text": "if(window.location.hash) {\n // Fragment exists\n} else {\n // Fragment doesn't exist\n}\n"
},
{
"answer_id": 298514,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": false,
"text": "if (url.indexOf('#') !== -1) {\n // Url contains a #\n}\n url"
},
{
"answer_id": 298525,
"author": "José Leal",
"author_id": 37190,
"author_profile": "https://Stackoverflow.com/users/37190",
"pm_score": 6,
"selected": false,
"text": "<script type=\"text/javascript\">\n if (location.href.indexOf(\"#\") != -1) {\n // Your code in here accessing the string like this\n // location.href.substr(location.href.indexOf(\"#\"))\n }\n</script>\n"
},
{
"answer_id": 3182463,
"author": "Emmanuel",
"author_id": 288564,
"author_profile": "https://Stackoverflow.com/users/288564",
"pm_score": 3,
"selected": false,
"text": "var hash = false; \ncheckHash();\n\nfunction checkHash(){ \n if(window.location.hash != hash) { \n hash = window.location.hash; \n processHash(hash); \n } t=setTimeout(\"checkHash()\",400); \n}\n\nfunction processHash(hash){\n alert(hash);\n}\n"
},
{
"answer_id": 6682514,
"author": "Mark Notton",
"author_id": 843131,
"author_profile": "https://Stackoverflow.com/users/843131",
"pm_score": 9,
"selected": false,
"text": " if(window.location.hash) {\n var hash = window.location.hash.substring(1); //Puts hash in variable, and removes the # character\n alert (hash);\n // hash found\n } else {\n // No hash found\n }\n"
},
{
"answer_id": 7257830,
"author": "oralunal",
"author_id": 842269,
"author_profile": "https://Stackoverflow.com/users/842269",
"pm_score": 4,
"selected": false,
"text": "$('#myanchor').click(function(){\n window.location.hash = \"myanchor\"; //set hash\n return false; //disables browser anchor jump behavior\n});\n$(window).bind('hashchange', function () { //detect hash change\n var hash = window.location.hash.slice(1); //hash to string (= \"myanchor\")\n //do sth here, hell yeah!\n});\n"
},
{
"answer_id": 9369544,
"author": "commonpike",
"author_id": 95733,
"author_profile": "https://Stackoverflow.com/users/95733",
"pm_score": 2,
"selected": false,
"text": "<a id=\"test\" href=\"foo.html?bar#quz\">test</a>\n<script type=\"text/javascript\">\n alert(document.getElementById('test').search); //bar\n alert(document.getElementById('test').hash); //quz\n</script>\n <a href=\"bar.html?foo\" onclick=\"alert(this.search)\">SAY FOO</a>\n var mylink = \"foo.html?bar#quz\";\n\nif ($('<a href=\"'+mylink+'\">').get(0).search=='bar')) {\n // do stuff\n}\n"
},
{
"answer_id": 9616357,
"author": "Marc Diethelm",
"author_id": 546491,
"author_profile": "https://Stackoverflow.com/users/546491",
"pm_score": 5,
"selected": false,
"text": "var url = 'example.com/page.html#anchor',\n hash = url.split('#')[1];\n\nif (hash) {\n alert(hash)\n} else {\n // do something else\n}\n"
},
{
"answer_id": 10228974,
"author": "BaronVonKaneHoffen",
"author_id": 398287,
"author_profile": "https://Stackoverflow.com/users/398287",
"pm_score": 3,
"selected": false,
"text": "$('a[href^=\"#\"]')\n"
},
{
"answer_id": 11125706,
"author": "Rolando",
"author_id": 1060474,
"author_profile": "https://Stackoverflow.com/users/1060474",
"pm_score": 1,
"selected": false,
"text": "$(\".nav\").click(function(){\n setTimeout(function(){\n updatedHash = location.hash\n },100);\n});\n window.onhashchange = function(evt){\n updatedHash = \"#\" + evt.newURL.split(\"#\")[1]\n};\n"
},
{
"answer_id": 16255536,
"author": "user2327502",
"author_id": 2327502,
"author_profile": "https://Stackoverflow.com/users/2327502",
"pm_score": 4,
"selected": false,
"text": "window.location.hash \n"
},
{
"answer_id": 16994579,
"author": "user2465270",
"author_id": 2465270,
"author_profile": "https://Stackoverflow.com/users/2465270",
"pm_score": 3,
"selected": false,
"text": "function getHash() {\n if (window.location.hash) {\n var hash = window.location.hash.substring(1);\n\n if (hash.length === 0) { \n return false;\n } else { \n return hash; \n }\n } else { \n return false; \n }\n}\n"
},
{
"answer_id": 17502081,
"author": "Graham",
"author_id": 2556056,
"author_profile": "https://Stackoverflow.com/users/2556056",
"pm_score": 2,
"selected": false,
"text": "var requestedHash = ((window.location.hash.substring(1).split(\"#\",1))+\"?\").split(\"?\",1);\n"
},
{
"answer_id": 18642521,
"author": "Nicholas Davison",
"author_id": 2751614,
"author_profile": "https://Stackoverflow.com/users/2751614",
"pm_score": 3,
"selected": false,
"text": "// To process anchors on click \njQuery('a').click(function () {\n if (this.hash) {\n // Clicked anchor has a hash\n } else {\n // Clicked anchor does not have a hash\n }\n});\n\n// To process anchors without waiting for an event\njQuery('a').each(function () {\n if (this.hash) {\n // Current anchor has a hash\n } else {\n // Current anchor does not have a hash\n }\n});\n"
},
{
"answer_id": 18720935,
"author": "Barney",
"author_id": 356541,
"author_profile": "https://Stackoverflow.com/users/356541",
"pm_score": 2,
"selected": false,
"text": "window.location instanceof Location Location hash query protocol href window.location var a = document.createElement('a');\na.href = string;\n\nstring.hash;\n Location window.location"
},
{
"answer_id": 26583799,
"author": "markg",
"author_id": 1838640,
"author_profile": "https://Stackoverflow.com/users/1838640",
"pm_score": -1,
"selected": false,
"text": "var hashId = window.location.hash;\nhashId = hashId.match(/#[^?&\\/]*/g);\n\nreturns -> #anchorlink\n"
},
{
"answer_id": 33982215,
"author": "dnns",
"author_id": 2345943,
"author_profile": "https://Stackoverflow.com/users/2345943",
"pm_score": 1,
"selected": false,
"text": "true false var urlToCheck = 'http://www.domain.com/#hashtag';\n\nfunction hasHashtag(url) {\n return (url.indexOf(\"#\") != -1) ? true : false;\n}\n\n// Condition\nif(hasHashtag(urlToCheck)) {\n // Do something if has\n}\nelse {\n // Do something if doesn't\n}\n true"
},
{
"answer_id": 51398478,
"author": "aabiro",
"author_id": 7848529,
"author_profile": "https://Stackoverflow.com/users/7848529",
"pm_score": 0,
"selected": false,
"text": " function checkHash(){\n return (location.hash ? true : false);\n }\n"
},
{
"answer_id": 64334419,
"author": "Fusion",
"author_id": 4322159,
"author_profile": "https://Stackoverflow.com/users/4322159",
"pm_score": 3,
"selected": false,
"text": "var my_url = new URL('http://www.google.sk/foo?boo=123#baz');\n\nmy_url.hash; // outputs \"#baz\"\nmy_url.pathname; // outputs \"/moo\"\nmy_url.protocol; // \"http:\"\nmy_url.search; // outputs \"?doo=123\"\n"
},
{
"answer_id": 67100972,
"author": "Uzair Ashraf",
"author_id": 1964636,
"author_profile": "https://Stackoverflow.com/users/1964636",
"pm_score": 1,
"selected": false,
"text": " const hasHash = string => string.includes('#')\n const removeHash = string => {\n const [url] = string.split('#')\n return url\n}\n if(hasHash(url)) {\n url = removeHash(url)\n}\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21709/"
] |
298,507 | <p>Following the <a href="http://www.json.org/JSONRequest.html" rel="nofollow noreferrer">JSONRequest proposa</a>l, I've found <a href="http://www.devpro.it/code/153.html" rel="nofollow noreferrer">code for the JSONRequest object</a>. However, this object depends on JSONRequestError, and the code for that is nowhere to be found.</p>
<p>Anyone know where I can find the code?</p>
<p>Thanks in advance!</p>
| [
{
"answer_id": 298639,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 1,
"selected": true,
"text": "JSONRequestError site:devpro.it"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33046/"
] |
298,510 | <p>I'm making a C program where I need to get the directory that the program is started from. This program is written for UNIX computers. I've been looking at <code>opendir()</code> and <code>telldir()</code>, but <code>telldir()</code> returns a <code>off_t (long int)</code>, so it really doesn't help me. </p>
<p>How can I get the current path in a string (char array)?</p>
| [
{
"answer_id": 298516,
"author": "CAdaker",
"author_id": 30579,
"author_profile": "https://Stackoverflow.com/users/30579",
"pm_score": 6,
"selected": false,
"text": "getcwd"
},
{
"answer_id": 298518,
"author": "Mic",
"author_id": 35656,
"author_profile": "https://Stackoverflow.com/users/35656",
"pm_score": 10,
"selected": true,
"text": "getcwd() #include <unistd.h>\nchar *getcwd(char *buf, size_t size);\n #include <unistd.h>\n#include <stdio.h>\n#include <limits.h>\n\nint main() {\n char cwd[PATH_MAX];\n if (getcwd(cwd, sizeof(cwd)) != NULL) {\n printf(\"Current working dir: %s\\n\", cwd);\n } else {\n perror(\"getcwd() error\");\n return 1;\n }\n return 0;\n}\n"
},
{
"answer_id": 31487237,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 5,
"selected": false,
"text": "GetCurrentDirectory() DWORD WINAPI GetCurrentDirectory(\n _In_ DWORD nBufferLength,\n _Out_ LPTSTR lpBuffer\n);\n"
},
{
"answer_id": 46896671,
"author": "rvx",
"author_id": 7385431,
"author_profile": "https://Stackoverflow.com/users/7385431",
"pm_score": 1,
"selected": false,
"text": "getcwd(3) -loldnames _getcwd()"
},
{
"answer_id": 47877476,
"author": "Jevgenij Kononov",
"author_id": 6504460,
"author_profile": "https://Stackoverflow.com/users/6504460",
"pm_score": 2,
"selected": false,
"text": "#include <stdio.h> /* defines FILENAME_MAX */\n//#define WINDOWS /* uncomment this line to use it for windows.*/\n#ifdef WINDOWS\n#include <direct.h>\n#define GetCurrentDir _getcwd\n#else\n#include <unistd.h>\n#define GetCurrentDir getcwd\n#endif\n\nint main(){\n char buff[FILENAME_MAX];\n GetCurrentDir( buff, FILENAME_MAX );\n printf(\"Current working dir: %s\\n\", buff);\n return 1;\n}\n"
},
{
"answer_id": 60058438,
"author": "ChrisZZ",
"author_id": 2999096,
"author_profile": "https://Stackoverflow.com/users/2999096",
"pm_score": 2,
"selected": false,
"text": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#if defined(_MSC_VER)\n#include <direct.h>\n#define getcwd _getcwd\n#elif defined(__GNUC__)\n#include <unistd.h>\n#endif\n\nint main() {\n char* buffer;\n\n if( (buffer=getcwd(NULL, 0)) == NULL) {\n perror(\"failed to get current directory\\n\");\n } else {\n printf(\"%s \\nLength: %zu\\n\", buffer, strlen(buffer));\n free(buffer);\n }\n\n return 0;\n}\n"
},
{
"answer_id": 65414442,
"author": "eeshtox",
"author_id": 14873734,
"author_profile": "https://Stackoverflow.com/users/14873734",
"pm_score": 0,
"selected": false,
"text": "#include <stdio.h> /* defines FILENAME_MAX */\n//#define WINDOWS /* uncomment this line to use it for windows.*/\n#ifdef WINDOWS\n#include <direct.h>\n#define GetCurrentDir _getcwd\n#else\n#include <unistd.h>\n#define GetCurrentDir getcwd\n#endif\n\nint main(){\n char buff[FILENAME_MAX];\n GetCurrentDir( buff, FILENAME_MAX );\n printf(\"Current working dir: %s\\n\", buff);\n return 1;\n}\n #include<stdio.h>\n#include<unistd.h> \n#include<stdlib.h>\n\nmain() {\nchar *buf;\nbuf=(char *)malloc(100*sizeof(char));\ngetcwd(buf,100);\nprintf(\"\\n %s \\n\",buf);\n}\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,511 | <p>On windows mobile when there is no internet connection and I try to
browse the web using internet explorer i get cannot connect
information at the top of the screen. It says cannot connect with
current connection settings. To change your connection settings, tap
settings. And I am able to tap Settings and setup network connections.
How can I display cannot connect information programmatically? When I
cannot connect to a webservice using my application I would like to
show the same information and let the user set up network connections.
I use compact framework 2.0 and csharp.</p>
<p>Thanks in advance. </p>
| [
{
"answer_id": 298516,
"author": "CAdaker",
"author_id": 30579,
"author_profile": "https://Stackoverflow.com/users/30579",
"pm_score": 6,
"selected": false,
"text": "getcwd"
},
{
"answer_id": 298518,
"author": "Mic",
"author_id": 35656,
"author_profile": "https://Stackoverflow.com/users/35656",
"pm_score": 10,
"selected": true,
"text": "getcwd() #include <unistd.h>\nchar *getcwd(char *buf, size_t size);\n #include <unistd.h>\n#include <stdio.h>\n#include <limits.h>\n\nint main() {\n char cwd[PATH_MAX];\n if (getcwd(cwd, sizeof(cwd)) != NULL) {\n printf(\"Current working dir: %s\\n\", cwd);\n } else {\n perror(\"getcwd() error\");\n return 1;\n }\n return 0;\n}\n"
},
{
"answer_id": 31487237,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 5,
"selected": false,
"text": "GetCurrentDirectory() DWORD WINAPI GetCurrentDirectory(\n _In_ DWORD nBufferLength,\n _Out_ LPTSTR lpBuffer\n);\n"
},
{
"answer_id": 46896671,
"author": "rvx",
"author_id": 7385431,
"author_profile": "https://Stackoverflow.com/users/7385431",
"pm_score": 1,
"selected": false,
"text": "getcwd(3) -loldnames _getcwd()"
},
{
"answer_id": 47877476,
"author": "Jevgenij Kononov",
"author_id": 6504460,
"author_profile": "https://Stackoverflow.com/users/6504460",
"pm_score": 2,
"selected": false,
"text": "#include <stdio.h> /* defines FILENAME_MAX */\n//#define WINDOWS /* uncomment this line to use it for windows.*/\n#ifdef WINDOWS\n#include <direct.h>\n#define GetCurrentDir _getcwd\n#else\n#include <unistd.h>\n#define GetCurrentDir getcwd\n#endif\n\nint main(){\n char buff[FILENAME_MAX];\n GetCurrentDir( buff, FILENAME_MAX );\n printf(\"Current working dir: %s\\n\", buff);\n return 1;\n}\n"
},
{
"answer_id": 60058438,
"author": "ChrisZZ",
"author_id": 2999096,
"author_profile": "https://Stackoverflow.com/users/2999096",
"pm_score": 2,
"selected": false,
"text": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#if defined(_MSC_VER)\n#include <direct.h>\n#define getcwd _getcwd\n#elif defined(__GNUC__)\n#include <unistd.h>\n#endif\n\nint main() {\n char* buffer;\n\n if( (buffer=getcwd(NULL, 0)) == NULL) {\n perror(\"failed to get current directory\\n\");\n } else {\n printf(\"%s \\nLength: %zu\\n\", buffer, strlen(buffer));\n free(buffer);\n }\n\n return 0;\n}\n"
},
{
"answer_id": 65414442,
"author": "eeshtox",
"author_id": 14873734,
"author_profile": "https://Stackoverflow.com/users/14873734",
"pm_score": 0,
"selected": false,
"text": "#include <stdio.h> /* defines FILENAME_MAX */\n//#define WINDOWS /* uncomment this line to use it for windows.*/\n#ifdef WINDOWS\n#include <direct.h>\n#define GetCurrentDir _getcwd\n#else\n#include <unistd.h>\n#define GetCurrentDir getcwd\n#endif\n\nint main(){\n char buff[FILENAME_MAX];\n GetCurrentDir( buff, FILENAME_MAX );\n printf(\"Current working dir: %s\\n\", buff);\n return 1;\n}\n #include<stdio.h>\n#include<unistd.h> \n#include<stdlib.h>\n\nmain() {\nchar *buf;\nbuf=(char *)malloc(100*sizeof(char));\ngetcwd(buf,100);\nprintf(\"\\n %s \\n\",buf);\n}\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,521 | <p>I'm using Tomcat 5.5 as my servlet container. My web application deploys via .jar and has some resource files (textual files with strings and configuration parameters) located under its WEB-INF directory. Tomcat 5.5 runs on ubuntu linux. The resource file is read with a file reader:<br>
<code>fr = new FileReader("messages.properties");</code></p>
<p>The problem is that sometimes the servlet can't find the resource file, but if i restart it a couple of times it works, then again after some time it stops working.
Can someone suggest what's the best way of reading resource strings from a servlet? Or a workaround for this problem?
Putting the resource files under WEB-INF/classes doesn't help either.</p>
| [
{
"answer_id": 298574,
"author": "diciu",
"author_id": 2811,
"author_profile": "https://Stackoverflow.com/users/2811",
"pm_score": 4,
"selected": true,
"text": "Properties props = new Properties();\n\nInputStream is =\ngetClass().getClassLoader().getResourceAsStream(\"messages.properties\");\n\nprops.load(is);\n"
},
{
"answer_id": 298880,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 2,
"selected": false,
"text": "new FileReader(\"message.properties\");\n"
},
{
"answer_id": 303833,
"author": "James Schek",
"author_id": 17871,
"author_profile": "https://Stackoverflow.com/users/17871",
"pm_score": 3,
"selected": false,
"text": "ClassLoader void myFunc(ServletContext context) {\n //returns full path. Ex: C:\\tomcat\\5.5\\webapps\\myapp\\web-inf\\message.properties \n String fullCanonicalPath = context.getRealPath(\"/WEB-INF/message.properties\");\n\n //Returns a URL to the file. Ex: file://c:/tomcat..../message.properties\n URL urlToFile = context.getResource(\"/WEB-INF/message.properties\");\n\n //Returns an input stream. Like calling getResource().openStream();\n InputStream inputStream = context.getResourceAsStream(\"/WEB-INF/message.properties\");\n //do something\n}\n"
},
{
"answer_id": 1079426,
"author": "Saulo Silva",
"author_id": 112335,
"author_profile": "https://Stackoverflow.com/users/112335",
"pm_score": 2,
"selected": false,
"text": "public void init(ServletConfig config) throws ServletException {\n String pathToFile = config.getServletContext().getRealPath(\"\")\n + \"/WEB-INF/config.properties\";\n Properties properties = new Properties();\n properties.load(new FileInputStream(pathToPropertiesFile));\n}\n"
},
{
"answer_id": 1712549,
"author": "Marcus Vinícius",
"author_id": 208322,
"author_profile": "https://Stackoverflow.com/users/208322",
"pm_score": 0,
"selected": false,
"text": "ServletLifecycle.getServletContext().getRealPath(\"\")"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7337/"
] |
298,534 | <p>IBM Rational Application Developer is very slow and has many problems.</p>
<p>I tried to use ant scripts to build EAR/WAR files for Websphere Application Server
but it did not work.</p>
| [
{
"answer_id": 306970,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 2,
"selected": false,
"text": "com.ibm.websphere.ant.tasks.WSDL2Java lib.path <taskdef name=\"wsdl2java\"\n classname=\"com.ibm.websphere.ant.tasks.WSDL2Java\">\n <classpath refid=\"lib.path\"/>\n</taskdef>\n find . -type f -name \"*.jar\" | while read file\ndo\n jar tvf $file | grep WSDL2Java && echo $file\ndone\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24550/"
] |
298,535 | <p>In PHP 5.2 there was a nice security function added called "input_filter", so instead of saying:</p>
<pre><code>$name = $_GET['name'];
</code></pre>
<p>you can now say:</p>
<pre><code>$name = filter_input (INPUT_GET, 'name', FILTER_SANITIZE_STRING);
</code></pre>
<p>and it automatically sanitizes your string, there is also:</p>
<ul>
<li><code>FILTER_SANITIZE_ENCODED</code></li>
<li><code>FILTER_SANITIZE_NUMBER_INT</code></li>
<li><code>FILTER_SANITIZE_EMAIL</code></li>
<li><code>FILTER_SANITIZE_URL</code></li>
</ul>
<p>etc.
so this is a very convenient security feature to use and I want to switch over to it completely.</p>
<p><b>The problem is...</b> I often manipulate the $_GET and $_POST arrays before processing them, like this:</p>
<p>$_GET['name'] = '(default name)';</p>
<p>but it seems that filter_input does not have access to the changes in $_GET since it reads "INPUT_GET" which is of type int (?). It would be nice if I could get filter_input to read $_GET instead but:</p>
<pre><code>$name = filter_input ( $_GET, 'name', FILTER_SANITIZE_STRING );
</code></pre>
<p>gives me the error:</p>
<pre><code>Warning: filter_input() expects parameter 1 to be long, array given.
</code></pre>
<p>Can anyone think of a way that I could:</p>
<ul>
<li>manipulate the source of <code>INPUT_GET</code> (whereever it is) so that I can change its values before filter_input can read them</li>
<li>get filter_input to read <code>$_GET</code></li>
</ul>
<p><code>ADDENDUM:</code></p>
<hr/>
<p>Rich asked: "Why are you changing the arrays anyway, surely you want them to be an input, rather than something you've programmatically inserted."</p>
<p>It is just a very convenient place to preprocess variables coming in, e.g. in order to:</p>
<ul>
<li>set defaults (if $_GET['state'] = '' then $_GET['state'] = 'AL')</li>
<li>do manual processing (delete all spaces, etc.)</li>
<li>security (some of which will be done by filter_input now)</li>
</ul>
<p>Then I know by the time I get the incoming variable, it is secure and valid. Of course I could copy the $_GET array to another array and process THAT array but that is just an unnecessary step since I $_GET is already a functioning array so it makes sense to do it with these system arrays that already exist.</p>
| [
{
"answer_id": 298567,
"author": "Simon",
"author_id": 33036,
"author_profile": "https://Stackoverflow.com/users/33036",
"pm_score": 5,
"selected": true,
"text": "$name = filter_var ( $_GET['name'], FILTER_SANITIZE_STRING );\n"
},
{
"answer_id": 3553504,
"author": "Jrgns",
"author_id": 6681,
"author_profile": "https://Stackoverflow.com/users/6681",
"pm_score": 3,
"selected": false,
"text": "if (!($name = filter_input(INPUT_GET, 'name'))) {\n $name = 'default_value';\n}\n $name = ($name = filter_input(INPUT_GET, 'name')) ? $name : 'default_value';\n"
},
{
"answer_id": 8291820,
"author": "hemant0106",
"author_id": 1068742,
"author_profile": "https://Stackoverflow.com/users/1068742",
"pm_score": 0,
"selected": false,
"text": "$_GET $_POST $_GET $_POST filter_var ( $_GET['name'], FILTER_SANITIZE_STRING )"
},
{
"answer_id": 20447501,
"author": "Michal Sukupčák",
"author_id": 2691493,
"author_profile": "https://Stackoverflow.com/users/2691493",
"pm_score": 2,
"selected": false,
"text": ".../?var=1\nvar_dump($_GET['var']); ---> string '1' (length=1)\nvar_dump($_REQUEST['var']); ---> string '1' (length=1)\n$_GET['var'] = 2;\nvar_dump($_GET['var']); ---> int 2\nvar_dump($_REQUEST['var']; ---> string '1' (length=1)\n filter_var($_GET['var'],FILTER_SANITIZE_STRING); ---> JUST NO!\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] |
298,554 | <pre><code>$sourcePath = 'images/'; // Path of original image
$sourceUrl = '';
$sourceName = 'photo1.jpg'; // Name of original image
$thumbPath = 'thumbs/'; // Writeable thumb path
$thumbUrl = 'thumbs/';
$thumbName = "test_thumb.jpg"; // Tip: Name dynamically
$thumbWidth = 100; // Intended dimension of thumb
// Beyond this point is simply code.
$sourceImage = imagecreatefromjpeg("$sourcePath/$sourceName");
$sourceWidth = imagesx($sourceImage);
$sourceHeight = imagesy($sourceImage);
$targetImage = imagecreate($thumbWidth,$thumbWidth);
imagecopyresized($targetImage,$sourceImage,0,0,0,0,$thumbWidth,$thumbWidth,imagesx($sourceImage),imagesy($sourceImage));
imagejpeg($targetImage, "$thumbPath/$thumbName");
// By now, the thumbnail is copied into the $thumbpath
// as the file name specified in $thumbName, so display
echo "<img src='$thumbUrl$thumbName' alt=''>";
</code></pre>
<p>The above code gives me a thumbnail and that's great, but the image quality is awful. It looks like the image has had the colours inverted and it looks like it has been squashed. I've had headaches all day doing this. Any one have any ideas?</p>
| [
{
"answer_id": 298558,
"author": "Dominic Rodger",
"author_id": 20972,
"author_profile": "https://Stackoverflow.com/users/20972",
"pm_score": 1,
"selected": false,
"text": "imagejpeg($targetImage, \"$thumbPath/$thumbName\", 100);\n"
},
{
"answer_id": 298570,
"author": "philistyne",
"author_id": 16597,
"author_profile": "https://Stackoverflow.com/users/16597",
"pm_score": 3,
"selected": false,
"text": "function makeSquareThumb($srcImage, $destSize, $destImage = null) {\n //I'm sure there's a better way than this, but it works...\n //I don't like my folder and file checking in the middle, but need to illustrate the need for this. \n\n $srcFolder = dirname($srcImage); //source folder\n $srcName = basename($srcImage); //original image filename\n\n //the IF ELSEIF ELSE below is NOT comprehensive - eg: what if the dest folder is the same as the source?\n //writeable nature of the destination is not checked!\n if(!destImage) {\n $destFolder = $srcFolder.'/thumbs/';\n if(!is_dir($destFolder)) {\n //make the thumbs folder if there isn't one!\n mkdir($destFolder);\n }\n $destImage = $destFolder.$srcName;\n } elseif (is_dir($destImage)) {\n $destFolder = $destImage;\n $destImage = $destFolder.'/'.$srcName;\n } else {\n $destFolder = dirname($destImage);\n }\n\n\n //Now make it!\n $srcCanvas = imagecreatefromjpeg($srcImage);\n $srcWidth = imagesx($srcCanvas);\n $srcHeight = imagesy($srcCanvas);\n\n //this let's us easily sample a square from the middle, regardless of apsect ratio.\n $shortSide = array($srcWidth,$srcHeight);\n sort($shortSide);\n\n $src_x = $srcWidth/2 - $shortSide[0]/2;\n $src_y = $srcHeight/2 - $shortSide[0]/2;\n\n //do it!\n $destCanvas = imagecreatetruecolor($destSize, $destSize);\n imagecopyresampled($destCanvas,$srcCanvas,0,0,$src_x,$src_y,$destSize,$destSize,$shortSide[0],$shortSide[0]);\n imagejpeg($destCanvas, $destImage);\n}\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31677/"
] |
298,562 | <p>I know I have already answered a similar question (<a href="https://stackoverflow.com/questions/289498">Running Batch File in background when windows boots up</a>), but this time I need to launch a batch:</p>
<ul>
<li>from another batch,</li>
<li>without any console window displayed,</li>
<li><em>with all arguments</em> passed to the invisible batch.</li>
</ul>
<p>The first batch is executed in a console window. However, I do not want the second batch (launched by the first in a <strong>asynchronous way</strong>) to also display a console window.</p>
<p>I have come up with a VBScript script which does just that, and I put the script as an <a href="https://stackoverflow.com/questions/298562#298564">answer for others to refer to</a>, but if you have other ideas/solutions, feel free to contribute.</p>
<p>Note: The console window of Windows command processor is named not really correct DOS window by many people.</p>
<hr>
<p>Thank you all for the answers. From what I understand, if I need to asynchronously call a script to run in an invisible mode:</p>
<ul>
<li>From a second script already in a console window, <strong><code>start /b</code></strong> is enough.</li>
<li>From Windows, <em>without triggering a second window</em>, my solution is still valid.</li>
</ul>
| [
{
"answer_id": 298564,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 7,
"selected": false,
"text": "wscript.exe invis.vbs run.bat %*\n %* set args = WScript.Arguments\nnum = args.Count\n\nif num = 0 then\n WScript.Echo \"Usage: [CScript | WScript] invis.vbs aScript.bat <some script arguments>\"\n WScript.Quit 1\nend if\n\nsargs = \"\"\nif num > 1 then\n sargs = \" \"\n for k = 1 to num - 1\n anArg = args.Item(k)\n sargs = sargs & anArg & \" \"\n next\nend if\n\nSet WshShell = WScript.CreateObject(\"WScript.Shell\")\n\nWshShell.Run \"\"\"\" & WScript.Arguments(0) & \"\"\"\" & sargs, 0, False\n"
},
{
"answer_id": 298636,
"author": "P Daddy",
"author_id": 36388,
"author_profile": "https://Stackoverflow.com/users/36388",
"pm_score": 7,
"selected": true,
"text": "call start /b exit cmd"
},
{
"answer_id": 298687,
"author": "wimh",
"author_id": 33499,
"author_profile": "https://Stackoverflow.com/users/33499",
"pm_score": 2,
"selected": false,
"text": "echo call c:\\path\\to\\batch.cmd %* > c:\\windows\\system32\\autoexnt.bat\nnet start autoexnt\n"
},
{
"answer_id": 21130357,
"author": "indago",
"author_id": 154199,
"author_profile": "https://Stackoverflow.com/users/154199",
"pm_score": 3,
"selected": false,
"text": "Set WshShell = CreateObject(\"WScript.Shell\" ) \nWshShell.Run chr(34) & \"C:\\Batch Files\\ mycommands.bat\" & Chr(34), 0 \nSet WshShell = Nothing \n"
},
{
"answer_id": 21480639,
"author": "Vinod Chelladurai",
"author_id": 1905020,
"author_profile": "https://Stackoverflow.com/users/1905020",
"pm_score": 0,
"selected": false,
"text": "Dim WshShell\nDim obj\nSet WshShell = WScript.CreateObject(\"WScript.Shell\") \nobj = WshShell.Run(\"C:\\Users\\file1.bat\", 0) \nobj = WshShell.Run(\"C:\\Users\\file2.bat\", 0) and so on\nset WshShell = Nothing \n"
},
{
"answer_id": 33152424,
"author": "npocmaka",
"author_id": 388389,
"author_profile": "https://Stackoverflow.com/users/388389",
"pm_score": 3,
"selected": false,
"text": "@echo off\n\necho --- self hiding bat ----\npause\ncall getCmdPid.bat\nset PID=%errorlevel%\ncall windowMode.bat -pid %PID% -mode hidden\n call IEXPhidden.bat \"cmd /c myBat.bat\" \"argument\"\n call SCHPhidden.bat \"cmd /c myBat.bat\" \"argument\"\n call ShellRunJS.bat \"notepad.exe\" -style 0 -wait no \n call win32process.bat \"notepad\" -arguments \"/A openFile.txt\" -showWindows 0 -title \"notepad\"\n call ProcessStartJS.bat \"notepad\" -arguments \"/A openFile.txt\" -style Hidden -directory \".\" -title \"notepad\" -priority Normal\n"
},
{
"answer_id": 55142689,
"author": "user2928048",
"author_id": 2928048,
"author_profile": "https://Stackoverflow.com/users/2928048",
"pm_score": 0,
"selected": false,
"text": "start /MIN notepad.exe\n start /MIN calc.exe\n"
},
{
"answer_id": 68245360,
"author": "i Mr Oli i",
"author_id": 11199164,
"author_profile": "https://Stackoverflow.com/users/11199164",
"pm_score": 2,
"selected": false,
"text": "@echo off\nnircmd exec hide \"MainScript.bat\"\n @echo off\necho Can you see me now?\npause \nexit\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6309/"
] |
298,563 | <p>I am getting the following error when trying to <code>Save as Document Object</code> while trying to implement a word automation in C#:</p>
<blockquote>
<pre><code>System.Runtime.InteropServices.COMException
</code></pre>
<p>(0x80020005): Type mismatch.
(Exception from HRESULT: 0x80020005
(DISP_E_TYPEMISMATCH))</p>
<pre><code> at Microsoft.Office.Interop.Word.DocumentClass.SaveAs(Object&
</code></pre>
<p>FileName, Object& FileFormat, Object&
LockComments, Object& Password,
Object& AddToRecentFiles, Object&
WritePassword, Object&
ReadOnlyRecommended, Object&
EmbedTrueTypeFonts, Object&
SaveNativePictureFormat, Object&
SaveFormsData, Object&
SaveAsAOCELetter, Object& Encoding,
Object& InsertLineBreaks, Object&
AllowSubstitutions, Object&
LineEnding, Object& AddBiDiMarks)</p>
<pre><code> at TestWordAutomation.Form1.SaveAs(String
</code></pre>
<p>fileName) in
D:\dotnet\WordAutomation\TestWordAutomation\TestWordAutomation\Form1.cs:line
246</p>
<pre><code> at TestWordAutomation.Form1.button4_Click(Object
</code></pre>
<p>sender, EventArgs e) in
D:\dotnet\WordAutomation\TestWordAutomation\TestWordAutomation\Form1.cs:line
557</p>
</blockquote>
<p>I am calling the <code>Save As</code> method like so:</p>
<pre><code>MySaveAs("Doc1.doc");
MySaveAs("Doc2.doc");
MySaveAs("Doc3.doc");
//I have a MySaveAs function
public void MySaveAs(string fileName)
{
object FileName = null, FileFormat = null, LockComments = null, _Password = null, AddToRecentFiles = null, _WritePassword = null, _ReadOnlyRecommended = null, _EmbedTrueTypeFonts = null, SaveNativePictureFormat = null, _SaveFormsData = null, SaveAsAOCELetter = null, Encoding = null, InsertLineBreaks = null, AllowSubstitutions = null, LineEnding = null, AddBiDiMarks = null;
FileName = (object) fileName;
oDoc.SaveAs(ref FileName, ref FileFormat, ref LockComments, ref _Password, ref AddToRecentFiles,
ref _WritePassword, ref _ReadOnlyRecommended, ref _EmbedTrueTypeFonts,
ref SaveNativePictureFormat, ref _SaveFormsData, ref SaveAsAOCELetter, ref Encoding,
ref InsertLineBreaks, ref AllowSubstitutions, ref LineEnding, ref AddBiDiMarks);
}
</code></pre>
<p>Can any one help me to resolve this ?</p>
| [
{
"answer_id": 298584,
"author": "kenny",
"author_id": 3225,
"author_profile": "https://Stackoverflow.com/users/3225",
"pm_score": 3,
"selected": false,
"text": "static object s_missing = System.Reflection.Missing.Value;\nstatic object s_true = true;\nstatic object s_false = false;\nstatic object s_forcesave = Word.WdSaveOptions.wdSaveChanges;\n\nstatic Word._Application s_app = null;\n...\nreturn s_app.Documents.Open ( ref filename,\n ref s_missing,\n ref s_missing,\n ref s_missing,\n ref s_missing,\n ref s_missing,\n ref s_missing,\n ref s_missing,\n ref s_missing,\n ref s_missing,\n ref s_missing,\n ref s_missing,\n ref s_missing,\n ref s_missing,\n ref s_missing,\n ref s_missing );\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,568 | <p>I'm trying to import a large SQL file; created by mysqldump on one server, then converted with iconv; using these commands:</p>
<pre><code>$ mysqldump -uxxx -p xxx > data.sql
$ iconv -f UTF-8 -t ISO-8859-1//TRANSLIT data.sql data.iconv.sql
</code></pre>
<p>I noticed that the "\x91" in the database had turned into "\xc3\x82\xc2\x91" in the dump, because mysqldump tries to convert everything to utf-8. I converted it back to "\x91" with iconv. If I do not convert them, they end up being "\xc2\x3f" on the new server; instead of just "\x3f" as we have now.</p>
<p>So, as read before, there are some characters unique to the cp1252 encoding, for example "\x91" and "\x92". Both these characters have turned to "\x3f" in the new database; this is the command I use to import:</p>
<pre><code>$ /opt/mysql5/bin/mysql -uxxx -p -Dxxx < data.iconv.sql
</code></pre>
<p>Anybody knows how this could happen and what to do to prevent it? Knowing this I should be able to migrate data exactly as it was.</p>
<p>Extra information:</p>
<p>I used <a href="http://www.outofcontrol.ca/2006/05/31/mysql-exportimport-and-charset-problems/" rel="nofollow noreferrer">this source</a> for the iconv-things. As you can see, on this page one other person had troubles with cp1252 as well; maybe that's the cause.</p>
<p>The serverversion are:</p>
<p>old-host: Ver 10.10 Distrib 5.0.18, for pc-linux-gnu (i486)
new-host: Ver 10.11 Distrib 5.0.51, for pc-linux-gnu (i686)</p>
| [
{
"answer_id": 302227,
"author": "James Anderson",
"author_id": 38207,
"author_profile": "https://Stackoverflow.com/users/38207",
"pm_score": 0,
"selected": false,
"text": "iconv -f utf-8 -t IBM-1252 xxxx\n"
},
{
"answer_id": 305411,
"author": "Martin",
"author_id": 37367,
"author_profile": "https://Stackoverflow.com/users/37367",
"pm_score": 0,
"selected": false,
"text": "SET @saved_cs_client = @@character_set_client;\nSET character_set_client = utf8;\n\nCREATE TABLE ...\n...\n...\nSET character_set_client = @saved_cs_client;\n"
},
{
"answer_id": 346342,
"author": "Martin",
"author_id": 37367,
"author_profile": "https://Stackoverflow.com/users/37367",
"pm_score": 1,
"selected": false,
"text": "mysqldump --set-charset ...\n set name = utf-8 --default-character-set=xxx -set-charset"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21580/"
] |
298,569 | <p>I need to write a little tool for a customer to be run on Windows 98. Since this is a very small project I'd hope that I could avoid having to go native C++ and use C#.</p>
<p>The <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=0856eacb-4362-4b0d-8edd-aab15c5e04f5" rel="noreferrer">.net Framework 2.0 download</a> claims to support Windows 98. Are there any caveats or hitches to be aware of when installing or coding?</p>
| [
{
"answer_id": 298608,
"author": "P Daddy",
"author_id": 36388,
"author_profile": "https://Stackoverflow.com/users/36388",
"pm_score": 4,
"selected": true,
"text": "CharSet.Auto"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4918/"
] |
298,571 | <p>I Have a problem with my custom Addin to word because sometimes, MS Word was disabled my addin, and I need to write another AddIn, which Was enabled to turn - on/off my first AddIn. Is it possible?</p>
<p>sorry for my English :(</p>
| [
{
"answer_id": 320831,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 0,
"selected": false,
"text": "LoadBehavior"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,577 | <p>I have run into a bit of a tricky problem in some C++ code, which is most easily described using code. I have classes that are something like:</p>
<pre><code>class MyVarBase
{
}
class MyVar : public MyVarBase
{
int Foo();
}
class MyBase
{
public:
MyBase(MyVarBase* v) : m_var(v) {}
virtual MyVarBase* GetVar() { return m_var; }
private:
MyVarBase* m_var;
}
</code></pre>
<p>I also have a subclass of MyBase that needs to have a member of type MyVar because it needs to call Foo. Moving the Foo function into MyVarBase is not an option. Does it make sense to do this:</p>
<pre><code>class MyClass : public MyBase
{
public:
MyClass(MyVar* v) : MyBase(v), m_var(v) {}
MyVar* GetVar() { return m_var; }
private:
MyVar* m_var;
}
</code></pre>
<p>This seems to work but looks really bad and I'm not sure if it's going to cause a memory leak or break a copy constructor. My other options might be to name the MyVar variable in MyClass something else but have it be equal to the m_var pointer in the base, or to templatise MyBase on the MyVar type. </p>
<p>All these options don't seem ideal so I wanted to know if anyone else has run into a situation like this and if there is a good way to make it work.</p>
| [
{
"answer_id": 298590,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 5,
"selected": true,
"text": "MyVar class MyClass : public MyBase\n{\npublic:\n MyClass(MyVar* v) : MyBase(v) {}\n MyVar* GetVar() { return static_cast<MyVar*>(MyBase::GetVar()); }\n}\n GetVar MyBase static_cast dynamic_cast MyBase::GetVar() MyVar* GetVar() { \n assert(dynamic_cast<MyVar*>(MyBase::GetVar()) != 0);\n return static_cast<MyVar*>(MyBase::GetVar()); \n}\n"
},
{
"answer_id": 298844,
"author": "Brian",
"author_id": 17356,
"author_profile": "https://Stackoverflow.com/users/17356",
"pm_score": 0,
"selected": false,
"text": "class MyVarBase\n{\n};\n\nclass MyVar : public MyVarBase\n{\n int Foo();\n};\n\ntemplate <class T> class MyBase\n{\npublic: \n MyBase(T* v) : m_var(v) {}\n T* GetVar() { return m_var; }\n\nprivate:\n T* m_var;\n};\n\nclass MyClass : public MyBase<MyVar>\n{\npublic:\n MyClass(MyVar* v) : MyBase(v) {}\n};\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20925/"
] |
298,580 | <p>For those of you who are decent with subsonic!</p>
<pre><code> TblNewsCollection col =
new Select().From(Tables.TblNews)
.InnerJoin(Tables.TblContent)
.Paged(currentPage, pageSize)
.OrderDesc(TblContent.Columns.PubDate)
.ExecuteAsCollection<TblNewsCollection>();
</code></pre>
<p>The above works, no problem, but when I try to add a where clause</p>
<pre><code> TblNewsCollection col =
new Select().From(Tables.TblNews)
.InnerJoin(Tables.TblContent)
.Where(TblContent.Columns.UserFK)
.IsEqualTo(guidUserFK)
.Paged(currentPage, pageSize)
.OrderDesc(TblContent.Columns.PubDate)
.ExecuteAsCollection<TblNewsCollection>();
</code></pre>
<p>I get this message</p>
<pre><code>System.InvalidCastException: Object must implement IConvertible.
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType)
System.InvalidCastException: Failed to convert parameter value from a Guid to a String.
</code></pre>
<p>I've tried it from other fields, for example a bit field in a database it says it can't convert from bool to bit!</p>
<p>Seems to only be an issue on where statements after joins</p>
| [
{
"answer_id": 298605,
"author": "asleep",
"author_id": 29445,
"author_profile": "https://Stackoverflow.com/users/29445",
"pm_score": 0,
"selected": false,
"text": "Northwind.CustomerCollection customersByCategory = new Select()\n .From(Northwind.Customer.Schema)\n .InnerJoin(Northwind.Order.Schema)\n .InnerJoin(Northwind.OrderDetail.OrderIDColumn, Northwind.Order.OrderIDColumn)\n .InnerJoin(Northwind.Product.ProductIDColumn, Northwind.OrderDetail.ProductIDColumn)\n .Where(\"CategoryID\").IsEqualTo(5)\n .ExecuteAsCollection<Northwind.CustomerCollection>();\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29445/"
] |
298,588 | <p>How can I figure out the CRC algorithm if a given code + CRC string is given? </p>
<p>I have got several strings consisting of code + matching CRCs but don't know how to calculate the CRC in question so that I could produce more code strings. Here are some samples (16bit code + 4bit CRC):</p>
<pre>
0010101000011101 + 0000
0010101000011111 + 0001
1000110011101101 + 0001
0000000000000100 + 0010
0011100011001110 + 0011
1000110011101110 + 0100
0001011110101100 + 0100
0010101000011110 + 0101
0011100011001101 + 0110
0001011110101111 + 0111
0011100011001100 + 1001
0011100011001111 + 1010
0001011110101101 + 1011
0000000000001000 + 1011
0000111100001101 + 1100
0000000000001100 + 1100
1111111111111111 + 1101
1000110011101111 + 1101
1000110011101100 + 1110
0001011110101110 + 1110
1111111100001101 + 1110
0010101000011100 + 1111
</pre>
<p>These codes come from a RF (433MHz) sender like the X10 products.</p>
<p>I am not sure if this is a CRC or what it is, but at least it calculated somehow out of those code strings.</p>
<h2>Updates</h2>
<p>RE: finding the specifications I also think would be the best solution but since this is no option I need to brute force the checksum calculation somehow.</p>
<p>This is the problem, I don't have the specifications and I can´t get them anywhere. I have tried several different checksum calculation methods without result, isn't there a way to compare the input strings finding out what they have in common and this way getting the algorithm</p>
| [
{
"answer_id": 5708332,
"author": "DIma Q",
"author_id": 666876,
"author_profile": "https://Stackoverflow.com/users/666876",
"pm_score": 2,
"selected": false,
"text": "['0010101000011101', '0000', '0'] ['0010101000011110', '0101', '5'] [1, 3]\n['1000110011101101', '0001', '1'] ['1000110011101110', '0100', '4'] [1, 3]\n['0000000000000100', '0010', '2'] ['0000000000001000', '1011', 'b'] [0, 3]\n['0011100011001110', '0011', '3'] ['0011100011001101', '0110', '6'] [1, 3]\n['0001011110101100', '0100', '4'] ['0001011110101111', '0111', '7'] [2, 3]\n['0011100011001100', '1001', '9'] ['0011100011001111', '1010', 'a'] [2, 3]\n['0001011110101101', '1011', 'b'] ['0001011110101110', '1110', 'e'] [1, 3]\n['1000110011101111', '1101', 'd'] ['1000110011101100', '1110', 'e'] [2, 3]\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,592 | <p>I have a COM interop assembly, and I would like to check from a .NET application whether the component I'm about to create is installed on the machine. </p>
<p>I would like to provide a nice error message if it is not installed.</p>
<p>Put the instantiation into try-catch is not a good solution for me, as I would like to distingwish between the missing installation and the other errors that may occur. </p>
<p>My idea is to check whether the node with the COM class id exists in the registry under the <em>HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface</em> path. But is there a better approach?</p>
| [
{
"answer_id": 969908,
"author": "Christian Hayter",
"author_id": 115413,
"author_profile": "https://Stackoverflow.com/users/115413",
"pm_score": 1,
"selected": false,
"text": "Type.GetTypeFromProgID(\"MyProgID\") != null"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26530/"
] |
298,607 | <p>I've been dipping into SitePoint book concerning CSS.</p>
<p>The thing that struck me about the examples was the use of ID as a CSS selector.</p>
<p>Some bits of CSS design I've done, I've always found it easier and more versatile to use Class as the selector.</p>
<p>Maybe its a .Net thing as we don't always have control of the ID of an element...</p>
<p>Is the best practice here to use CLASS or ID as the selector?</p>
| [
{
"answer_id": 298637,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 2,
"selected": false,
"text": "div.header\n div#header\n"
},
{
"answer_id": 298930,
"author": "Ola Tuvesson",
"author_id": 6903,
"author_profile": "https://Stackoverflow.com/users/6903",
"pm_score": 4,
"selected": false,
"text": "class=\"someClass someOtherClass\" <style>\ndiv.box {\nfloat: left;\nborder: 1px solid blue;\npadding: 1em;\n}\n\ndiv.wide {\nwidth: 40em; \n}\n\ndiv.narrow {\nwidth: 10em; \n}\n\ndiv#oddOneOut {\nfloat: right;\n}\n</style>\n\n<div class=\"box wide\">a wide box</div>\n<div class=\"box narrow\">a narrow box</div>\n<div class=\"box wide\" id=\"oddOneOut\">an odd box</div>\n div.box.narrow {something: somevalue;}"
},
{
"answer_id": 301101,
"author": "Zak Linder",
"author_id": 26836,
"author_profile": "https://Stackoverflow.com/users/26836",
"pm_score": 3,
"selected": false,
"text": "id class"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15710/"
] |
298,626 | <p>I'm trying to make <a href="https://stackoverflow.com/questions/298491/how-do-i-receive-clicks-outside-a-forms-window">a window that closes when you click outside it</a>, and at the moment I'm looking into doing that by handling the WndProc function.</p>
<p>None of the messages I'm getting so far seem useful, but there are a few I don't understand at all. What do codes 0x0118, 0xC123, 0xC128 and 0xC12E represent?</p>
| [
{
"answer_id": 298654,
"author": "P Daddy",
"author_id": 36388,
"author_profile": "https://Stackoverflow.com/users/36388",
"pm_score": 2,
"selected": false,
"text": "RegisterWindowMessage"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] |
298,648 | <p>I’m writing pl/sql procedure that exports data from Oracle to Excel. I need data formatting so I can’t use CSV. I’ve already tried with XML but it generates too large files when I want to export e.g. 70000 rows with 50 columns (almost 300 MB!!!). </p>
<p>That’s why I decided to use HTML tags to generate XLS file – it is smaller than XML and I must directly define format of only some special columns (strings, numbers and dates are formatted automatically by Excel).
It’s very simple and convenient but I can’t define more than one worksheet.</p>
<p>Do you know how to add/define more than one worksheet in excel file written using HTML? I’ve tried to use VBScript formula like <% ActiveWorkbook.Worksheet.Add %>, but it doesn’t work.</p>
| [
{
"answer_id": 927673,
"author": "moleboy",
"author_id": 114501,
"author_profile": "https://Stackoverflow.com/users/114501",
"pm_score": 2,
"selected": false,
"text": "Private Sub getMyRows(inSchema As String, InTable As String)\n Dim RS As Object\n Dim TableSQL As String\n Dim DataType As String\n Dim DataLength As String\n Dim DataPrecision As String\n Dim DataScale As String\n Dim ColCount As Integer\n Dim WS As Worksheet\n' create a sheet with the current table as name\n Worksheets.Add().Name = InTable\n Set RS = CreateObject(\"ADODB.recordset\")\n TableSQL = \"Select * from \" & inSchema & \".\" & InTable\n' grab the data\n RS.Open TableSQL, conn, adOpenStatic\n For ColCount = 0 To RS.Fields.Count - 1\n' set column headings to match table\n ActiveSheet.Cells(1, ColCount + 1).Value = RS.Fields(ColCount).Name\n Next\n\n' copy table data to sheet\n With Worksheets(InTable).Range(\"A2\")\n .CopyFromRecordset RS\n End With\n RS.Close\n\n End Sub\n"
},
{
"answer_id": 4505962,
"author": "gWay",
"author_id": 524607,
"author_profile": "https://Stackoverflow.com/users/524607",
"pm_score": 1,
"selected": false,
"text": "set feed off markup html on spool on\nspool c:\\table1.xls\nselect * from table1;\nspool off\nset markup html off spool off\n"
},
{
"answer_id": 10205456,
"author": "vbence",
"author_id": 638471,
"author_profile": "https://Stackoverflow.com/users/638471",
"pm_score": 1,
"selected": false,
"text": "Dim cnn As ADODB.Connection\nSet cnn = New ADODB.Connection\n\ncnn.ConnectionString = \"Provider=OraOLEDB.Oracle.1;Password=<PASSWORD>;Persist Security Info=True;User ID=<USER ID>;Data Source=<DATABASE NAME>\"\ncnn.Open\n"
},
{
"answer_id": 41356216,
"author": "Migs Isip",
"author_id": 6859002,
"author_profile": "https://Stackoverflow.com/users/6859002",
"pm_score": 0,
"selected": false,
"text": "as_xlsx"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,653 | <p>I'm inserting something in the cache when the user does a login. </p>
<p>Now I want to delete that from the cache when the user's session expires. HttpContext is null .. so I don't know for which user the session expired. How can I go about finding this ?</p>
<p><strong>EDIT:</strong> unfortunately SessionID doesn't offer me much. What i'm doing in this particular case is using an HttpModule that handles AuthorizeRequest to insert the current userName in Cache to ensure that another user from another machine can't login. But the Session is null in the HttpModule. So I can't use that. Any other suggestions ?</p>
| [
{
"answer_id": 927673,
"author": "moleboy",
"author_id": 114501,
"author_profile": "https://Stackoverflow.com/users/114501",
"pm_score": 2,
"selected": false,
"text": "Private Sub getMyRows(inSchema As String, InTable As String)\n Dim RS As Object\n Dim TableSQL As String\n Dim DataType As String\n Dim DataLength As String\n Dim DataPrecision As String\n Dim DataScale As String\n Dim ColCount As Integer\n Dim WS As Worksheet\n' create a sheet with the current table as name\n Worksheets.Add().Name = InTable\n Set RS = CreateObject(\"ADODB.recordset\")\n TableSQL = \"Select * from \" & inSchema & \".\" & InTable\n' grab the data\n RS.Open TableSQL, conn, adOpenStatic\n For ColCount = 0 To RS.Fields.Count - 1\n' set column headings to match table\n ActiveSheet.Cells(1, ColCount + 1).Value = RS.Fields(ColCount).Name\n Next\n\n' copy table data to sheet\n With Worksheets(InTable).Range(\"A2\")\n .CopyFromRecordset RS\n End With\n RS.Close\n\n End Sub\n"
},
{
"answer_id": 4505962,
"author": "gWay",
"author_id": 524607,
"author_profile": "https://Stackoverflow.com/users/524607",
"pm_score": 1,
"selected": false,
"text": "set feed off markup html on spool on\nspool c:\\table1.xls\nselect * from table1;\nspool off\nset markup html off spool off\n"
},
{
"answer_id": 10205456,
"author": "vbence",
"author_id": 638471,
"author_profile": "https://Stackoverflow.com/users/638471",
"pm_score": 1,
"selected": false,
"text": "Dim cnn As ADODB.Connection\nSet cnn = New ADODB.Connection\n\ncnn.ConnectionString = \"Provider=OraOLEDB.Oracle.1;Password=<PASSWORD>;Persist Security Info=True;User ID=<USER ID>;Data Source=<DATABASE NAME>\"\ncnn.Open\n"
},
{
"answer_id": 41356216,
"author": "Migs Isip",
"author_id": 6859002,
"author_profile": "https://Stackoverflow.com/users/6859002",
"pm_score": 0,
"selected": false,
"text": "as_xlsx"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5246/"
] |
298,660 | <p>Is it possible to generate a XML Schema of a Database programatically with .Net and C#? I want to look into NDbUnit but for big databases it would not really be feasible to make a Schema manually? </p>
| [
{
"answer_id": 298866,
"author": "George Stocker",
"author_id": 16587,
"author_profile": "https://Stackoverflow.com/users/16587",
"pm_score": 6,
"selected": true,
"text": "create table Person\n(\nAge int not NULL check( Age > 0) ,\nHeight numeric(10,2) not NULL check( Height > 5),\nGender varchar(5) not null check( Gender in ('M', 'F', 'O')),\nBirthDate datetime null,\n)\n\nDECLARE @schema xml\nSET @schema = (SELECT * FROM Person FOR XML AUTO, ELEMENTS, XMLSCHEMA('PersonSchema'))\nselect @schema\n"
},
{
"answer_id": 298927,
"author": "Damien",
"author_id": 35454,
"author_profile": "https://Stackoverflow.com/users/35454",
"pm_score": 2,
"selected": false,
"text": "DataSet results = new DataSet();\n\nSqlCommand command = new SqlCommand(\"SELECT * FROM table\", new SqlConnection(connectionString));\n\nSqlDataAdapter sqlAdapter = new SqlDataAdapter(command);\n\nsqlAdapter.FillSchema(results, SchemaType.Mapped);//Fills dataset with schema from query\nresults.WriteXmlSchema(mySchema);\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35454/"
] |
298,669 | <p>How can I find the location of exe that runs as a windows service in run-time?</p>
| [
{
"answer_id": 298674,
"author": "Harry Lime",
"author_id": 21590,
"author_profile": "https://Stackoverflow.com/users/21590",
"pm_score": 0,
"selected": false,
"text": "netstat -ab\n"
},
{
"answer_id": 298722,
"author": "P Daddy",
"author_id": 36388,
"author_profile": "https://Stackoverflow.com/users/36388",
"pm_score": 3,
"selected": true,
"text": "Assembly.GetExecutingAssembly().Location Application.ExecutablePath System.Windows.Forms GetModuleFileName(NULL, ...)"
},
{
"answer_id": 298823,
"author": "tomsee",
"author_id": 38568,
"author_profile": "https://Stackoverflow.com/users/38568",
"pm_score": 3,
"selected": false,
"text": "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\' + ServiceDisplayName;\n ImagePath"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34623/"
] |
298,677 | <p>can anyome help me find an elegant design for splitting, traversing and tracking objects.</p>
<p>The diagram below shows an object with an initial size of 100 which is spilt into two (50, 75) then one of the child objects (75) is subsequently split into three (25, 25 ,25).</p>
<p>My question is can anyone think of an elegant design that will allow me from <strong>any object</strong> to traverse the entire tree (for example to identify the root parent from any subsequently child object)? </p>
<p>My current attempt (see code below) uses the instance fields Parent and Children to track the objects but it obviously doesn’t give me the functionality I require – as from Obj [Id:6] I cannot recursively find the root parent.</p>
<p>Can anyone think of a solution? I don’t think a double linked list will work as the spilt parameter is not limited to just two.</p>
<pre><code> Obj [Id:1, Size:100]
|
Split operation (50, 75)
<>
Obj [Id:2, Size:25] Obj [Id:2, Size:75]
|
Split operation (25, 25, 25)
<>
Obj [Id:4, Size:25] Obj [Id:5, Size:25] Obj [Id:6, Size:25]
public class SplitableObj : IEquatable<SplitableObj>
{
private Guid _id = Guid.NewGuid();
private int _size;
private SplitableObj _parent;
private List<SplitableObj> _childern;
public SplitableObj(int size)
{
_size = size;
}
public Guid id
{
get { return _id; }
set { _id = value; }
}
public SplitableObj Parent
{
get { return _parent; }
set { _parent = value; }
}
public List<SplitableObj> Children
{
get { return _childern; }
set { _childern = value; }
}
public int Size
{
get { return _size; }
set { _size = value; }
}
public IEnumerable<SplitableObj> Split(params int[] splits)
{
if (splits.Length < 2)
{
throw new ApplicationException("splits must be least 2.");
}
int totalSplits = 0;
foreach (int split in splits)
{
totalSplits += split;
}
if (_size != totalSplits)
{
throw new ApplicationException("Total splits must equal Size.");
}
foreach (int split in splits)
{
SplitableObj splitAmount = new SplitableObj(split);
splitAmount.Parent = this;
this.Children.Add(splitAmount);
yield return splitAmount;
}
}
public bool Equals(SplitableObj splitableObj)
{
if (splitableObj == null) return false;
return Equals(_id, splitableObj._id);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj)) return true;
return Equals(obj as SplitableObj);
}
public override int GetHashCode()
{
return _id.GetHashCode();
}
}
</code></pre>
| [
{
"answer_id": 298961,
"author": "Svante",
"author_id": 31615,
"author_profile": "https://Stackoverflow.com/users/31615",
"pm_score": 1,
"selected": false,
"text": "set RootObject to the current object.\nwhile the parent of RootObject is not undefined, set RootObject to its parent.\nFinally, return RootObject.\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,689 | <p>The code below always return an empty array from <code>GetModifiedMembers(object)</code>
but <code>dx.GetChangeSet().Updates.Contains( foo )</code> returns true.</p>
<pre><code>DataContext dx = new DataContext( string.Empty );
MockLinqDataObject foo = new MockLinqDataObject();
dx.GetTable( foo.GetType() ).Attach( foo );
foo.PK = Guid.NewGuid();
// always returns empty array
ModifiedMemberInfo[] arr_Result = dx.GetTable( foo.GetType() ).GetModifiedMembers( foo );
bool isOk = ( arr_Result.Length == 1 );
return isOk;
</code></pre>
<p>Does anyone know what there is wrong?</p>
<p>Thanks in advance?</p>
| [
{
"answer_id": 298961,
"author": "Svante",
"author_id": 31615,
"author_profile": "https://Stackoverflow.com/users/31615",
"pm_score": 1,
"selected": false,
"text": "set RootObject to the current object.\nwhile the parent of RootObject is not undefined, set RootObject to its parent.\nFinally, return RootObject.\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20382/"
] |
298,692 | <p>For the project I'm working on I noticed that file transfer* speed is really bad if I'm using IIS FTP and HTTP services. I know that the last thing I should think is "it's a Windows bug", but the fact that simply by using IIS on Windows Server or by changing IIS on that Windows XP machine to FileZilla and LightHTTPd, my file transfer speeds go up twice from the original configuration, makes me go "hmmm".</p>
<p>Are there any limitation on IIS running on Windows XP? Any file transfer throttling or something like that?</p>
<p><strong>File transfer is being done using one connection to one file. My file transfer client is the only one client connecting to the PC.</strong></p>
<p>Thanks.</p>
| [
{
"answer_id": 1403796,
"author": "Coxy",
"author_id": 45563,
"author_profile": "https://Stackoverflow.com/users/45563",
"pm_score": 2,
"selected": false,
"text": " cd \\inetpub\\adminscripts \n cscript adsutil.vbs set w3svc/MaxConnections 40 \n iisreset \n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21952/"
] |
298,702 | <p>How to create a windows toolbar-dockable application - like <a href="http://www.winamp.com/plugins/details/82271" rel="nofollow noreferrer">Winamp Desk Band</a> - in .NET?</p>
| [
{
"answer_id": 1403796,
"author": "Coxy",
"author_id": 45563,
"author_profile": "https://Stackoverflow.com/users/45563",
"pm_score": 2,
"selected": false,
"text": " cd \\inetpub\\adminscripts \n cscript adsutil.vbs set w3svc/MaxConnections 40 \n iisreset \n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3182/"
] |
298,708 | <p>I'm developing a C++ command-line application in Visual Studio and need to debug it with command-line arguments. At the moment I just run the generated EXE file with the arguments I need (like this <code>program.exe -file.txt</code>) , but this way I can't debug. Is there somewhere I can specify the arguments for debugging?</p>
| [
{
"answer_id": 50530649,
"author": "Blubsiwubsi",
"author_id": 8433911,
"author_profile": "https://Stackoverflow.com/users/8433911",
"pm_score": 2,
"selected": false,
"text": "argv int main(int argc, char **argv){\n}\n int main(int argc, char *argv[]){\n}\n"
},
{
"answer_id": 66578963,
"author": "Lars Pellarin",
"author_id": 5247321,
"author_profile": "https://Stackoverflow.com/users/5247321",
"pm_score": 1,
"selected": false,
"text": "MyStartUpProject.csproj.user MyStartUpProject.csproj.user"
},
{
"answer_id": 70995615,
"author": "user1602",
"author_id": 2290413,
"author_profile": "https://Stackoverflow.com/users/2290413",
"pm_score": 2,
"selected": false,
"text": "{\n \"version\": \"0.2.1\",\n \"defaults\": {},\n \"configurations\": [\n {\n \"type\": \"default\",\n \"project\": \"ffprobe.exe\",\n \"projectTarget\": \"\",\n \"name\": \"ffprobe.exe\",\n \"args\": [ \"C:\\\\Temp\\\\test-file\" ]\n }\n ]\n}\n"
},
{
"answer_id": 71621948,
"author": "mateus_cesar",
"author_id": 11948374,
"author_profile": "https://Stackoverflow.com/users/11948374",
"pm_score": 0,
"selected": false,
"text": "args launchSettings.json \"commandLineArgs\": \" \","
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3037/"
] |
298,712 | <p>We're currently using WinCVS but it's slow and has no merge dialog. I'm looking for something like Eclipse's Team Synchronize (so people can see what they'll get before they update).</p>
<p>What do you suggest? <a href="http://www.tortoisecvs.org/" rel="noreferrer">TortoiseCVS</a> with <a href="http://winmerge.org/" rel="noreferrer">WinMerge</a>?</p>
<p>Note: OSS preferred :)</p>
| [
{
"answer_id": 302006,
"author": "Oliver Giesen",
"author_id": 9784,
"author_profile": "https://Stackoverflow.com/users/9784",
"pm_score": 4,
"selected": false,
"text": "cvs -n up HEAD"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34088/"
] |
298,721 | <p>P1 and P2 are processes or nodes in a cluster. f1 and f2 are their flags. Supposing strong memory model, and that both processes may be restarted at any moment, and that restarting a process clears it's flag, here's an algorithm that I came up with and couldn't yet break, but that bothers me for it's not theoretically proven and looks too simple compared with Peterson's.</p>
<pre><code>P1 start:
set f1
if f2 set then clear f1, wait some, goto start
else enter critical section
do whatever
clear f1
P2 start:
set f2
if f1 set then clear f2, wait some, goto start
else enter critical section
do whatever
clear f2
</code></pre>
<p>Can anybody see a flow? Except may be that one of the processes may starve the other by quickly re-entering the section?</p>
| [
{
"answer_id": 298752,
"author": "Michael Madsen",
"author_id": 27528,
"author_profile": "https://Stackoverflow.com/users/27528",
"pm_score": 3,
"selected": false,
"text": "P1: set f1\nP2: set f2\nP1: is f2 set?\nP2: is f1 set?\nP1: yes, clear f1\nP2: yes, clear f2\nP1: start wait\nP2: start wait\nP1: end wait\nP2: end wait\nP1: goto start\nP2: goto start\n"
},
{
"answer_id": 298820,
"author": "Sunlight",
"author_id": 33650,
"author_profile": "https://Stackoverflow.com/users/33650",
"pm_score": 0,
"selected": false,
"text": "P1 start:\nset f1\nx = 2\nwhile f2 and (x == 2) wait\nenter critical section, etc.\nclear f1\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23420/"
] |
298,725 | <p>I have two tables, <code>movies</code> and <code>categories</code>, and I want to get an ordered list by <strong>categoryID</strong> first and then by <strong>Name</strong>.</p>
<p>The movie table has three columns <strong>ID, Name and CategoryID</strong>.
The category table has two columns <strong>ID and Name</strong>.</p>
<p>I tried something like the following, but it didn't work.</p>
<pre><code>var movies = _db.Movies.OrderBy( m => { m.CategoryID, m.Name })
</code></pre>
| [
{
"answer_id": 298741,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 13,
"selected": true,
"text": "var movies = _db.Movies.OrderBy(c => c.Category).ThenBy(n => n.Name)\n"
},
{
"answer_id": 3831749,
"author": "Scott Stafford",
"author_id": 237091,
"author_profile": "https://Stackoverflow.com/users/237091",
"pm_score": 9,
"selected": false,
"text": "var movies = from row in _db.Movies \n orderby row.Category, row.Name\n select row;\n ascending descending var movies = from row in _db.Movies \n orderby row.Category descending, row.Name\n select row;\n"
},
{
"answer_id": 6441561,
"author": "Alex",
"author_id": 197359,
"author_profile": "https://Stackoverflow.com/users/197359",
"pm_score": 6,
"selected": false,
"text": "var movies = _db.Movies.OrderBy( m => new { m.CategoryID, m.Name })\n var movies = _db.Movies.OrderBy( m => (m.CategoryID.ToString() + m.Name))\n"
},
{
"answer_id": 29433742,
"author": "prudentcoder",
"author_id": 4540222,
"author_profile": "https://Stackoverflow.com/users/4540222",
"pm_score": 4,
"selected": false,
"text": "OrberBy() IComparer IComparer Movie public class MovieComparer : IComparer<Movie>\n{\n public int Compare(Movie x, Movie y)\n {\n if (x.CategoryId == y.CategoryId)\n {\n return x.Name.CompareTo(y.Name);\n }\n else\n {\n return x.CategoryId.CompareTo(y.CategoryId);\n }\n }\n}\n var movies = _db.Movies.OrderBy(item => item, new MovieComparer());\n Compare() MovieComparer"
},
{
"answer_id": 35492359,
"author": "Oliver Slay",
"author_id": 522753,
"author_profile": "https://Stackoverflow.com/users/522753",
"pm_score": 5,
"selected": false,
"text": "DataContext DataContext _db.Log = Console.Out\n var movies = from row in _db.Movies \n orderby row.CategoryID, row.Name\n select row;\n var movies = _db.Movies.OrderBy(m => m.CategoryID).ThenBy(m => m.Name);\n SELECT [t0].ID, [t0].[Name], [t0].CategoryID\nFROM [dbo].[Movies] as [t0]\nORDER BY [t0].CategoryID, [t0].[Name]\n OrderBy var movies = from row in _db.Movies \n orderby row.CategoryID\n orderby row.Name\n select row;\n var movies = _db.Movies.OrderBy(m => m.CategoryID).OrderBy(m => m.Name);\n SELECT [t0].ID, [t0].[Name], [t0].CategoryID\nFROM [dbo].[Movies] as [t0]\nORDER BY [t0].[Name], [t0].CategoryID\n"
},
{
"answer_id": 44438959,
"author": "sjkm",
"author_id": 2435406,
"author_profile": "https://Stackoverflow.com/users/2435406",
"pm_score": 5,
"selected": false,
"text": "// We do not have to care if the queryable is already sorted or not. \n// The order of the Smart* calls defines the order priority\nqueryable.SmartOrderBy(i => i.Property1).SmartOrderByDescending(i => i.Property2);\n public static class IQueryableExtension\n{\n public static bool IsOrdered<T>(this IQueryable<T> queryable) {\n if(queryable == null) {\n throw new ArgumentNullException(\"queryable\");\n }\n\n return queryable.Expression.Type == typeof(IOrderedQueryable<T>);\n }\n\n public static IQueryable<T> SmartOrderBy<T, TKey>(this IQueryable<T> queryable, Expression<Func<T, TKey>> keySelector) {\n if(queryable.IsOrdered()) {\n var orderedQuery = queryable as IOrderedQueryable<T>;\n return orderedQuery.ThenBy(keySelector);\n } else {\n return queryable.OrderBy(keySelector);\n }\n }\n\n public static IQueryable<T> SmartOrderByDescending<T, TKey>(this IQueryable<T> queryable, Expression<Func<T, TKey>> keySelector) {\n if(queryable.IsOrdered()) {\n var orderedQuery = queryable as IOrderedQueryable<T>;\n return orderedQuery.ThenByDescending(keySelector);\n } else {\n return queryable.OrderByDescending(keySelector);\n }\n }\n}\n"
},
{
"answer_id": 51383971,
"author": "Saint-martin Guillaume",
"author_id": 6363241,
"author_profile": "https://Stackoverflow.com/users/6363241",
"pm_score": 3,
"selected": false,
"text": "> lstModule = _ModuleRepository.GetAll().OrderBy(x => new { x.Level,\n> x.Rank}).ToList();\n > _db.Module.Where(x=> ......).OrderBy(x => new { x.Level, x.Rank}).ToList();\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2246271/"
] |
298,726 | <p>I need to access an excel spreadsheet and insert the data from the spreadsheet into a SQL Database. However the Primary Keys are mixed, most are numeric and some are alpha-numeric.</p>
<p>The problem I have is that when the numeric and alpha-numeric Keys are in the same spreadsheet the alpha-numeric cells return blank values, whereas all the other cells return their data without problems.</p>
<p>I am using the OleDb method to access the Excel file. After retrieving the data with a Command string I put the data into a DataAdapter and then I fill a DataSet. I iterate through all the rows (dr) in the first DataTable in the DataSet.</p>
<p>I reference the columns by using, dr["..."].ToString()</p>
<p>If I debug the project in Visual Studio 2008 and I view the "extended properties", by holding my mouse over the "dr" I can view the values of the DataRow, but the Primary Key that should be alpha-numeric is {}. The other values are enclosed in quotes, but the blank value has braces.</p>
<p>Is this a C# problem or an Excel problem?</p>
<p>Has anyone ever encountered this problem before, or maybe found a workaround/fix?</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 1253129,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": false,
"text": "HDR=Yes; HDR=No; IMEX=1; SELECT * FROM [sheet1$] $ [ ]"
},
{
"answer_id": 3678453,
"author": "Andrew Garrison",
"author_id": 16460,
"author_profile": "https://Stackoverflow.com/users/16460",
"pm_score": 1,
"selected": false,
"text": "public void ImportSpreadsheet(string path)\n{\n string extendedProperties = \"Excel 12.0;HDR=YES;IMEX=1\";\n string connectionString = string.Format(\n CultureInfo.CurrentCulture,\n \"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\\\"{1}\\\"\",\n path,\n extendedProperties);\n\n using (OleDbConnection connection = new OleDbConnection(connectionString))\n {\n using (OleDbCommand command = connection.CreateCommand())\n {\n command.CommandText = \"SELECT * FROM [Worksheet1$]\";\n connection.Open();\n\n using (OleDbDataAdapter adapter = new OleDbDataAdapter(command))\n using (DataSet columnDataSet = new DataSet())\n using (DataSet dataSet = new DataSet())\n {\n columnDataSet.Locale = CultureInfo.CurrentCulture;\n adapter.Fill(columnDataSet);\n\n if (columnDataSet.Tables.Count == 1)\n {\n var worksheet = columnDataSet.Tables[0];\n\n // Now that we have a valid worksheet read in, with column names, we can create a\n // new DataSet with a table that has preset columns that are all of type string.\n // This fixes a problem where the OLEDB provider is trying to guess the data types\n // of the cells and strange data appears, such as scientific notation on some cells.\n dataSet.Tables.Add(\"WorksheetData\");\n DataTable tempTable = dataSet.Tables[0];\n\n foreach (DataColumn column in worksheet.Columns)\n {\n tempTable.Columns.Add(column.ColumnName, typeof(string));\n }\n\n adapter.Fill(dataSet, \"WorksheetData\");\n\n if (dataSet.Tables.Count == 1)\n {\n worksheet = dataSet.Tables[0];\n\n foreach (var row in worksheet.Rows)\n {\n // TODO: Consume some data.\n }\n }\n }\n }\n }\n }\n}\n"
},
{
"answer_id": 5989440,
"author": "balaji",
"author_id": 751973,
"author_profile": "https://Stackoverflow.com/users/751973",
"pm_score": 0,
"selected": false,
"text": "using System.Data.OleDb;\n\nstring ConnectionString = @\"Provider=Microsoft.Jet.OLEDB.4.0;\" + \"Data Source=\" + filepath + \";\" + \"Extended Properties=\"+(char)34+\"Excel 8.0;IMEX=1;\"+(char)34;\n\nstring CommandText = \"select * from [Sheet1$]\";\n\nOleDbConnection myConnection = new OleDbConnection(ConnectionString);\nmyConnection.Open();\n\nOleDbDataAdapter myAdapter = new OleDbDataAdapter(CommandText, myConnection);\n\nds = null;\nds = new DataSet();\nmyAdapter.Fill(ds);\n"
},
{
"answer_id": 11511523,
"author": "jbrumbaugh",
"author_id": 1529932,
"author_profile": "https://Stackoverflow.com/users/1529932",
"pm_score": 0,
"selected": false,
"text": " \n\ntry\n{\n Console.Write(wsReader.GetDouble(j).ToString());\n}\ncatch //Lame unfixable bug\n{\n Console.Write(wsReader.GetString(j));\n}\n\n\n try\n{\n Console.Write(wsReader.GetDouble(j).ToString());\n}\ncatch //Lame unfixable bug\n{\n Console.Write(wsReader.GetString(j));\n}\n "
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,733 | <p>I seemed to get the following exception when trying to deploy my application:</p>
<pre><code>Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
java.util.List is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at java.util.List
at private java.util.List foobar.alkohol.register.webservice.jaxws.GetRelationsFromPersonResponse._return
at foobar.alkohol.register.webservice.jaxws.GetRelationsFromPersonResponse
java.util.List does not have a no-arg default constructor.
this problem is related to the following location:
at java.util.List
at private java.util.List foobar.alkohol.register.webservice.jaxws.GetRelationsFromPersonResponse._return
at foobar.alkohol.register.webservice.jaxws.GetRelationsFromPersonResponse
</code></pre>
<p><strong><br/>My code worked just well until I changed the return type from List to List<List<RelationCanonical>></strong></p>
<p>Here is the partial webservice:</p>
<pre><code>
@Name("relationService")
@Stateless
@WebService(name = "RelationService", serviceName = "RelationService")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public class RelationService implements RelationServiceLocal {
private boolean login(String username, String password) {
Identity.instance().setUsername(username);
Identity.instance().setPassword(password);
Identity.instance().login();
return Identity.instance().isLoggedIn();
}
private boolean logout() {
Identity.instance().logout();
return !Identity.instance().isLoggedIn();
}
@WebMethod
public List<List<RelationCanonical>> getRelationsFromPerson(@WebParam(name = "username")
String username, @WebParam(name = "password")
String password, @WebParam(name = "foedselsnummer")
String... foedselsnummer) {
......
......
......
}
</code></pre>
<p><br/>
<strong>I have also tried by removing the @SOAPBinding and trying default, but the same result occurs.
Appreciate any help</strong></p>
<p><strong>UPDATE</strong></p>
<p>I want to note out something. I changed all List to ArrayList, and then it compiled. The reason why I say compiled and not worked is because it behaves strange. I get an Object of type:
RelationServiceStub.ArrayList
but the object has no get methods or does not behave as a List either. I also tried to cast it to a List but that didnt work.</p>
<p>Note that this is after I have used Axis 2 and wsdl2java So yes, now it compiles, but I dont know how to get the data out.</p>
| [
{
"answer_id": 298914,
"author": "Henning",
"author_id": 7034,
"author_profile": "https://Stackoverflow.com/users/7034",
"pm_score": 6,
"selected": true,
"text": "List List<RelationCanonical> Type1 List<List<...>> Type2 <Type2 ...>\n <Type1 ...>\n <RelationCanonical ...> ... </RelationCanonical>\n <RelationCanonical ...> ... </RelationCanonical>\n ...\n </Type1>\n <Type1>\n <RelationCanonical ...> ... </RelationCanonical>\n <RelationCanonical ...> ... </RelationCanonical>\n ...\n </Type1>\n ...\n</Type2>\n @XmlType\npublic class Type1{\n\n private List<RelationCanonical> relations;\n\n @XmlElement\n public List<RelationCanonical> getRelations(){\n return this.relations;\n }\n\n public void setRelations(List<RelationCanonical> relations){\n this.relations = relations;\n }\n}\n @XmlRootElement\npublic class Type2{\n\n private List<Type1> type1s;\n\n @XmlElement\n public List<Type1> getType1s(){\n return this.type1s;\n }\n\n public void setType1s(List<Type1> type1s){\n this.type1s= type1s;\n }\n}\n"
},
{
"answer_id": 1119241,
"author": "Argo",
"author_id": 137195,
"author_profile": "https://Stackoverflow.com/users/137195",
"pm_score": 3,
"selected": false,
"text": "YourType[]\n"
},
{
"answer_id": 7960987,
"author": "Nick",
"author_id": 1022867,
"author_profile": "https://Stackoverflow.com/users/1022867",
"pm_score": 1,
"selected": false,
"text": "return items.size() > 0 ? items.toArray((Object[]) Array.newInstance(\n items.get(0).getClass(), 0)) : new Object[0];\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37298/"
] |
298,739 | <p>This is probably a n00blike (or worse) question. But I've always viewed a schema as a table definition in a database. This is wrong or not entirely correct. I don't remember much from my database courses. </p>
| [
{
"answer_id": 11306076,
"author": "Iswarya",
"author_id": 1497978,
"author_profile": "https://Stackoverflow.com/users/1497978",
"pm_score": 2,
"selected": false,
"text": "Schema database"
},
{
"answer_id": 49285636,
"author": "Sridhar Sarnobat",
"author_id": 714112,
"author_profile": "https://Stackoverflow.com/users/714112",
"pm_score": 3,
"selected": false,
"text": "database/schema :: table database :: (schema/namespace ::) table database/schema/user :: (tablespace ::) table"
},
{
"answer_id": 58230603,
"author": "Siddharth Kumar",
"author_id": 4332110,
"author_profile": "https://Stackoverflow.com/users/4332110",
"pm_score": 3,
"selected": false,
"text": "schema1 myschema mytable"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20023/"
] |
298,745 | <p>How do I send a cross-domain POST request via JavaScript?</p>
<p>Notes - it shouldn't refresh the page, and I need to grab and parse the response afterwards.</p>
| [
{
"answer_id": 298763,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 6,
"selected": false,
"text": " var ifr = document.createElement('iframe');\n var frm = document.createElement('form');\n frm.setAttribute(\"action\", \"yoururl\");\n frm.setAttribute(\"method\", \"post\");\n\n // create hidden inputs, add them\n // not shown, but similar (create, setAttribute, appendChild)\n\n ifr.appendChild(frm);\n document.body.appendChild(ifr);\n frm.submit();\n"
},
{
"answer_id": 2329962,
"author": "ndeuma",
"author_id": 124194,
"author_profile": "https://Stackoverflow.com/users/124194",
"pm_score": 3,
"selected": false,
"text": "post_method"
},
{
"answer_id": 4765353,
"author": "Robb Lovell",
"author_id": 585244,
"author_profile": "https://Stackoverflow.com/users/585244",
"pm_score": 4,
"selected": false,
"text": "header('Access-Control-Allow-Origin: *');\n function xmlrpc_server_output($xml) {\n $xml = '<?xml version=\"1.0\"?>'.\"\\n\". $xml;\n header('Connection: close');\n header('Content-Length: '. strlen($xml));\n header('Access-Control-Allow-Origin: *');\n header('Content-Type: application/x-www-form-urlencoded');\n header('Date: '. date('r'));\n // $xml = str_replace(\"\\n\", \" \", $xml); \n\n echo $xml;\n exit;\n}\n"
},
{
"answer_id": 6169703,
"author": "Dan Fabulich",
"author_id": 54829,
"author_profile": "https://Stackoverflow.com/users/54829",
"pm_score": 7,
"selected": false,
"text": "function crossDomainPost() {\n // Add the iframe with a unique name\n var iframe = document.createElement(\"iframe\");\n var uniqueString = \"CHANGE_THIS_TO_SOME_UNIQUE_STRING\";\n document.body.appendChild(iframe);\n iframe.style.display = \"none\";\n iframe.contentWindow.name = uniqueString;\n\n // construct a form with hidden inputs, targeting the iframe\n var form = document.createElement(\"form\");\n form.target = uniqueString;\n form.action = \"http://INSERT_YOUR_URL_HERE\";\n form.method = \"POST\";\n\n // repeat for each parameter\n var input = document.createElement(\"input\");\n input.type = \"hidden\";\n input.name = \"INSERT_YOUR_PARAMETER_NAME_HERE\";\n input.value = \"INSERT_YOUR_PARAMETER_VALUE_HERE\";\n form.appendChild(input);\n\n document.body.appendChild(form);\n form.submit();\n}\n window.postMessage"
},
{
"answer_id": 7605119,
"author": "rynop",
"author_id": 563420,
"author_profile": "https://Stackoverflow.com/users/563420",
"pm_score": 9,
"selected": false,
"text": "Access-Control-Allow-Origin OPTIONS switch ($_SERVER['HTTP_ORIGIN']) {\n case 'http://from.com': case 'https://from.com':\n header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']);\n header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');\n header('Access-Control-Max-Age: 1000');\n header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');\n break;\n}\n $.ajax({\n type: 'POST',\n url: 'https://to.com/postHere.php',\n crossDomain: true,\n data: '{\"some\":\"json\"}',\n dataType: 'json',\n success: function(responseData, textStatus, jqXHR) {\n var value = responseData.someKey;\n },\n error: function (responseData, textStatus, errorThrown) {\n alert('POST failed.');\n }\n});\n"
},
{
"answer_id": 9006942,
"author": "BasTaller",
"author_id": 411671,
"author_profile": "https://Stackoverflow.com/users/411671",
"pm_score": 3,
"selected": false,
"text": "$.ajax({\n type : 'POST',\n dataType : 'json', \n url : 'another-remote-server',\n ...\n});\n"
},
{
"answer_id": 22233843,
"author": "Ivan Durst",
"author_id": 1631537,
"author_profile": "https://Stackoverflow.com/users/1631537",
"pm_score": 2,
"selected": false,
"text": "<?\n\nfunction post($url, $data) {\n$header = array(\"User-Agent: \" . $_SERVER[\"HTTP_USER_AGENT\"], \"Content-Type: application/x-www-form-urlencoded\");\n$curl = curl_init();\ncurl_setopt($curl, CURLOPT_URL, $url);\ncurl_setopt($curl, CURLOPT_HTTPHEADER, $header);\ncurl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);\ncurl_setopt($curl, CURLOPT_POST, 1);\ncurl_setopt($curl, CURLOPT_POSTFIELDS, $data);\n$response = curl_exec($curl);\ncurl_close($curl);\nreturn $response;\n}\n\n$url = \"your cross domain request here\";\n$data = $_SERVER[\"QUERY_STRING\"];\necho(post($url, $data));\n $.ajax({\ntype: 'POST',\nurl: 'submit.php',\ncrossDomain: true,\ndata: '{\"some\":\"json\"}',\ndataType: 'json',\nsuccess: function(responseData, textStatus, jqXHR) {\n var value = responseData.someKey;\n},\nerror: function (responseData, textStatus, errorThrown) {\n alert('POST failed.');\n}\n});\n"
},
{
"answer_id": 23501289,
"author": "Sujeewa",
"author_id": 1658297,
"author_profile": "https://Stackoverflow.com/users/1658297",
"pm_score": 3,
"selected": false,
"text": " <httpProtocol>\n <customHeaders>\n <add name=\"Access-Control-Allow-Origin\" value=\"*\" />\n <add name=\"Access-Control-Allow-Headers\" value=\"Content-Type\" />\n <add name=\"Access-Control-Allow-Methods\" value=\"POST, GET, OPTIONS\" />\n </customHeaders>\n </httpProtocol>\n [HttpPost]\npublic JsonResult Save()\n{\n //Handle the post data...\n\n return Json(\n new\n {\n IsSuccess = true\n });\n}\n $.ajax({\n type: \"POST\",\n url: \"http://www.server.com/home/save\",\n dataType: 'json',\n crossDomain: true,\n data: $(formId).serialize(),\n success: function (jsonResult) {\n //do what ever with the reply\n },\n error: function (jqXHR, textStatus) {\n //handle error\n }\n });\n"
},
{
"answer_id": 24464232,
"author": "jcubic",
"author_id": 387194,
"author_profile": "https://Stackoverflow.com/users/387194",
"pm_score": 2,
"selected": false,
"text": "var win = $('iframe')[0].contentWindow\n\nfunction get(event) {\n if (event.origin === \"http://reciver.com\") {\n // event.data is response from POST\n }\n}\n\nif (window.addEventListener){\n addEventListener(\"message\", get, false)\n} else {\n attachEvent(\"onmessage\", get)\n}\nwin.postMessage(JSON.stringify({url: \"URL\", data: {}}),\"http://reciver.com\");\n function listener(event) {\n if (event.origin === \"http://sender.com\") {\n var data = JSON.parse(event.data);\n $.post(data.url, data.data, function(reponse) {\n window.parent.postMessage(reponse, \"*\");\n });\n }\n}\n// don't know if we can use jQuery here\nif (window.addEventListener){\n addEventListener(\"message\", listener, false)\n} else {\n attachEvent(\"onmessage\", listener)\n}\n"
},
{
"answer_id": 26183413,
"author": "Alain Gauthier",
"author_id": 2085677,
"author_profile": "https://Stackoverflow.com/users/2085677",
"pm_score": 5,
"selected": false,
"text": "crossDomain: true, success error $.ajax({\n type: \"POST\",\n url: \"http://www.yoururl.com/\",\n crossDomain: true,\n data: 'param1=value1¶m2=value2',\n success: function (data) {\n // do something with server response data\n },\n error: function (err) {\n // handle your error logic here\n }\n });\n"
},
{
"answer_id": 41744627,
"author": "Jelly",
"author_id": 5881703,
"author_profile": "https://Stackoverflow.com/users/5881703",
"pm_score": 1,
"selected": false,
"text": "catta('./data/simple.json').then(function (res) {\n console.log(res);\n});\n <script>"
},
{
"answer_id": 52284453,
"author": "Raj Malakpet",
"author_id": 3154825,
"author_profile": "https://Stackoverflow.com/users/3154825",
"pm_score": 1,
"selected": false,
"text": "<script src=\"js/xdomain.min.js\" slave=\"https://crossdomain_server/proxy.html\"></script>\n proxy.html:\n<!DOCTYPE HTML>\n<script src=\"js/xdomain.min.js\"></script>\n<script>\n xdomain.masters({\n \"https://server1\" : '*'\n });\n</script>\n $.ajax({\n url: 'https://crossdomain_server/proxy.html',\n type: \"POST\",\n data: JSON.stringify(_data),\n dataType: \"json\",\n contentType: \"application/json; charset=utf-8\"\n })\n .done(_success)\n .fail(_failed)\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33046/"
] |
298,750 | <p>I would like to get all descendant text nodes of an element, as a jQuery collection. What is the best way to do that?</p>
| [
{
"answer_id": 298758,
"author": "Christian Oudard",
"author_id": 3757,
"author_profile": "https://Stackoverflow.com/users/3757",
"pm_score": 8,
"selected": false,
"text": "$(elem)\n .contents()\n .filter(function() {\n return this.nodeType === 3; //Node.TEXT_NODE\n });\n"
},
{
"answer_id": 4399718,
"author": "Tim Down",
"author_id": 96100,
"author_profile": "https://Stackoverflow.com/users/96100",
"pm_score": 9,
"selected": true,
"text": "contents() find() var getTextNodesIn = function(el) {\n return $(el).find(\":not(iframe)\").addBack().contents().filter(function() {\n return this.nodeType == 3;\n });\n};\n\ngetTextNodesIn(el);\n addBack() andSelf() andSelf() addBack() contents() includeWhitespaceNodes function getTextNodesIn(node, includeWhitespaceNodes) {\n var textNodes = [], nonWhitespaceMatcher = /\\S/;\n\n function getTextNodes(node) {\n if (node.nodeType == 3) {\n if (includeWhitespaceNodes || nonWhitespaceMatcher.test(node.nodeValue)) {\n textNodes.push(node);\n }\n } else {\n for (var i = 0, len = node.childNodes.length; i < len; ++i) {\n getTextNodes(node.childNodes[i]);\n }\n }\n }\n\n getTextNodes(node);\n return textNodes;\n}\n\ngetTextNodesIn(el);\n"
},
{
"answer_id": 5732333,
"author": "colllin",
"author_id": 361609,
"author_profile": "https://Stackoverflow.com/users/361609",
"pm_score": 2,
"selected": false,
"text": "$('selector').clone().children().remove().end().contents();\n $('selector').clone().children().remove().end();\n"
},
{
"answer_id": 6444803,
"author": "Rahen Rangan",
"author_id": 4804876,
"author_profile": "https://Stackoverflow.com/users/4804876",
"pm_score": 0,
"selected": false,
"text": "String.prototype.stripTags=function(){\nvar rtag=/<.*?[^>]>/g;\nreturn this.replace(rtag,'');\n}\n var newText=$('selector').html().stripTags();\n"
},
{
"answer_id": 6884909,
"author": "Guillermo",
"author_id": 193447,
"author_profile": "https://Stackoverflow.com/users/193447",
"pm_score": 0,
"selected": false,
"text": "$.fn.nextNode = function(){\n var contents = $(this).parent().contents();\n return contents.get(contents.index(this)+1);\n}\n $('#my_id').nextNode();\n next()"
},
{
"answer_id": 7824394,
"author": "He Nrik",
"author_id": 263025,
"author_profile": "https://Stackoverflow.com/users/263025",
"pm_score": 4,
"selected": false,
"text": "$('body').find('*').contents().filter(function () { return this.nodeType === 3; });\n"
},
{
"answer_id": 17189915,
"author": "Mr_Green",
"author_id": 1577396,
"author_profile": "https://Stackoverflow.com/users/1577396",
"pm_score": 1,
"selected": false,
"text": "var textContents = $(document.getElementById(\"ElementId\").childNodes).filter(function(){\n return this.nodeType == 3;\n});\n"
},
{
"answer_id": 18405619,
"author": "davenpcj",
"author_id": 4777,
"author_profile": "https://Stackoverflow.com/users/4777",
"pm_score": 0,
"selected": false,
"text": ".contents() pre jQuery(\"#resultTable td\").content().wrap(\"<pre/>\")\n"
},
{
"answer_id": 21215587,
"author": "Salman A",
"author_id": 87015,
"author_profile": "https://Stackoverflow.com/users/87015",
"pm_score": 3,
"selected": false,
"text": "jQuery.contents() jQuery.filter $(function() {\n var $textNodes = $(\"#test, #test *\").contents().filter(function() {\n return this.nodeType === Node.TEXT_NODE;\n });\n /*\n * for testing\n */\n $textNodes.each(function() {\n console.log(this);\n });\n}); div { margin-left: 1em; } <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js\"></script>\n\n<div id=\"test\">\n child text 1<br>\n child text 2\n <div>\n grandchild text 1\n <div>grand-grandchild text 1</div>\n grandchild text 2\n </div>\n child text 3<br>\n child text 4\n</div>"
},
{
"answer_id": 21807626,
"author": "iConnor",
"author_id": 1907358,
"author_profile": "https://Stackoverflow.com/users/1907358",
"pm_score": 2,
"selected": false,
"text": "contents() jQuery.fn.descendants jQuery('body').descendants('all');\n jQuery('body').descendants(true);\n jQuery('body').descendants();\n jQuery.fn.descendants = ( textNodes ) ->\n\n # if textNodes is 'all' then textNodes and elementNodes are allowed\n # if textNodes if true then only textNodes will be returned\n # if textNodes is not provided as an argument then only element nodes\n # will be returned\n\n allowedTypes = if textNodes is 'all' then [1,3] else if textNodes then [3] else [1]\n\n # nodes we find\n nodes = []\n\n\n dig = (node) ->\n\n # loop through children\n for child in node.childNodes\n\n # push child to collection if has allowed type\n nodes.push(child) if child.nodeType in allowedTypes\n\n # dig through child if has children\n dig child if child.childNodes.length\n\n\n # loop and dig through nodes in the current\n # jQuery object\n dig node for node in this\n\n\n # wrap with jQuery\n return jQuery(nodes)\n var __indexOf=[].indexOf||function(e){for(var t=0,n=this.length;t<n;t++){if(t in this&&this[t]===e)return t}return-1}; /* indexOf polyfill ends here*/ jQuery.fn.descendants=function(e){var t,n,r,i,s,o;t=e===\"all\"?[1,3]:e?[3]:[1];i=[];n=function(e){var r,s,o,u,a,f;u=e.childNodes;f=[];for(s=0,o=u.length;s<o;s++){r=u[s];if(a=r.nodeType,__indexOf.call(t,a)>=0){i.push(r)}if(r.childNodes.length){f.push(n(r))}else{f.push(void 0)}}return f};for(s=0,o=this.length;s<o;s++){r=this[s];n(r)}return jQuery(i)}\n Array.indexOf"
},
{
"answer_id": 26346136,
"author": "Alex W",
"author_id": 1399491,
"author_profile": "https://Stackoverflow.com/users/1399491",
"pm_score": 2,
"selected": false,
"text": "nodeValue filter $.trim(this.nodevalue) !== '' $('element')\n .contents()\n .filter(function(){\n return this.nodeType === 3 && $.trim(this.nodeValue) !== '';\n });\n ­ \\n \\S $('element')\n .contents()\n .filter(function(){\n return this.nodeType === 3 && /\\S/.test(this.nodeValue);\n });\n"
},
{
"answer_id": 74669152,
"author": "toddmo",
"author_id": 1045881,
"author_profile": "https://Stackoverflow.com/users/1045881",
"pm_score": 0,
"selected": false,
"text": "$('parent')\n.find(\":not(iframe)\")\n.addBack()\n.contents()\n.filter(function() {return this.nodeType == 3;})\n//.map((i,v) => $(v).text()) // uncomment if you want strings\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3757/"
] |
298,753 | <p>can i somehow compare two numbers in regex?
i want regex that is correct for 10-12, but incorrect for 12-10. I mean that 10 must be smaller than 12.
I want to do it in Javascript.</p>
| [
{
"answer_id": 298759,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 2,
"selected": false,
"text": "10+12 12+10"
},
{
"answer_id": 298832,
"author": "Unsliced",
"author_id": 2902,
"author_profile": "https://Stackoverflow.com/users/2902",
"pm_score": 2,
"selected": false,
"text": "x-y x y"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
298,760 | <p>I'm trying to ensure a script remains running on a development server. It collates stats and provides a web service so it's supposed to persist, yet a few times a day, it dies off for unknown reasons. When we notice we just launch it again, but it's a pain in the rear and some users don't have permission (or the knowhow) to launch it up.</p>
<p>The programmer in me wants to spend a few hours getting to the bottom of the problem but the busy person in me thinks there must be an easy way to detect if an app is not running, and launch it again.</p>
<p>I know I <em>could</em> cron-script ps through grep:</p>
<pre><code>ps -A | grep appname
</code></pre>
<p>But again, that's another hour of my life wasted on doing something that must already exist... Is there not a pre-made app that I can pass an executable (optionally with arguments) and that will keep a process running indefinitely?</p>
<p>In case it makes any difference, it's Ubuntu.</p>
| [
{
"answer_id": 298774,
"author": "gx.",
"author_id": 21580,
"author_profile": "https://Stackoverflow.com/users/21580",
"pm_score": 1,
"selected": false,
"text": "if [ `pidof -s app` -eq 0 ]; then\n nohup app &\nfi\n"
},
{
"answer_id": 298919,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 1,
"selected": false,
"text": "nanny"
},
{
"answer_id": 298944,
"author": "JimB",
"author_id": 32880,
"author_profile": "https://Stackoverflow.com/users/32880",
"pm_score": 6,
"selected": true,
"text": "#!/bin/bash\nif [[ ! `pidof -s yourapp` ]]; then\n invoke-rc.d yourapp start\nfi\n"
},
{
"answer_id": 911146,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 7,
"selected": false,
"text": "#!/bin/bash\n#make-run.sh\n#make sure a process is always running.\n\nexport DISPLAY=:0 #needed if you are running a simple gui app.\n\nprocess=YourProcessName\nmakerun=\"/usr/bin/program\"\n\nif ps ax | grep -v grep | grep $process > /dev/null\nthen\n exit\nelse\n $makerun &\nfi\n\nexit\n"
},
{
"answer_id": 30787007,
"author": "Asfand Qazi",
"author_id": 144876,
"author_profile": "https://Stackoverflow.com/users/144876",
"pm_score": 2,
"selected": false,
"text": "supervise daemontools"
},
{
"answer_id": 31157881,
"author": "Radosław Ganczarek",
"author_id": 1381549,
"author_profile": "https://Stackoverflow.com/users/1381549",
"pm_score": 0,
"selected": false,
"text": "#!/bin/bash\n\nexport DISPLAY=:0\n\nprocess=processname\nmakerun=\"/usr/bin/processname\"\n\nif ! pgrep $process > /dev/null\nthen\n $makerun &\nfi\n"
},
{
"answer_id": 34333783,
"author": "Raman",
"author_id": 430128,
"author_profile": "https://Stackoverflow.com/users/430128",
"pm_score": 5,
"selected": false,
"text": "no on-success on-failure on-abnormal on-watchdog on-abort always ~/.config/systemd/user/something.service [Unit]\nDescription=Something\n\n[Service]\nExecStart=/path/to/something\nRestart=on-failure\n\n[Install]\nWantedBy=graphical.target\n systemctl --user daemon-reload\nsystemctl --user [status|start|stop|restart] something\n"
},
{
"answer_id": 38304470,
"author": "cjohansson",
"author_id": 771405,
"author_profile": "https://Stackoverflow.com/users/771405",
"pm_score": 2,
"selected": false,
"text": "bash ./root/makerun-mysql.sh process makerun nano /root/makerun-mysql.sh #!/bin/bash\nprocess=\"mysql\"\nmakerun=\"/etc/init.d/mysql restart\"\nif ps ax | grep -v grep | grep -v bash | grep --quiet $process\nthen\n printf \"Process '%s' is running.\\n\" \"$process\"\n exit\nelse\n printf \"Starting process '%s' with command '%s'.\\n\" \"$process\" \"$makerun\"\n $makerun\nfi\nexit\n chmod 700 /root/makerun-mysql.sh crontab -e # Keep processes running every 5 minutes\n*/5 * * * * bash /root/makerun-mysql.sh\n"
},
{
"answer_id": 64795449,
"author": "16851556",
"author_id": 2504130,
"author_profile": "https://Stackoverflow.com/users/2504130",
"pm_score": 0,
"selected": false,
"text": "ps aux|grep \"appname\" \"appname\" &"
},
{
"answer_id": 74577751,
"author": "osiris rodriguez",
"author_id": 4756976,
"author_profile": "https://Stackoverflow.com/users/4756976",
"pm_score": 0,
"selected": false,
"text": "sudo apt-get pm2 \n Sudo npm install pm2 -g\n sudo pm2 start [service_name]\n pm2 start index.js\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12870/"
] |
298,772 | <p>When I render a page using the Django template renderer, I can pass in a dictionary variable containing various values to manipulate them in the page using <code>{{ myVar }}</code>.</p>
<p>Is there a way to access the same variable in Javascript (perhaps using the DOM, I don't know how Django makes the variables accessible)? I want to be able to lookup details using an AJAX lookup based on the values contained in the variables passed in.</p>
| [
{
"answer_id": 298793,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 10,
"selected": true,
"text": "{{variable}} <script type=\"text/javascript\"> \n var a = \"{{someDjangoVariable}}\";\n</script>\n"
},
{
"answer_id": 8483184,
"author": "bosco-",
"author_id": 581420,
"author_profile": "https://Stackoverflow.com/users/581420",
"pm_score": 6,
"selected": false,
"text": "<input type=\"hidden\" id=\"myVar\" name=\"variable\" value=\"{{ variable }}\">\n var myVar = document.getElementById(\"myVar\").value;\n"
},
{
"answer_id": 25538871,
"author": "Yaroslav Admin",
"author_id": 1377864,
"author_profile": "https://Stackoverflow.com/users/1377864",
"pm_score": 6,
"selected": false,
"text": "dict list // myapp/templatetags/js.py\n\nfrom django.utils.safestring import mark_safe\nfrom django.template import Library\n\nimport json\n\n\nregister = Library()\n\n\n@register.filter(is_safe=True)\ndef js(obj):\n return mark_safe(json.dumps(obj))\n // myapp/templates/example.html\n\n{% load js %}\n\n<script type=\"text/javascript\">\n var someVar = {{ some_var | js }};\n</script>\n"
},
{
"answer_id": 29032335,
"author": "Insomniak",
"author_id": 2599358,
"author_profile": "https://Stackoverflow.com/users/2599358",
"pm_score": 3,
"selected": false,
"text": "{% if DJdata %}\n <script type=\"text/javascript\">\n (function () {window.DJdata = {{DJdata|safe}};})();\n </script>\n{% endif %}\n context['DJdata'] = json.dumps(DJdata)"
},
{
"answer_id": 32998283,
"author": "Conquistador",
"author_id": 5306148,
"author_profile": "https://Stackoverflow.com/users/5306148",
"pm_score": 3,
"selected": false,
"text": "<script type=\"text/javascript\"> \n var a = \"{{someDjangoVariable}}\"\n</script>\n"
},
{
"answer_id": 42656640,
"author": "shacker",
"author_id": 8438,
"author_profile": "https://Stackoverflow.com/users/8438",
"pm_score": 4,
"selected": false,
"text": "escapejs JSON.parse() var CropOpts = JSON.parse(\"{{ profile.last_crop_coords|escapejs }}\");\n escapejs JSON.parse()"
},
{
"answer_id": 52827769,
"author": "Daniel Kislyuk",
"author_id": 1772802,
"author_profile": "https://Stackoverflow.com/users/1772802",
"pm_score": 3,
"selected": false,
"text": "<script type=\"text/javascript\">\n var myVar = \"{{ myVar }}\"\n</script>\n\n<script type=\"text/javascript\" src=\"{% static \"scripts/my_script.js\" %}\"></script>\n data get_context_data def get_context_data(self, *args, **kwargs):\n context['myVar'] = True\n return context\n"
},
{
"answer_id": 53234407,
"author": "Shoval Sadde",
"author_id": 8205650,
"author_profile": "https://Stackoverflow.com/users/8205650",
"pm_score": 3,
"selected": false,
"text": "{{contact}} contact.html {{posts}} index.html <script> {%endblock%} base.html contact.html index.html <script type=\"text/javascript\">\n var myVar = \"{{ myVar }}\"\n</script>\n // index.html\n<div id=\"myvar\">{{ myVar }}</div>\n // somecode.js\nvar someVar = document.getElementById(\"myvar\").innerHTML;\n <script src=\"static/js/somecode.js\"></script> base.html"
},
{
"answer_id": 54270838,
"author": "Jon Sakas",
"author_id": 2253270,
"author_profile": "https://Stackoverflow.com/users/2253270",
"pm_score": 6,
"selected": false,
"text": "json_script"
},
{
"answer_id": 57466791,
"author": "Daniel Muñoz",
"author_id": 9820681,
"author_profile": "https://Stackoverflow.com/users/9820681",
"pm_score": 0,
"selected": false,
"text": " aaa = [41, 56, 25, 48, 72, 34, 12]\n prueba = \"<script>var data2 =[\"\n for a in aaa:\n aa = str(a)\n prueba = prueba + \"'\" + aa + \"',\"\n prueba = prueba + \"];</script>\"\n prueba = \"<script>var data2 =['41','56','25','48','72','34','12'];</script>\"\n return render(request, 'example.html', {\"prueba\": prueba})\n {{ prueba|safe }}\n <script>\n console.log(data2);\n</script>\n"
},
{
"answer_id": 60918028,
"author": "nofoobar",
"author_id": 11652661,
"author_profile": "https://Stackoverflow.com/users/11652661",
"pm_score": 0,
"selected": false,
"text": "'{{context_variable|escapejs }}'\n from json import dumps as jdumps\n\ndef func(request):\n context={'message': jdumps('hello there')}\n return render(request,'index.html',context)\n {{ message|safe }}\n"
},
{
"answer_id": 61256736,
"author": "henrry",
"author_id": 12780274,
"author_profile": "https://Stackoverflow.com/users/12780274",
"pm_score": 2,
"selected": false,
"text": "def age(request):\n mydata = {'age':12}\n return render(request, 'test.html', context={\"mydata_json\": json.dumps(mydata)})\n <script type='text/javascript'>\n const mydata = {{ mydata_json|safe }};\nconsole.log(mydata)\n </script>\n"
},
{
"answer_id": 62953940,
"author": "Devesh Pradhan",
"author_id": 9308248,
"author_profile": "https://Stackoverflow.com/users/9308248",
"pm_score": 3,
"selected": false,
"text": "<button type=\"button\" onclick=\"myJavascriptFunction('{{ my_django_variable }}')\"></button>\n<script>\n myJavascriptFunction(djangoVariable){\n alert(djangoVariable);\n }\n</script>\n"
},
{
"answer_id": 62990588,
"author": "Josh",
"author_id": 5403449,
"author_profile": "https://Stackoverflow.com/users/5403449",
"pm_score": 4,
"selected": false,
"text": "{{ variable|json_script:'name' }} <script> var js_variable = JSON.parse(document.getElementById('name').textContent);"
},
{
"answer_id": 65286399,
"author": "Shahriar.M",
"author_id": 3777814,
"author_profile": "https://Stackoverflow.com/users/3777814",
"pm_score": 4,
"selected": false,
"text": "{{ mydata|json_script:\"mydata\" }} {{ mydata|json_script:\"mydata\" }}\n<script>\n const mydata = JSON.parse(document.getElementById('mydata').textContent);\n</script>\n"
},
{
"answer_id": 74164921,
"author": "Tiago Martins Peres",
"author_id": 5675325,
"author_profile": "https://Stackoverflow.com/users/5675325",
"pm_score": 0,
"selected": false,
"text": "json_script"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38581/"
] |
298,779 | <p>I'm working on my first Django application. In short, what it needs to do is to display a list of film titles, and allow users to give a rating (out of 10) to each film. I've been able to use the {{ form }} and {{ formset }} syntax in a template to produce a form which lets you rate one film at a time, which corresponds to one row in a MySQL table, but how do I produce a form that iterates over all the movie titles in the database and produces a form that lets you rate lots of them at once? </p>
<p>At first, I thought this was what formsets were for, but I can't see any way to automatically iterate over the contents of a database table to produce items to go in the form, if you see what I mean.</p>
<p>Currently, my views.py has this code:</p>
<pre><code>def survey(request):
ScoreFormSet = formset_factory(ScoreForm)
if request.method == 'POST':
formset = ScoreFormSet(request.POST, request.FILES)
if formset.is_valid():
return HttpResponseRedirect('/')
else:
formset = ScoreFormSet()
return render_to_response('cf/survey.html', {
'formset':formset,
})
</code></pre>
<p>And my survey.html has this:</p>
<pre><code><form action="/survey/" method="POST">
<table>
{{ formset }}
</table>
<input type = "submit" value = "Submit">
</form>
</code></pre>
<p>Oh, and the definition of ScoreForm and Score from models.py are:</p>
<pre><code>class Score(models.Model):
movie = models.ForeignKey(Movie)
score = models.IntegerField()
user = models.ForeignKey(User)
class ScoreForm(ModelForm):
class Meta:
model = Score
</code></pre>
<p>So, in case the above is not clear, what I'm aiming to produce is a form which has one row per movie, and each row shows a title, and has a box to allow the user to enter their score.</p>
<p>If anyone can point me at the right sort of approach to this, I'd be most grateful.</p>
| [
{
"answer_id": 298835,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 3,
"selected": true,
"text": "initial = [ list of { dictionaries }, one per form ] \n values"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11522/"
] |
298,780 | <p>i could call a page inside the same domain, but its not working when i calling a page in a sub domain due to security issues. what i have to do? help me!!!</p>
| [
{
"answer_id": 7017086,
"author": "beausoleilm",
"author_id": 888680,
"author_profile": "https://Stackoverflow.com/users/888680",
"pm_score": 1,
"selected": false,
"text": "<script type=\"text/javascript\">\njQuery.ajax({\n success: function(data) {\n alert(data.field);\n },\n dataType: 'json'\n});\n</script>\n <script src=\"http://sub.domain.com/file\"></script>\n data = {'field': 'bleh'}\nalert(data.field);\n"
}
] | 2008/11/18 | [
"https://Stackoverflow.com/questions/298780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38578/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.