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
244,854
<p>When I construct my control (which inherits DataGrid), I add specific rows and columns. This works great at design time. Unfortunately, at runtime I add my rows and columns in the same constructor, but then the DataGrid is serialized (after the constructor runs) adding <strong>more</strong> rows and columns.</p> <p...
[ { "answer_id": 248782, "author": "Tim Robinson", "author_id": 32133, "author_profile": "https://Stackoverflow.com/users/32133", "pm_score": 1, "selected": false, "text": "<p>What seems to be happening is this:</p>\n\n<ol>\n<li>You've designed a custom DataGrid that adds its own rows and ...
2008/10/28
[ "https://Stackoverflow.com/questions/244854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
When I construct my control (which inherits DataGrid), I add specific rows and columns. This works great at design time. Unfortunately, at runtime I add my rows and columns in the same constructor, but then the DataGrid is serialized (after the constructor runs) adding **more** rows and columns. After serialization is...
What seems to be happening is this: 1. You've designed a custom DataGrid that adds its own rows and columns in the constructor 2. You've added your custom DataGrid to a form 3. You've found that the form designer has written code inside the form's InitializeComponent that adds those rows and columns a second time The...
244,875
<p>I have a custom webpart that is displaying dynamic list data, it needs to render an image from a Picture Library (or at least provide me the URL so I can encapsulate it with an tag), however, none of the fields in the Picture Library seem to contain the image URL? Is there a 'image utility' (SPImageUtility) or som...
[ { "answer_id": 244989, "author": "Nat", "author_id": 13813, "author_profile": "https://Stackoverflow.com/users/13813", "pm_score": 0, "selected": false, "text": "<p>Are getting information from a CAML query? If so you will need to add the required field to the query.</p>\n\n<p>Otherwise ...
2008/10/28
[ "https://Stackoverflow.com/questions/244875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/105/" ]
I have a custom webpart that is displaying dynamic list data, it needs to render an image from a Picture Library (or at least provide me the URL so I can encapsulate it with an tag), however, none of the fields in the Picture Library seem to contain the image URL? Is there a 'image utility' (SPImageUtility) or somethin...
Assuming you are using the object model then the you should use this (c#) ``` SPListItem["EncodedAbsUrl"] ``` to get the HTML encoded absolute URL of the image (where "**EncodedAbsUrl**" is the name of the field/column). To get the unencoded site relative url you can use **ServerUrl** or **FileRef** (they appear to...
244,884
<p>I'm really stumped on this one. I want to output a list and have the tag file take care of commas, singular versus plural, etc. but when I display the list it completely ignores whitespace so everythingrunstogetherlikethis. I tried using the HTML entities "thinsp", "ensp" and "emsp" (I can't use "nbsp", these have t...
[ { "answer_id": 245305, "author": "alex77", "author_id": 1555, "author_profile": "https://Stackoverflow.com/users/1555", "pm_score": 2, "selected": false, "text": "<p>Maybe put the jsp content in an html <code>&lt;pre&gt;</code> tag?\nThis seems to me to be the right thing to do as the li...
2008/10/28
[ "https://Stackoverflow.com/questions/244884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484/" ]
I'm really stumped on this one. I want to output a list and have the tag file take care of commas, singular versus plural, etc. but when I display the list it completely ignores whitespace so everythingrunstogetherlikethis. I tried using the HTML entities "thinsp", "ensp" and "emsp" (I can't use "nbsp", these have to b...
It's actually a bug in the EL parser which causes spaces in between EL expressions to be eaten. E.g. ``` ${bean.foo} ${bean.bar} ${bean.waa} ``` would get printed as (assuming that they returns the very same String value as its property name is): ``` foobarwaa ``` I recall that this issue was reported somewhere b...
244,886
<p>Consider the following code:</p> <pre><code>Public Class Animal Public Overridable Function Speak() As String Return "Hello" End Function End Class Public Class Dog Inherits Animal Public Overrides Function Speak() As String Return "Ruff" End Function End Class Dim dog As New Dog Dim a...
[ { "answer_id": 244910, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 4, "selected": false, "text": "<p>You don't; the subclass's method overrides the superclass's method, by definition of inheritance.</p>\n\n<p>If you...
2008/10/28
[ "https://Stackoverflow.com/questions/244886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/81/" ]
Consider the following code: ``` Public Class Animal Public Overridable Function Speak() As String Return "Hello" End Function End Class Public Class Dog Inherits Animal Public Overrides Function Speak() As String Return "Ruff" End Function End Class Dim dog As New Dog Dim animal As Anima...
You don't; the subclass's method overrides the superclass's method, by definition of inheritance. If you want the overridden method to be available, expose it in the subclass, e.g. ``` Public Class Dog Inherits Animal Public Overrides Function Speak() As String Return "Ruff" End Function Publ...
244,889
<p>I have a performance problem with my ruby on my machine, which I think I have isolated to loading libraries (when #require is called), so I'm trying to work out whether ruby is searching too many folders for libraries.</p> <p>When I run </p> <pre><code>$ gem environment RubyGems Environment: - RUBYGEMS VERSION: ...
[ { "answer_id": 248064, "author": "Gabe Hollombe", "author_id": 30632, "author_profile": "https://Stackoverflow.com/users/30632", "pm_score": 4, "selected": true, "text": "<p>Yep. That all looks pretty standard to me. My mac running MacOS 10.5 similarly has nothing in ~/.gem/ruby/1.8/gem...
2008/10/28
[ "https://Stackoverflow.com/questions/244889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20011/" ]
I have a performance problem with my ruby on my machine, which I think I have isolated to loading libraries (when #require is called), so I'm trying to work out whether ruby is searching too many folders for libraries. When I run ``` $ gem environment RubyGems Environment: - RUBYGEMS VERSION: 1.3.0 - RUBY VERSIO...
Yep. That all looks pretty standard to me. My mac running MacOS 10.5 similarly has nothing in ~/.gem/ruby/1.8/gems/ and quite a bit in the other two locations.
244,892
<p>I have a protected Excel worksheet, without a password. What I'd like to do is trap the event that a user unprotects the worksheet, so that I can generate a message (and nag 'em!). I can setup event checking for the application, for when new workbooks are opened, etc., but not for Unprotect.<br> Does anyone have an...
[ { "answer_id": 245036, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 2, "selected": false, "text": "<p>It is possible to modify the menu using Tools->Customize. Protect/Unprotect can be set to run a macro, for example:</p>...
2008/10/28
[ "https://Stackoverflow.com/questions/244892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a protected Excel worksheet, without a password. What I'd like to do is trap the event that a user unprotects the worksheet, so that I can generate a message (and nag 'em!). I can setup event checking for the application, for when new workbooks are opened, etc., but not for Unprotect. Does anyone have an ide...
It is possible to modify the menu using Tools->Customize. Protect/Unprotect can be set to run a macro, for example: ``` Sub UnprotectTrap() If ActiveSheet.ProtectContents = True Then MsgBox "Tut,tut!" ActiveSheet.Unprotect Else ActiveSheet.Protect End If End Sub ```
244,913
<p>I need to match a string like "one. two. three. four. five. six. seven. eight. nine. ten. eleven" into groups of four sentences. I need a regular expression to break the string into a group after every fourth period. Something like: </p> <pre><code> string regex = @"(.*.\s){4}"; System.Text.RegularExpressi...
[ { "answer_id": 244955, "author": "configurator", "author_id": 9536, "author_profile": "https://Stackoverflow.com/users/9536", "pm_score": 1, "selected": false, "text": "<p>Try defining the method</p>\n\n<pre><code>private string AppendNewLineToMatch(Match match) {\n return match.Value...
2008/10/28
[ "https://Stackoverflow.com/questions/244913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4555/" ]
I need to match a string like "one. two. three. four. five. six. seven. eight. nine. ten. eleven" into groups of four sentences. I need a regular expression to break the string into a group after every fourth period. Something like: ``` string regex = @"(.*.\s){4}"; System.Text.RegularExpressions.Regex exp = new...
`.` in a regex means "any character" so in your regex, you have used `.*.` which will match a word (this is equivalent to `.+`) You were probably looking for `[^.]\*[.]` - a series of characters that are not "`.`"s followed by a "`.`".
244,918
<p>I'm writing an application and I'm trying to tie simple AJAX functionality in. It works well in Mozilla Firefox, but there's an interesting bug in Internet Explorer: Each of the links can only be clicked once. The browser must be completely restarted, simply reloading the page won't work. I've written a <a href="htt...
[ { "answer_id": 244923, "author": "pkaeding", "author_id": 4257, "author_profile": "https://Stackoverflow.com/users/4257", "pm_score": 3, "selected": false, "text": "<p>It looks like IE is caching the response. If you either change your calls to POST methods, or send the appropriate head...
2008/10/28
[ "https://Stackoverflow.com/questions/244918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23335/" ]
I'm writing an application and I'm trying to tie simple AJAX functionality in. It works well in Mozilla Firefox, but there's an interesting bug in Internet Explorer: Each of the links can only be clicked once. The browser must be completely restarted, simply reloading the page won't work. I've written a [very simple ex...
This happens because Internet Explorer ignores the no-cache directive, and caches the results of ajax calls. Then, if the next request is identical, it will just serve up the cached version. There's an easy workaround, and that is to just append random string on the end of your query. ``` xmlHttp.open("GET","blurb.ph...
244,926
<p>I'm using a the TreeView control and it scrolls automatically to left-align TreeViewItem when one of them is clicked. I've gone looking at my Styles and ControlTemplates, but I haven't found anything. Is there a default ControlTemplate that causes this? I want to disable it.</p>
[ { "answer_id": 244986, "author": "Ben Collins", "author_id": 3279, "author_profile": "https://Stackoverflow.com/users/3279", "pm_score": 0, "selected": false, "text": "<p>It looks like I found a good clue on <a href=\"http://social.msdn.microsoft.com/forums/en-US/wpf/thread/9abff78f-481d...
2008/10/28
[ "https://Stackoverflow.com/questions/244926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3279/" ]
I'm using a the TreeView control and it scrolls automatically to left-align TreeViewItem when one of them is clicked. I've gone looking at my Styles and ControlTemplates, but I haven't found anything. Is there a default ControlTemplate that causes this? I want to disable it.
The items scroll because the ScrollViewer calls BringIntoView() on them. So one way to avoid scrolling is to suppress the handling of the RequestBringIntoView event. You can try that out quickly by subclassing TreeView and instantiating this control instead: ``` public class NoScrollTreeView : TreeView { public cl...
244,934
<p>I'd like to create a table which has an integer primary key limited between 000 and 999. Is there any way to enforce this 3 digit limit within the sql?</p> <p>I'm using sqlite3. Thanks.</p>
[ { "answer_id": 244972, "author": "AlexCuse", "author_id": 794, "author_profile": "https://Stackoverflow.com/users/794", "pm_score": 1, "selected": false, "text": "<p>You may be able to do so using a CHECK constraint.</p>\n\n<p>But, </p>\n\n<blockquote>\n <p>CHECK constraints are support...
2008/10/28
[ "https://Stackoverflow.com/questions/244934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20883/" ]
I'd like to create a table which has an integer primary key limited between 000 and 999. Is there any way to enforce this 3 digit limit within the sql? I'm using sqlite3. Thanks.
SQLite supports two ways of doing this: Define a `CHECK` constraint on the primary key column: ``` CREATE TABLE mytable ( mytable_id INT PRIMARY KEY CHECK (mytable_id BETWEEN 0 and 999) ); ``` Create a trigger on the table that aborts any `INSERT` or `UPDATE` that attempts to set the primary key column to a value...
244,935
<p>How can I inject the value of an appSettings entry (from app.config or web.config) into a service using the Windsor container? If I wanted to inject the value of a Windsor property into a service, I would do something like this:</p> <pre><code>&lt;properties&gt; &lt;importantIntegerProperty&gt;666&lt;/important...
[ { "answer_id": 283875, "author": "Mauricio Scheffer", "author_id": 21239, "author_profile": "https://Stackoverflow.com/users/21239", "pm_score": 2, "selected": false, "text": "<p>I <a href=\"http://bugsquash.blogspot.com/2008/09/changing-windsor-components.html\" rel=\"nofollow noreferre...
2008/10/28
[ "https://Stackoverflow.com/questions/244935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30321/" ]
How can I inject the value of an appSettings entry (from app.config or web.config) into a service using the Windsor container? If I wanted to inject the value of a Windsor property into a service, I would do something like this: ``` <properties> <importantIntegerProperty>666</importantIntegerProperty> </properties...
I came up with a solution for this eventually based on hints from various sources on the web. The end result though involved pretty much copying three classes from Windsor verbatim and modifying them just a little bit. The end result is up on codeplex for your enjoyment. <http://windsorappcfgprops.codeplex.com/> I or...
244,953
<p>I have a class with a nullable int? datatype set to serialize as an xml element. Is there any way to set it up so the xml serializer will not serialize the element if the value is null? </p> <p>I've tried to add the [System.Xml.Serialization.XmlElement(IsNullable=false)] attribute, but I get a runtime serializati...
[ { "answer_id": 244998, "author": "Serge Wautier", "author_id": 12379, "author_profile": "https://Stackoverflow.com/users/12379", "pm_score": 1, "selected": false, "text": "<p>Unfortunately, the behaviours you describe are accurately documented as such in the docs for XmlElementAttribute....
2008/10/28
[ "https://Stackoverflow.com/questions/244953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9266/" ]
I have a class with a nullable int? datatype set to serialize as an xml element. Is there any way to set it up so the xml serializer will not serialize the element if the value is null? I've tried to add the [System.Xml.Serialization.XmlElement(IsNullable=false)] attribute, but I get a runtime serialization exception...
XmlSerializer supports the `ShouldSerialize{Foo}()` pattern, so you can add a method: ``` public bool ShouldSerializeID() {return ID.HasValue;} ``` There is also the `{Foo}Specified` pattern - not sure if XmlSerializer supports that one.
244,959
<p>Suppose I have the following two strings containing regular expressions. How do I coalesce them? More specifically, I want to have the two expressions as alternatives.</p> <pre><code>$a = '# /[a-z] #i'; $b = '/ Moo /x'; $c = preg_magic_coalesce('|', $a, $b); // Desired result should be equivalent to: // '/ \/[a-zA-Z...
[ { "answer_id": 244985, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 1, "selected": false, "text": "<p>I'm pretty sure it's not possible to just put regexps together like that in any language - they could have incompatible mo...
2008/10/28
[ "https://Stackoverflow.com/questions/244959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1968/" ]
Suppose I have the following two strings containing regular expressions. How do I coalesce them? More specifically, I want to have the two expressions as alternatives. ``` $a = '# /[a-z] #i'; $b = '/ Moo /x'; $c = preg_magic_coalesce('|', $a, $b); // Desired result should be equivalent to: // '/ \/[a-zA-Z] |Moo/' ```...
I see that porneL actually [described](https://stackoverflow.com/questions/244959/coalescing-regular-expressions-in-php#245326) a bunch of this, but this handles most of the problem. It cancels modifiers set in previous sub-expressions (which the other answer missed) and sets modifiers as specified in each sub-expressi...
245,012
<p>By default Windows (XP) shows the <strong>underlined hotkeys</strong> only, when ALT is pressed. This can be changed in display-properties in the subdialog "Effects" so, that the hotkeys are <strong>always underlined</strong></p> <p>How can it be changed programmatically? Which API-call or registry-setting can be u...
[ { "answer_id": 245151, "author": "Mentat", "author_id": 30198, "author_profile": "https://Stackoverflow.com/users/30198", "pm_score": 2, "selected": false, "text": "<p>Do you mean you want to change this system-wide setting, or that you want to be able to override the behavior only in yo...
2008/10/28
[ "https://Stackoverflow.com/questions/245012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26820/" ]
By default Windows (XP) shows the **underlined hotkeys** only, when ALT is pressed. This can be changed in display-properties in the subdialog "Effects" so, that the hotkeys are **always underlined** How can it be changed programmatically? Which API-call or registry-setting can be used to change this setting?
I found the solution, how to query and to set: ``` BOOL b SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &b, 0); if (!b) { b = TRUE; SystemParametersInfo(SPI_SETKEYBOARDCUES, 0, &b, 0); } ```
245,019
<p>Has anybody else had trouble with getting the .Net Framework source code? Google doesn't have anything to say about this error message, and neither does the CodePlex issue tracker.</p> <p>Here is the command I'm using to get the source code for the modules that make up mscorlib.dll. Am I doing something obviously...
[ { "answer_id": 245151, "author": "Mentat", "author_id": 30198, "author_profile": "https://Stackoverflow.com/users/30198", "pm_score": 2, "selected": false, "text": "<p>Do you mean you want to change this system-wide setting, or that you want to be able to override the behavior only in yo...
2008/10/28
[ "https://Stackoverflow.com/questions/245019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31205/" ]
Has anybody else had trouble with getting the .Net Framework source code? Google doesn't have anything to say about this error message, and neither does the CodePlex issue tracker. Here is the command I'm using to get the source code for the modules that make up mscorlib.dll. Am I doing something obviously wrong? Net...
I found the solution, how to query and to set: ``` BOOL b SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &b, 0); if (!b) { b = TRUE; SystemParametersInfo(SPI_SETKEYBOARDCUES, 0, &b, 0); } ```
245,027
<p>...I want to Show the 'delete' button when user is an admin, and show the 'add item' button when user is a contributor:</p> <pre><code>&lt;!-- More code above --&gt; &lt;asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" /&gt; &lt;asp:TemplateField ShowHeader="F...
[ { "answer_id": 245032, "author": "Keltex", "author_id": 28260, "author_profile": "https://Stackoverflow.com/users/28260", "pm_score": 1, "selected": false, "text": "<p>Try:</p>\n\n<pre><code>Visible='&lt;%= User.IsInRole(@\"DOMAIN\\CMDB_CONTRIBUTE\") %&gt;'\n</code></pre>\n\n<p>The asp:t...
2008/10/28
[ "https://Stackoverflow.com/questions/245027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13959/" ]
...I want to Show the 'delete' button when user is an admin, and show the 'add item' button when user is a contributor: ``` <!-- More code above --> <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" /> <asp:TemplateField ShowHeader="False"> <ItemT...
Try setting it in code behind, instead of in mark up, in Page\_Load. Assuming the id is promptTable (it wasn't given in your example), just add: ``` promptTable.Visible = User.IsInRole(@"DOMAIN\CMDB_CONTRIBUTE"); ``` Presumably this needs to be done regardless of whether it is a postback or not. FWIW, @Keltex is ri...
245,045
<p>I'm looking for a way to add a close button to a .NET ToolTip object similar to the one the NotifyIcon has. I'm using the tooltip as a message balloon called programatically with the Show() method. That works fine but there is no onclick event or easy way to close the tooltip. You have to call the Hide() method some...
[ { "answer_id": 245128, "author": "avgbody", "author_id": 8737, "author_profile": "https://Stackoverflow.com/users/8737", "pm_score": 3, "selected": true, "text": "<p>You could try an implement your own tool tip window by overriding the existing one and customizing the onDraw function. I ...
2008/10/28
[ "https://Stackoverflow.com/questions/245045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13556/" ]
I'm looking for a way to add a close button to a .NET ToolTip object similar to the one the NotifyIcon has. I'm using the tooltip as a message balloon called programatically with the Show() method. That works fine but there is no onclick event or easy way to close the tooltip. You have to call the Hide() method somewhe...
You could try an implement your own tool tip window by overriding the existing one and customizing the onDraw function. I never tried adding a button, but have done other customizations with the tooltip before. ``` 1 class MyToolTip : ToolTip 2 { 3 public MyToolTip() 4 { 5 ...
245,055
<p>So what I have right now is something like this:</p> <pre><code>PropertyInfo[] info = obj.GetType().GetProperties(BindingFlags.Public); </code></pre> <p>where <code>obj</code> is some object.</p> <p>The problem is some of the properties I want aren't in <code>obj.GetType()</code> they're in one of the base classe...
[ { "answer_id": 245105, "author": "Seibar", "author_id": 357, "author_profile": "https://Stackoverflow.com/users/357", "pm_score": 3, "selected": false, "text": "<p>If you access <code>Type.BaseType</code>, you can get the base type. You can recursively access each base type and you'll kn...
2008/10/28
[ "https://Stackoverflow.com/questions/245055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23822/" ]
So what I have right now is something like this: ``` PropertyInfo[] info = obj.GetType().GetProperties(BindingFlags.Public); ``` where `obj` is some object. The problem is some of the properties I want aren't in `obj.GetType()` they're in one of the base classes further up. If I stop the debugger and look at obj, t...
Use this: ``` PropertyInfo[] info = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); ``` EDIT: Of course the correct answer is that of [Jay](https://stackoverflow.com/questions/245055/how-do-you-get-the-all-properties-of-a-class-and-its-base-classes-up-the-hierar#245131). `GetProperties()` w...
245,058
<p>Lately I've been using XPathDocument and XNavigator to parse an XML file for a given XPath and attribute. It's been working very well, when I know in advance what the XPath is. </p> <p>Sometimes though, the XPath will be one of several possible XPath values, and I'd like to be able to test whether or not a given XP...
[ { "answer_id": 245077, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>If you've given valid XPath but it doesn't match anything, <code>SelectSingleNode</code> won't <em>throw</em> a <code>...
2008/10/28
[ "https://Stackoverflow.com/questions/245058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5948/" ]
Lately I've been using XPathDocument and XNavigator to parse an XML file for a given XPath and attribute. It's been working very well, when I know in advance what the XPath is. Sometimes though, the XPath will be one of several possible XPath values, and I'd like to be able to test whether or not a given XPath exists...
If you've given valid XPath but it doesn't match anything, `SelectSingleNode` won't *throw* a `NullReferenceException` - it will just return null. If you pass `SelectSingleNode` some syntactically invalid XPath, that's when it will throw an `XPathException`. So normally, you'd just need to test whether the returned v...
245,082
<p>I'm making a shell script to find bigrams, which works, sort of.</p> <pre><code>#tokenise words tr -sc 'a-zA-z0-9.' '\012' &lt; $1 &gt; out1 #create 2nd list offset by 1 word tail -n+2 out1 &gt; out2 #paste list together paste out1 out2 #clean up rm out1 out2 </code></pre> <p>The only problem is that it pairs wor...
[ { "answer_id": 245065, "author": "Kirk Strauser", "author_id": 32538, "author_profile": "https://Stackoverflow.com/users/32538", "pm_score": 4, "selected": false, "text": "<p>Everything. They're unrelated languages.</p>\n" }, { "answer_id": 245066, "author": "ddaa", "aut...
2008/10/28
[ "https://Stackoverflow.com/questions/245082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm making a shell script to find bigrams, which works, sort of. ``` #tokenise words tr -sc 'a-zA-z0-9.' '\012' < $1 > out1 #create 2nd list offset by 1 word tail -n+2 out1 > out2 #paste list together paste out1 out2 #clean up rm out1 out2 ``` The only problem is that it pairs words from the end and start of the pr...
Java and Javascript are similar like Car and Carpet are similar.
245,121
<p>I'm looking for a code library that converts ANSI escape sequences into HTML color, via plain tags or CSS. For example, something that would convert this:</p> <pre>ESC[00mESC[01;34mbinESC[00m ESC[01;34mcodeESC[00m ESC[01;31mdropbox-lnx.x86-0.6.404.tar.gzESC[00m ESC[00mfooESC[00m</pre> <p>Into this:</p> <pre><cod...
[ { "answer_id": 252452, "author": "Pistos", "author_id": 28558, "author_profile": "https://Stackoverflow.com/users/28558", "pm_score": 5, "selected": true, "text": "<p>There seems to be <a href=\"http://search.cpan.org/perldoc?HTML::FromANSI\" rel=\"noreferrer\">an HTML::FromANSI Perl mod...
2008/10/28
[ "https://Stackoverflow.com/questions/245121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9084/" ]
I'm looking for a code library that converts ANSI escape sequences into HTML color, via plain tags or CSS. For example, something that would convert this: ``` ESC[00mESC[01;34mbinESC[00m ESC[01;34mcodeESC[00m ESC[01;31mdropbox-lnx.x86-0.6.404.tar.gzESC[00m ESC[00mfooESC[00m ``` Into this: ``` <span style="color:blue...
There seems to be [an HTML::FromANSI Perl module](http://search.cpan.org/perldoc?HTML::FromANSI).
245,124
<p>I need to set the onload attribute for a newly popped-up window. The following code works for Firefox:</p> <pre><code>&lt;a onclick="printwindow=window.open('www.google.com');printwindow.document.body.onload=self.print();return false;" href='www.google.com'&gt; </code></pre> <p>However, when I try this in IE, I ge...
[ { "answer_id": 245203, "author": "buti-oxa", "author_id": 2515, "author_profile": "https://Stackoverflow.com/users/2515", "pm_score": 0, "selected": false, "text": "<p>You are relying on \"printwindow.document.body.onload=self.print();\" line being executed before the child document fini...
2008/10/28
[ "https://Stackoverflow.com/questions/245124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26001/" ]
I need to set the onload attribute for a newly popped-up window. The following code works for Firefox: ``` <a onclick="printwindow=window.open('www.google.com');printwindow.document.body.onload=self.print();return false;" href='www.google.com'> ``` However, when I try this in IE, I get an error - "printwindow.docume...
While earlier answers correctly stated the new window must be from the same domain, they incorrectly answered why he got the error 'printwindow.document.body null or not defined'. It's because IE doesn't return any status from window.open() which means you can open a page and try to access it BEFORE onload is available...
245,168
<p>How do I properly convert two columns from SQL (2008) using Linq into a <code>Dictionary</code> (for caching)?</p> <p>I currently loop through the <code>IQueryable</code> b/c I can't get the <code>ToDictionary</code> method to work. Any ideas? This works:</p> <pre><code>var query = from p in db.Table sel...
[ { "answer_id": 245174, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 8, "selected": true, "text": "<pre><code>var dictionary = db\n .Table\n .Select(p =&gt; new { p.Key, p.Value })\n .AsEnumerable()\n .ToDict...
2008/10/28
[ "https://Stackoverflow.com/questions/245168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17729/" ]
How do I properly convert two columns from SQL (2008) using Linq into a `Dictionary` (for caching)? I currently loop through the `IQueryable` b/c I can't get the `ToDictionary` method to work. Any ideas? This works: ``` var query = from p in db.Table select p; Dictionary<string, string> dic = new Diction...
``` var dictionary = db .Table .Select(p => new { p.Key, p.Value }) .AsEnumerable() .ToDictionary(kvp => kvp.Key, kvp => kvp.Value) ; ```
245,178
<p>I read some properties from an xml file, amongst which is a string that refers to an llblgen object for example 'article'. For now I have set up a rather long </p> <pre><code>Select Case myString Case "article" return New ArticleEntity() </code></pre> <p>Etc. which is getting rather ugly as it gets longer an...
[ { "answer_id": 245181, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 2, "selected": false, "text": "<p>You could store the type names in the file and use:</p>\n\n<pre><code>return Activator.CreateInstance(Type.GetType(\"Some...
2008/10/28
[ "https://Stackoverflow.com/questions/245178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31489/" ]
I read some properties from an xml file, amongst which is a string that refers to an llblgen object for example 'article'. For now I have set up a rather long ``` Select Case myString Case "article" return New ArticleEntity() ``` Etc. which is getting rather ugly as it gets longer and longer ;). Is there a be...
you could create a dictionary mapping strings to factory methods eg ``` Dictionary<string, Func<Animal>> _map = new Dictionary { ("cat", () => new Cat()), ("dog", () => new Dog()) ... } ``` Then your case statement becomes ``` return _map[myString](); ```
245,180
<p>I am writing a stored procedure where I have an input parameter called <em>my_size</em> that is an <em>INTEGER</em>. I want to be able to use it in a <code>LIMIT</code> clause in a <code>SELECT</code> statement. Apparently this is not supported, is there a way to work around this?</p> <pre><code># I want something ...
[ { "answer_id": 245210, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 5, "selected": true, "text": "<p>A search turned up <a href=\"http://bugs.mysql.com/bug.php?id=8094\" rel=\"noreferrer\">this article</a>. I've ...
2008/10/28
[ "https://Stackoverflow.com/questions/245180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24694/" ]
I am writing a stored procedure where I have an input parameter called *my\_size* that is an *INTEGER*. I want to be able to use it in a `LIMIT` clause in a `SELECT` statement. Apparently this is not supported, is there a way to work around this? ``` # I want something like: SELECT * FROM some_table LIMIT my_size; # ...
A search turned up [this article](http://bugs.mysql.com/bug.php?id=8094). I've pasted the relevant text below. > > Here's a forum post showing an example of prepared statements letting > you assign a variable value to the limit clause: > > > <http://forums.mysql.com/read.php?98,126379,133966#msg-133966> > > > Ho...
245,183
<p>How do you go about verifying the type of an uploaded file reliably without using the extension? I'm guessing that you have to examine the header / read some of the bytes, but I really have no idea how to go about it. Im using c# and asp.net.</p> <p>Thanks for any advice.</p> <hr> <p>ok, so from the above links I...
[ { "answer_id": 245196, "author": "Corey Trager", "author_id": 9328, "author_profile": "https://Stackoverflow.com/users/9328", "pm_score": 1, "selected": false, "text": "<p>The first few bytes of a file will often tell you the file type. See, for example,<br>\n<a href=\"http://www.garyke...
2008/10/28
[ "https://Stackoverflow.com/questions/245183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27805/" ]
How do you go about verifying the type of an uploaded file reliably without using the extension? I'm guessing that you have to examine the header / read some of the bytes, but I really have no idea how to go about it. Im using c# and asp.net. Thanks for any advice. --- ok, so from the above links I now know that I a...
Here's a quick-and-dirty response to the followup question you posted: ``` byte[] jpg = new byte[] { 0xFF, 0xD8, 0xFF, 0xE0 }; bool match = true; for (int i = 0; i < jpg.Length; i++) { if (jpg[i] != b[i]) { match = false; break; } } ```
245,192
<p>When are objects or something else said to be &quot;first-class&quot; in a given programming language, and why? In what way do they differ from languages where they are not?</p> <p>When one says &quot;everything is an object&quot; (like in Python), do they indeed mean that &quot;everything is first-class&quot;?</p>
[ { "answer_id": 245208, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 9, "selected": true, "text": "<p>In short, it means there are no restrictions on the object's use. It's the same as\nany other object.</p>\n\n<p>A f...
2008/10/28
[ "https://Stackoverflow.com/questions/245192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18770/" ]
When are objects or something else said to be "first-class" in a given programming language, and why? In what way do they differ from languages where they are not? When one says "everything is an object" (like in Python), do they indeed mean that "everything is first-class"?
In short, it means there are no restrictions on the object's use. It's the same as any other object. A first class object is an entity that can be dynamically created, destroyed, passed to a function, returned as a value, and have all the rights as other variables in the programming language have. > > Depending on ...
245,236
<p>Is there a pure-Java equivalent to &lt;jsp:forward page="..." /&gt; that I can use within a &lt;% ... %> block?</p> <p>For example, I currently have a JSP page something like this:</p> <pre><code>&lt;% String errorMessage = SomeClass.getInstance().doSomething(); if (errorMessage != null) { session....
[ { "answer_id": 245257, "author": "Adam", "author_id": 8604, "author_profile": "https://Stackoverflow.com/users/8604", "pm_score": 6, "selected": true, "text": "<p>The <code>someObject</code> you are looking for is <a href=\"http://java.sun.com/products/jsp/2.1/docs/jsp-2_1-pfd2/javax/ser...
2008/10/28
[ "https://Stackoverflow.com/questions/245236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1119/" ]
Is there a pure-Java equivalent to <jsp:forward page="..." /> that I can use within a <% ... %> block? For example, I currently have a JSP page something like this: ``` <% String errorMessage = SomeClass.getInstance().doSomething(); if (errorMessage != null) { session.setAttribute("error", errorMessag...
The `someObject` you are looking for is [pageContext](http://java.sun.com/products/jsp/2.1/docs/jsp-2_1-pfd2/javax/servlet/jsp/PageContext.html#forward(java.lang.String)). This object is implicitly defined in JSP, so you can use it like this: ``` pageContext.forward("<some relative jsp>"); ```
245,241
<p>I'd like to check ancestry using two jQuery objects. They don't have IDs, and are only going to be available as jQuery objects (or DOM nodes if you called <code>get()</code>). jQuery's <code>is()</code> only works with expressions, so this code would be ideal but will not work:</p> <pre><code>var someDiv = $('#div...
[ { "answer_id": 245266, "author": "Gareth", "author_id": 31582, "author_profile": "https://Stackoverflow.com/users/31582", "pm_score": 5, "selected": true, "text": "<p>You can use the index() method to check if an element exists in a list, so would the following work?</p>\n\n<pre><code>va...
2008/10/28
[ "https://Stackoverflow.com/questions/245241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32229/" ]
I'd like to check ancestry using two jQuery objects. They don't have IDs, and are only going to be available as jQuery objects (or DOM nodes if you called `get()`). jQuery's `is()` only works with expressions, so this code would be ideal but will not work: ``` var someDiv = $('#div'); $('a').click(function() { if...
You can use the index() method to check if an element exists in a list, so would the following work? ``` var someDiv = $('#div'); $('a').click(function() { if ($(this).parents().index(someDiv) >= 0) { alert('boo'); } } ``` From [#index reference](http://docs.jquery.com/Core/index#subject).
245,251
<p>Is there an <strong>efficient</strong> way to create a file with a given size in Java?</p> <p>In C it can be done with <a href="http://linux.die.net/man/2/ftruncate" rel="noreferrer">ftruncate</a> (see <a href="https://stackoverflow.com/questions/139261/how-to-create-a-file-with-a-given-size-in-linux#245239">that a...
[ { "answer_id": 245271, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "<p>You can open the file for writing, seek to offset (n-1), and write a single byte. The OS will automatically extend the...
2008/10/28
[ "https://Stackoverflow.com/questions/245251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4308/" ]
Is there an **efficient** way to create a file with a given size in Java? In C it can be done with [ftruncate](http://linux.die.net/man/2/ftruncate) (see [that answer](https://stackoverflow.com/questions/139261/how-to-create-a-file-with-a-given-size-in-linux#245239)). Most people would just write **n** dummy bytes i...
Create a new [RandomAccessFile](https://docs.oracle.com/javase/8/docs/api/java/io/RandomAccessFile.html) and call the setLength method, specifying the desired file length. The underlying JRE implementation should use the most efficient method available in your environment. The following program ``` import java.io.*; ...
245,292
<p>I've been running into this problem with Flex for nearly a year, and each time I work up a quick hack solution that works for the time being. I'd like to see if anyone has a better idea.</p> <p>Here are the conditions of a problem:</p> <pre><code>|------Container ------------| | explicitHeight: 400 (or whateve...
[ { "answer_id": 246363, "author": "netsuo", "author_id": 27911, "author_profile": "https://Stackoverflow.com/users/27911", "pm_score": 4, "selected": true, "text": "<p>You have to use the \"autoLayout\" parameter on the VBox as documentation say:<br /><br />\n<i>\"By default, the size of ...
2008/10/28
[ "https://Stackoverflow.com/questions/245292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23965/" ]
I've been running into this problem with Flex for nearly a year, and each time I work up a quick hack solution that works for the time being. I'd like to see if anyone has a better idea. Here are the conditions of a problem: ``` |------Container ------------| | explicitHeight: 400 (or whatever) | ...
You have to use the "autoLayout" parameter on the VBox as documentation say: *"By default, the size of the VBox container is big enough to hold the image at it original size. If you disable layout updates, and use the Zoom effect to enlarge the image, or use the Move effect to reposition the image, the image might e...
245,317
<p>Has anyone else had any problems using google's Domain Tracking API, I am specifically talking about the _link() method.</p> <p><a href="http://code.google.com/apis/analytics/docs/gaJS/gaJSApiDomainDirectory.html#_gat.GA_Tracker_._link" rel="nofollow noreferrer">The documentation is here</a></p> <p>The example pro...
[ { "answer_id": 245330, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "<p>You should ensure that you are using the correct version of <code>svnadmin</code> for your repository version. It's po...
2008/10/28
[ "https://Stackoverflow.com/questions/245317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25767/" ]
Has anyone else had any problems using google's Domain Tracking API, I am specifically talking about the \_link() method. [The documentation is here](http://code.google.com/apis/analytics/docs/gaJS/gaJSApiDomainDirectory.html#_gat.GA_Tracker_._link) The example provided shows that the \_link() method should be used i...
I had this same error with svnadmin 1.5 awhile back after renaming files and directories. Specifically I renamed some files from "Filename" to "filename" and SVN pretended it was okay with this... only to freak out later when I tried doing a fresh checkout. When I tried a fresh checkout I got a weird abort message abou...
245,334
<p>Ok, this is very weird. I'm trying to do a database migration, and all of a sudden, I'm getting these errors:</p> <pre> [C:\source\fe]: rake db:migrate --trace (in C:/source/fe) ** Invoke db:migrate (first_time) ** Invoke setup (first_time) ** Invoke gems:install (first_time) ** Invoke gems:set_gem_status (first_ti...
[ { "answer_id": 245340, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": -1, "selected": false, "text": "<pre><code>rake aborted!\ncan`'t activate rake\n</code></pre>\n\n<p>It is mid-Autumn - perhaps too many leaves ha...
2008/10/29
[ "https://Stackoverflow.com/questions/245334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4322/" ]
Ok, this is very weird. I'm trying to do a database migration, and all of a sudden, I'm getting these errors: ``` [C:\source\fe]: rake db:migrate --trace (in C:/source/fe) ** Invoke db:migrate (first_time) ** Invoke setup (first_time) ** Invoke gems:install (first_time) ** Invoke gems:set_gem_status (first_time) ** E...
Interestingly, the solution here was that i needed to downgrade my rake version. The local version (in my C:\ruby dir) was overriding the one in the source directory, and couldn't be loaded. I had done gem update and updated all my local gems. The commands were: ``` gem uninstall rake gem install rake -v ('= 1.5.1')...
245,342
<p>Does anybody know how to call the <code>import data</code> built-in dialog excel from a macro (vba)?</p> <p>I've tried <code>Application.Dialogs.Item(...).Show</code> but I can´t find the right dialog. Please help.</p> <p>Thanks in advance.</p>
[ { "answer_id": 245378, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 0, "selected": false, "text": "<p>If you choose the Object Browser and search for say, xlDialogImportTextFile, you will get a list of possible dialogs.</...
2008/10/29
[ "https://Stackoverflow.com/questions/245342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24927/" ]
Does anybody know how to call the `import data` built-in dialog excel from a macro (vba)? I've tried `Application.Dialogs.Item(...).Show` but I can´t find the right dialog. Please help. Thanks in advance.
The closest I can find using the dialog system is: ``` Application.Dialogs(xlDialogImportTextFile).Show ``` You can get a reference to the command bar button (at least for me in both 2k3 and 2k7) via: ``` Set button = Application.CommandBars.FindControl(ID:=6262) ``` But calling the `Execute` method on the button...
245,345
<p>I have a series of text that contains mixed numbers (ie: a whole part and a fractional part). The problem is that the text is full of human-coded sloppiness:</p> <ol> <li>The whole part may or may not exist (ex: "10")</li> <li>The fractional part may or may not exist (ex: "1/3")</li> <li>The two parts may be separa...
[ { "answer_id": 245351, "author": "Craig Walker", "author_id": 3488, "author_profile": "https://Stackoverflow.com/users/3488", "pm_score": 5, "selected": true, "text": "<p>Here's a regex that will handle all of the data I can throw at it:</p>\n\n<pre><code>(\\d++(?! */))? *-? *(?:(\\d+) *...
2008/10/29
[ "https://Stackoverflow.com/questions/245345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3488/" ]
I have a series of text that contains mixed numbers (ie: a whole part and a fractional part). The problem is that the text is full of human-coded sloppiness: 1. The whole part may or may not exist (ex: "10") 2. The fractional part may or may not exist (ex: "1/3") 3. The two parts may be separated by spaces and/or a hy...
Here's a regex that will handle all of the data I can throw at it: ``` (\d++(?! */))? *-? *(?:(\d+) */ *(\d+))?.*$ ``` This will put the digits into the following groups: 1. The whole part of the mixed number, if it exists 2. The numerator, if a fraction exits 3. The denominator, if a fraction exists Also, here's ...
245,349
<p>I'd like to show an image in an iPhone app, but the image I'm using is too big. I'd like to scale it to fit the iPhone screen, I can't find any class to handle it.</p>
[ { "answer_id": 245364, "author": "Max Stewart", "author_id": 18338, "author_profile": "https://Stackoverflow.com/users/18338", "pm_score": 5, "selected": true, "text": "<pre><code>UIImageView* view = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @\"your_image.png\"]];\nview.fr...
2008/10/29
[ "https://Stackoverflow.com/questions/245349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32096/" ]
I'd like to show an image in an iPhone app, but the image I'm using is too big. I'd like to scale it to fit the iPhone screen, I can't find any class to handle it.
``` UIImageView* view = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"your_image.png"]]; view.frame = CGRectMake(0, 0, width, height); ``` To get the frame of the iPhone screen you can use ``` CGRect frame = [[UIScreen mainScreen] bounds]; ```
245,352
<p>I have the following intentionally trivial function:</p> <pre><code>void ReplaceSome(ref string text) { StringBuilder sb = new StringBuilder(text); sb[5] = 'a'; text = sb.ToString(); } </code></pre> <p>It appears to be inefficient to convert this to a StringBuilder to index into and replace some of the...
[ { "answer_id": 245371, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": -1, "selected": false, "text": "<p>I don't know if this is more efficient, but it works. Either way you'll have to recreate the string after each chan...
2008/10/29
[ "https://Stackoverflow.com/questions/245352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
I have the following intentionally trivial function: ``` void ReplaceSome(ref string text) { StringBuilder sb = new StringBuilder(text); sb[5] = 'a'; text = sb.ToString(); } ``` It appears to be inefficient to convert this to a StringBuilder to index into and replace some of the characters only to copy i...
C# strings are "immutable," which means that they can't be modified. If you have a string, and you want a similar but different string, you must create a new string. Using a StringBuilder as you do above is probably as easy a method as any.
245,354
<p>I'm fairly new to Castle Windsor and am looking into the in's and out's of the logging facility. It seems fairly impressive but the only thing i can't work out is where Windsor sets the Logger property on my classes. As in the following code will set Logger to the nullLogger if the class hasn't been setup yet but wh...
[ { "answer_id": 245478, "author": "Todd", "author_id": 31940, "author_profile": "https://Stackoverflow.com/users/31940", "pm_score": 4, "selected": false, "text": "<p>The logger is setup by the logging facility, which is in the <code>&lt;facilities&gt;</code> section of the configuration....
2008/10/29
[ "https://Stackoverflow.com/questions/245354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30572/" ]
I'm fairly new to Castle Windsor and am looking into the in's and out's of the logging facility. It seems fairly impressive but the only thing i can't work out is where Windsor sets the Logger property on my classes. As in the following code will set Logger to the nullLogger if the class hasn't been setup yet but when ...
The logger is setup by the logging facility, which is in the `<facilities>` section of the configuration. For example to use log4net your app or web.config would look something like this: ``` <?xml version="1.0"?> <configuration> <configSections> <section name="castle" type="Castle.Windsor.Configuration.Ap...
245,369
<p>If I have the following string:</p> <pre><code>string s = "abcdefghab"; </code></pre> <p>Then how do I get a string (or char[]) that has just the characters that are repeated in the original string using C# and LINQ. In my example I want to end up with "ab".</p> <p>Although not necessary, I was trying to do this ...
[ { "answer_id": 245363, "author": "Benson", "author_id": 13816, "author_profile": "https://Stackoverflow.com/users/13816", "pm_score": 3, "selected": false, "text": "<p>There isn't likely to be a foolproof method, as that's an intrusion into the privacy of the user. </p>\n\n<p>One thing ...
2008/10/29
[ "https://Stackoverflow.com/questions/245369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
If I have the following string: ``` string s = "abcdefghab"; ``` Then how do I get a string (or char[]) that has just the characters that are repeated in the original string using C# and LINQ. In my example I want to end up with "ab". Although not necessary, I was trying to do this in a single line of LINQ and had ...
Mozilla/Firefox has a [`window.home()`](https://developer.mozilla.org/En/DOM/Window.home) method which loads the user's home page. This method could be used (in an iframe, maybe) combined with server access logging, to see if the site's home page is instantly requested loaded by the current user. However, other browse...
245,395
<p>What are some of the lesser know, but important and useful features of Windows batch files?</p> <p>Guidelines:</p> <ul> <li>One feature per answer</li> <li>Give both a short <strong>description</strong> of the feature and an <strong>example</strong>, not just a link to documentation</li> <li>Limit answers to <stro...
[ { "answer_id": 245398, "author": "Chris Noe", "author_id": 14749, "author_profile": "https://Stackoverflow.com/users/14749", "pm_score": 6, "selected": false, "text": "<p>I have always found it difficult to read comments that are marked by a keyword on each line:</p>\n\n<pre><code>REM bl...
2008/10/29
[ "https://Stackoverflow.com/questions/245395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14749/" ]
What are some of the lesser know, but important and useful features of Windows batch files? Guidelines: * One feature per answer * Give both a short **description** of the feature and an **example**, not just a link to documentation * Limit answers to **native funtionality**, i.e., does not require additional softwar...
Line continuation: ``` call C:\WINDOWS\system32\ntbackup.exe ^ backup ^ /V:yes ^ /R:no ^ /RS:no ^ /HC:off ^ /M normal ^ /L:s ^ @daily.bks ^ /F daily.bkf ```
245,406
<p>I have done this:</p> <pre><code>$ z() { echo 'hello world'; } </code></pre> <p>How do I get rid of it?</p>
[ { "answer_id": 245409, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 9, "selected": true, "text": "<pre><code>unset -f z\n</code></pre>\n\n<p>Will unset the function named z. A couple people have answered with:</p>\...
2008/10/29
[ "https://Stackoverflow.com/questions/245406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28835/" ]
I have done this: ``` $ z() { echo 'hello world'; } ``` How do I get rid of it?
``` unset -f z ``` Will unset the function named z. A couple people have answered with: ``` unset z ``` but if you have a function and a variable named z only the variable will be unset, not the function.
245,418
<p>I have an ASHX handler that returns an XML response (FileStructureXML.ashx).</p> <p>Now I need to get the XML response from the ASHX handler and use it as a data source for my ASPX page.</p> <p>If I point the XMLDataSource to a static XML file on the server, the treeview populates as expected. However, if I point...
[ { "answer_id": 245676, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "<p>I think that the XmlDataSource only works with an actual file, not a URL. You might be able to work around this by n...
2008/10/29
[ "https://Stackoverflow.com/questions/245418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an ASHX handler that returns an XML response (FileStructureXML.ashx). Now I need to get the XML response from the ASHX handler and use it as a data source for my ASPX page. If I point the XMLDataSource to a static XML file on the server, the treeview populates as expected. However, if I point the XMLDataSource...
I think that the XmlDataSource only works with an actual file, not a URL. You might be able to work around this by not specifying a DataFile property and loading the Data property dynamically in your code behind. I think the FirstChild.OuterXml selection is correct, but you may need to experiment. I'm not in a place wh...
245,420
<p>Here's the situation - I've got a shell that loads an external .swf. Now, that .swf is 800x600, but it's an animation piece, and there are elements that extends off the stage. When I load the .swf into the shell and call its width attribute, it returns 1200 - because it's including the elements that break out of the...
[ { "answer_id": 247078, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": true, "text": "<p>The width and height of the loaded SWF as defined by the FLA it was created with can be found in the <code>Loader</code> obj...
2008/10/29
[ "https://Stackoverflow.com/questions/245420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14026/" ]
Here's the situation - I've got a shell that loads an external .swf. Now, that .swf is 800x600, but it's an animation piece, and there are elements that extends off the stage. When I load the .swf into the shell and call its width attribute, it returns 1200 - because it's including the elements that break out of the st...
The width and height of the loaded SWF as defined by the FLA it was created with can be found in the `Loader` object in which you've loaded the SWF into. ``` swfLoader.contentLoaderInfo.width swfLoader.contentLoaderInfo.height ``` This will always show you the dimensions as defined in the FLA properties. It makes no...
245,441
<p>I want to add complex databinding to my custom winforms control, so I can do the following:</p> <pre><code>myControl.DisplayMember = "Name"; myControl.ValueMember = "Name"; myControl.DataSource = new List&lt;someObject&gt;(); </code></pre> <p>Does anyone know what interfaces, etc. have to be implemented to achieve...
[ { "answer_id": 23501663, "author": "2ndstep", "author_id": 3609356, "author_profile": "https://Stackoverflow.com/users/3609356", "pm_score": 0, "selected": false, "text": "<p>Your class needs to inherit the DataBoundControl class instead of UserControl.</p>\n" }, { "answer_id": 5...
2008/10/29
[ "https://Stackoverflow.com/questions/245441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1736/" ]
I want to add complex databinding to my custom winforms control, so I can do the following: ``` myControl.DisplayMember = "Name"; myControl.ValueMember = "Name"; myControl.DataSource = new List<someObject>(); ``` Does anyone know what interfaces, etc. have to be implemented to achieve this? I have had a look into i...
Apply one of the following attributes to your custom control, depending on which kind of data binding you need: * For complex data binding: [`ComplexBindingPropertiesAttribute`](https://learn.microsoft.com/dotnet/api/system.componentmodel.complexbindingpropertiesattribute "Documentation") * For lookup data binding: [`...
245,447
<p>Using Python I want to be able to draw text at different angles using PIL.</p> <p>For example, imagine you were drawing the number around the face of a clock. The number <strong>3</strong> would appear as expected whereas <strong>12</strong> would we drawn rotated counter-clockwise 90 degrees.</p> <p>Therefore, I...
[ { "answer_id": 245837, "author": "user12861", "author_id": 12861, "author_profile": "https://Stackoverflow.com/users/12861", "pm_score": 2, "selected": false, "text": "<p>I'm not saying this is going to be easy, or that this solution will necessarily be perfect for you, but look at the d...
2008/10/29
[ "https://Stackoverflow.com/questions/245447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20498/" ]
Using Python I want to be able to draw text at different angles using PIL. For example, imagine you were drawing the number around the face of a clock. The number **3** would appear as expected whereas **12** would we drawn rotated counter-clockwise 90 degrees. Therefore, I need to be able to draw many different stri...
Draw text into a temporary blank image, rotate that, then paste that onto the original image. You could wrap up the steps in a function. Good luck figuring out the exact coordinates to use - my cold-fogged brain isn't up to it right now. This demo writes yellow text on a slant over an image: ``` # Demo to add rotate...
245,453
<p>I'm pretty new to the idea of recursion and this is actually my first attempt at writing a recursive method. </p> <p>I tried to implement a recursive function Max that passes an array, along with a variable that holds the array's size in order to print the largest element. </p> <p>It works, but it just doesn't <em...
[ { "answer_id": 245463, "author": "XPav", "author_id": 27550, "author_profile": "https://Stackoverflow.com/users/27550", "pm_score": 2, "selected": false, "text": "<p>A \"max\" function is the wrong type of thing to write a recursive function for -- and the fact you're using static values...
2008/10/29
[ "https://Stackoverflow.com/questions/245453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14013/" ]
I'm pretty new to the idea of recursion and this is actually my first attempt at writing a recursive method. I tried to implement a recursive function Max that passes an array, along with a variable that holds the array's size in order to print the largest element. It works, but it just doesn't *feel* right! I hav...
Your use of static variables for holding state outside the function will be a source of difficulty. An example of a recursive implementation of a max() function in pseudocode might be: ``` function Max(data, size) { assert(size > 0) if (size == 1) { return data[0] } maxtail = Max(data[1..size]...
245,456
<p>I'm looking for a way to get the name of the main HTML form so I can submit it from JavaScript.</p> <p>The reason I can just set the name of the form is because the JavaScript is on a User Control that could get added to many different sites with different form names.</p> <p>Thanks.</p>
[ { "answer_id": 245489, "author": "Mohamed Faramawi", "author_id": 20006, "author_profile": "https://Stackoverflow.com/users/20006", "pm_score": 2, "selected": false, "text": "<p>I'm not sure , try \"YourUserControl.Page.Form\"</p>\n\n<p>But why do you need the form name, are you going to...
2008/10/29
[ "https://Stackoverflow.com/questions/245456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10420/" ]
I'm looking for a way to get the name of the main HTML form so I can submit it from JavaScript. The reason I can just set the name of the form is because the JavaScript is on a User Control that could get added to many different sites with different form names. Thanks.
I'm not totally sure that this will address what you're asking for, so please comment on it: In your script, when the User Control renders, you could have this placed in there. So long as script doesn't have a "runat" attribute, you should be good. ``` <script type="text/javascript"> var formname = '<%=this.Page.For...
245,465
<p>How do you connect to a remote server via IP address in the manner that TOAD, SqlDeveloper, are able to connect to databases with just the ip address, username, SID and password?</p> <p>Whenever I try to specify and IP address, it seems to be taking it locally.</p> <p>In other words, how should the string for cx_O...
[ { "answer_id": 1181699, "author": "Jeffrey Kemp", "author_id": 103295, "author_profile": "https://Stackoverflow.com/users/103295", "pm_score": 5, "selected": false, "text": "<p>You can specify the server in the connection string, e.g.:</p>\n\n<pre><code>import cx_Oracle\nconnstr = 'scott...
2008/10/29
[ "https://Stackoverflow.com/questions/245465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do you connect to a remote server via IP address in the manner that TOAD, SqlDeveloper, are able to connect to databases with just the ip address, username, SID and password? Whenever I try to specify and IP address, it seems to be taking it locally. In other words, how should the string for cx\_Oracle.connect() ...
I like to do it this way: ``` ip = '192.168.0.1' port = 1521 SID = 'YOURSIDHERE' dsn_tns = cx_Oracle.makedsn(ip, port, SID) db = cx_Oracle.connect('username', 'password', dsn_tns) ``` One of the main reasons I like this method is that I usually have a TNSNAMES.ORA file lying around someplace, and I can check that t...
245,475
<p>Having a vector containing pointers to objects then using the clear function doesn't call the destructors for the objects in the vector. I made a function to do this manually but I don't know how to make this a generic function for any kind of objects that might be in the vector.</p> <pre><code>void buttonVectorCle...
[ { "answer_id": 245483, "author": "KeithB", "author_id": 2298, "author_profile": "https://Stackoverflow.com/users/2298", "pm_score": 4, "selected": true, "text": "<p>The best thing to do is use smart pointers, such as from <a href=\"http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/smar...
2008/10/29
[ "https://Stackoverflow.com/questions/245475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/370/" ]
Having a vector containing pointers to objects then using the clear function doesn't call the destructors for the objects in the vector. I made a function to do this manually but I don't know how to make this a generic function for any kind of objects that might be in the vector. ``` void buttonVectorCleanup(vector<Bu...
The best thing to do is use smart pointers, such as from [Boost](http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/smart_ptr.htm). Then the objects will be deleted automatically. Or you can make a template function ``` template <class T> void vectorCleanup(vector<T *>& dVector){ T* tmpClass; for(vector<T*>:...
245,482
<p>I have form area in my view. If I click button <kbd>A</kbd>, I want to submit to <code>/Books/1</code> and if I click button <kbd>B</kbd>, I want to submit to <code>/Books/2</code></p> <p>How do I achieve this with MVC?</p>
[ { "answer_id": 245501, "author": "Codewerks", "author_id": 17729, "author_profile": "https://Stackoverflow.com/users/17729", "pm_score": 1, "selected": false, "text": "<p>MVC Views can have multiple forms on a 'page', so just create separate sections and give each one their own form act...
2008/10/29
[ "https://Stackoverflow.com/questions/245482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5463/" ]
I have form area in my view. If I click button `A`, I want to submit to `/Books/1` and if I click button `B`, I want to submit to `/Books/2` How do I achieve this with MVC?
It sounds like what you want to do is call the Books Controller, with, say, the Search action. So for instance you might want to call /Books/Search/<search expression>/1, or /Books/Search/<search expression>/2, etc. (There's a few different ways you could be formatting these URLs, but it's mostly a matter of personal p...
245,509
<p>What's the best algorithm for comparing two arrays to see if they have the same members?</p> <p>Assume there are no duplicates, the members can be in any order, and that neither is sorted.</p> <pre><code>compare( [a, b, c, d], [b, a, d, c] ) ==&gt; true compare( [a, b, e], [a, b, c] ) ==&gt; false...
[ { "answer_id": 245510, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": -1, "selected": false, "text": "<p>The best I can think of is O(n^2), I guess.</p>\n\n<pre><code>function compare($foo, $bar) {\n if (count($foo) != count...
2008/10/29
[ "https://Stackoverflow.com/questions/245509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
What's the best algorithm for comparing two arrays to see if they have the same members? Assume there are no duplicates, the members can be in any order, and that neither is sorted. ``` compare( [a, b, c, d], [b, a, d, c] ) ==> true compare( [a, b, e], [a, b, c] ) ==> false compare( [a, b, c], ...
Obvious answers would be: 1. Sort both lists, then check each element to see if they're identical 2. Add the items from one array to a hashtable, then iterate through the other array, checking that each item is in the hash 3. nickf's iterative search algorithm Which one you'd use would depend on whether you can sort ...
245,532
<p>I have a web application that has many faces and so far I've implemented this through creating themes. A theme is a set of html, css and images to be used with the common back end.</p> <p>Things are laid out like so:</p> <pre><code>code/ themes/theme1 themes/theme2 </code></pre> <p>And each instance of the web a...
[ { "answer_id": 245622, "author": "Hapkido", "author_id": 27646, "author_profile": "https://Stackoverflow.com/users/27646", "pm_score": 1, "selected": false, "text": "<p>I don't have a specific recommendation. However, I strongly suggest to <strong>NOT</strong> take shortcut... Use the ...
2008/10/29
[ "https://Stackoverflow.com/questions/245532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a web application that has many faces and so far I've implemented this through creating themes. A theme is a set of html, css and images to be used with the common back end. Things are laid out like so: ``` code/ themes/theme1 themes/theme2 ``` And each instance of the web application has a configuration fil...
I don't have a specific recommendation. However, I strongly suggest to **NOT** take shortcut... Use the solution that will you will find comfortable to add a third theme or to change something next year. Duplication is the enemy of maintainability.
245,557
<p>Let's say I have two arrays:</p> <blockquote> <p>int ArrayA[] = {5, 17, 150, 230, 285};</p> <p>int ArrayB[] = {7, 11, 57, 110, 230, 250};</p> </blockquote> <p>Both arrays are sorted and can be any size. I am looking for an efficient algorithm to find if the arrays contain any duplicated elements between them. I just...
[ { "answer_id": 245563, "author": "Andru Luvisi", "author_id": 5922, "author_profile": "https://Stackoverflow.com/users/5922", "pm_score": 6, "selected": true, "text": "<p>Pretend that you are doing a mergesort, but don't send the results anywhere. If you get to the end of either source,...
2008/10/29
[ "https://Stackoverflow.com/questions/245557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3175/" ]
Let's say I have two arrays: > > int ArrayA[] = {5, 17, 150, 230, 285}; > > > int ArrayB[] = {7, 11, 57, 110, 230, 250}; > > > Both arrays are sorted and can be any size. I am looking for an efficient algorithm to find if the arrays contain any duplicated elements between them. I just want a true/false answer, ...
Pretend that you are doing a mergesort, but don't send the results anywhere. If you get to the end of either source, there is no intersection. Each time you compare the next element of each, if they are equal, there is an intersection. For example: ``` counterA = 0; counterB = 0; for(;;) { if(counterA == ArrayA.l...
245,592
<p>In DB2, you can name a column ORDER and write SQL like</p> <pre><code>SELECT ORDER FROM tblWHATEVER ORDER BY ORDER </code></pre> <p>without even needing to put any special characters around the column name. This is causing me pain that I won't get into, but my question is: why do databases allow the use of SQL k...
[ { "answer_id": 245595, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": false, "text": "<p>Many SQL parsers (expecially DB2/z, which I use) are smarter than some of the regular parsers which sometimes separat...
2008/10/29
[ "https://Stackoverflow.com/questions/245592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14606/" ]
In DB2, you can name a column ORDER and write SQL like ``` SELECT ORDER FROM tblWHATEVER ORDER BY ORDER ``` without even needing to put any special characters around the column name. This is causing me pain that I won't get into, but my question is: why do databases allow the use of SQL keywords for object names? Su...
I largely agree with the sentiment that keywords shouldn't be allowed as identifiers. Most modern computing languages have 20 or maybe 30 keywords, in which case imposing a moratorium on their use as identifiers is entirely reasonable. Unfortunately, SQL comes from the old COBOL school of languages ("computing language...
245,600
<p>In an information security lab I'm working on, I've been tasked with executing multiple commands with a single call to "system()" (written in C, running on Fedora). What is the syntax that will allow me to execute more than command through system()? (The idea being you could execute arbitrary commands through a pr...
[ { "answer_id": 245608, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 5, "selected": true, "text": "<p>That depends on the shell being invoked to execute the commands, but in general most shells use <code>;</code> to ...
2008/10/29
[ "https://Stackoverflow.com/questions/245600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28076/" ]
In an information security lab I'm working on, I've been tasked with executing multiple commands with a single call to "system()" (written in C, running on Fedora). What is the syntax that will allow me to execute more than command through system()? (The idea being you could execute arbitrary commands through a program...
That depends on the shell being invoked to execute the commands, but in general most shells use `;` to separate commands so something like this should work: ``` command1; command2; command3 ``` [EDIT] As @dicroce mentioned, you can use `&&` instead of `;` which will stop execution at the first command that returns ...
245,614
<p>Okay still fighting with doing some SqlCacheDependecy in my Asp.net MVC application</p> <p>I got this piece of code from Microsoft to cache LINQtoSQL, basically what it does is it gets the SqlCommand text from the LINQ query and executes that via the System.Data.SqlClient.SqlCommand which SqlDependecy needs...</p> ...
[ { "answer_id": 245637, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 0, "selected": false, "text": "<p>Why can't you just add SqlParameter objects to the Parameters collection of SqlCommand object before adding them t...
2008/10/29
[ "https://Stackoverflow.com/questions/245614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22093/" ]
Okay still fighting with doing some SqlCacheDependecy in my Asp.net MVC application I got this piece of code from Microsoft to cache LINQtoSQL, basically what it does is it gets the SqlCommand text from the LINQ query and executes that via the System.Data.SqlClient.SqlCommand which SqlDependecy needs... However there...
`@something` is a SQL Parameter, which .NET handles by adding to the SqlParameter collection of the SqlCommand object. You can create parameters with any name, Linq to SQL just generates them named `p#`, where `#` represents its position on the collection.
245,624
<p>Are there any 'standard' plugins for detecting the CPU architecture in <strong>scons</strong>? </p> <p>BTW, this question was asked already <a href="https://stackoverflow.com/questions/152016/detecting-cpu-architecture-compile-time">here</a> in a more general form... just wondering if anyone has already taken the t...
[ { "answer_id": 418719, "author": "dsvensson", "author_id": 5962, "author_profile": "https://Stackoverflow.com/users/5962", "pm_score": 2, "selected": false, "text": "<p>Something like this?</p>\n\n<pre><code>env = Environment()\nconf = Configure(env)\nif conf.CheckDeclaration(\"__i386__\...
2008/10/29
[ "https://Stackoverflow.com/questions/245624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14069/" ]
Are there any 'standard' plugins for detecting the CPU architecture in **scons**? BTW, this question was asked already [here](https://stackoverflow.com/questions/152016/detecting-cpu-architecture-compile-time) in a more general form... just wondering if anyone has already taken the time to incorporate this informatio...
Using **i386** is rather compiler dependant, and won't detect non x86 32 bits archs. Assuming the python interpreter used by scons runs on the CPU you are interested in (not always the case - think cross compilation), you can just use python itself. ``` import platform print platform.machine() print platform.architect...
245,628
<pre><code>template &lt;class T&gt; bool BST&lt;T&gt;::search(const T&amp; x, int&amp; len) const { return search(BT&lt;T&gt;::root, x); } template &lt;class T&gt; bool BST&lt;T&gt;::search(struct Node&lt;T&gt;*&amp; root, const T&amp; x) { if (root == NULL) return false; else { if (ro...
[ { "answer_id": 245636, "author": "oz10", "author_id": 14069, "author_profile": "https://Stackoverflow.com/users/14069", "pm_score": 3, "selected": true, "text": "<p>Okay, <code>bool BST&lt;T&gt;::search(struct Node&lt;T&gt;*&amp; root, const T&amp; x)</code> should probably have const af...
2008/10/29
[ "https://Stackoverflow.com/questions/245628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28392/" ]
``` template <class T> bool BST<T>::search(const T& x, int& len) const { return search(BT<T>::root, x); } template <class T> bool BST<T>::search(struct Node<T>*& root, const T& x) { if (root == NULL) return false; else { if (root->data == x) return true; else if(ro...
Okay, `bool BST<T>::search(struct Node<T>*& root, const T& x)` should probably have const after it like so: `bool BST<T>::search(struct Node<T>*& root, const T& x) const`. Basically, you've called a non-const function from a const function and this is a no-no. BTW, this looks suspect to me "`struct Node<T>*&`"... I'd ...
245,654
<p>My database consists of 3 tables (one for storing all items, one for the tags, and one for the relation between the two):</p> <p>Table: Post Columns: PostID, Name, Desc</p> <p>Table: Tag Columns: TagID, Name</p> <p>Table: PostTag Columns: PostID, TagID</p> <p>What is the best way to save a space separated string...
[ { "answer_id": 245757, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 1, "selected": false, "text": "<p>If you have a Tag Table, wouldn't you have a row for each Tag?</p>\n\n<pre><code>tag.id = 1; tag.name = 'smart'\ntag.i...
2008/10/29
[ "https://Stackoverflow.com/questions/245654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27163/" ]
My database consists of 3 tables (one for storing all items, one for the tags, and one for the relation between the two): Table: Post Columns: PostID, Name, Desc Table: Tag Columns: TagID, Name Table: PostTag Columns: PostID, TagID What is the best way to save a space separated string (e.g. "smart funny wonderful")...
Roughly, something like this: ``` class Post { static hasMany [tags:Tag] } class Tag { static belongsTo = Post static hasMany [posts:Post] } class someService { def createPostWithTags(name, desc, tags) { def post = new Post(name: name, desc: desc).save() tags.split(' ').each { ...
245,666
<p>When I'm using an If statement and I want to check if a boolean is false should I use the "Not" keyword or just = false, like so</p> <pre><code>If (Not myboolean) then </code></pre> <p>vs</p> <pre><code>If (myboolean = False) then </code></pre> <p>Which is better practice and more readable?</p>
[ { "answer_id": 245673, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 3, "selected": false, "text": "<p>Since there's no functional difference between either style, this is one of those things that just comes down to personal p...
2008/10/29
[ "https://Stackoverflow.com/questions/245666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
When I'm using an If statement and I want to check if a boolean is false should I use the "Not" keyword or just = false, like so ``` If (Not myboolean) then ``` vs ``` If (myboolean = False) then ``` Which is better practice and more readable?
Definitely, use "Not". And for the alternately, use "If (myboolean)" instead of "If (myboolean = true)" The works best if you give the boolean a readable name: ``` if (node.HasChildren) ```
245,677
<p>Many examples of macros seem to be about hiding lambdas, e.g. with-open-file in CL. I'm looking for some more exotic uses of macros, particularly in PLT Scheme. I'd like to get a feel for when to consider using a macro vs. using functions.</p>
[ { "answer_id": 246065, "author": "pupeno", "author_id": 6068, "author_profile": "https://Stackoverflow.com/users/6068", "pm_score": 3, "selected": false, "text": "<p>I'll start answering the last question. When to use a macro instead of a function. The macros do things the functions can'...
2008/10/29
[ "https://Stackoverflow.com/questions/245677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28604/" ]
Many examples of macros seem to be about hiding lambdas, e.g. with-open-file in CL. I'm looking for some more exotic uses of macros, particularly in PLT Scheme. I'd like to get a feel for when to consider using a macro vs. using functions.
I only use Scheme macros (`define-syntax`) for tiny things like better lambda syntax: ``` (define-syntax [: x] (syntax-case x () ([src-: e es ...] (syntax-case (datum->syntax-object #'src-: '_) () (_ #'(lambda (_) (e es ...))))))) ``` Which lets you write ``` [: / _ 2] ; <-- much better than (lam...
245,698
<p>This is similar to <a href="https://stackoverflow.com/questions/105212/linux-recursively-list-all-files-in-a-directory-including-files-in-symlink-dire">this question</a>, but I want to include the path relative to the current directory in unix. If I do the following:</p> <pre><code>ls -LR | grep .txt </code></pre> ...
[ { "answer_id": 245710, "author": "Jonathan Adelson", "author_id": 8092, "author_profile": "https://Stackoverflow.com/users/8092", "pm_score": 5, "selected": false, "text": "<p>Try <code>find</code>. You can look it up exactly in the man page, but it's sorta like this:</p>\n\n<p><code>fin...
2008/10/29
[ "https://Stackoverflow.com/questions/245698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
This is similar to [this question](https://stackoverflow.com/questions/105212/linux-recursively-list-all-files-in-a-directory-including-files-in-symlink-dire), but I want to include the path relative to the current directory in unix. If I do the following: ``` ls -LR | grep .txt ``` It doesn't include the full paths...
Use find: ``` find . -name \*.txt -print ``` On systems that use GNU find, like most GNU/Linux distributions, you can leave out the -print.
245,705
<p>I'm trying to decide what to put in a dialog box that tells the user their login doesn't work, there is probably a duplicate. The system uses email addresses as user names, then requires a password.</p> <p>Right now, I'm using "Email Login" but that just sounds stupid.</p> <p>For instance:</p> <p>1) Application ...
[ { "answer_id": 245713, "author": "Martin Beckett", "author_id": 10897, "author_profile": "https://Stackoverflow.com/users/10897", "pm_score": 4, "selected": true, "text": "<p>Tell them explicitly that their email address is already in use.</p>\n\n<p>Call it an email address, thats what t...
2008/10/29
[ "https://Stackoverflow.com/questions/245705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22917/" ]
I'm trying to decide what to put in a dialog box that tells the user their login doesn't work, there is probably a duplicate. The system uses email addresses as user names, then requires a password. Right now, I'm using "Email Login" but that just sounds stupid. For instance: 1) Application Starts, recognizes that i...
Tell them explicitly that their email address is already in use. Call it an email address, thats what the user thinks of it as. The fact that you are using it as an id or a database primary key or a hash key is irrelevant to them.
245,727
<p>I have one website on my server, and my IIS Worker Process is using 4GB RAM consistently. What should I be checking?</p> <pre><code>c:\windows\system32\inetsrv\w3wp.exe </code></pre>
[ { "answer_id": 245731, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "https://Stackoverflow.com/users/4337", "pm_score": 3, "selected": false, "text": "<p>check the section on troubleshooting memory bottlenecks in <a href=\"http://msdn.microsoft.com/en-us/library/ms99858...
2008/10/29
[ "https://Stackoverflow.com/questions/245727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16794/" ]
I have one website on my server, and my IIS Worker Process is using 4GB RAM consistently. What should I be checking? ``` c:\windows\system32\inetsrv\w3wp.exe ```
I would check the CLR Tuning Section in the [document](http://msdn.microsoft.com/en-us/library/ms998583.aspx#scalenetchapt17_topic9) Gulzar mentioned. As the other posters pointed out, any object that implements `IDispose` should have `Dispose()` called on it when it's finished with, preferably using the `using` const...
245,735
<p>By which I mean this:</p> <p>Given the input set of numbers: </p> <p>1,2,3,4,5 becomes "1-5".</p> <p>1,2,3,5,7,9,10,11,12,14 becomes "1-3, 5, 7, 9-12, 14"</p> <p>This is the best I managed to come up with: [C#]</p> <p><em>Which feels a little sloppy to me, so the question is, is there somehow more readable and/...
[ { "answer_id": 245743, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://Stackoverflow.com/users/29157", "pm_score": 1, "selected": false, "text": "<p>Looks clear and straightforward to me. You can simplify a bit if you either assume the input array is sorted, or sor...
2008/10/29
[ "https://Stackoverflow.com/questions/245735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15409/" ]
By which I mean this: Given the input set of numbers: 1,2,3,4,5 becomes "1-5". 1,2,3,5,7,9,10,11,12,14 becomes "1-3, 5, 7, 9-12, 14" This is the best I managed to come up with: [C#] *Which feels a little sloppy to me, so the question is, is there somehow more readable and/or elegant solution to this?* ``` public...
I've rewritten your code like this: ``` public static string[] FormatInts(int[] ints) { Array.Sort<int>(ints); List<string> values = new List<string>(); for (int i = 0; i < ints.Length; i++) { int groupStart = ints[i]; int groupEnd = groupStart; ...
245,740
<p>For example, when I'm dividing two ints and want a float returned, I superstitiously write something like this:</p> <pre><code>int a = 2, b = 3; float c = (float)a / (float)b; </code></pre> <p>If I do not cast <code>a</code> and <code>b</code> to floats, it'll do integer division and return an int.</p> <p>Similar...
[ { "answer_id": 245746, "author": "wilhelmtell", "author_id": 456, "author_profile": "https://Stackoverflow.com/users/456", "pm_score": 2, "selected": false, "text": "<p>Division of integers: cast any one of the operands, no need to cast them both. If both operands are integers the divi...
2008/10/29
[ "https://Stackoverflow.com/questions/245740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813/" ]
For example, when I'm dividing two ints and want a float returned, I superstitiously write something like this: ``` int a = 2, b = 3; float c = (float)a / (float)b; ``` If I do not cast `a` and `b` to floats, it'll do integer division and return an int. Similarly, if I want to multiply a signed 8-bit number with an...
### Question 1: Float division ``` int a = 2, b = 3; float c = static_cast<float>(a) / b; // need to convert 1 operand to a float ``` ### Question 2: How the compiler works Five rules of thumb to remember: * Arithmetic operations are always performed on values of the same type. * The result type is the same as th...
245,742
<p>In this thread, we look at examples of good uses of <code>goto</code> in C or C++. It's inspired by <a href="https://stackoverflow.com/questions/244445/best-refactoring-for-the-dreaded-while-true-loop#244644">an answer</a> which people voted up because they thought I was joking.</p> <p>Summary (label changed from ...
[ { "answer_id": 245745, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 3, "selected": false, "text": "<p>Here is an example of a good goto:</p>\n\n<pre><code>// No Code\n</code></pre>\n" }, { "answer_id": 245749, "...
2008/10/29
[ "https://Stackoverflow.com/questions/245742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18167/" ]
In this thread, we look at examples of good uses of `goto` in C or C++. It's inspired by [an answer](https://stackoverflow.com/questions/244445/best-refactoring-for-the-dreaded-while-true-loop#244644) which people voted up because they thought I was joking. Summary (label changed from original to make intent even clea...
Heres one trick I've heard of people using. I've never seen it in the wild though. And it only applies to C because C++ has RAII to do this more idiomatically. ``` void foo() { if (!doA()) goto exit; if (!doB()) goto cleanupA; if (!doC()) goto cleanupB; /* everything has succe...
245,747
<p>In SQL Server given a Table/View how can you generate a definition of the Table/View in the form:</p> <blockquote> <p>C1 int,<br> C2 varchar(20),<br> C3 double</p> </blockquote> <p>The information required to do it is contained in the meta-tables of SQL Server but is there a standard script / IDE faciltity t...
[ { "answer_id": 245935, "author": "Ady", "author_id": 31395, "author_profile": "https://Stackoverflow.com/users/31395", "pm_score": 0, "selected": false, "text": "<p>If you want to duplpicate a table definition you could use:</p>\n\n<pre><code>select top 0\n *\ninto\n newtable\nfrom\n ...
2008/10/29
[ "https://Stackoverflow.com/questions/245747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In SQL Server given a Table/View how can you generate a definition of the Table/View in the form: > > C1 int, > > C2 varchar(20), > > C3 double > > > The information required to do it is contained in the meta-tables of SQL Server but is there a standard script / IDE faciltity to output the data contained ...
Here is an example of listing the names and types of columns in a table: ``` select COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'YOUR_TABLE_NAME_HERE' ord...
245,765
<p>For example, using the answer for this question: </p> <p><a href="https://stackoverflow.com/questions/152024/how-to-select-all-users-who-made-more-than-10-submissions">How to select all users who made more than 10 submissions</a> "How to select all users who made more than 10 submissions."</p> <pre><code>select us...
[ { "answer_id": 245769, "author": "Dave Neeley", "author_id": 9660, "author_profile": "https://Stackoverflow.com/users/9660", "pm_score": 2, "selected": false, "text": "<p>In SQL Server you could do</p>\n\n<pre><code>select @@ROWCOUNT \n</code></pre>\n\n<p>immediately following the query ...
2008/10/29
[ "https://Stackoverflow.com/questions/245765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10352/" ]
For example, using the answer for this question: [How to select all users who made more than 10 submissions](https://stackoverflow.com/questions/152024/how-to-select-all-users-who-made-more-than-10-submissions) "How to select all users who made more than 10 submissions." ``` select userId from submission group by...
Slight error in previously posted example, need an alias for a table name for the subquery: ``` select count(*) from (select userId from submission group by userId having count(submissionGuid) > 10) t ``` I'm not sure about scalability, but this is the solution. If this isn't scaling well enough for you...
245,766
<p>In a fictitious web application ...</p> <ol> <li>The user clicks a link </li> <li>The server starts to prepare the response, but it takes several seconds</li> <li>The user cancels the page load</li> </ol> <p>What happens to the request? Does the server continue to prepare the response? Does the response arrive t...
[ { "answer_id": 245782, "author": "dreamlax", "author_id": 10320, "author_profile": "https://Stackoverflow.com/users/10320", "pm_score": 0, "selected": false, "text": "<p>I would think that the actual TCP connection is closed by the browser and therefore the web-server will be unable to s...
2008/10/29
[ "https://Stackoverflow.com/questions/245766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14755/" ]
In a fictitious web application ... 1. The user clicks a link 2. The server starts to prepare the response, but it takes several seconds 3. The user cancels the page load What happens to the request? Does the server continue to prepare the response? Does the response arrive to the browser?
The server will continue to prepare the response. When it tries to send the response to the client, it'll fail. When this actually happens will probably depend on the actual application server implementation, whether the response is buffered etc. In Java EE app servers (Tomcat and WebLogic, probably others as well), y...
245,787
<p>Whenever I run any jython program in Eclipse, I got the following error in the beginning of the output: </p> <blockquote> <p>" Failed to get environment, environ will be empty: (0, 'Failed to execute command ([\'sh\', \'-c\', \'env\']): java.io.IOException: Cannot run program "sh": Crea teProcess error=...
[ { "answer_id": 245871, "author": "user12861", "author_id": 12861, "author_profile": "https://Stackoverflow.com/users/12861", "pm_score": 2, "selected": false, "text": "<p>Interesting. Well, I seem to have found the relevant code here:\n<a href=\"http://www.koders.com/python/fid4B7C33153...
2008/10/29
[ "https://Stackoverflow.com/questions/245787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32267/" ]
Whenever I run any jython program in Eclipse, I got the following error in the beginning of the output: > > " Failed to > get environment, environ will be > empty: (0, 'Failed to execute command > ([\'sh\', \'-c\', \'env\']): > java.io.IOException: Cannot run > program "sh": Crea teProcess error=2, > The syste...
Try to uncomment and change the os setting in the 'registry' file (it is in the same directory as your jython.jar / i hope) ``` # python.os determines operating-specific features, similar to and overriding the # Java property "os.name". # Some generic values are also supported: 'nt', 'ce' and 'posix'. # Uncomment th...
245,792
<p>This is rather the inverse of <a href="https://stackoverflow.com/questions/102535/what-can-you-use-python-generator-functions-for">What can you use Python generator functions for?</a>: python generators, generator expressions, and the <code>itertools</code> module are some of my favorite features of python these day...
[ { "answer_id": 245797, "author": "Steven Huwig", "author_id": 28604, "author_profile": "https://Stackoverflow.com/users/28604", "pm_score": 4, "selected": false, "text": "<p>You should never favor <a href=\"http://docs.python.org/2/library/functions.html#zip\" rel=\"nofollow noreferrer\"...
2008/10/29
[ "https://Stackoverflow.com/questions/245792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18950/" ]
This is rather the inverse of [What can you use Python generator functions for?](https://stackoverflow.com/questions/102535/what-can-you-use-python-generator-functions-for): python generators, generator expressions, and the `itertools` module are some of my favorite features of python these days. They're especially use...
**Use a list instead of a generator when:** 1) You need to access the data **multiple** times (i.e. cache the results instead of recomputing them): ``` for i in outer: # used once, okay to be a generator or return a list for j in inner: # used multiple times, reusing a list is better ... ...
245,798
<p>I use screen to persist my work session and connect to the same session from multiple machines. How can I setup SSH and screen such that the XDISPLAY variable <em>inside</em> my persistent screen session is always set to the machine I am currently connecting from?</p> <p>ie. I start the screen session at work and u...
[ { "answer_id": 246046, "author": "David Schmitt", "author_id": 4918, "author_profile": "https://Stackoverflow.com/users/4918", "pm_score": 2, "selected": false, "text": "<p>There is no \"trivial\" way to change environment variables in foreign processes.</p>\n\n<p>A straightforward solut...
2008/10/29
[ "https://Stackoverflow.com/questions/245798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26715/" ]
I use screen to persist my work session and connect to the same session from multiple machines. How can I setup SSH and screen such that the XDISPLAY variable *inside* my persistent screen session is always set to the machine I am currently connecting from? ie. I start the screen session at work and use gvim, which us...
The following is a manual solution, but there's no reason you couldn't use an alias or a script to have it done automagically when you remotely log in. Assuming that your local shell sets the DISPLAY variable appropriately, you could use `screen -X` to send the following commads to your remote screen before connecting...
245,802
<p>I am using fscanf to read a file which has lines like<br> Number &lt;-whitespace-> string &lt;-whitespace-> optional_3rd_column </p> <p>I wish to extract the number and string out of each column, but ignore the 3rd_column if it exists</p> <p>Example Data:<br> 12 foo something<br> 03 bar<br> 24 something #rand...
[ { "answer_id": 245806, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 2, "selected": false, "text": "<p>Use fgets() to read a line at a time and then use sscanf() to look for the two columns you are interested in, mor...
2008/10/29
[ "https://Stackoverflow.com/questions/245802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25990/" ]
I am using fscanf to read a file which has lines like Number <-whitespace-> string <-whitespace-> optional\_3rd\_column I wish to extract the number and string out of each column, but ignore the 3rd\_column if it exists Example Data: 12 foo something 03 bar 24 something #randomcomment I would want to ex...
It would appear to me that the simplest solution is to scanf("%d %s", &num, &word) and then fgets() to eat the rest of the line.
245,803
<p>I have recently discovered the incredibly useful <a href="http://www.eclipse.org/mat/" rel="nofollow noreferrer">Eclipse Memory Analysis Tool</a>, which makes quick work of finding memory leaks in Java applications. Unfortunately, after switching my JDK to 1.6 (under Mac OS 10.5), the JVM terminates immediately upo...
[ { "answer_id": 246197, "author": "Guðmundur Bjarni", "author_id": 27349, "author_profile": "https://Stackoverflow.com/users/27349", "pm_score": 1, "selected": false, "text": "<p>The official Java 6 for the Mac only has a 64 bit data model. Unfortunately, Eclipse uses Carbon on the Mac wh...
2008/10/29
[ "https://Stackoverflow.com/questions/245803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9931/" ]
I have recently discovered the incredibly useful [Eclipse Memory Analysis Tool](http://www.eclipse.org/mat/), which makes quick work of finding memory leaks in Java applications. Unfortunately, after switching my JDK to 1.6 (under Mac OS 10.5), the JVM terminates immediately upon startup. All that appears is a dialog s...
To configure Eclipse to use another VM use this command line: ``` eclipse -vm <path to java> ``` You can also specify the path in Eclipse.app/Contents/Info.plist. There is a section like this: ``` <!-- to use a specific Java version (instead of the platform's default) uncomment one of the following options: <st...
245,827
<p>I have a legacy app where it reads message from a client program from file descriptor 3. This is an external app so I cannot change this. The client is written in C#. How can we open a connection to a specific file descriptor in C#? Can we use something like AnonymousPipeClientStream()? But how do we specify the fil...
[ { "answer_id": 493768, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 3, "selected": false, "text": "<p>Unfortunately, you won't be able to do that without P/Invoking to the native Windows API first.</p>\n\n<p>First, yo...
2008/10/29
[ "https://Stackoverflow.com/questions/245827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a legacy app where it reads message from a client program from file descriptor 3. This is an external app so I cannot change this. The client is written in C#. How can we open a connection to a specific file descriptor in C#? Can we use something like AnonymousPipeClientStream()? But how do we specify the file d...
Unfortunately, you won't be able to do that without P/Invoking to the native Windows API first. First, you will need to open your file descriptor with a native P/Invoke call. This is done by the OpenFileById WINAPI function. [Here's how to use it](http://msdn.microsoft.com/en-us/library/aa365432(VS.85).aspx) on MSDN, ...
245,834
<p>I usually hate posting these types of questions as normally I find that the best way to really learn is to figure out the answer yourself. </p> <p>However, I need an answer to this question really quickly as I have a client who can't run her business due to this problem.</p> <p>Yesterday my ASP.NET host provider m...
[ { "answer_id": 245843, "author": "Maxam", "author_id": 15310, "author_profile": "https://Stackoverflow.com/users/15310", "pm_score": 1, "selected": false, "text": "<p>Is your web application calling a web service or accessing external web sites? If so, you might need to talk with your ho...
2008/10/29
[ "https://Stackoverflow.com/questions/245834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26300/" ]
I usually hate posting these types of questions as normally I find that the best way to really learn is to figure out the answer yourself. However, I need an answer to this question really quickly as I have a client who can't run her business due to this problem. Yesterday my ASP.NET host provider moved my applicati...
Not sure if this will help, but I once had a client with the same type of problem. Their webhosting company made some changes, resulting in their website throwing similar kinds of errors. Managed to get things working again by adding the following just inside the System.Web section in web.config: ``` <trust level="Ful...
245,835
<p>I have a site behind basic authentication (IIS6).</p> <p>Part of this site calls a web service that is also part of the site and thus behind basic authentication as well.</p> <p>However, when this happens the calling code receives a 401 Authentication Error.</p> <p>I've tried a couple of things, with the general ...
[ { "answer_id": 245946, "author": "Ady", "author_id": 31395, "author_profile": "https://Stackoverflow.com/users/31395", "pm_score": 0, "selected": false, "text": "<p>The Line:</p>\n\n<pre><code>s.Credentials = System.Net.CredentialCache.DefaultCredentials();</code></pre>\n\n<p>Maybe you s...
2008/10/29
[ "https://Stackoverflow.com/questions/245835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
I have a site behind basic authentication (IIS6). Part of this site calls a web service that is also part of the site and thus behind basic authentication as well. However, when this happens the calling code receives a 401 Authentication Error. I've tried a couple of things, with the general recommendation being cod...
Solution: (I am almost certain this will help someone) ------------------------------------------------------ **See [this link](http://forums.asp.net/t/1172902.aspx) for the source of this solution in VB (thanks jshardy!), all I did was convert to C#.** **NB:** You must be using ONLY basic authentication on IIS for t...
245,838
<p>Ok so I thought it was fixed, but I'm getting totally inconsistent results. I rewrote it kind of from scratch to start fresh and here are my results. I get no errors, no crashing, it just doesn't remove them. It just totally messes up the tree and gives me a ton more leaves, and mixes everything up. Not sure wher...
[ { "answer_id": 245883, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 0, "selected": false, "text": "<p>You shouldn't be calling <code>remove()</code> recursively in the third case (where your \"not sure if this is ri...
2008/10/29
[ "https://Stackoverflow.com/questions/245838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28392/" ]
Ok so I thought it was fixed, but I'm getting totally inconsistent results. I rewrote it kind of from scratch to start fresh and here are my results. I get no errors, no crashing, it just doesn't remove them. It just totally messes up the tree and gives me a ton more leaves, and mixes everything up. Not sure where else...
Are each T found in the tree unique? It looks like they are from your code... It looks like this should work: In the else case deleting the root node: ``` Node<T> *tmp_r = root->left; Node<T> *parent = root; while (tmp_r->right != NULL) { parent = tmp_r; tmp_r = tmp_r->right; } Node<T> *tmp_l = tmp_r; while ...
245,840
<p>Is there any way of batch renaming files in sub directories?</p> <p>For example:</p> <p>Rename <code>*.html</code> to <code>*.htm</code> in a folder which has directories and sub directories.</p>
[ { "answer_id": 245854, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 3, "selected": false, "text": "<p>In Bash, you could do the following:</p>\n\n<pre><code>for x in $(find . -name \\*.html); do\n mv $x $(echo \"$x...
2008/10/29
[ "https://Stackoverflow.com/questions/245840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12178/" ]
Is there any way of batch renaming files in sub directories? For example: Rename `*.html` to `*.htm` in a folder which has directories and sub directories.
Windows command prompt: (If inside a batch file, change %x to %%x) ``` for /r %x in (*.html) do ren "%x" *.htm ``` This also works for renaming the middle of the files ``` for /r %x in (website*.html) do ren "%x" site*.htm ```
245,866
<p>Given a System.Timers.Timer, is there a way from the main thread to tell if the worker thread running the elapsed event code is still running?</p> <p>In other words, how can one make sure the code running in the worker thread is not currently running before stopping the timer or the main app/service thread the time...
[ { "answer_id": 245926, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 0, "selected": false, "text": "<p>For the out of the box solution, there is no way. The main reason is the thread running the TimerCallback function is...
2008/10/29
[ "https://Stackoverflow.com/questions/245866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91911/" ]
Given a System.Timers.Timer, is there a way from the main thread to tell if the worker thread running the elapsed event code is still running? In other words, how can one make sure the code running in the worker thread is not currently running before stopping the timer or the main app/service thread the timer is runni...
Look up ManualResetEvent, as it is made to do specifically what you're asking for. Your threads create a new reset event, and add it to an accessible queue that your main thread can use to see if any threads are still running. ``` // main thread owns this private List<ManualResetEvent> _resetEvents; ... // main threa...
245,868
<p>I have seen the following methods of putting JavaScript code in an <code>&lt;a&gt;</code> tag:</p> <pre><code>function DoSomething() { ... return false; } </code></pre> <ol> <li><code>&lt;a href="javascript:;" onClick="return DoSomething();"&gt;link&lt;/a&gt;</code></li> <li><code>&lt;a href="javascript:DoSomethin...
[ { "answer_id": 245886, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 3, "selected": false, "text": "<p>Why would you do this when you can use <code>addEventListener</code>/<code>attachEvent</code>? If there is no <c...
2008/10/29
[ "https://Stackoverflow.com/questions/245868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
I have seen the following methods of putting JavaScript code in an `<a>` tag: ``` function DoSomething() { ... return false; } ``` 1. `<a href="javascript:;" onClick="return DoSomething();">link</a>` 2. `<a href="javascript:DoSomething();">link</a>` 3. `<a href="javascript:void(0);" onClick="return DoSomething();">l...
I quite enjoy [Matt Kruse's Javascript Best Practices article](http://web.archive.org/web/20190822202858/http://www.javascripttoolbox.com/bestpractices/). In it, he states that using the `href` section to execute JavaScript code is a bad idea. Even though you have stated that your users must have JavaScript enabled, th...
245,916
<p>What is the best way to extract the MAC address from <code>ifconfig</code>'s output?</p> <p>Sample output:</p> <pre><code>bash-3.00# ifconfig eth0 eth0 Link encap:Ethernet HWaddr 1F:2E:19:10:3B:52 inet addr:127.0.0.66 Bcast:127.255.255.255 Mask:255.0.0.0 UP BROADCAST RUN...
[ { "answer_id": 245923, "author": "albertb", "author_id": 26715, "author_profile": "https://Stackoverflow.com/users/26715", "pm_score": 3, "selected": false, "text": "<p>Not sure whether there really are any advantages, but you can simply use awk:</p>\n\n<pre><code>ifconfig eth0 | awk '/H...
2008/10/29
[ "https://Stackoverflow.com/questions/245916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29405/" ]
What is the best way to extract the MAC address from `ifconfig`'s output? Sample output: ``` bash-3.00# ifconfig eth0 eth0 Link encap:Ethernet HWaddr 1F:2E:19:10:3B:52 inet addr:127.0.0.66 Bcast:127.255.255.255 Mask:255.0.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric...
You can do a cat under `/sys/class/` ``` cat /sys/class/net/*/address ``` Specifically for `eth0` ``` cat /sys/class/net/eth0/address ```
245,929
<p>Some APIs, like the WebClient, use the <a href="http://msdn.microsoft.com/en-us/library/wewwczdw.aspx" rel="nofollow noreferrer">Event-based Async pattern</a>. While this looks simple, and probably works well in a loosely coupled app (say, BackgroundWorker in a UI), it doesn't chain together very well. </p> <p>For ...
[ { "answer_id": 246310, "author": "Tim Robinson", "author_id": 32133, "author_profile": "https://Stackoverflow.com/users/32133", "pm_score": 2, "selected": false, "text": "<p>In the past I've implemented this using an iterator method: every time you want another URL requested, you use \"y...
2008/10/29
[ "https://Stackoverflow.com/questions/245929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27012/" ]
Some APIs, like the WebClient, use the [Event-based Async pattern](http://msdn.microsoft.com/en-us/library/wewwczdw.aspx). While this looks simple, and probably works well in a loosely coupled app (say, BackgroundWorker in a UI), it doesn't chain together very well. For instance, here's a program that's multithreaded...
You might want to look into `F#`. `F#` can automate this coding for you with its «workflow» feature. The '08 PDC presentation of `F#` dealt with asynchronous web requests using a standard library workflow called `async`, which handles the `BeginXXX`/`EndXXX` pattern, but you can write a workflow for the event pattern w...
245,947
<p>I have <code>www.example.com</code> and also <code>store.example.com</code>. (Yes they are subdomains of the same parent domain)</p> <p><code>store.example.com</code> is on ASP.NET 1.1</p> <p><code>www.example.com</code> is on ASP.NET 3.5</p> <p>I want to know what options are available for sharing 'session' data...
[ { "answer_id": 245965, "author": "Eli", "author_id": 27580, "author_profile": "https://Stackoverflow.com/users/27580", "pm_score": -1, "selected": false, "text": "<p>Here is how you would do it in PHP:</p>\n\n<p><a href=\"http://php.dtbaker.com.au/post/keeping_cookies_across_multiple_sub...
2008/10/29
[ "https://Stackoverflow.com/questions/245947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
I have `www.example.com` and also `store.example.com`. (Yes they are subdomains of the same parent domain) `store.example.com` is on ASP.NET 1.1 `www.example.com` is on ASP.NET 3.5 I want to know what options are available for sharing 'session' data between the two sites. I need some kind of shared login and also th...
If you want to share sessions between different apps there are a few things you need to do. First you'll need to run the session state in SQL mode. At this point I found out that the SQL session state takes the machine key and your \_appDomainAppId to generate a key for your app to access it's own session data. So we...
245,957
<pre><code>void f(cli::array&lt;PointF&gt; ^points){ PointF&amp; a = points[0]; // and so on... } </code></pre> <p>Compile error at line 2. </p> <pre><code>.\ndPanel.cpp(52) : error C2440: 'initializing' : cannot convert from 'System::Drawing::PointF' to 'System::Drawing::PointF &amp;' An object from ...
[ { "answer_id": 245981, "author": "Bogdan Maxim", "author_id": 23795, "author_profile": "https://Stackoverflow.com/users/23795", "pm_score": 1, "selected": false, "text": "<p>You need to use the <code>gcroot</code> template from <code>vcclr.h</code> file:</p>\n\n<p>These are samples from ...
2008/10/29
[ "https://Stackoverflow.com/questions/245957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45603/" ]
``` void f(cli::array<PointF> ^points){ PointF& a = points[0]; // and so on... } ``` Compile error at line 2. ``` .\ndPanel.cpp(52) : error C2440: 'initializing' : cannot convert from 'System::Drawing::PointF' to 'System::Drawing::PointF &' An object from the gc heap (element of a managed array) can...
If you just want to declare a reference to the first PointF in the array then you need to use a [tracking reference](http://msdn.microsoft.com/en-us/library/8903062a(VS.80).aspx) (%): ``` void f(cli::array<PointF>^ points) { PointF% a = points[0]; } ```
245,975
<p>To implement "method-missing"-semantics and such in C# 4.0, you have to implement IDynamicObject:</p> <pre><code>public interface IDynamicObject { MetaObject GetMetaObject(Expression parameter); } </code></pre> <p>As far as I can figure out IDynamicObject is actually part of the DLR, so it is not new. But I have...
[ { "answer_id": 246629, "author": "Rasmus Faber", "author_id": 5542, "author_profile": "https://Stackoverflow.com/users/5542", "pm_score": 0, "selected": false, "text": "<p>Here is what I have figured out so far:</p>\n\n<p>The Dynamic Language Runtime is currently maintained as part of th...
2008/10/29
[ "https://Stackoverflow.com/questions/245975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5542/" ]
To implement "method-missing"-semantics and such in C# 4.0, you have to implement IDynamicObject: ``` public interface IDynamicObject { MetaObject GetMetaObject(Expression parameter); } ``` As far as I can figure out IDynamicObject is actually part of the DLR, so it is not new. But I have not been able to find muc...
The short answer is that the MetaObject is what's responsible for actually generating the code that will be run at the call site. The mechanism that it uses for this is LINQ expression trees, which have been enhanced in the DLR. So instead of starting with an object, it starts with an expression that represents the obj...
246,007
<p>When I type <code>uname -a</code>, it gives the following output.</p> <pre><code>Linux mars 2.6.9-67.0.15.ELsmp #1 SMP Tue Apr 22 13:50:33 EDT 2008 i686 i686 i386 GNU/Linux </code></pre> <p>How can I know from this that the given OS is 32 or 64 bit?</p> <p>This is useful when writing <code>configure</code> script...
[ { "answer_id": 246012, "author": "Thomas Watnedal", "author_id": 4059, "author_profile": "https://Stackoverflow.com/users/4059", "pm_score": 7, "selected": false, "text": "<p>If you were running a 64 bit platform you would see x86_64 or something very similar in the output from <a href=\...
2008/10/29
[ "https://Stackoverflow.com/questions/246007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11602/" ]
When I type `uname -a`, it gives the following output. ``` Linux mars 2.6.9-67.0.15.ELsmp #1 SMP Tue Apr 22 13:50:33 EDT 2008 i686 i686 i386 GNU/Linux ``` How can I know from this that the given OS is 32 or 64 bit? This is useful when writing `configure` scripts, for example: what architecture am I building for?
Try [`uname -m`](http://linuxmanpages.net/manpages/fedora16/man1/uname.1.html). Which is short of `uname --machine` and it outputs: ``` x86_64 ==> 64-bit kernel i686 ==> 32-bit kernel ``` --- Otherwise, **not for the Linux kernel, but for the CPU**, you type: ``` cat /proc/cpuinfo ``` or: ``` grep flags /pro...
246,017
<p>I have an oc4j installation bereft of any release notes or version documentation. In the absence of such documents, how do I know for sure, which version of oc4j I am using?</p>
[ { "answer_id": 246034, "author": "Maglob", "author_id": 27520, "author_profile": "https://Stackoverflow.com/users/27520", "pm_score": 4, "selected": true, "text": "<p>Check Server header in HTTP headers. For example with wget or curl; </p>\n\n<pre><code>wget -S &lt;url-to-server&gt;\ncur...
2008/10/29
[ "https://Stackoverflow.com/questions/246017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11602/" ]
I have an oc4j installation bereft of any release notes or version documentation. In the absence of such documents, how do I know for sure, which version of oc4j I am using?
Check Server header in HTTP headers. For example with wget or curl; ``` wget -S <url-to-server> curl -I <url-to-server> ``` or with browser, which can show HTTP headers. There should be a header something like ``` Server: Oracle-Application-Server-10g/10.1.3.1.0 Oracle-HTTP-Server ```
246,038
<p>What is the best way to unit test a method that doesn't return anything? Specifically in c#.</p> <p>What I am really trying to test is a method that takes a log file and parses it for specific strings. The strings are then inserted into a database. Nothing that hasn't been done before but being VERY new to TDD I am...
[ { "answer_id": 246044, "author": "Keith Nicholas", "author_id": 10431, "author_profile": "https://Stackoverflow.com/users/10431", "pm_score": 3, "selected": false, "text": "<p>it will have some effect on an object.... query for the result of the effect. If it has no visible effect its...
2008/10/29
[ "https://Stackoverflow.com/questions/246038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/831/" ]
What is the best way to unit test a method that doesn't return anything? Specifically in c#. What I am really trying to test is a method that takes a log file and parses it for specific strings. The strings are then inserted into a database. Nothing that hasn't been done before but being VERY new to TDD I am wondering...
If a method doesn't return anything, it's either one of the following * **imperative** - You're either asking the object to do something to itself.. e.g change state (without expecting any confirmation.. its assumed that it will be done) * **informational** - just notifying someone that something happened (without exp...
246,058
<p>I got this error when trying to update an image. It was a cross-thread update, but I used .Invoke(), so that shouldn't be the problem, should it.</p>
[ { "answer_id": 246064, "author": "Benjol", "author_id": 11410, "author_profile": "https://Stackoverflow.com/users/11410", "pm_score": 4, "selected": true, "text": "<p><em>(Answering my own question, for others, and for future reference)</em></p>\n\n<p>I <em>think</em> (not yet entirely s...
2008/10/29
[ "https://Stackoverflow.com/questions/246058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11410/" ]
I got this error when trying to update an image. It was a cross-thread update, but I used .Invoke(), so that shouldn't be the problem, should it.
*(Answering my own question, for others, and for future reference)* I *think* (not yet entirely sure) that this is because InvokeRequired will always return false if the control has not yet been loaded/shown. I have done a workaround which seems to work for the moment, which is to simple reference the handle of the as...
246,071
<p>My experience to write a plugin for Firefox is below zero. Is someone out there who could point me to sample code on how to get this accomplished in C++ with VS2005/8? </p> <p>What I need to do with JavaScript in the hosting html page is something like this:</p> <pre><code>var obj = document.getElementById("MyFFPl...
[ { "answer_id": 246083, "author": "RWendi", "author_id": 15152, "author_profile": "https://Stackoverflow.com/users/15152", "pm_score": 3, "selected": true, "text": "<p>The SDK has basic samples on how to write mozzila plugins which can be downloaded here: <a href=\"http://mxr.mozilla.org/...
2008/10/29
[ "https://Stackoverflow.com/questions/246071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1890/" ]
My experience to write a plugin for Firefox is below zero. Is someone out there who could point me to sample code on how to get this accomplished in C++ with VS2005/8? What I need to do with JavaScript in the hosting html page is something like this: ``` var obj = document.getElementById("MyFFPlugin"); var value = ...
The SDK has basic samples on how to write mozzila plugins which can be downloaded here: <http://mxr.mozilla.org/seamonkey/source/modules/plugin/tools/sdk/> Here is the official mozilla plugin site <http://www.mozilla.org/projects/plugins/> Hope it helps.
246,077
<p>For example VK_LEFT, VK_DELETE, VK_ESCAPE, VK_RETURN, etc. How and where are they declared? Are they constants, #defines, or something else? Where do they come from?</p> <p>If possible, please provide a file name/path where they are declared. Or some other info as specific as possible.</p>
[ { "answer_id": 246084, "author": "ChrisN", "author_id": 3853, "author_profile": "https://Stackoverflow.com/users/3853", "pm_score": 3, "selected": true, "text": "<p>These are declared using <code>#define</code> in the file <code>winuser.h</code> in the Platform SDK. In my installation of...
2008/10/29
[ "https://Stackoverflow.com/questions/246077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9403/" ]
For example VK\_LEFT, VK\_DELETE, VK\_ESCAPE, VK\_RETURN, etc. How and where are they declared? Are they constants, #defines, or something else? Where do they come from? If possible, please provide a file name/path where they are declared. Or some other info as specific as possible.
These are declared using `#define` in the file `winuser.h` in the Platform SDK. In my installation of Visual Studio 2008, the full path is ``` C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\WinUser.h ```
246,091
<p>The problem is very simple. An object needs to notify some events that might be of interest to observers.</p> <p>When I sat to validate a design that I cooked up now in Ruby just to validate it.. I find myself stumped as to how to implement the object events. In .Net this would be a one-liner.. .Net also does handl...
[ { "answer_id": 246157, "author": "Farrel", "author_id": 7889, "author_profile": "https://Stackoverflow.com/users/7889", "pm_score": 2, "selected": false, "text": "<p>The <a href=\"http://ruby-doc.org/core/classes/Observable.html\" rel=\"nofollow noreferrer\">Observable module</a>? </p>\n...
2008/10/29
[ "https://Stackoverflow.com/questions/246091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
The problem is very simple. An object needs to notify some events that might be of interest to observers. When I sat to validate a design that I cooked up now in Ruby just to validate it.. I find myself stumped as to how to implement the object events. In .Net this would be a one-liner.. .Net also does handler method ...
Firstly, in Ruby there are no method signatures. The closest would be checking the function's arity. Duck typing requires thinking differently (slightly). The Observable module is a start, but if you have a requirement to have multiple events from a single class it might not be enough. This is a quick sketch. It supp...
246,112
<p>We are using LINQ very widely in our system. Particularly LINQ-to-objects. So in some places we end up having a LINQ query in memory build up from some huge expressions. The problem comes when there's some bug in the expressions. So we get NullReferenceException and the stack trace leads us nowhere (to [Lightweight ...
[ { "answer_id": 246116, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>If you're using LINQ to Objects, I wouldn't expect to see dynamic methods being created. I'd expect them with LINQ to...
2008/10/29
[ "https://Stackoverflow.com/questions/246112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18001/" ]
We are using LINQ very widely in our system. Particularly LINQ-to-objects. So in some places we end up having a LINQ query in memory build up from some huge expressions. The problem comes when there's some bug in the expressions. So we get NullReferenceException and the stack trace leads us nowhere (to [Lightweight Fun...
If you are building your own expressions and compiling them, or using AsQueryable, then yes; the LINQ-generated methods will be a royal pain to debug. You can save some pain by using small fragements of *actual* methods - at least something useful will show in the stack trace... Another consideration is: rather than ...
246,121
<p>I have an Ant script that needs to checkout a directory from Subversion. This works using svnant/svnkit. However, Subversion access is authenticated, and I do not want to store my user password in a file.</p> <p>Can I make svnkit pop up a password dialog? Or even better, make it use the same credential caching tha...
[ { "answer_id": 246378, "author": "Thilo", "author_id": 14955, "author_profile": "https://Stackoverflow.com/users/14955", "pm_score": 2, "selected": false, "text": "<p>To answer my own question, I can use the Ant [input] task to ask the user for a password and store it in a property that ...
2008/10/29
[ "https://Stackoverflow.com/questions/246121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14955/" ]
I have an Ant script that needs to checkout a directory from Subversion. This works using svnant/svnkit. However, Subversion access is authenticated, and I do not want to store my user password in a file. Can I make svnkit pop up a password dialog? Or even better, make it use the same credential caching that subversi...
To answer my own question, I can use the Ant [input] task to ask the user for a password and store it in a property that can be passed to the [svn] task. ``` <target name="checkout"> <input message="Please enter subversion password for ${username}:" addproperty="password" /> <svn svnki...
246,127
<p>Why is <code>volatile</code> needed in C? What is it used for? What will it do?</p>
[ { "answer_id": 246139, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 6, "selected": false, "text": "<p><code>volatile</code> tells the compiler that your variable may be changed by other means, than the code that is accessin...
2008/10/29
[ "https://Stackoverflow.com/questions/246127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Why is `volatile` needed in C? What is it used for? What will it do?
`volatile` tells the compiler not to optimize anything that has to do with the `volatile` variable. There are at least three common reasons to use it, all involving situations where the value of the variable can change without action from the visible code: * When you interface with hardware that changes the value its...
246,130
<p>I'm working on a eclipse plug-in and I've tried to create another test project seperate from the plug-in. The reason I do this is to not let the plug-in depend on jUnit when it is exported. However, I can't access the Eclipse Plug-in API when I do the testing. Whenever I try to add Plug-in dependencies the import li...
[ { "answer_id": 246179, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 0, "selected": false, "text": "<p>You could try to add the plugin nature to your new myplugin.test project.</p>\n\n<p>In your .project file:</p>\n\n<pre><code...
2008/10/29
[ "https://Stackoverflow.com/questions/246130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3713/" ]
I'm working on a eclipse plug-in and I've tried to create another test project seperate from the plug-in. The reason I do this is to not let the plug-in depend on jUnit when it is exported. However, I can't access the Eclipse Plug-in API when I do the testing. Whenever I try to add Plug-in dependencies the import list ...
The recomended way of ding this seems to be with Plug-in fragments: <http://rcpquickstart.com/2007/06/20/unit-testing-plug-ins-with-fragments/> The fragment gets a high-degree of access to your plugin's code and separates the testing logic / dependencies from the plugin itsself. Now if only I could find a way to tes...
246,137
<p>Im a coding a library including textual feedback that I need to translate.</p> <p>I put the following lines in a <code>_config.py</code> module that I import everywhere in my app :</p> <pre><code>import gettext, os, sys pathname = os.path.dirname(sys.argv[0]) localdir = os.path.abspath(pathname) + "/locale" gettex...
[ { "answer_id": 246254, "author": "Thomas Wouters", "author_id": 17624, "author_profile": "https://Stackoverflow.com/users/17624", "pm_score": 2, "selected": false, "text": "<p>You can only gettext.install() once. In general it's useless for library work -- gettext.install() will only do ...
2008/10/29
[ "https://Stackoverflow.com/questions/246137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9951/" ]
Im a coding a library including textual feedback that I need to translate. I put the following lines in a `_config.py` module that I import everywhere in my app : ``` import gettext, os, sys pathname = os.path.dirname(sys.argv[0]) localdir = os.path.abspath(pathname) + "/locale" gettext.install("messages", localdir) ...
You can use the class based gettext api to isolate message catalogs. This is also what is recommended in the [python gettext documentation](http://docs.python.org/library/gettext.html#class-based-api). The drawback is that you, or the other dev, will have to use the gettext method or define the `_()` method in the loc...
246,143
<p>this is my old code</p> <hr> <pre><code> protected override bool OnPreAction(string actionName, System.Reflection.MethodInfo methodInfo) { if ("|Register|RegisterPage|Login|LoginPage|Logout|Service".ToLower().Contains(actionName.ToLower())) { return base.OnPreAction(actionName, m...
[ { "answer_id": 246778, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 5, "selected": true, "text": "<pre><code>string actionName = (string)filterContext.RouteData.Values[\"action\"];\n</code></pre>\n" }, { "answe...
2008/10/29
[ "https://Stackoverflow.com/questions/246143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31966/" ]
this is my old code --- ``` protected override bool OnPreAction(string actionName, System.Reflection.MethodInfo methodInfo) { if ("|Register|RegisterPage|Login|LoginPage|Logout|Service".ToLower().Contains(actionName.ToLower())) { return base.OnPreAction(actionName, methodInfo); ...
``` string actionName = (string)filterContext.RouteData.Values["action"]; ```