qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
325,004
<p>I have an onclick handler for an &lt;a&gt; element (actually, it's a jQuery-created handler, but that's not important). It looks like this:</p> <pre><code>function handleOnClick() { if(confirm("Are you sure?")) { return handleOnClickConfirmed(); } return false; } </code></pre> <p>From this fun...
[ { "answer_id": 325013, "author": "Rob", "author_id": 3542, "author_profile": "https://Stackoverflow.com/users/3542", "pm_score": 6, "selected": true, "text": "<p>The following ought to do it:</p>\n\n<pre><code>function handleOnClick() {\n if( confirm( \"Sure?\" ) ) {\n return h...
2008/11/28
[ "https://Stackoverflow.com/questions/325004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39992/" ]
I have an onclick handler for an <a> element (actually, it's a jQuery-created handler, but that's not important). It looks like this: ``` function handleOnClick() { if(confirm("Are you sure?")) { return handleOnClickConfirmed(); } return false; } ``` From this function, the **this** object is acc...
The following ought to do it: ``` function handleOnClick() { if( confirm( "Sure?" ) ) { return handleOnClickConfirmed.call( this ); } return false; } ``` The [`call()`](https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function/call) function attached to `Function` obj...
325,007
<p>can anyone show me how to get the users within a certain group using sharepoint?</p> <p>so i have a list that contains users and or groups. i want to retrieve all users in that list. is there a way to differentiate between whether the list item is a group or user. if its a group, i need to get all the users within ...
[ { "answer_id": 326218, "author": "Pedrin", "author_id": 36183, "author_profile": "https://Stackoverflow.com/users/36183", "pm_score": 5, "selected": true, "text": "<p>The first thing you need to know is that when you have a list with a User / Group field you must be aware of its type. Wh...
2008/11/28
[ "https://Stackoverflow.com/questions/325007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23491/" ]
can anyone show me how to get the users within a certain group using sharepoint? so i have a list that contains users and or groups. i want to retrieve all users in that list. is there a way to differentiate between whether the list item is a group or user. if its a group, i need to get all the users within that group...
The first thing you need to know is that when you have a list with a User / Group field you must be aware of its type. When you have one user or group within the item value, the field type is SPFieldUserValue. However, if the field has multiple user / group selection the field type is SPFieldUserValueCollection. I'l...
325,020
<p>WinForms C#.. am getting some JSON in the format below (bottom of message) and trying to deserialise using:</p> <p>using System.Web.Script.Serialization;</p> <p>When I had simply this json returned:</p> <pre><code>{ "objects": [ { "categoryid": "1", "name": "funny", "serverimageid": "1...
[ { "answer_id": 325098, "author": "Simon Buchan", "author_id": 20135, "author_profile": "https://Stackoverflow.com/users/20135", "pm_score": 3, "selected": true, "text": "<p>This seems to work fine (And no wacky string trimming!):</p>\n\n<pre><code>using System;\nusing System.Collections....
2008/11/28
[ "https://Stackoverflow.com/questions/325020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26086/" ]
WinForms C#.. am getting some JSON in the format below (bottom of message) and trying to deserialise using: using System.Web.Script.Serialization; When I had simply this json returned: ``` { "objects": [ { "categoryid": "1", "name": "funny", "serverimageid": "1", "dateuploaded": "...
This seems to work fine (And no wacky string trimming!): ``` using System; using System.Collections.Generic; using System.Web.Script.Serialization; class Program { static void Main( string[] args ) { string json = System.IO.File.ReadAllText( "../../input.json" ); var serializer = new JavaScri...
325,035
<p>This is a program I'm writing (myself as opposed to copying someone else's and thus not learning) as part of the ObjectiveC and Cocoa learning curve. I want to draw simple shapes on a NSView (limiting it to ovals and rectangles for now). The idea is that I record each NSBezierPath to an NSMutableArray so I can also ...
[ { "answer_id": 325053, "author": "Peter Hosey", "author_id": 30461, "author_profile": "https://Stackoverflow.com/users/30461", "pm_score": 0, "selected": false, "text": "<p>What do you mean by “crash”?</p>\n\n<p>Does anything appear in the Debugger Console (⇧⌘R)?</p>\n\n<p>Does a stack t...
2008/11/28
[ "https://Stackoverflow.com/questions/325035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This is a program I'm writing (myself as opposed to copying someone else's and thus not learning) as part of the ObjectiveC and Cocoa learning curve. I want to draw simple shapes on a NSView (limiting it to ovals and rectangles for now). The idea is that I record each NSBezierPath to an NSMutableArray so I can also inv...
You said your init method was: ``` -(void)init { [super init]; //set default color = black toolColor.rd=1.0; toolColor.grn=1.0; toolColor.blu=1.0; toolColor.alp=1.0; //set default size toolSize=0.8; //set default toolType toolType=0; //oval NSLog(@"Init %@",self); } ``` This is ***definitely*** wrong; read up on how...
325,057
<p>I'm trying to display the contents of an ordered array in something like a JTextField.</p> <pre><code>for (int i=0; i&lt;array.length; i++) { this.textField.setText(array[i]); } </code></pre> <p>This won't work for two reasons. The first minor reason: if the array length is 4 then jtextfield is getting it's va...
[ { "answer_id": 325062, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 0, "selected": false, "text": "<p>You can concatenate all those integers into a string the then present that value in the textfield.</p>\n\n<pre><code>S...
2008/11/28
[ "https://Stackoverflow.com/questions/325057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to display the contents of an ordered array in something like a JTextField. ``` for (int i=0; i<array.length; i++) { this.textField.setText(array[i]); } ``` This won't work for two reasons. The first minor reason: if the array length is 4 then jtextfield is getting it's value reset 4 times rather than...
Quick & Dirty Answer -------------------- ``` for (int i=0; i<array.length; i++) { this.myJTextField.setText(this.myJTextField.getText() + ", " + array[i]); } ``` Correct Way ----------- First, calling a member variable `JTextField` probably isn't wise. Since the class is already called like that, it will confu...
325,075
<p>I am using a RichTextBox in WPF, and am trying to set the default paragraph spacing to 0 (so that there is no paragraph spacing). While I could do this in XAML, I would like to achieve it programmatically if possible. Any ideas?</p>
[ { "answer_id": 325080, "author": "Ramesh Soni", "author_id": 191, "author_profile": "https://Stackoverflow.com/users/191", "pm_score": 5, "selected": false, "text": "<p>Using Line Height</p>\n\n<pre><code>RichTextBox rtb = new RichTextBox(); \nParagraph p = rtb.Document.Blocks.FirstBl...
2008/11/28
[ "https://Stackoverflow.com/questions/325075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/691/" ]
I am using a RichTextBox in WPF, and am trying to set the default paragraph spacing to 0 (so that there is no paragraph spacing). While I could do this in XAML, I would like to achieve it programmatically if possible. Any ideas?
I did it **with style** (pun indented) ``` <RichTextBox Margin="0,51,0,0" Name="mainTextBox" > <RichTextBox.Resources> <Style TargetType="{x:Type Paragraph}"> <Setter Property="Margin" Value="0"/> </Style> </RichTextBox.Resources> </RichTextBox> ```
325,082
<p>If there is more than one way, please list them. I only know of one, but I'm wondering if there is a cleaner, in-Ruby way.</p>
[ { "answer_id": 325088, "author": "Dustin", "author_id": 39975, "author_profile": "https://Stackoverflow.com/users/39975", "pm_score": 7, "selected": true, "text": "<p>If it's a process you expect to \"own\" (e.g. you're using this to validate a pid for a process you control), you can jus...
2008/11/28
[ "https://Stackoverflow.com/questions/325082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28558/" ]
If there is more than one way, please list them. I only know of one, but I'm wondering if there is a cleaner, in-Ruby way.
If it's a process you expect to "own" (e.g. you're using this to validate a pid for a process you control), you can just send sig 0 to it. ``` >> Process.kill 0, 370 => 1 >> Process.kill 0, 2 Errno::ESRCH: No such process from (irb):5:in `kill' from (irb):5 >> ```
325,087
<p>Given a jQuery result set, how do you convert that back into plain HTML?</p> <pre><code>&lt;div class="abc"&gt; foo &lt;strong&gt;FOO&lt;/strong&gt; &lt;/div&gt; &lt;div class="def"&gt; bar &lt;/div&gt; </code></pre> <p>--</p> <pre><code>var $mySet = $('div'); </code></pre> <p>Given <code>$mySet</code>, ...
[ { "answer_id": 325089, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 0, "selected": false, "text": "<pre><code>var $mySet = $('div');\nvar html = $mySet.html();\n</code></pre>\n\n<p>If you want the element's HTML as well (...
2008/11/28
[ "https://Stackoverflow.com/questions/325087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
Given a jQuery result set, how do you convert that back into plain HTML? ``` <div class="abc"> foo <strong>FOO</strong> </div> <div class="def"> bar </div> ``` -- ``` var $mySet = $('div'); ``` Given `$mySet`, how would you go about returning to the plain HTML above?
If your set consists of precisely one item, you can use ye olde Javascript: ``` var html = $mySet[0].outerHTML; // note HTML is all caps... that always burns me ```
325,114
<p>I have a Java file <code>TestThis.java</code> like the following:</p> <pre><code>class A { public void foo() { System.out.println("Executing foo"); } } class B { public void bar() { System.out.println("Executing bar"); } } </code></pre> <p>The above code file is compiling ...
[ { "answer_id": 325120, "author": "Lawrence Dol", "author_id": 8946, "author_profile": "https://Stackoverflow.com/users/8946", "pm_score": 1, "selected": false, "text": "<p>Any other class in the same package can access A and B; in this case the null package is being used since no package...
2008/11/28
[ "https://Stackoverflow.com/questions/325114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37626/" ]
I have a Java file `TestThis.java` like the following: ``` class A { public void foo() { System.out.println("Executing foo"); } } class B { public void bar() { System.out.println("Executing bar"); } } ``` The above code file is compiling fine without any warnings/errors. Is ...
As usual (for example, accessing from the Test.java): ``` public class Test { public static void main(String... args) { A a = new A(); a.foo(); B b = new B(); b.bar(); } } ``` The rule here is that you could not have more than one public class in the source file. If you have o...
325,116
<p>Here I am faced with an issue that I believe(or at least hope) was solved 1 million times already. What I got as the input is a string that represents a length of an object in imperial units. It can go like this:</p> <pre><code>$length = "3' 2 1/2\""; </code></pre> <p>or like this:</p> <pre><code>$length = "1/2\...
[ { "answer_id": 325131, "author": "Claudiu", "author_id": 15055, "author_profile": "https://Stackoverflow.com/users/15055", "pm_score": 1, "selected": false, "text": "<p>The regexp would look something like this: </p>\n\n<pre><code>\"([0-9]+)'\\s*([0-9]+)\\\"\"\n</code></pre>\n\n<p>(where...
2008/11/28
[ "https://Stackoverflow.com/questions/325116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35520/" ]
Here I am faced with an issue that I believe(or at least hope) was solved 1 million times already. What I got as the input is a string that represents a length of an object in imperial units. It can go like this: ``` $length = "3' 2 1/2\""; ``` or like this: ``` $length = "1/2\""; ``` or in fact in any other way...
Here is my solution. It uses [eval()](http://php.net/eval) to evaluate the expression, but don't worry, the regex check at the end makes it completely safe. ``` function imperial2metric($number) { // Get rid of whitespace on both ends of the string. $number = trim($number); // This results in the number o...
325,122
<p>I'm following the sample code in <em>CFNetwork Programming Guide</em>, specifically the section on <strong>Preventing Blocking When Working with Streams</strong>. my code is nearly identical to theirs (below) but, when I connect to my server, I get posix error 14 (bad address -- is that bad IP address (except it's ...
[ { "answer_id": 325138, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 0, "selected": false, "text": "<p>I'm not familiar with Cocoa or Objective-C, but I can tell you that POSIX error code 14 is called <a href=\"http:...
2008/11/28
[ "https://Stackoverflow.com/questions/325122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34820/" ]
I'm following the sample code in *CFNetwork Programming Guide*, specifically the section on **Preventing Blocking When Working with Streams**. my code is nearly identical to theirs (below) but, when I connect to my server, I get posix error 14 (bad address -- is that bad IP address (except it's not)? Bad memory address...
Olie, where does ``` buffer ``` that you supply to ``` CFReadStreamRead() ``` come from? EFAULT is a bad buffer address... are you sure you've actually initialized this buffer to point to something valid? It's obviously a global or sometime... which itself is a pretty bad idea. You should allocate it in your func...
325,165
<p>Writing a python script and it needs to find out what language a block of code is written in. <strong>I could easily write this myself, but I'd like to know if a solution already exists.</strong></p> <p>Pygments is insufficient and unreliable.</p>
[ { "answer_id": 325180, "author": "Robert Gould", "author_id": 15124, "author_profile": "https://Stackoverflow.com/users/15124", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p>what language a block of code is written in</p>\n</blockquote>\n\n<p>What are your alternatives, a...
2008/11/28
[ "https://Stackoverflow.com/questions/325165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/432/" ]
Writing a python script and it needs to find out what language a block of code is written in. **I could easily write this myself, but I'd like to know if a solution already exists.** Pygments is insufficient and unreliable.
[Pygments](http://pygments.org) can guess too. Here is an example from the documentation: ``` >>> from pygments.lexers import guess_lexer, guess_lexer_for_filename >>> guess_lexer('#!/usr/bin/python\nprint "Hello World!"') <pygments.lexers.PythonLexer> >>> guess_lexer_for_filename('test.py', 'print "Hello World!"') ...
325,171
<p>I have a project built and packaged with a specific version of jsp-apiand servlet-api jar files. Now I want these jars to be loaded when deploying the web project on any application server for example tomcat, WAS, Weblogic etc.</p> <p>The behaviour I have seen on tomcat is that it gives messages that the packaged v...
[ { "answer_id": 325178, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 3, "selected": true, "text": "<ol>\n<li>If you have control over the server where you want to install this webapp you can replace the core jars with you...
2008/11/28
[ "https://Stackoverflow.com/questions/325171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37626/" ]
I have a project built and packaged with a specific version of jsp-apiand servlet-api jar files. Now I want these jars to be loaded when deploying the web project on any application server for example tomcat, WAS, Weblogic etc. The behaviour I have seen on tomcat is that it gives messages that the packaged version of ...
1. If you have control over the server where you want to install this webapp you can replace the core jars with yours. 2. Additionally you can prepend the jars in the startup of the app server. **Update:** As for the second part, you'll need to modify the startup file of the application server it self. I don't have...
325,200
<p>I have 6 links on a page to an mp3.</p> <p>The plugin I installed replaces those links with a swf and plays that mp3 inline.</p> <p>The problem I <em>had</em> was that it was possible to activate all 6 links and have all audio playing at once. I <em>solved</em> that problem (I feel in a clumsy novice way though) b...
[ { "answer_id": 325208, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 1, "selected": false, "text": "<p>The &lt;a&gt; loses the onclick handler because it is being removed. When you re-add the HTML, it doesn't get back tha...
2008/11/28
[ "https://Stackoverflow.com/questions/325200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have 6 links on a page to an mp3. The plugin I installed replaces those links with a swf and plays that mp3 inline. The problem I *had* was that it was possible to activate all 6 links and have all audio playing at once. I *solved* that problem (I feel in a clumsy novice way though) by catching the `<a>` tag before...
Use event delegation - this means binding the click to some container and let that handle the event. You can then query the event.target to see if it was an anchor that was clicked then do you required behaviour. This is better for a number of reasons. 1. Less events bound to elements (performance) 2. No need to rebin...
325,204
<p>I'm refactoring some code I inherited from a long-gone developer, and I find this:</p> <pre><code>ImportExportForm l_Form = new ImportExportForm(); l_Form.InitializeLifetimeService(); l_Form.ShowDialog(); </code></pre> <p>I've never seen or used the LifetimeService before, but from the little I've read, I don't un...
[ { "answer_id": 325372, "author": "netadictos", "author_id": 31791, "author_profile": "https://Stackoverflow.com/users/31791", "pm_score": 3, "selected": true, "text": "<p>As far as I know this is a method normally use for Remote .Net Objects, and to establish the lifetime of an instance....
2008/11/28
[ "https://Stackoverflow.com/questions/325204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11410/" ]
I'm refactoring some code I inherited from a long-gone developer, and I find this: ``` ImportExportForm l_Form = new ImportExportForm(); l_Form.InitializeLifetimeService(); l_Form.ShowDialog(); ``` I've never seen or used the LifetimeService before, but from the little I've read, I don't understand why I would want ...
As far as I know this is a method normally use for Remote .Net Objects, and to establish the lifetime of an instance. Look here: <http://msdn.microsoft.com/es-es/magazine/cc300474(en-us).aspx> I don't think that it's important for normal Windows Form.
325,241
<p>I currently have a list view which has several rows of data and I have a contextmenustrip in C# .NET.</p> <p>What I am having problems with is when you click on the menu strip item I want to know which row has been selected.</p>
[ { "answer_id": 325268, "author": "sindre j", "author_id": 37119, "author_profile": "https://Stackoverflow.com/users/37119", "pm_score": 0, "selected": false, "text": "<p>I really don't know what you mean here. Can you please explain your problem further or provide a code example?</p>\n\...
2008/11/28
[ "https://Stackoverflow.com/questions/325241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41541/" ]
I currently have a list view which has several rows of data and I have a contextmenustrip in C# .NET. What I am having problems with is when you click on the menu strip item I want to know which row has been selected.
To get selected rows as sindre says you do like this: ``` foreach (ListViewItem item in lvFiles.SelectedItems) { .................................... } ``` lvFiles is the ListView.
325,267
<p>I have a question about using <code>new[]</code>.</p> <p>Imagine this:</p> <pre><code>Object.SomeProperty = new[] {"string1", "string2"}; </code></pre> <p>Where SomeProperty expects an array of strings.</p> <p>I know this code snippet will work. But i want to know what it does under the hood. Does <code>new[]</c...
[ { "answer_id": 325274, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 4, "selected": false, "text": "<p>This is just syntactical sugar. The compiler will infer the type actually necessary here and create code that is e...
2008/11/28
[ "https://Stackoverflow.com/questions/325267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40676/" ]
I have a question about using `new[]`. Imagine this: ``` Object.SomeProperty = new[] {"string1", "string2"}; ``` Where SomeProperty expects an array of strings. I know this code snippet will work. But i want to know what it does under the hood. Does `new[]` makes an instance of the class `object` and in `SomePrope...
Okay, there's still a *little* bit of confusion here. The inference that's going on has nothing to with the type of Object.SomeProperty, but everything to do with the types of the expressions in the array initializer. In other words, you could do: ``` object o = new[] { "string1", "string2" }; ``` and o would still...
325,273
<p>I want to design a web page with a banner and an iframe. I hope the iframe can fill all the remaining page height and be resized automatically as the browser is resizing. Is it possible to get it done without writing JavaScript code, only with CSS?</p> <p>I tried to set <code>height:100%</code> on iframe, the result...
[ { "answer_id": 325334, "author": "Vilx-", "author_id": 41360, "author_profile": "https://Stackoverflow.com/users/41360", "pm_score": 9, "selected": true, "text": "<h3>Update in 2019</h3>\n<p><strong>TL;DR:</strong> Today the best option is - <strong>flexbox</strong>. Everything supports ...
2008/11/28
[ "https://Stackoverflow.com/questions/325273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/288936/" ]
I want to design a web page with a banner and an iframe. I hope the iframe can fill all the remaining page height and be resized automatically as the browser is resizing. Is it possible to get it done without writing JavaScript code, only with CSS? I tried to set `height:100%` on iframe, the result is quite close but ...
### Update in 2019 **TL;DR:** Today the best option is - **flexbox**. Everything supports it nicely and has for years. Go for that and don't look back. Here is a code sample for flexbox: ```css body, html {width: 100%; height: 100%; margin: 0; padding: 0} .row-container {display: flex; width: 100%; height: 100%; flex...
325,299
<p>I'm using Java 1.5 and I'd like to launch the associated application to open the file. I know that Java 1.6 introduced the <a href="http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/desktop_api/" rel="noreferrer">Desktop API</a>, but I need a solution for <strong>Java 1.5</strong>.</p> <p>So far ...
[ { "answer_id": 325319, "author": "boutta", "author_id": 15108, "author_profile": "https://Stackoverflow.com/users/15108", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://www.eclipse.org/swt/\" rel=\"nofollow noreferrer\">SWT</a> gives you the possibility to lokk for the st...
2008/11/28
[ "https://Stackoverflow.com/questions/325299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21348/" ]
I'm using Java 1.5 and I'd like to launch the associated application to open the file. I know that Java 1.6 introduced the [Desktop API](http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/desktop_api/), but I need a solution for **Java 1.5**. So far I found a way to do it in Windows: ``` Runtime.get...
+1 for [this answer](https://stackoverflow.com/questions/325299/#325517) Additionally I would suggest the following implementation using polymorphism: This way you can add new platform easier by reducing coupling among classes. *The Client code:* ``` Desktop desktop = Desktop.getDesktop(); desktop.open( aFile );...
325,323
<p>I was just working on a localizable Lua string solution, when I came up with this hack, problem is I don't know how to avoid getting hacked by it :) So I was wondering if anyone, has done something similar and or knows how to protect from this kind of attack. (in user code)</p> <p>Since we can do this:</p> <pre><c...
[ { "answer_id": 325343, "author": "The Archetypal Paul", "author_id": 21755, "author_profile": "https://Stackoverflow.com/users/21755", "pm_score": 3, "selected": false, "text": "<p>If your hacker has the ability to add code, and you need to allow that code to call things like os.exit, th...
2008/11/28
[ "https://Stackoverflow.com/questions/325323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15124/" ]
I was just working on a localizable Lua string solution, when I came up with this hack, problem is I don't know how to avoid getting hacked by it :) So I was wondering if anyone, has done something similar and or knows how to protect from this kind of attack. (in user code) Since we can do this: ``` =("foo"):upper() ...
First and foremost execute untrusted code in sandboxed environment only – as it was said by other posters. Except for loading bytecode chunks, Lua allows all other sandboxing issues to be covered. (And bytecode chunk problems get fixed promptly as discovered.) See [Lua Live Demo](http://www.lua.org/cgi-bin/demo) for a...
325,325
<p>I have an intermittent problem with some code that writes to a Windows Event Log, using C# and .Net's <code>EventLog</code> class.</p> <p>Basically, this code works day-to-day perfectly, but very occasionally, we start getting errors like this:</p> <blockquote> <p>"System.ArgumentException: Only the first eigh...
[ { "answer_id": 325381, "author": "bruno conde", "author_id": 31136, "author_profile": "https://Stackoverflow.com/users/31136", "pm_score": 3, "selected": true, "text": "<p>The <a href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx\" rel=\"nofollow noreferrer\"...
2008/11/28
[ "https://Stackoverflow.com/questions/325325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6004/" ]
I have an intermittent problem with some code that writes to a Windows Event Log, using C# and .Net's `EventLog` class. Basically, this code works day-to-day perfectly, but very occasionally, we start getting errors like this: > > "System.ArgumentException: Only the > first eight characters of a custom log > name ...
The [documentation](http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx) states that: > > You can only use the Source to write > to one log at a time > > > So I suspect this problem is caused by your multithreaded app calling the `Log` method more that once at a given time and for the same S...
325,337
<p>I have below a list of text, it is from a popular online game called EVE Online and this basically gets mailed to you when you kill a person in-game. I'm building a tool to parse these using PHP to extract all relevant information. I will need all pieces of information shown and i'm writting classes to nicely break ...
[ { "answer_id": 325353, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 4, "selected": false, "text": "<p>I'd probably go with a state machine approach, reading each line in sequence and dealing with it depending on the curr...
2008/11/28
[ "https://Stackoverflow.com/questions/325337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227/" ]
I have below a list of text, it is from a popular online game called EVE Online and this basically gets mailed to you when you kill a person in-game. I'm building a tool to parse these using PHP to extract all relevant information. I will need all pieces of information shown and i'm writting classes to nicely break it ...
If you want something flexible, use the state machine approach. If you want something quick and dirty, use regexp. For the first solution, you can use libraries that are specialized in parsin since it's not a trivial task. But because it's fairly simple format, you can hack a naive parser, as for example : ``` <?php...
325,346
<p>There's one thing I haven't found in <a href="https://www.rfc-editor.org/rfc/rfc2616" rel="nofollow noreferrer">RFC 2616</a> (&quot;Hypertext Transfer Protocol -- HTTP/1.1&quot;) and that's a &quot;canonical&quot; name for a request/response pair. Is there such thing?</p> <p><a href="https://www.rfc-editor.org/rfc/r...
[ { "answer_id": 325356, "author": "ysth", "author_id": 17389, "author_profile": "https://Stackoverflow.com/users/17389", "pm_score": -1, "selected": false, "text": "<p>Transaction, yes, or \"A singe HTTP Request consists of one HTTP Request message and one HTTP Response message.\"</p>\n" ...
2008/11/28
[ "https://Stackoverflow.com/questions/325346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4833/" ]
There's one thing I haven't found in [RFC 2616](https://www.rfc-editor.org/rfc/rfc2616) ("Hypertext Transfer Protocol -- HTTP/1.1") and that's a "canonical" name for a request/response pair. Is there such thing? [4.1 Message Types](https://www.rfc-editor.org/rfc/rfc2616#section-4.1): > > > ```none > 4.1 Message Typ...
The spec calls them "exchanges" (or "request/response exchanges"). Per [section 1.4, "Overall Operation"](https://www.rfc-editor.org/rfc/rfc2616#section-1.4): > > In HTTP/1.0, most implementations used a new connection for each request/response exchange. In HTTP/1.1, a connection may be used for one or more request/...
325,370
<p>In SQL, How we make a check to filter all row which contain a column data is null or empty ?<br> For examile </p> <pre><code>Select Name,Age from MEMBERS </code></pre> <p>We need a check Name should not equal to null or empty.</p>
[ { "answer_id": 325377, "author": "Gilles", "author_id": 36141, "author_profile": "https://Stackoverflow.com/users/36141", "pm_score": 0, "selected": false, "text": "<p>nvl(Name, 'some dumb string') this will return Name if Name is not null and different of '' (oracle, don't know for othe...
2008/11/28
[ "https://Stackoverflow.com/questions/325370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34588/" ]
In SQL, How we make a check to filter all row which contain a column data is null or empty ? For examile ``` Select Name,Age from MEMBERS ``` We need a check Name should not equal to null or empty.
This will work in all sane databases (*wink, wink*) and will return the rows for which name is not null nor empty ``` select name,age from members where name is not null and name <> '' ```
325,375
<p>I'm building a small Winform in which I can view types of food in my kitchen.</p> <p>My entire stock can be displayed by a datagrid view.</p> <p>Now, I have a filtermenu which contains a dropdownlist of items that can be checked and unchecked.</p> <p>Based on which items in that list are checked, the display in t...
[ { "answer_id": 325377, "author": "Gilles", "author_id": 36141, "author_profile": "https://Stackoverflow.com/users/36141", "pm_score": 0, "selected": false, "text": "<p>nvl(Name, 'some dumb string') this will return Name if Name is not null and different of '' (oracle, don't know for othe...
2008/11/28
[ "https://Stackoverflow.com/questions/325375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11795/" ]
I'm building a small Winform in which I can view types of food in my kitchen. My entire stock can be displayed by a datagrid view. Now, I have a filtermenu which contains a dropdownlist of items that can be checked and unchecked. Based on which items in that list are checked, the display in the datagridview is chang...
This will work in all sane databases (*wink, wink*) and will return the rows for which name is not null nor empty ``` select name,age from members where name is not null and name <> '' ```
325,383
<p>I am getting a runtime error 13 at the end of the following code:</p> <pre><code>Sub plausibilitaet_check() Dim rs As DAO.Recordset Dim rs2 As ADODB.Recordset Dim db As database Dim strsql As String Dim strsql2 As String Dim tdf As TableDef Set db = opendatabase("C:\Codebook.mdb") Set rs = db.OpenRecordset("pl...
[ { "answer_id": 325394, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 2, "selected": false, "text": "<p>CurrentDB.OpenRecordset returns an instance of DAO.Recordset. You are trying to assign the result to ADODB.Recordse...
2008/11/28
[ "https://Stackoverflow.com/questions/325383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31132/" ]
I am getting a runtime error 13 at the end of the following code: ``` Sub plausibilitaet_check() Dim rs As DAO.Recordset Dim rs2 As ADODB.Recordset Dim db As database Dim strsql As String Dim strsql2 As String Dim tdf As TableDef Set db = opendatabase("C:\Codebook.mdb") Set rs = db.OpenRecordset("plausen1") Set rs2...
You are mixing up ADO and DAO. In this case rs2 should be a DAO recordset. ``` Sub plausibilitaet_check() Dim rs As DAO.Recordset Dim rs2 As DAO.Recordset Dim db As database Dim strsql As String Dim strsql2 As String Dim tdf As TableDef Set db = opendatabase("C:\Codebook.mdb") Set rs = db.OpenRecordset("plausen1") ...
325,392
<p>I am calling a .txt file from a jquery ajax call. It has some special characters like <code>±</code>. This <code>±</code> is a delimiter for a set of array; data I want to split out and push into a JavaScript array.</p> <p>It is not treated as <code>±</code> symbol when interpreted like this.</p> <p>How do I get t...
[ { "answer_id": 325408, "author": "Berzemus", "author_id": 2452, "author_profile": "https://Stackoverflow.com/users/2452", "pm_score": 3, "selected": false, "text": "<p>Why don't you encode your text file using <a href=\"http://www.json.org/\" rel=\"nofollow noreferrer\">JSON</a> ? Much m...
2008/11/28
[ "https://Stackoverflow.com/questions/325392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38578/" ]
I am calling a .txt file from a jquery ajax call. It has some special characters like `±`. This `±` is a delimiter for a set of array; data I want to split out and push into a JavaScript array. It is not treated as `±` symbol when interpreted like this. How do I get that data as just like browser content?
you could use the `escape()` value to split a string. for ± i found two values (maybe there are more?). ``` var string = escape('test±test2±test3'); var split = string.split('%C2%B1'); alert(split); // test,test2,test3 // %B1%0A is the value i found for ± // %C2%B1 is the value escape() gives me when i just copy and...
325,399
<pre><code>% rails ... General Options: ... -c, --svn Modify files with subversion. (Note: svn must be in path) -g, --git Modify files with git. (Note: git must be in path) </code></pre> <p>What do these "Modify files" options do for me?</p> <p>Edit: It is unclear to me w...
[ { "answer_id": 325423, "author": "James Anderson", "author_id": 38207, "author_profile": "https://Stackoverflow.com/users/38207", "pm_score": 1, "selected": false, "text": "<p>'-c' will direct rails to retrieve and store data from a subversion source code repositry.\n'-g' will drect reai...
2008/11/28
[ "https://Stackoverflow.com/questions/325399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10841/" ]
``` % rails ... General Options: ... -c, --svn Modify files with subversion. (Note: svn must be in path) -g, --git Modify files with git. (Note: git must be in path) ``` What do these "Modify files" options do for me? Edit: It is unclear to me what using one (or both?) o...
Looks like `--git` was added in [r8772](http://dev.rubyonrails.org/changeset/8772) in response to [ticket #10690](http://dev.rubyonrails.org/ticket/10690). Reading that patch is the closest thing to documentation I've found. The option applies to [Rails::Generator::Commands](http://api.rubyonrails.org/classes/Rails/Gen...
325,404
<p>I am using oracle wallet to store the oracle database passwords, the batch file to create the wallet asks for password when you run it. is there any way to modify the batch file , and provide the password before hand </p> <p>so that i can avoid inputtting the password every time i run that.</p> <p>so to generalize...
[ { "answer_id": 325444, "author": "cjanssen", "author_id": 2950, "author_profile": "https://Stackoverflow.com/users/2950", "pm_score": 3, "selected": true, "text": "<p>You can use the pipe operator \"|\" to redirect the standard output stream of one program into the input stream of anothe...
2008/11/28
[ "https://Stackoverflow.com/questions/325404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32670/" ]
I am using oracle wallet to store the oracle database passwords, the batch file to create the wallet asks for password when you run it. is there any way to modify the batch file , and provide the password before hand so that i can avoid inputtting the password every time i run that. so to generalize the problem, is ...
You can use the pipe operator "|" to redirect the standard output stream of one program into the input stream of another. I works both on unix and windows platforms. In your example you would have a script doing just ``` echo mypassword ``` and you would run this from the command line: ``` myscript | wallet ``` ...
325,407
<p>Essentially i want to have a generic function which accepts a LINQ anonymous list and returns an array back. I was hoping to use generics but i just can seem to get it to work.</p> <p>hopefully the example below helps</p> <p>say i have a person object with id, fname, lname and dob. i have a generic class with cont...
[ { "answer_id": 325438, "author": "Richard Ev", "author_id": 39709, "author_profile": "https://Stackoverflow.com/users/39709", "pm_score": 1, "selected": false, "text": "<p>Your question is a little unclear, so I'm not sure how much my answers will help, but here goes...</p>\n\n<ul>\n<li>...
2008/11/28
[ "https://Stackoverflow.com/questions/325407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Essentially i want to have a generic function which accepts a LINQ anonymous list and returns an array back. I was hoping to use generics but i just can seem to get it to work. hopefully the example below helps say i have a person object with id, fname, lname and dob. i have a generic class with contains a list of ob...
You'd just call [ToArray](http://msdn.microsoft.com/en-us/library/bb298736.aspx). Sure, the type is anonymous... but because of type inference, you don't have to say the type's name. From the example code: ``` packages _ .Select(Function(pkg) pkg.Company) _ .ToArray() ``` Company happens to be string, b...
325,414
<p>To follow on from my question yesterday....</p> <p><a href="https://stackoverflow.com/questions/323842/mysql-table-design-for-a-questionnaire">MySQL Table Design for a Questionnaire</a></p> <p>I sat down with my boss yesterday afternoon to run through how I was proposing to design the database. However, now I am ...
[ { "answer_id": 325458, "author": "J.D. Fitz.Gerald", "author_id": 11542, "author_profile": "https://Stackoverflow.com/users/11542", "pm_score": 2, "selected": true, "text": "<p>In this case I wouldn't go for an enum, I'd go for a \"score\" column. So the columns might be:</p>\n\n<pre><co...
2008/11/28
[ "https://Stackoverflow.com/questions/325414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41378/" ]
To follow on from my question yesterday.... [MySQL Table Design for a Questionnaire](https://stackoverflow.com/questions/323842/mysql-table-design-for-a-questionnaire) I sat down with my boss yesterday afternoon to run through how I was proposing to design the database. However, now I am more confused than ever. He ...
In this case I wouldn't go for an enum, I'd go for a "score" column. So the columns might be: ``` userid, questionid, score 1,1,4 1,2,4 1,3,3 2,1,1 2,2,4 ... ``` 1 being very unsatisfied and 4 being very satisfied. Then a query like: ``` select 25*avg(score) from Blah ``` will give you your overall percentage. ...
325,419
<p>I am a newbie for Visual Basic 6 project. I downloaded some tutorials for testing; however, I am not able to drag, move, or edit the UI form designer objects in those projects.</p> <p>Does anybody know there is an object lock function in VB6?<br /> If there is, how can I unlock it?</p>
[ { "answer_id": 325458, "author": "J.D. Fitz.Gerald", "author_id": 11542, "author_profile": "https://Stackoverflow.com/users/11542", "pm_score": 2, "selected": true, "text": "<p>In this case I wouldn't go for an enum, I'd go for a \"score\" column. So the columns might be:</p>\n\n<pre><co...
2008/11/28
[ "https://Stackoverflow.com/questions/325419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am a newbie for Visual Basic 6 project. I downloaded some tutorials for testing; however, I am not able to drag, move, or edit the UI form designer objects in those projects. Does anybody know there is an object lock function in VB6? If there is, how can I unlock it?
In this case I wouldn't go for an enum, I'd go for a "score" column. So the columns might be: ``` userid, questionid, score 1,1,4 1,2,4 1,3,3 2,1,1 2,2,4 ... ``` 1 being very unsatisfied and 4 being very satisfied. Then a query like: ``` select 25*avg(score) from Blah ``` will give you your overall percentage. ...
325,424
<p>Is there any way to throw errors or warnings in a KornShell (ksh) script to prevent the use of unset variables? Let's assume I have a temporary folder that I want to remove.</p> <pre><code>TEMP_FILES_DIR='/app/myapp/tmp' rm -Rf $TEMP_FILE_DIR #notice the misspelling </code></pre> <p>How to prevent this kind of mi...
[ { "answer_id": 325473, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 0, "selected": false, "text": "<p>You could check the variable for having content, ie not being '', and print-out a message like \"the variable is empty\".<...
2008/11/28
[ "https://Stackoverflow.com/questions/325424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2046272/" ]
Is there any way to throw errors or warnings in a KornShell (ksh) script to prevent the use of unset variables? Let's assume I have a temporary folder that I want to remove. ``` TEMP_FILES_DIR='/app/myapp/tmp' rm -Rf $TEMP_FILE_DIR #notice the misspelling ``` How to prevent this kind of mistakes before they actuall...
The command ``` set -u ``` Will cause POSIX *sh*(1) and its derivatives to grouse when an attempt to expand an unset variable is made. Example: ``` $ echo $foo $ set -u $ echo $foo sh: foo: parameter not set ```
325,426
<p>I'm using reflection to loop through a <code>Type</code>'s properties and set certain types to their default. Now, I could do a switch on the type and set the <code>default(Type)</code> explicitly, but I'd rather do it in one line. Is there a programmatic equivalent of default?</p>
[ { "answer_id": 325527, "author": "kpollock", "author_id": 41557, "author_profile": "https://Stackoverflow.com/users/41557", "pm_score": 2, "selected": false, "text": "<p>I do the same task like this. </p>\n\n<pre><code>//in MessageHeader \n private void SetValuesDefault()\n {\n ...
2008/11/28
[ "https://Stackoverflow.com/questions/325426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192/" ]
I'm using reflection to loop through a `Type`'s properties and set certain types to their default. Now, I could do a switch on the type and set the `default(Type)` explicitly, but I'd rather do it in one line. Is there a programmatic equivalent of default?
* In case of a value type use [Activator.CreateInstance](http://msdn.microsoft.com/en-us/library/system.activator.createinstance.aspx) and it should work fine. * When using reference type just return null ``` public static object GetDefault(Type type) { if(type.IsValueType) { return Activator.CreateInstanc...
325,453
<p>When I first started programming, I wrote everything in main. But as I learned, I tried to do as little as possible in my <code>main()</code> methods.</p> <p>But where do you decide to give the other Class/Method the responsibility to take over the program from <code>main()</code>? How do you do it?</p> <p>I've se...
[ { "answer_id": 325459, "author": "guerda", "author_id": 32043, "author_profile": "https://Stackoverflow.com/users/32043", "pm_score": 0, "selected": false, "text": "<p>I think the main method should explain, what the program does at starting up.\nSo it may call initialzing methods, but t...
2008/11/28
[ "https://Stackoverflow.com/questions/325453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7205/" ]
When I first started programming, I wrote everything in main. But as I learned, I tried to do as little as possible in my `main()` methods. But where do you decide to give the other Class/Method the responsibility to take over the program from `main()`? How do you do it? I've seen many ways of doing it, like this: `...
In my opinion, the "main" of a sizable project should contain around 3 function calls: * Calling an Initialization function that sets up all the required settings, preferences, etc. for the application. * Starting up the main "controller" of the application * Waiting for the main controller to terminate, and then call...
325,463
<p>I've a python script that has to launch a shell command for every file in a dir:</p> <pre><code>import os files = os.listdir(".") for f in files: os.execlp("myscript", "myscript", f) </code></pre> <p>This works fine for the first file, but after the "myscript" command has ended, the execution stops and does n...
[ { "answer_id": 325467, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<p>The <code>os.exec*()</code> functions <em>replace</em> the current programm with the new one. When this programm ends so do...
2008/11/28
[ "https://Stackoverflow.com/questions/325463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28582/" ]
I've a python script that has to launch a shell command for every file in a dir: ``` import os files = os.listdir(".") for f in files: os.execlp("myscript", "myscript", f) ``` This works fine for the first file, but after the "myscript" command has ended, the execution stops and does not come back to the python...
> > subprocess: The `subprocess` module > allows you to spawn new processes, > connect to their input/output/error > pipes, and obtain their return codes. > > > <http://docs.python.org/library/subprocess.html> Usage: ``` import subprocess process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)...
325,464
<p>I want a way to list files in a directory and putting a check box beside each one of them so I can select some of them and perform operations with each selected file, what's the best way to do this?</p>
[ { "answer_id": 325478, "author": "milot", "author_id": 22637, "author_profile": "https://Stackoverflow.com/users/22637", "pm_score": 2, "selected": false, "text": "<p>You can use checked list box control which is built-in winforms control (see links below):</p>\n\n<p><a href=\"http://www...
2008/11/28
[ "https://Stackoverflow.com/questions/325464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36532/" ]
I want a way to list files in a directory and putting a check box beside each one of them so I can select some of them and perform operations with each selected file, what's the best way to do this?
Drop a CheckedListBox control onto the form, then populate the contents using the DirectoryInfo and FileSystemInfo classes, like this: ``` System.IO.DirectoryInfo di = new System.IO.DirectoryInfo("c:\\"); System.IO.FileSystemInfo[] files = di.GetFileSystemInfos(); checkedListBox1.Items.AddRange(files); ```
325,475
<p>I am trying to comment an API (.Net) that I am exposing to a customer. I am doing this by using XML comments, and extracting via SandCastle.</p> <p>This is all fine and dandy, however I have unittesting for the API, and thought the code from these would be good to place in the example tags.</p> <p>So does anyone k...
[ { "answer_id": 325487, "author": "khebbie", "author_id": 4189, "author_profile": "https://Stackoverflow.com/users/4189", "pm_score": 1, "selected": false, "text": "<p>I see that Jon Skeet har an answer, that requires some work:\n<a href=\"https://stackoverflow.com/questions/301365/automa...
2008/11/28
[ "https://Stackoverflow.com/questions/325475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4189/" ]
I am trying to comment an API (.Net) that I am exposing to a customer. I am doing this by using XML comments, and extracting via SandCastle. This is all fine and dandy, however I have unittesting for the API, and thought the code from these would be good to place in the example tags. So does anyone know of a good way...
I am using NUnit and Sandcastle Help File Builder. Please take a look at Sandcastle Help File Builder documentation about The Code Block Component. Here is an example how I place unit tests code in the example tag: ``` /// <summary> /// Returns a string representation of an object. /// </summary> /// ...
325,479
<p>Basically I have a small template that looks like:</p> <pre><code>&lt;xsl:template name="templt"&gt; &lt;xsl:param name="filter" /&gt; &lt;xsl:variable name="numOrders" select="count(ORDERS/ORDER[$filter])" /&gt; &lt;/xsl:template&gt; </code></pre> <p>And I'm trying to call it using</p> <pre><code>&lt;xsl...
[ { "answer_id": 325518, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 4, "selected": true, "text": "<p>how about the following:</p>\n\n<pre><code>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;xsl:stylesheet ver...
2008/11/28
[ "https://Stackoverflow.com/questions/325479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1601/" ]
Basically I have a small template that looks like: ``` <xsl:template name="templt"> <xsl:param name="filter" /> <xsl:variable name="numOrders" select="count(ORDERS/ORDER[$filter])" /> </xsl:template> ``` And I'm trying to call it using ``` <xsl:call-template name="templt"> <xsl:with-param name="filter" ...
how about the following: ``` <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template name="templt"> <xsl:param name="filterNodeName" /> <xsl:param name="filterValue" /> <xsl:variable na...
325,508
<p>I'm wanting to write a method that I can use to initialise a Map. First cut:</p> <pre><code>Map map(Object ... o) {for (int i = 0; i &lt; o.length; i+=2){result.put(o[i], o[i+1])}} </code></pre> <p>Simple, but not type-safe. Using generics, maybe something like:</p> <pre><code>&lt;TKey, TValue&gt; HashMap&lt;TKe...
[ { "answer_id": 325526, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 4, "selected": true, "text": "<p>To make life easier for yourself, never use a return type that contains wildcards. Wildcard types, in general, are for met...
2008/11/28
[ "https://Stackoverflow.com/questions/325508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm wanting to write a method that I can use to initialise a Map. First cut: ``` Map map(Object ... o) {for (int i = 0; i < o.length; i+=2){result.put(o[i], o[i+1])}} ``` Simple, but not type-safe. Using generics, maybe something like: ``` <TKey, TValue> HashMap<TKey, TValue> map(TKey ... keys, TValue ... values) ...
To make life easier for yourself, never use a return type that contains wildcards. Wildcard types, in general, are for method parameters only. So, try this: ``` public static <TKey, TValue, TMap extends Map<TKey, TValue>> TMap map(TMap map, Pair<? extends TKey, ? extends TValue>... pairs) { for (Pair<? extends TK...
325,511
<p>I am wondering how you would approach this problem</p> <p>I have two Taxrates that can apply to my products. I specifically want to avoid persisting the Taxrates into the database while still being able to change them in a central place (like Taxrate from 20% to 19% etc).</p> <p>so I decided it would be great to h...
[ { "answer_id": 325538, "author": "Winston Smith", "author_id": 35086, "author_profile": "https://Stackoverflow.com/users/35086", "pm_score": 1, "selected": false, "text": "<p>Why not store the tax rates in application configuration, eg in the web.config or app.config file? These are sim...
2008/11/28
[ "https://Stackoverflow.com/questions/325511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21699/" ]
I am wondering how you would approach this problem I have two Taxrates that can apply to my products. I specifically want to avoid persisting the Taxrates into the database while still being able to change them in a central place (like Taxrate from 20% to 19% etc). so I decided it would be great to have them just com...
EDIT: Note that the code here could easily be abbreviated by having a private constructor taking the tax rate and the name. I'm assuming that in real life there might be actual behavioral differences between the tax rates. It sounds like you want something like Java's enums. C# makes that fairly tricky, but you can d...
325,512
<p>Does anyone know if it's possible to open a file in the file system via a link in a WebBrowser component? I'm writing a little reporting tool in which I display a summary as HTML in a WebBrowser component with a link to a more detailed analysis which is saved as an Excel file on disk. </p> <p>I want the user to be ...
[ { "answer_id": 325557, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>I just tried this with a link that looks like \n&lt;a href=\"file:///C:\\temp\\browsertest\\bin\\Debug\\testing.xls\"&gt;Te...
2008/11/28
[ "https://Stackoverflow.com/questions/325512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4019/" ]
Does anyone know if it's possible to open a file in the file system via a link in a WebBrowser component? I'm writing a little reporting tool in which I display a summary as HTML in a WebBrowser component with a link to a more detailed analysis which is saved as an Excel file on disk. I want the user to be able to cl...
I also tested Ross's solution and it worked for me too. But here's another approach, instead of using the built-in functionality that popups a dialog box asking you to download, open or cancel the download, you can use your own C# code in your application (not the HTML page) to directly open the file (or maybe do some...
325,555
<p>Here is a little test program: </p> <pre><code>#include &lt;iostream&gt; class Test { public: static void DoCrash(){ std::cout&lt;&lt; "TEST IT!"&lt;&lt; std::endl; } }; int main() { Test k; k.DoCrash(); // calling a static method like a member method... std::system("pause"); return 0; } </c...
[ { "answer_id": 325569, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 2, "selected": false, "text": "<p>static methods can be called also using an object of the class, just like it can be done in Java. Nevert...
2008/11/28
[ "https://Stackoverflow.com/questions/325555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2368/" ]
Here is a little test program: ``` #include <iostream> class Test { public: static void DoCrash(){ std::cout<< "TEST IT!"<< std::endl; } }; int main() { Test k; k.DoCrash(); // calling a static method like a member method... std::system("pause"); return 0; } ``` On VS2008 + SP1 (vc9) it comp...
The standard states that it is not necessary to call the method through an instance, that does not mean that you cannot do it. There is even an example where it is used: C++03, 9.4 static members > > A static member s of class X may be referred to using the > qualified-id expression X::s; it is > not necessary to ...
325,559
<p>I've a table with two columns are a unique key together and i cannot change the schema.</p> <p>I'm trying to execute an update using psql in which i change the value of one of the column that are key. The script is similar to the following:</p> <pre><code>BEGIN; UPDATE t1 SET P1='23' where P1='33'; UPDATE t1 SET P...
[ { "answer_id": 325574, "author": "Dan Vinton", "author_id": 21849, "author_profile": "https://Stackoverflow.com/users/21849", "pm_score": 2, "selected": false, "text": "<p>Security - checking that users have appropriate permissions prior to executing certain methods.</p>\n" }, { ...
2008/11/28
[ "https://Stackoverflow.com/questions/325559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41572/" ]
I've a table with two columns are a unique key together and i cannot change the schema. I'm trying to execute an update using psql in which i change the value of one of the column that are key. The script is similar to the following: ``` BEGIN; UPDATE t1 SET P1='23' where P1='33'; UPDATE t1 SET P1='23' where P1='55';...
One of the examples which was loaned straight from this [Aspect Oriented Programming: Radical Research in Modularity, Youtube video](http://www.youtube.com/watch?v=cq7wpLI0hco) was painting to a display. In the example you have a drawing program, which consists of points, shapes, etc and when changes to those objects o...
325,561
<p>I have used extension methods to extend html helpers to make an RSS repeater:</p> <pre><code> public static string RSSRepeater(this HtmlHelper html, IEnumerable&lt;IRSSable&gt; rss) { string result=""; foreach (IRSSable item in rss) { result += "&lt;item&gt;" + item.GetRS...
[ { "answer_id": 325567, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>You're running into <a href=\"https://stackoverflow.com/questions/229656\">generic variance issues</a>. Just because ...
2008/11/28
[ "https://Stackoverflow.com/questions/325561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3193/" ]
I have used extension methods to extend html helpers to make an RSS repeater: ``` public static string RSSRepeater(this HtmlHelper html, IEnumerable<IRSSable> rss) { string result=""; foreach (IRSSable item in rss) { result += "<item>" + item.GetRSSItem().InnerXml + "</item...
Ahh... try: ``` public static string RSSRepeater<T>(this HtmlHelper html, IEnumerable<T> rss) where T : IRSSable { ... } ``` This then should allow you to pass any sequence of things that implement `IRSSable` - and the generic type inference should mean you don't need to specify the `T` (as `Issue`) you...
325,583
<p>Strange error specific to a particular machine...</p> <p>I have a app in which a combo box's text value is set to the path of a document (i.e...</p> <pre><code>cmbAIDFile.Text = clsTonyToolkit.GetSetting("ExportAIDFile",gtypmetadata.gcnnCentral) &amp; "" </code></pre> <p>Forget about all the GetSetting procedure ...
[ { "answer_id": 325594, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 1, "selected": false, "text": "<p>What is the difference between the vista machines?</p>\n\n<ul>\n<li>version</li>\n<li>settings</li>\n<li>user perm...
2008/11/28
[ "https://Stackoverflow.com/questions/325583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28959/" ]
Strange error specific to a particular machine... I have a app in which a combo box's text value is set to the path of a document (i.e... ``` cmbAIDFile.Text = clsTonyToolkit.GetSetting("ExportAIDFile",gtypmetadata.gcnnCentral) & "" ``` Forget about all the GetSetting procedure etc, just that it returns a line of t...
You might be looking in the wrong place for the error. When you change the `Text` property of a `ComboBox`, the `ComboBox`'s `Change` event will fire, if the new text is different from the previous text. The `LostFocus` and/or `Validate` events might also fire, depending on what your code is doing and how your form is ...
325,590
<p>I write a Text Editor with Java , and I want to add Undo function to it </p> <p>but without UndoManager Class , I need to use a Data Structure like Stack or LinkedList but the Stack class in Java use Object parameters e.g : push(Object o) , Not Push(String s) I need some hints or links . Thanks</p>
[ { "answer_id": 325596, "author": "Yuval Adam", "author_id": 24545, "author_profile": "https://Stackoverflow.com/users/24545", "pm_score": 4, "selected": true, "text": "<p>Assuming you are using Java 5, Stack is a generic class. You can instantiate it according to the objects it should ho...
2008/11/28
[ "https://Stackoverflow.com/questions/325590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22634/" ]
I write a Text Editor with Java , and I want to add Undo function to it but without UndoManager Class , I need to use a Data Structure like Stack or LinkedList but the Stack class in Java use Object parameters e.g : push(Object o) , Not Push(String s) I need some hints or links . Thanks
Assuming you are using Java 5, Stack is a generic class. You can instantiate it according to the objects it should hold. You can then use: ``` Stack<String> stack = new Stack<String>(); String string = "someString"; stack.push(string); ``` Also note that in the case you are using Java 1.4 or below, you can still pu...
325,616
<p>What is the difference between the value and itemValue attribute of the radiobutton in Jsf?</p>
[ { "answer_id": 325641, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 0, "selected": false, "text": "<p>From this IBM article <a href=\"http://www.ibm.com/developerworks/rational/library/05/1213_he/\" rel=\"nofollow noreferrer\"...
2008/11/28
[ "https://Stackoverflow.com/questions/325616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40933/" ]
What is the difference between the value and itemValue attribute of the radiobutton in Jsf?
The value is meant to send in a SelectItem object and not a String like itemValue is. The itemValue is the items value, which is passed to the server as a request parameter, but the value is a value binding expression that points to a SelectItem instance. If you look at this JSF: ``` <h:selectOneRadio value=""> ...
325,628
<p>A typical approach to avoid two instances of the same script running simultaneously looks like this:</p> <pre><code>[ -f ".lock" ] &amp;&amp; exit 1 touch .lock # do something rm .lock </code></pre> <p>Is there a better way to lock on files from a shell-script, avoiding a race condition? Must directories be used i...
[ { "answer_id": 325645, "author": "Barry Kelly", "author_id": 3712, "author_profile": "https://Stackoverflow.com/users/3712", "pm_score": 6, "selected": true, "text": "<p>Yes, there is indeed a race condition in the sample script. You can use bash's <code>noclobber</code> option in order ...
2008/11/28
[ "https://Stackoverflow.com/questions/325628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23420/" ]
A typical approach to avoid two instances of the same script running simultaneously looks like this: ``` [ -f ".lock" ] && exit 1 touch .lock # do something rm .lock ``` Is there a better way to lock on files from a shell-script, avoiding a race condition? Must directories be used instead?
Yes, there is indeed a race condition in the sample script. You can use bash's `noclobber` option in order to get a failure in case of a race, when a different script sneaks in between the `-f` test and the `touch`. The following is a sample code-snippet (inspired by [this article](https://www.davidpashley.com/article...
325,654
<p>I want to change background color of Datagrid header in Silverlight.</p>
[ { "answer_id": 330697, "author": "David Padbury", "author_id": 26401, "author_profile": "https://Stackoverflow.com/users/26401", "pm_score": 3, "selected": false, "text": "<p>Although the DataGrid does not expose a Header Background property, it does have a property for the ColumnHeaderS...
2008/11/28
[ "https://Stackoverflow.com/questions/325654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to change background color of Datagrid header in Silverlight.
Although the DataGrid does not expose a Header Background property, it does have a property for the ColumnHeaderStyle. Using the technique that DaniCE has previously suggested for a single column we can replace the header template for all header columns including the empty space on the right hand side. The down side wi...
325,667
<p>Does anyone of you know, if and if so, how can I check, with my application code, if a server has ssl enabled or not?</p>
[ { "answer_id": 325681, "author": "dove", "author_id": 30913, "author_profile": "https://Stackoverflow.com/users/30913", "pm_score": 2, "selected": false, "text": "<p>not sure on your language of preference but here it is in c#</p>\n\n<pre><code>public bool IsSecureConnection()\n{\n re...
2008/11/28
[ "https://Stackoverflow.com/questions/325667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40077/" ]
Does anyone of you know, if and if so, how can I check, with my application code, if a server has ssl enabled or not?
["It's easier to ask forgiveness than permission"](http://mail.python.org/pipermail/python-list/2003-May/203039.html) For example, to read `stackoverflow.com` via SSL, don't ask whether `stackoverflow.com` supports it, just do it. In Python: ``` >>> import urllib2 >>> urllib2.urlopen('https://stackoverflow.com') Trac...
325,669
<p>I think I might be approaching this in the wrong way, so I would appreciate any comments/guidance. Hopefully I can explain coherently enough what I am trying to achieve:</p> <ul> <li><p>I want to create a block of HTML (e.g. a box containing a user's profile), which I will load as part of my layout on most pages th...
[ { "answer_id": 325707, "author": "foxy", "author_id": 30119, "author_profile": "https://Stackoverflow.com/users/30119", "pm_score": 4, "selected": true, "text": "<p>Create a view to generate the block of HTML for the user's profile and call it from your controller using:</p>\n\n<pre><cod...
2008/11/28
[ "https://Stackoverflow.com/questions/325669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22224/" ]
I think I might be approaching this in the wrong way, so I would appreciate any comments/guidance. Hopefully I can explain coherently enough what I am trying to achieve: * I want to create a block of HTML (e.g. a box containing a user's profile), which I will load as part of my layout on most pages that I generate. * ...
Create a view to generate the block of HTML for the user's profile and call it from your controller using: ``` $user_html = $this->load->view('user_view', $user_data, true); ``` The third parameter returns the view as a string instead of displaying it. This can then be passed into another view in the usual way. ```...
325,677
<p>I need to receive the key press events during cell editing in <code>DataGridView</code> control.</p> <p>From what I have found on the net the <code>DataGridView</code> is designed to pass all key events from <code>DataGridView</code> to the cell editing control and you cannot get these events easily.</p> <p>I foun...
[ { "answer_id": 325697, "author": "Mladen Prajdic", "author_id": 31345, "author_profile": "https://Stackoverflow.com/users/31345", "pm_score": 0, "selected": false, "text": "<p>you have to override the DataGridViewCell/DataGridViewTextBoxCell/otherTypes and handle key* events in the deriv...
2008/11/28
[ "https://Stackoverflow.com/questions/325677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1660/" ]
I need to receive the key press events during cell editing in `DataGridView` control. From what I have found on the net the `DataGridView` is designed to pass all key events from `DataGridView` to the cell editing control and you cannot get these events easily. I found this [piece of code](http://www.codeproject.com/...
Finally figured out. There are two parts of this puzzle - getting keys from cell editing control and getting keys from the DataGridView itself. Here's my code. To use it, you just need to subscribe to the custom event: **keyPressHook**. ``` class KeyPressAwareDataGridView : DataGridView { protected override void ...
325,706
<p>The following code produces an error hr=0x80020005 (wrong type).</p> <pre><code>#import &lt;msi.dll&gt; using namespace WindowsInstaller; main() { ::CoInitialize(NULL); InstallerPtr pInstaller("WindowsInstaller.Installer"); DatabasePtr pDB = pInstaller-&gt;OpenDatabase( "c:\\foo\\bar.msi", ...
[ { "answer_id": 348903, "author": "Tuminoid", "author_id": 40657, "author_profile": "https://Stackoverflow.com/users/40657", "pm_score": 1, "selected": false, "text": "<p>MSDN says <a href=\"http://msdn.microsoft.com/en-us/library/aa370338(VS.85).aspx\" rel=\"nofollow noreferrer\">OpenDat...
2008/11/28
[ "https://Stackoverflow.com/questions/325706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21132/" ]
The following code produces an error hr=0x80020005 (wrong type). ``` #import <msi.dll> using namespace WindowsInstaller; main() { ::CoInitialize(NULL); InstallerPtr pInstaller("WindowsInstaller.Installer"); DatabasePtr pDB = pInstaller->OpenDatabase( "c:\\foo\\bar.msi", msiOpe...
I finally got the answer on [msdn forums](http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/225c2a86-aa2e-4eab-b2be-0897c695eb7f/?ppud=4&ffpr=0) ``` DatabasePtr pDB = pInstaller->OpenDatabase( "c:\\foo\\bar.msi", (long)msiOpenDatabaseModeTransact); ...
325,725
<p>Starting with the following LINQ query:</p> <pre><code>from a in things where a.Id == b.Id &amp;&amp; a.Name == b.Name &amp;&amp; a.Value1 == b.Value1 &amp;&amp; a.Value2 == b.Value2 &amp;&amp; a.Value3 == b.Value3 select a; </code></pre> <p>How can I remove (at runtime) one or more of the conditions i...
[ { "answer_id": 325739, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "<p>Rather than try to change existing where clauses, I'd refactor it to this:</p>\n\n<pre><code>from a in things \nwhere...
2008/11/28
[ "https://Stackoverflow.com/questions/325725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1065/" ]
Starting with the following LINQ query: ``` from a in things where a.Id == b.Id && a.Name == b.Name && a.Value1 == b.Value1 && a.Value2 == b.Value2 && a.Value3 == b.Value3 select a; ``` How can I remove (at runtime) one or more of the conditions in the where clause in order to obtain queries similar to t...
Rather than try to change existing where clauses, I'd refactor it to this: ``` from a in things where a.Id == b.Id where a.Name == b.Name where a.Value1 == b.Value1 where a.Value2 == b.Value2 where a.Value3 == b.Value3 select a; ``` That then becomes: ``` things.Where(a => a.Id == b.Id) .Where(a => a.Na...
325,733
<p>In Apple's NSObject documentation, NSZoneFree is called in the - (void)dealloc example code:</p> <pre><code>- (void)dealloc { [companion release]; NSZoneFree(private, [self zone]) [super dealloc]; } </code></pre> <p>You can find it in context <a href="http://developer.apple.com/documentation/Cocoa/Refe...
[ { "answer_id": 325787, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 1, "selected": false, "text": "<p>According to the <a href=\"https://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Misce...
2008/11/28
[ "https://Stackoverflow.com/questions/325733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24051/" ]
In Apple's NSObject documentation, NSZoneFree is called in the - (void)dealloc example code: ``` - (void)dealloc { [companion release]; NSZoneFree(private, [self zone]) [super dealloc]; } ``` You can find it in context [over here](http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classe...
`NSZoneFree()` balances out a call to `NSZoneMalloc()`, just like `-release` balances a call to `-alloc` or `-copy` and `CFRelease()` balances a call to `CFRetain()` or `CF*Create*()` or, for that matter, `free()` balances a call to `malloc()` or `calloc()`. Given the allocator(s) that the C library uses on Mac OS X, ...
325,734
<p>When writing a class do you group members variables of the same type together? Is there any benefit to doing so? For example:</p> <pre><code>class Foo { private: bool a_; bool b_; int c_; int d_; std::string e_; std::string f_; ... }; </code></pre> <p>As opposed to:</p> <pre><code>cl...
[ { "answer_id": 325736, "author": "Alastair", "author_id": 31038, "author_profile": "https://Stackoverflow.com/users/31038", "pm_score": 3, "selected": false, "text": "<p>You should have them in the order you want them initialised, because that's the order they will be initialised, regard...
2008/11/28
[ "https://Stackoverflow.com/questions/325734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
When writing a class do you group members variables of the same type together? Is there any benefit to doing so? For example: ``` class Foo { private: bool a_; bool b_; int c_; int d_; std::string e_; std::string f_; ... }; ``` As opposed to: ``` class Bar { private: std::string e_; ...
I group them according to semantics, i.e. ``` class Foo { private: std::string peach; bool banana; int apple; int red; std::string green; std::string blue; ... }; ``` The more readable, the better.
325,756
<p>I need a Guid property in some attribute class like this:</p> <pre><code>public class SomeAttribute : Attribute { private Guid foreignIdentificator; public Guid ForeignIdentificator { get { return this.foreignIdentificator; } set { this.foreignIdentificator = value; } } } </code></pre> ...
[ { "answer_id": 325773, "author": "Brian Genisio", "author_id": 36687, "author_profile": "https://Stackoverflow.com/users/36687", "pm_score": 4, "selected": true, "text": "<p>I have run into your exact problem in the past. We simply required them to pass in the GUID as a string... the de...
2008/11/28
[ "https://Stackoverflow.com/questions/325756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20382/" ]
I need a Guid property in some attribute class like this: ``` public class SomeAttribute : Attribute { private Guid foreignIdentificator; public Guid ForeignIdentificator { get { return this.foreignIdentificator; } set { this.foreignIdentificator = value; } } } ``` But in attribute defini...
I have run into your exact problem in the past. We simply required them to pass in the GUID as a string... the default way that the VS GUID generator tool gives it to us (\*F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4). We essentially did what you did. We use it in a plug-in architecture, so our customers have been the ones to...
325,765
<p>Can jQuery ajax made browser request a new location in redirect header send by server?</p>
[ { "answer_id": 325799, "author": "Stein G. Strindhaug", "author_id": 26115, "author_profile": "https://Stackoverflow.com/users/26115", "pm_score": 0, "selected": false, "text": "<p>Haven't tried jQuery, and a quick peek at the doc doesn't really tell me what a redirect response is handle...
2008/11/28
[ "https://Stackoverflow.com/questions/325765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/441493/" ]
Can jQuery ajax made browser request a new location in redirect header send by server?
You should parse the code and use Javascript to set the document.location ``` $.get('page.php', { GETvar : 'redirectUrl' }, function(data, textString){ if (textString == "succes") { //Succes! document.location = data; } else{ // failure } }); ``` If you PHP script returns a valid url this will set the locatio...
325,788
<p>I'm trying to change assembly binding (from one version to another) dynamically.</p> <p>I've tried this code but it doesn't work:</p> <pre><code> Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); ConfigurationSection assemblyBindingSection = config.Sections["...
[ { "answer_id": 326011, "author": "Eric Rosenberger", "author_id": 41624, "author_profile": "https://Stackoverflow.com/users/41624", "pm_score": 6, "selected": true, "text": "<p>The best way I've found to dynamically bind to a different version of an assembly is to hook the <code>AppDomai...
2008/11/28
[ "https://Stackoverflow.com/questions/325788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12248/" ]
I'm trying to change assembly binding (from one version to another) dynamically. I've tried this code but it doesn't work: ``` Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); ConfigurationSection assemblyBindingSection = config.Sections["assemblyBinding"]; ...
The best way I've found to dynamically bind to a different version of an assembly is to hook the `AppDomain.AssemblyResolve` event. This event is fired whenever the runtime is unable to locate the exact assembly that the application was linked against, and it allows you to provide another assembly, that you load yourse...
325,791
<p>Here is the scenario. 2 web servers in two separate locations having two mysql databases with identical tables. The data within the tables is also expected to be identical in real time. </p> <p>Here is the problem. if a user in either location simultaneously enters a new record into identical tables, as illustrated...
[ { "answer_id": 325797, "author": "Pierre-Yves Gillier", "author_id": 2692, "author_profile": "https://Stackoverflow.com/users/2692", "pm_score": 0, "selected": false, "text": "<p>The only way to ensure your tables are synchronized is to setup a 2-ways replication between databases.</p>\n...
2008/11/28
[ "https://Stackoverflow.com/questions/325791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11190/" ]
Here is the scenario. 2 web servers in two separate locations having two mysql databases with identical tables. The data within the tables is also expected to be identical in real time. Here is the problem. if a user in either location simultaneously enters a new record into identical tables, as illustrated in the tw...
There isn't much performance to be gained from replicating your database on two masters. However, there is a nifty bit of failover if you code your application correct. Master-Master setup is essentially the same as the Slave-Master setup but has both Slaves started and an important change to your config files on each...
325,806
<p>I'm trying to update a variable in APC, and will be many processes trying to do that.</p> <p>APC doesn't provide locking functionality, so I'm considering using other mechanisms... what I've found so far is mysql's GET_LOCK(), and php's flock(). Anything else worth considering?</p> <p>Update: I've found sem_acquir...
[ { "answer_id": 329585, "author": "too much php", "author_id": 28835, "author_profile": "https://Stackoverflow.com/users/28835", "pm_score": 2, "selected": false, "text": "<p>If you don't mind basing your lock on the filesystem, then you could use fopen() with mode 'x'. Here is an example...
2008/11/28
[ "https://Stackoverflow.com/questions/325806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8437/" ]
I'm trying to update a variable in APC, and will be many processes trying to do that. APC doesn't provide locking functionality, so I'm considering using other mechanisms... what I've found so far is mysql's GET\_LOCK(), and php's flock(). Anything else worth considering? Update: I've found sem\_acquire, but it seems...
``` /* CLASS ExclusiveLock Description ================================================================== This is a pseudo implementation of mutex since php does not have any thread synchronization objects This class uses flock() as a base to provide locking functionality. Lock will be released in following cases 1 - u...
325,826
<p>I'm pre-compiling a C program containing Pro*C code with Oracle 10.2 and AIX 5.2</p> <p>The Oracle precompiler reads the <code>$ORACLE_HOME/precomp/admin/pcscfg.cfg file</code> which contains the definition of the sys_include variable (set to <code>/usr/include</code>).</p> <p>The Pro*C compiler complains that it ...
[ { "answer_id": 326173, "author": "EvilTeach", "author_id": 7734, "author_profile": "https://Stackoverflow.com/users/7734", "pm_score": 4, "selected": true, "text": "<p>From <a href=\"https://metalink2.oracle.com/metalink/plsql/f?p=130:3:9328216730994661370::::p3_database_id,p3_docid,p3_s...
2008/11/28
[ "https://Stackoverflow.com/questions/325826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/381/" ]
I'm pre-compiling a C program containing Pro\*C code with Oracle 10.2 and AIX 5.2 The Oracle precompiler reads the `$ORACLE_HOME/precomp/admin/pcscfg.cfg file` which contains the definition of the sys\_include variable (set to `/usr/include`). The Pro\*C compiler complains that it doesn't know what the `size_t` type ...
From [Metalink](https://metalink2.oracle.com/metalink/plsql/f?p=130:3:9328216730994661370::::p3_database_id,p3_docid,p3_show_header,p3_show_help,p3_black_frame,p3_font:NOT,102288.1,1,1,1,helvetica) ``` PCC-S-02201, Encountered the symbol "size_t" when expecting one of the following : ... auto, char, const, double,...
325,836
<p>I am attempting to integrate an existing payment platform into my webshop. After making a succesful transaction, the payment platform sends a request to an URL in my application with the transaction ID included in the query parameters.</p> <p>However, I need to do some post-processing like sending an order confirma...
[ { "answer_id": 325868, "author": "benlumley", "author_id": 39161, "author_profile": "https://Stackoverflow.com/users/39161", "pm_score": -1, "selected": false, "text": "<p>Dirty, but has worked for me:</p>\n\n<p>Tell the payment gateway to use </p>\n\n<pre><code>http://yourdomain.com/cal...
2008/11/28
[ "https://Stackoverflow.com/questions/325836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11568/" ]
I am attempting to integrate an existing payment platform into my webshop. After making a succesful transaction, the payment platform sends a request to an URL in my application with the transaction ID included in the query parameters. However, I need to do some post-processing like sending an order confirmation, etc....
Many thanks for all the replies. [Smazurov's answer](https://stackoverflow.com/questions/325836/how-to-re-initialize-a-session-in-php#326915) got me thinking and made me overlook my PHP configuration once more. PHP's default behaviour is not to encrypt the session-related data, which *should* make it possible to re...
325,838
<p>I have a php page that displays rows from a mysql db as a table. One of the fields contains HTML markup, and I would like to amke this row clickable and the html would open in a new popup window. What is the best way to do it, and is there a way to do it without writing the html to a file?</p> <p>edit: this php pa...
[ { "answer_id": 325858, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 3, "selected": true, "text": "<pre><code>child1 = window.open (\"about:blank\")\nchild1.document.write(\"Moo!\");\nchild1.document.clo...
2008/11/28
[ "https://Stackoverflow.com/questions/325838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I have a php page that displays rows from a mysql db as a table. One of the fields contains HTML markup, and I would like to amke this row clickable and the html would open in a new popup window. What is the best way to do it, and is there a way to do it without writing the html to a file? edit: this php page is actua...
``` child1 = window.open ("about:blank") child1.document.write("Moo!"); child1.document.close() ```
325,859
<p>I'm looking at the new object initializers in C# 3.0 and would like to use them. However, I can't see how to use them with something like Microsoft Unity. I'm probably missing something but if I want to keep strongly typed property names then I'm not sure I can. e.g. I can do this (pseudo code)</p> <pre><code>Dicti...
[ { "answer_id": 325860, "author": "Totty", "author_id": 30838, "author_profile": "https://Stackoverflow.com/users/30838", "pm_score": 0, "selected": false, "text": "<p>I am not sure how well it will fit your needs, but you might take a look at <a href=\"http://www.visifire.com/\" rel=\"no...
2008/11/28
[ "https://Stackoverflow.com/questions/325859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm looking at the new object initializers in C# 3.0 and would like to use them. However, I can't see how to use them with something like Microsoft Unity. I'm probably missing something but if I want to keep strongly typed property names then I'm not sure I can. e.g. I can do this (pseudo code) ``` Dictionary<string,o...
Look no further, use [visifire](http://visifire.com/silverlight_chart_designer.php).
325,871
<p>I'm trying to find out the most efficient (best performance) way to check date field for current date. Currently we are using:</p> <pre><code>SELECT COUNT(Job) AS Jobs FROM dbo.Job WHERE (Received BETWEEN DATEADD(d, DATEDIFF(d, 0, GETDATE()), 0) AND DATEADD(d, DATEDIFF(d, 0,...
[ { "answer_id": 325904, "author": "Mladen Prajdic", "author_id": 31345, "author_profile": "https://Stackoverflow.com/users/31345", "pm_score": 0, "selected": false, "text": "<p>that's pretty much the best way to do it.\nyou could put the DATEADD(d, DATEDIFF(d, 0, GETDATE()), 0) and DATEAD...
2008/11/28
[ "https://Stackoverflow.com/questions/325871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1491425/" ]
I'm trying to find out the most efficient (best performance) way to check date field for current date. Currently we are using: ``` SELECT COUNT(Job) AS Jobs FROM dbo.Job WHERE (Received BETWEEN DATEADD(d, DATEDIFF(d, 0, GETDATE()), 0) AND DATEADD(d, DATEDIFF(d, 0, GETDATE()), 1)...
``` WHERE DateDiff(d, Received, GETDATE()) = 0 ``` Edit: As lined out in the comments to this answer, that's not an ideal solution. Check the other answers in this thread, too.
325,872
<p>I've been using a 3G wireless card for a while and every time I connect, my anti-virus fires up the updates.</p> <p>I'm wondering what is the Win32 API set of functions that I can use to, either, get notified or query about the event of an Internet Connection coming up?</p> <p>And is there already a set of ported ...
[ { "answer_id": 325974, "author": "Bruce McGee", "author_id": 19183, "author_profile": "https://Stackoverflow.com/users/19183", "pm_score": 2, "selected": false, "text": "<p>Look at InternetGetConnectedState in WinINet.</p>\n\n<p>Some applications might also poll for a known server and no...
2008/11/28
[ "https://Stackoverflow.com/questions/325872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8167/" ]
I've been using a 3G wireless card for a while and every time I connect, my anti-virus fires up the updates. I'm wondering what is the Win32 API set of functions that I can use to, either, get notified or query about the event of an Internet Connection coming up? And is there already a set of ported headers for Delph...
I worked on a project to run a user's logon script whenever they connected our network over VPN. To do this, I wrote a helper unit that retrieves adapter info and stores it into a simple record. I then setup up a registry notification, [see here for how to do that in Delphi](http://delphi.about.com/od/kbwinshell/l/aa0...
325,873
<p>I use an SQL statement to remove records that exist on another database but this takes a very long time.</p> <p>Is there any other alternative to the code below that can be faster? Database is Access.</p> <p>email_DB.mdb is from where I want to remove the email addresses that exist on the other database (table New...
[ { "answer_id": 325974, "author": "Bruce McGee", "author_id": 19183, "author_profile": "https://Stackoverflow.com/users/19183", "pm_score": 2, "selected": false, "text": "<p>Look at InternetGetConnectedState in WinINet.</p>\n\n<p>Some applications might also poll for a known server and no...
2008/11/28
[ "https://Stackoverflow.com/questions/325873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36544/" ]
I use an SQL statement to remove records that exist on another database but this takes a very long time. Is there any other alternative to the code below that can be faster? Database is Access. email\_DB.mdb is from where I want to remove the email addresses that exist on the other database (table Newsletter\_Subscri...
I worked on a project to run a user's logon script whenever they connected our network over VPN. To do this, I wrote a helper unit that retrieves adapter info and stores it into a simple record. I then setup up a registry notification, [see here for how to do that in Delphi](http://delphi.about.com/od/kbwinshell/l/aa0...
325,874
<p>I have a TSqlDataSet which has a blob field, I need to get the data of this blob field in the BeforeUpdateRecord event of the provider and execute an update command, I've tried this:</p> <pre><code>Cmd := TSQLQuery.Create(nil); try Cmd.SQLConnection := SQLConnection; Cmd.CommandText := 'UPDATE MYTABLE SET IMAGE...
[ { "answer_id": 327089, "author": "Argalatyr", "author_id": 18484, "author_profile": "https://Stackoverflow.com/users/18484", "pm_score": 0, "selected": false, "text": "<p>Have you tried testing with another driver (e.g. ODBC)? It's possible that the error is not in your code. This appr...
2008/11/28
[ "https://Stackoverflow.com/questions/325874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/727/" ]
I have a TSqlDataSet which has a blob field, I need to get the data of this blob field in the BeforeUpdateRecord event of the provider and execute an update command, I've tried this: ``` Cmd := TSQLQuery.Create(nil); try Cmd.SQLConnection := SQLConnection; Cmd.CommandText := 'UPDATE MYTABLE SET IMAGE = :PIMAGE WHE...
Answering my own question, the correct way to do it is the following: ``` const SQL = 'UPDATE MYTABLE SET IMAGE = :PIMAGE WHERE ID = :PID;'; var Params: TParams; begin Params := TParams.Create(nil); try Params.CreateParam(ftBlob, 'PIMAGE', ptInput).AsBlob := DeltaDS.FieldByName('IMAGE').NewValue; Param...
325,879
<p>I'm not looking for a general discussion on <a href="https://stackoverflow.com/questions/157354/is-mathematics-necessary-for-programming">if math is important or not for programming</a>. </p> <p>Instead I'm looking for real world scenarios where you have actually used some branch of math to solve some particular pr...
[ { "answer_id": 325891, "author": "M. Utku ALTINKAYA", "author_id": 40948, "author_profile": "https://Stackoverflow.com/users/40948", "pm_score": 2, "selected": false, "text": "<p>Discrete math for everything, linear algebra for 3D, analysis for physics especially for calculating mass pro...
2008/11/28
[ "https://Stackoverflow.com/questions/325879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
I'm not looking for a general discussion on [if math is important or not for programming](https://stackoverflow.com/questions/157354/is-mathematics-necessary-for-programming). Instead I'm looking for real world scenarios where you have actually used some branch of math to solve some particular problem during your car...
I frequently find myself using [De Morgan's theorem](http://en.wikipedia.org/wiki/De_Morgan's_laws) when as well as general Boolean algebra when trying to simplify conditionals I've also occasionally written out truth tables to verify changes, as in the example below (found during a recent code review) (`showAll` and...
325,887
<p>I have this code</p> <pre><code>&lt;?php session_start(); if (isset($_GET["cmd"])) $cmd = $_GET["cmd"]; else die("You should have a 'cmd' parameter in your URL"); $pk = $_GET["pk"]; $con = mysql_connect("localhost","root","geheim"); if(!$con) { die('Connection failed because of' .mysql_error()); } mysql_select...
[ { "answer_id": 325934, "author": "Philip Morton", "author_id": 21709, "author_profile": "https://Stackoverflow.com/users/21709", "pm_score": 2, "selected": true, "text": "<p>It should be:</p>\n\n<pre><code>echo \"&lt;img src=\\\"\".$row['PIC_URL'].\"\\\"&gt;\";\n</code></pre>\n" }, {...
2008/11/28
[ "https://Stackoverflow.com/questions/325887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I have this code ``` <?php session_start(); if (isset($_GET["cmd"])) $cmd = $_GET["cmd"]; else die("You should have a 'cmd' parameter in your URL"); $pk = $_GET["pk"]; $con = mysql_connect("localhost","root","geheim"); if(!$con) { die('Connection failed because of' .mysql_error()); } mysql_select_db("ebay",$con);...
It should be: ``` echo "<img src=\"".$row['PIC_URL']."\">"; ```
325,906
<p>When I discovered <a href="http://www.boost.org/doc/libs/1_47_0/libs/conversion/lexical_cast.htm" rel="noreferrer"><code>boost::lexical_cast</code></a> I thought to myself "why didn't I know about this sooner!" - I hated having to write code like </p> <pre><code>stringstream ss; ss &lt;&lt; anIntVal; mystring = ss...
[ { "answer_id": 325911, "author": "fhe", "author_id": 4445, "author_profile": "https://Stackoverflow.com/users/4445", "pm_score": 7, "selected": true, "text": "<p>Probably the most used part of boost for me is <a href=\"http://www.boost.org/doc/libs/1_37_0/libs/smart_ptr/shared_ptr.htm\" ...
2008/11/28
[ "https://Stackoverflow.com/questions/325906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3590/" ]
When I discovered [`boost::lexical_cast`](http://www.boost.org/doc/libs/1_47_0/libs/conversion/lexical_cast.htm) I thought to myself "why didn't I know about this sooner!" - I hated having to write code like ``` stringstream ss; ss << anIntVal; mystring = ss.str(); ``` Now I write ``` mystring = boost::lexical_cas...
Probably the most used part of boost for me is [boost::shared\_ptr](http://www.boost.org/doc/libs/1_37_0/libs/smart_ptr/shared_ptr.htm).
325,918
<p>I've got an executable file, and I would like to know which version(s) of the Microsoft .NET Framework this file needs to be started.</p> <p>Is there an easy way to find this information somewhere?</p> <p>(So far I tried <a href="https://en.wikipedia.org/wiki/ILDASM#Metadata_storage" rel="noreferrer">ILDASM</a> and ...
[ { "answer_id": 325966, "author": "Scott Dorman", "author_id": 1559, "author_profile": "https://Stackoverflow.com/users/1559", "pm_score": 7, "selected": true, "text": "<p>I think the closest you can reliably get is to determine what version of the <strong>CLR</strong> is required. You ca...
2008/11/28
[ "https://Stackoverflow.com/questions/325918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7021/" ]
I've got an executable file, and I would like to know which version(s) of the Microsoft .NET Framework this file needs to be started. Is there an easy way to find this information somewhere? (So far I tried [ILDASM](https://en.wikipedia.org/wiki/ILDASM#Metadata_storage) and [DUMPBIN](https://support.microsoft.com/kb/...
I think the closest you can reliably get is to determine what version of the **CLR** is required. You can do this by using ILDASM and looking at the "MANIFEST" node or Reflector and looking at the dissasembly view of the "Application.exe" node as IL. In both cases there is a comment that indicates the CLR version. In I...
325,929
<p>In HTML, you can send data from one page to another using a GET request in a couple of ways:</p> <pre><code>http://www.example.com/somepage.php?data=1 </code></pre> <p>...or...</p> <pre><code>&lt;form action="somepage.php" method="get"&gt; &lt;input type="hidden" name="data" value="1" /&gt; &lt;input type="su...
[ { "answer_id": 325938, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 6, "selected": true, "text": "<p>There are only two ways to POST from a browser - a form, or an <a href=\"http://en.wikipedia.org/wiki/Ajax_%28programming%2...
2008/11/28
[ "https://Stackoverflow.com/questions/325929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21709/" ]
In HTML, you can send data from one page to another using a GET request in a couple of ways: ``` http://www.example.com/somepage.php?data=1 ``` ...or... ``` <form action="somepage.php" method="get"> <input type="hidden" name="data" value="1" /> <input type="submit" value="Submit"> </form> ``` With a POST requ...
There are only two ways to POST from a browser - a form, or an [Ajax](http://en.wikipedia.org/wiki/Ajax_%28programming%29) request.
325,931
<p>I want to do exactly the same as in <a href="https://stackoverflow.com/questions/74451/getting-actual-file-name-with-proper-casing-on-windows">this question</a>:</p> <blockquote> <p>Windows file system is case insensitive. How, given a file/folder name (e.g. "somefile"), I get the actual name of that file/folder ...
[ { "answer_id": 326017, "author": "Scott Dorman", "author_id": 1559, "author_profile": "https://Stackoverflow.com/users/1559", "pm_score": 0, "selected": false, "text": "<p>I think the only way you are going to be able to do this is by using the same Win32 API, namely the SHGetFileInfo me...
2008/11/28
[ "https://Stackoverflow.com/questions/325931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/755/" ]
I want to do exactly the same as in [this question](https://stackoverflow.com/questions/74451/getting-actual-file-name-with-proper-casing-on-windows): > > Windows file system is case insensitive. How, given a file/folder name (e.g. "somefile"), I get the actual name of that file/folder (e.g. it should return "SomeFil...
I seems that since NTFS is case insensitive it will always accept your input correctly regardless if the name is cased right. The only way to get the correct path name seems to find the file like John Sibly suggested. I created a method that will take a path (folder or file) and return the correctly cased version of ...
325,933
<p>Given two date ranges, what is the simplest or most efficient way to determine whether the two date ranges overlap?</p> <p>As an example, suppose we have ranges denoted by DateTime variables <code>StartDate1</code> to <code>EndDate1</code> <em>and</em> <code>StartDate2</code> to <code>EndDate2</code>.</p>
[ { "answer_id": 325939, "author": "Ian Nelson", "author_id": 2084, "author_profile": "https://Stackoverflow.com/users/2084", "pm_score": 9, "selected": false, "text": "<p>I believe that it is sufficient to say that the two ranges overlap if:</p>\n\n<pre><code>(StartDate1 &lt;= EndDate2) a...
2008/11/28
[ "https://Stackoverflow.com/questions/325933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2084/" ]
Given two date ranges, what is the simplest or most efficient way to determine whether the two date ranges overlap? As an example, suppose we have ranges denoted by DateTime variables `StartDate1` to `EndDate1` *and* `StartDate2` to `EndDate2`.
**(StartA <= EndB) and (EndA >= StartB)** *Proof:* Let ConditionA Mean that DateRange A Completely After DateRange B ``` _ |---- DateRange A ------| |---Date Range B -----| _ ``` (True if `StartA > EndB`) Let ConditionB Mean that DateRange A is Completely Before D...
325,952
<p>I need to loop through all the matches in say the following string:</p> <p><code>&lt;a href='/Product/Show/{ProductRowID}'&gt;{ProductName}&lt;/a&gt;</code></p> <p>I am looking to capture the values in the {} including them, so I want {ProductRowID} and {ProductName}</p> <p>Here is my code so far:</p> <pre><code...
[ { "answer_id": 325967, "author": "RickL", "author_id": 7261, "author_profile": "https://Stackoverflow.com/users/7261", "pm_score": 1, "selected": false, "text": "<p>Change your RegEx pattern to <code>\\{\\w*\\}</code> then it will match as you expect.</p>\n\n<p>You can test it with an <a...
2008/11/28
[ "https://Stackoverflow.com/questions/325952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34548/" ]
I need to loop through all the matches in say the following string: `<a href='/Product/Show/{ProductRowID}'>{ProductName}</a>` I am looking to capture the values in the {} including them, so I want {ProductRowID} and {ProductName} Here is my code so far: ``` Dim r As Regex = New Regex("{\w*}", RegexOptions.IgnoreCa...
Your Pattern is missing a small detail: ``` \{\w*?\} ``` Curly braces must be escaped, and you want the non-greedy star, or your first (and only) match will be this: `"{ProductRowID}'>{ProductName}"`. ``` Dim r As Regex = New Regex("\{\w*?\}") Dim input As String = "<a href='/Product/Show/{ProductRowID}'>{ProductNa...
325,953
<p>Given <em>test.txt</em> containing:</p> <pre><code>test message </code></pre> <p>I want to end up with:</p> <pre><code>testing a message </code></pre> <p>I think the following should work, but it doesn't:</p> <pre><code>Get-Content test.txt |% {$_-replace "t`r`n", "ting`r`na "} </code></pre> <p>How can I do a ...
[ { "answer_id": 326082, "author": "Don Jones", "author_id": 40405, "author_profile": "https://Stackoverflow.com/users/40405", "pm_score": 7, "selected": true, "text": "<p>A CRLF is two characters, of course, the CR and the LF. However, <code>`n</code> consists of both. For example:</p>\n\...
2008/11/28
[ "https://Stackoverflow.com/questions/325953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5993/" ]
Given *test.txt* containing: ``` test message ``` I want to end up with: ``` testing a message ``` I think the following should work, but it doesn't: ``` Get-Content test.txt |% {$_-replace "t`r`n", "ting`r`na "} ``` How can I do a find and replace where what I'm finding contains CRLF?
A CRLF is two characters, of course, the CR and the LF. However, ``n` consists of both. For example: ``` PS C:\> $x = "Hello >> World" PS C:\> $x Hello World PS C:\> $x.contains("`n") True PS C:\> $x.contains("`r") False PS C:\> $x.replace("o`nW","o There`nThe W") Hello There The World PS C:\> ``` I think you're ru...
325,990
<p>I need to write a row to the database regardless of whether it already exists or not. Before using NHibernate this was done with a stored procedure. The procedure would attempt an update and if no rows were modified it would fallback to an insert. This worked well because the application doesn't care if the record e...
[ { "answer_id": 326001, "author": "Elie", "author_id": 23249, "author_profile": "https://Stackoverflow.com/users/23249", "pm_score": -1, "selected": false, "text": "<p>call hibernate.saveOrUpdate() which will check if the object is in the database, update it if it is, and save (i.e. inser...
2008/11/28
[ "https://Stackoverflow.com/questions/325990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6944/" ]
I need to write a row to the database regardless of whether it already exists or not. Before using NHibernate this was done with a stored procedure. The procedure would attempt an update and if no rows were modified it would fallback to an insert. This worked well because the application doesn't care if the record exis...
I`m using ``` public IList<T> GetByExample<T>(T exampleInstance) { return _session.CreateCriteria(typeof(T)) .Add(Example.Create(exampleInstance)) .List<T>(); } public void InsertOrUpdate<T>(T target) { ITransaction transaction = _session.Be...
326,053
<p>Is there a way to get a list ordered by two fields, say last and first names?</p> <p>I know <code>.listOrderByLastAndFirst</code> and <code>.list(sort:'last, first')</code> won't work.</p>
[ { "answer_id": 326150, "author": "j pimmel", "author_id": 52175, "author_profile": "https://Stackoverflow.com/users/52175", "pm_score": 0, "selected": false, "text": "<p>If you were sorting lists on the contents of their items, you would need to implement a comparator which would have so...
2008/11/28
[ "https://Stackoverflow.com/questions/326053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12803/" ]
Is there a way to get a list ordered by two fields, say last and first names? I know `.listOrderByLastAndFirst` and `.list(sort:'last, first')` won't work.
**This old solution no longer works. Please see mattlary's answer below** You may have to write a custom finder in HQL or use the Criteria Builder. ``` MyDomain.find("from Domain as d order by last,first desc") ``` Or ``` def c = MyDomain.createCriteria() def results = c.list { order("last,first", "desc") }...
326,059
<p>I'm trying to create a "workflow" bar on a web page.</p> <p>The items in the workflow might be of different lengths.</p> <p>There might be enough items to fill the width of the screen, hence the flow needs to wrap onto the next line.</p> <p>I'm using left floating divs to do this. </p> <p>However, I'd like the d...
[ { "answer_id": 326065, "author": "John Polling", "author_id": 41609, "author_profile": "https://Stackoverflow.com/users/41609", "pm_score": 1, "selected": false, "text": "<p>could probably do with seeing the surrounding markup to understand what elements you have in place. You could try...
2008/11/28
[ "https://Stackoverflow.com/questions/326059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7144/" ]
I'm trying to create a "workflow" bar on a web page. The items in the workflow might be of different lengths. There might be enough items to fill the width of the screen, hence the flow needs to wrap onto the next line. I'm using left floating divs to do this. However, I'd like the divs to take an appropriate amou...
just a couple of other pointers. You should not have empty li tags, that is not semantically correct. Also in an ideal world you should [not give id attributes layout names](http://nate.koechley.com/blog/2006/12/22/note_on_structural_and_semantic_meaning/). Personally I'd place the starting image on the ul and then pl...
326,060
<p>Let's say I have an integer that I need to convert to a string (I might be displaying the value to the user by means of a TextBox, for example.</p> <p>Should I prefer <code>.ToString()</code> or <code>Convert.ToString()</code>. They both do the same thing (don't they?).</p> <pre><code>int someValue = 4; // You ca...
[ { "answer_id": 326067, "author": "James Orr", "author_id": 41457, "author_profile": "https://Stackoverflow.com/users/41457", "pm_score": 3, "selected": false, "text": "<p>With its large number of overloads, Convert.ToString() is useful as a catch-all for all sorts of input types, handy w...
2008/11/28
[ "https://Stackoverflow.com/questions/326060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39709/" ]
Let's say I have an integer that I need to convert to a string (I might be displaying the value to the user by means of a TextBox, for example. Should I prefer `.ToString()` or `Convert.ToString()`. They both do the same thing (don't they?). ``` int someValue = 4; // You can do this txtSomeValue.Text = someValue.ToS...
One test is ``` //This will set the variable test to null: string test = Convert.ToString(ConfigurationSettings.AppSettings["Missing.Value"]); //This will throw an exception: string test = ConfigurationSettings.AppSettings["Missing.Value"].ToString(); ``` Got the above ready example from <http://weblogs.asp.net/jg...
326,062
<p>A while ago, I had a discussion with a colleague about how to insert values in STL <a href="http://www.sgi.com/tech/stl/Map.html" rel="noreferrer">maps</a>. I preferred <code>map[key] = value;</code> because it feels natural and is clear to read whereas he preferred <code>map.insert(std::make_pair(key, value))</code...
[ { "answer_id": 326115, "author": "Greg Rogers", "author_id": 5963, "author_profile": "https://Stackoverflow.com/users/5963", "pm_score": 6, "selected": false, "text": "<p>The two have different semantics when it comes to the key already existing in the map. So they aren't really directly...
2008/11/28
[ "https://Stackoverflow.com/questions/326062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12663/" ]
A while ago, I had a discussion with a colleague about how to insert values in STL [maps](http://www.sgi.com/tech/stl/Map.html). I preferred `map[key] = value;` because it feels natural and is clear to read whereas he preferred `map.insert(std::make_pair(key, value))`. I just asked him and neither of us can remember t...
When you write ``` map[key] = value; ``` there's no way to tell if you **replaced** the `value` for `key`, or if you **created** a new `key` with `value`. [`map::insert()`](http://en.cppreference.com/w/cpp/container/map/insert) will only create: ``` using std::cout; using std::endl; typedef std::map<int, std::stri...
326,068
<p>I was discussing multiple inheritance vs. single inheritance with a friend of mine, and discovered that plainly, my conception of Object-Oriented design is completely different than his. I am mostly an Obj-C programmer, so Multiple Inheritance is not something I use daily. He is mostly a C++ programmer under Window...
[ { "answer_id": 326085, "author": "James Orr", "author_id": 41457, "author_profile": "https://Stackoverflow.com/users/41457", "pm_score": 3, "selected": false, "text": "<p>To take the analogy head-on, the new human gets its traits from a pair of zygotes generated by the parents, which are...
2008/11/28
[ "https://Stackoverflow.com/questions/326068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23623/" ]
I was discussing multiple inheritance vs. single inheritance with a friend of mine, and discovered that plainly, my conception of Object-Oriented design is completely different than his. I am mostly an Obj-C programmer, so Multiple Inheritance is not something I use daily. He is mostly a C++ programmer under Windows/PS...
The parents are also humans, which are part of the family of creatures called mammals. Your thoughts seem most logical to me. ``` public class Human extends Mammal implements HunterGatherer, Speech, CognitiveThought { public Human(Human mother, Human father) { super(mother, father); // ... } ...
326,069
<p>I am writing an iframe based facebook app. Now I want to use the same html page to render the normal website as well as the canvas page within facebook. I want to know if I can determine whether the page has been loaded inside the iframe or directly in the browser?</p>
[ { "answer_id": 326076, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 11, "selected": true, "text": "<p>Browsers can block access to <code>window.top</code> due to <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScr...
2008/11/28
[ "https://Stackoverflow.com/questions/326069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29653/" ]
I am writing an iframe based facebook app. Now I want to use the same html page to render the normal website as well as the canvas page within facebook. I want to know if I can determine whether the page has been loaded inside the iframe or directly in the browser?
Browsers can block access to `window.top` due to [same origin policy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Same_origin_policy_for_JavaScript). IE bugs also take place. Here's the working code: ``` function inIframe () { try { return window.self !== window.top; } catch (e) { r...
326,084
<p>I have an XML document with several <code>&lt;person&gt;</code> elements, each of which contains the <code>&lt;name&gt;</code> of the person, and several <code>&lt;preferred-number&gt;</code> elements inside a grouping <code>&lt;preferred-numbers&gt;</code> element. </p> <p>I already found that to obtain the greate...
[ { "answer_id": 326178, "author": "glenatron", "author_id": 15394, "author_profile": "https://Stackoverflow.com/users/15394", "pm_score": 0, "selected": false, "text": "<p>When it comes to sorting stuff in XSLT 1.0 you have to use a slightly roundabout approach as I recall. If you haven't...
2008/11/28
[ "https://Stackoverflow.com/questions/326084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an XML document with several `<person>` elements, each of which contains the `<name>` of the person, and several `<preferred-number>` elements inside a grouping `<preferred-numbers>` element. I already found that to obtain the greatest `<preferred-number>` I have to do an `<xsl:apply-template>` with a `<xsl:so...
One can use the "maximum" template as provided by [**FXSL -- the Functional Programming Library for XSLT**](http://fxsl.sf.net). FXSL is written entirely in XSLT itself. Here is an example of using the "maximum" template: When this transformation: ``` <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/...
326,098
<p>This is my code:</p> <pre><code>internal enum WindowsMessagesFlags { WM_EXITSIZEMOVE = 0x00000232, WM_DISPLAYCHANGE = 0x0000007e, WM_MOVING = 0x00000216, } protected override void WndProc(ref Message m) { switch(m.Msg) { case (int)WindowsMessagesFlags.WM_DISPLAYCHANGE: ...
[ { "answer_id": 326104, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": true, "text": "<p>Sort of - cast m.Msg instead:</p>\n\n<pre><code>protected override void WndProc(ref Message m) {\n switch((WindowsM...
2008/11/28
[ "https://Stackoverflow.com/questions/326098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40480/" ]
This is my code: ``` internal enum WindowsMessagesFlags { WM_EXITSIZEMOVE = 0x00000232, WM_DISPLAYCHANGE = 0x0000007e, WM_MOVING = 0x00000216, } protected override void WndProc(ref Message m) { switch(m.Msg) { case (int)WindowsMessagesFlags.WM_DISPLAYCHANGE: Fix...
Sort of - cast m.Msg instead: ``` protected override void WndProc(ref Message m) { switch((WindowsMessagesFlags) m.Msg) { case WindowsMessagesFlags.WM_DISPLAYCHANGE: FixWindowSnapping(); break; case WindowsMessagesFlags.WM_EXITSIZEMOVE: SaveWindowProp...
326,103
<p>I'm writing a function that fishes out the src from the first image tag it finds in an html file. Following the instructions in <a href="https://stackoverflow.com/questions/138313/how-to-extract-img-src-title-and-alt-from-html-using-php">this thread</a> on here, I got something that seemed to be working:</p> <pre>...
[ { "answer_id": 326117, "author": "Kibbee", "author_id": 1862, "author_profile": "https://Stackoverflow.com/users/1862", "pm_score": 0, "selected": false, "text": "<p>Most likely because the \"XML\" being picked up by the regex isn't proper XML for whatever reason. I would probably go fo...
2008/11/28
[ "https://Stackoverflow.com/questions/326103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm writing a function that fishes out the src from the first image tag it finds in an html file. Following the instructions in [this thread](https://stackoverflow.com/questions/138313/how-to-extract-img-src-title-and-alt-from-html-using-php) on here, I got something that seemed to be working: ``` preg_match_all('#<im...
These two lines of PHP code should give you a list of all the values of the src attribute in all img tags in an HTML file: ``` preg_match_all('/<img\s+[^<>]*src=["\']?([^"\'<>\s]+)["\']?/i', $content, $result, PREG_PATTERN_ORDER); $result = $result[1]; ``` To keep the regex simple, I'm not allowing file names to hav...
326,112
<p>Is there a single algorithm that removes elements from a container as happens in the following code?</p> <pre><code>vec_it = std::remove_if( vec.begin(), vec.end(), pred ); vec.erase( vec_it, vec.end() ); </code></pre>
[ { "answer_id": 326148, "author": "Ralph", "author_id": 23154, "author_profile": "https://Stackoverflow.com/users/23154", "pm_score": -1, "selected": false, "text": "<p>I don't know. Maybe there is. But if there is, then it will be a hell of a statement. Nobody will be able to understand ...
2008/11/28
[ "https://Stackoverflow.com/questions/326112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38892/" ]
Is there a single algorithm that removes elements from a container as happens in the following code? ``` vec_it = std::remove_if( vec.begin(), vec.end(), pred ); vec.erase( vec_it, vec.end() ); ```
The idiomatic way to do it is like jalf has said. You can build your own function to do that more easily: ``` template<typename T, typename Pred> void erase_if(T &vec, Pred pred) { vec.erase(std::remove_if(vec.begin(), vec.end(), pred), vec.end()); } ``` So you can use ``` std::vector<int> myVec; // (...) fill ...
326,128
<p>Imagine I have a document (word document).</p> <p>I have an enumeration which will indicate how to extract data from the document. So if I want just text, the images, or both (3 members of the enumeration).</p> <p>I have a case statement based on this enumeration, but without falling into a code smell, how can I w...
[ { "answer_id": 326142, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "<p>I would use a Strategy pattern coupled with a factory to create the appropriate strategy based on the value of the e...
2008/11/28
[ "https://Stackoverflow.com/questions/326128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
Imagine I have a document (word document). I have an enumeration which will indicate how to extract data from the document. So if I want just text, the images, or both (3 members of the enumeration). I have a case statement based on this enumeration, but without falling into a code smell, how can I write code which i...
I would use a Strategy pattern coupled with a factory to create the appropriate strategy based on the value of the enumeration. **EDIT** As others have pointed out you could also determine the correct strategy via a Map as well. Factory is my choice because it only encapsulates the logic and doesn't require any data st...
326,136
<p>I am trying to get a <code>MethodInfo</code> object for the method:</p> <pre><code>Any&lt;TSource&gt;(IEnumerable&lt;TSource&gt;, Func&lt;TSource, Boolean&gt;) </code></pre> <p>The problem I'm having is working out how you specify the type parameter for the <code>Func&lt;TSource, Boolean&gt;</code> bit... </p> <p...
[ { "answer_id": 326155, "author": "Jb Evain", "author_id": 36702, "author_profile": "https://Stackoverflow.com/users/36702", "pm_score": 3, "selected": true, "text": "<p>There's no way of getting it in a single call, as you would need to make a generic type constructed of the generic para...
2008/11/28
[ "https://Stackoverflow.com/questions/326136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27805/" ]
I am trying to get a `MethodInfo` object for the method: ``` Any<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>) ``` The problem I'm having is working out how you specify the type parameter for the `Func<TSource, Boolean>` bit... ``` MethodInfo method = typeof(Enumerable).GetMethod("Any", new[] { typeof(Fun...
There's no way of getting it in a single call, as you would need to make a generic type constructed of the generic parameter of the method (TSource in this case). And as it's specific to the method, you would need to get the method to get it and build the generic Func type. Chicken and egg issue heh? What you can do t...
326,141
<p>I have a new project which simply put, is an attempt to formalize the look and feel of all of our departmental pages. I Googled around and found many tutorials which discussed the pros and cons of several techniques. And from what I've been reading, the thing I'm ooking for is controls. Basically, I want a common he...
[ { "answer_id": 326145, "author": "dove", "author_id": 30913, "author_profile": "https://Stackoverflow.com/users/30913", "pm_score": 3, "selected": true, "text": "<p><a href=\"http://www.odetocode.com/Articles/419.aspx\" rel=\"nofollow noreferrer\">Masterpages</a> would seem to be what yo...
2008/11/28
[ "https://Stackoverflow.com/questions/326141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25371/" ]
I have a new project which simply put, is an attempt to formalize the look and feel of all of our departmental pages. I Googled around and found many tutorials which discussed the pros and cons of several techniques. And from what I've been reading, the thing I'm ooking for is controls. Basically, I want a common heade...
[Masterpages](http://www.odetocode.com/Articles/419.aspx) would seem to be what you are looking for.
326,186
<p>Is there a way to query or just access newly added object (using ObjectContext.AddObject method) in Entity Framework? I mean situation when it is not yet saved to data store using SaveChanges</p> <p>I understand that queries are translated to underlying SQL and executed against data store, and it don't have this ne...
[ { "answer_id": 491091, "author": "Johann Blais", "author_id": 363385, "author_profile": "https://Stackoverflow.com/users/363385", "pm_score": 4, "selected": true, "text": "<p>In EF, if you use this code, you have all the entities that are already loaded in the context (including newly ad...
2008/11/28
[ "https://Stackoverflow.com/questions/326186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37366/" ]
Is there a way to query or just access newly added object (using ObjectContext.AddObject method) in Entity Framework? I mean situation when it is not yet saved to data store using SaveChanges I understand that queries are translated to underlying SQL and executed against data store, and it don't have this new object y...
In EF, if you use this code, you have all the entities that are already loaded in the context (including newly added ones) : ``` context.ObjectStateManager.GetObjectStateEntries(EntityState.Added | EntityState.Modified | EntityState.Unchanged).Select(o => o.Entity).OfType<YourObjectType>() ```
326,194
<p>I know there is a similar problem on this forum, but the solutions did not really work for me. I am populating form controls with fields from a few different data sources, and the data shows up great.</p> <p>I have an <code>ImageButton</code> control, which has an <code>OnClick</code> Event set to grab all of the ...
[ { "answer_id": 491091, "author": "Johann Blais", "author_id": 363385, "author_profile": "https://Stackoverflow.com/users/363385", "pm_score": 4, "selected": true, "text": "<p>In EF, if you use this code, you have all the entities that are already loaded in the context (including newly ad...
2008/11/28
[ "https://Stackoverflow.com/questions/326194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I know there is a similar problem on this forum, but the solutions did not really work for me. I am populating form controls with fields from a few different data sources, and the data shows up great. I have an `ImageButton` control, which has an `OnClick` Event set to grab all of the data from the form. Unfortunately...
In EF, if you use this code, you have all the entities that are already loaded in the context (including newly added ones) : ``` context.ObjectStateManager.GetObjectStateEntries(EntityState.Added | EntityState.Modified | EntityState.Unchanged).Select(o => o.Entity).OfType<YourObjectType>() ```
326,196
<p>I'm stuck on what appears to be a CSS/z-index conflict with the YouTube player. In Firefox 3 under Windows XP, Take a look at this page: <a href="http://spokenword.org/program/21396" rel="noreferrer">http://spokenword.org/program/21396</a> Click on the Collect button and note that the pop-up &lt;div> appears <em>und...
[ { "answer_id": 326220, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 8, "selected": true, "text": "<p>Try to add the <code>wmode</code> parameter to be <code>opaque</code> like this:</p>\n\n<p>(Note that it's in...
2008/11/28
[ "https://Stackoverflow.com/questions/326196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17307/" ]
I'm stuck on what appears to be a CSS/z-index conflict with the YouTube player. In Firefox 3 under Windows XP, Take a look at this page: <http://spokenword.org/program/21396> Click on the Collect button and note that the pop-up <div> appears *under* the YouTube player. On other browsers the <div> appears on top. It has...
Try to add the `wmode` parameter to be `opaque` like this: (Note that it's included in *both* a `<param>` tag **and** a `wmode` attribute on the `<embed>` tag.) ``` <object width='425' height='344'> <param name='movie' value='http://www.youtube.com/v/Wj_JNwNbETA&hl=en&fs=1'> <param name='type' value='applic...
326,202
<p>What is a generic list manipulation function in C? (I saw this when I was going through some materials.)</p> <p>What is the difference between this function and a function which can accept elements of any kind?</p> <p>Are they same...? How can we implement them individually if they are not same?</p>
[ { "answer_id": 326211, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 4, "selected": true, "text": "<p>A generic list is likely to be singly-linked, and probably assumes that the items in the list have a structure ...
2008/11/28
[ "https://Stackoverflow.com/questions/326202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31116/" ]
What is a generic list manipulation function in C? (I saw this when I was going through some materials.) What is the difference between this function and a function which can accept elements of any kind? Are they same...? How can we implement them individually if they are not same?
A generic list is likely to be singly-linked, and probably assumes that the items in the list have a structure like this: ``` typedef struct list_item list_item; struct list_item { list_item *next; ...data for node... }; ``` Using this layout, you can write functions to manipulate lists using just the next ...
326,205
<p>What is forward reference in C with respect to pointers?</p> <p>Can I get an example?</p>
[ { "answer_id": 326214, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 5, "selected": true, "text": "<p>See this page on <a href=\"https://web.archive.org/web/20080314031412/http://h30097.www3.hp.com/docs/base_doc/DOCUMENTAT...
2008/11/28
[ "https://Stackoverflow.com/questions/326205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31116/" ]
What is forward reference in C with respect to pointers? Can I get an example?
See this page on [forward references](https://web.archive.org/web/20080314031412/http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V40F_HTML/AQTLTBTE/DOCU_024.HTM). I don't see how forward referencing would be different with pointers and with other PoD types. Note that you can forward declare types, and declare va...
326,223
<p>I have an abstract base class and I want to declare a field or a property that will have a different value in each class that inherits from this parent class. </p> <p>I want to define it in the baseclass so I can reference it in a base class method - for example overriding ToString to say "This object is of type <i...
[ { "answer_id": 326230, "author": "Winston Smith", "author_id": 35086, "author_profile": "https://Stackoverflow.com/users/35086", "pm_score": 0, "selected": false, "text": "<p>I'd go with option 3, but have an abstract setMyInt method that subclasses are forced to implement. This way you ...
2008/11/28
[ "https://Stackoverflow.com/questions/326223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11534/" ]
I have an abstract base class and I want to declare a field or a property that will have a different value in each class that inherits from this parent class. I want to define it in the baseclass so I can reference it in a base class method - for example overriding ToString to say "This object is of type *property/fi...
Of the three solutions only **Option 1** is **polymorphic**. Fields by themselves cannot be overridden. Which is exactly why **Option 2** returns the ***new*** keyword warning. The solution to the warning is not to append the “new” keyword, but to implement Option 1. **If you need your field to be polymorphic you...
326,224
<p>I want to cache custom data in an ASP.NET application. I am putting lots of data into it, such as List&lt;objects&gt;, and other objects.</p> <p>Is there a best practice for this? Since if I use a static data, if the <code>w3p.exe</code> dies or gets recycled, the cache will need to be filled again.</p> <p>The datab...
[ { "answer_id": 326276, "author": "rajesh pillai", "author_id": 34644, "author_profile": "https://Stackoverflow.com/users/34644", "pm_score": 2, "selected": false, "text": "<p>Also have a look at the MS Enterprise Caching Application block which allows your to write custom expiration poli...
2008/11/28
[ "https://Stackoverflow.com/questions/326224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25531/" ]
I want to cache custom data in an ASP.NET application. I am putting lots of data into it, such as List<objects>, and other objects. Is there a best practice for this? Since if I use a static data, if the `w3p.exe` dies or gets recycled, the cache will need to be filled again. The database is also getting updated by o...
You are looking for either out of process caching or a distributed caching system of some sort, based upon your requirements. I recommend distributed caching, because it is very scalable and is dedicated to caching. Someone else had recommended Velocity, which we have been evaluating and thoroughly enjoying. We have wr...