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
308,954
<p>I need a method to return a random string in the format:</p> <p>Letter Number Letter Number Letter Number</p>
[ { "answer_id": 308960, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 2, "selected": false, "text": "<p>You just need 2 methods.</p>\n\n<p>1) Random a char (You can use <a href=\"http://asciitable.com/\" rel=\"no...
2008/11/21
[ "https://Stackoverflow.com/questions/308954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
I need a method to return a random string in the format: Letter Number Letter Number Letter Number
Assuming you don't need it to be threadsafe: ``` private static readonly Random rng = new Random(); private static RandomChar(string domain) { int selection = rng.Next(domain.Length); return domain[selection]; } private static char RandomDigit() { return RandomChar("0123456789"); } private static char R...
308,963
<p>What is the proper way to split up SQL statements to send to an Oracle ADO.NET client? For instance, lets say you have the following code in a text file and want to execute these statements:</p> <pre><code>CREATE TABLE foo (bar VARCHAR2(100)); INSERT INTO foo (bar) VALUES('one'); INSERT INTO foo (bar) VALUES('two'...
[ { "answer_id": 309003, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 3, "selected": false, "text": "<p>Without the DDL, you could create an anonymous PL/SQL block by surrounding the statements with BEGIN and END:</p>\...
2008/11/21
[ "https://Stackoverflow.com/questions/308963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16501/" ]
What is the proper way to split up SQL statements to send to an Oracle ADO.NET client? For instance, lets say you have the following code in a text file and want to execute these statements: ``` CREATE TABLE foo (bar VARCHAR2(100)); INSERT INTO foo (bar) VALUES('one'); INSERT INTO foo (bar) VALUES('two'); ``` I beli...
Without the DDL, you could create an anonymous PL/SQL block by surrounding the statements with BEGIN and END: ``` BEGIN INSERT INTO foo (bar) VALUES('one'); INSERT INTO foo (bar) VALUES('two'); END; ``` To perform DDL (like CREATE TABLE) you would need to use dynamic PL/SQL: ``` BEGIN EXECUTE IMMEDIATE 'CREAT...
308,980
<p>I'm installing SVN with Apache 2.2 on windows 2003 everything seems good but when I try to login no username/password works.</p> <p>Here is some info<br /> I load this module in httpd.conf</p> <p><code>LoadModule auth_basic_module modules/mod_auth_basic.so</code><br /> and in <code>svnserv.conf</code> I have</p> <pr...
[ { "answer_id": 308996, "author": "Nik Reiman", "author_id": 14302, "author_profile": "https://Stackoverflow.com/users/14302", "pm_score": 0, "selected": false, "text": "<p>Ok, this isnt't technically an answer to the question you've asked, but you should try installing <a href=\"http://w...
2008/11/21
[ "https://Stackoverflow.com/questions/308980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm installing SVN with Apache 2.2 on windows 2003 everything seems good but when I try to login no username/password works. Here is some info I load this module in httpd.conf `LoadModule auth_basic_module modules/mod_auth_basic.so` and in `svnserv.conf` I have ``` [general] anon-access=read auth-access=write ...
I think the problem might be that you need to generate the password file using [htpasswd](http://httpd.apache.org/docs/1.3/programs/htpasswd.html). Storing unencrypted passwords isn't a good thing!
308,985
<p>I'm coding a simple code editor for a very simple scripting language we use at work. My syntax highlighting code works fine if I do it on the entire <code>RichTextBox</code> (<code>rtbMain</code>) but when I try to get it to work on just that line, so I can run the function with <code>rtbMain</code> changes, it gets...
[ { "answer_id": 310512, "author": "The Digital Ninja", "author_id": 39143, "author_profile": "https://Stackoverflow.com/users/39143", "pm_score": 5, "selected": true, "text": "<p>Ok I figured it out. I was calling the even on rtbMain.TextChange thinking that this would only trigger if the...
2008/11/21
[ "https://Stackoverflow.com/questions/308985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39143/" ]
I'm coding a simple code editor for a very simple scripting language we use at work. My syntax highlighting code works fine if I do it on the entire `RichTextBox` (`rtbMain`) but when I try to get it to work on just that line, so I can run the function with `rtbMain` changes, it gets weird. I can't seem to figure out w...
Ok I figured it out. I was calling the even on rtbMain.TextChange thinking that this would only trigger if the text actually changed. Nay Nay, it will also trigger if formatting is changed. so each time it changed something while it was doing its first pass and highlighting everything, it would then trigger to highligh...
308,988
<p>It is really annoying.</p> <pre><code>Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new mainForm()); &lt;-- pausing visual studio breaks here. </code></pre> <p>Thanks guys.</p>
[ { "answer_id": 309036, "author": "Sandeep Datta", "author_id": 39648, "author_profile": "https://Stackoverflow.com/users/39648", "pm_score": 2, "selected": false, "text": "<p>@sramey are you sure pausing always breaks on the said line? If I may hazard a guess here I think when you press ...
2008/11/21
[ "https://Stackoverflow.com/questions/308988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11059/" ]
It is really annoying. ``` Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new mainForm()); <-- pausing visual studio breaks here. ``` Thanks guys.
The debugger wil only pause there if your application is in an idle state (i.e it is actually executing Application.Run). If you really don't wont to end up there, you might try using the 'DebuggerNonUserCode' attribute on the method that calls Application.Run, but I wouldn't recommend it.
308,999
<p>In a comment on this <a href="https://stackoverflow.com/questions/306130/python-decorator-makes-function-forget-that-it-belongs-to-a-class#306277">answer to another question</a>, someone said that they weren't sure what <code>functools.wraps</code> was doing. So, I'm asking this question so that there will be a reco...
[ { "answer_id": 309000, "author": "Eli Courtwright", "author_id": 1694, "author_profile": "https://Stackoverflow.com/users/1694", "pm_score": 11, "selected": true, "text": "<p>When you use a decorator, you're replacing one function with another. In other words, if you have a decorator</p...
2008/11/21
[ "https://Stackoverflow.com/questions/308999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1694/" ]
In a comment on this [answer to another question](https://stackoverflow.com/questions/306130/python-decorator-makes-function-forget-that-it-belongs-to-a-class#306277), someone said that they weren't sure what `functools.wraps` was doing. So, I'm asking this question so that there will be a record of it on StackOverflow...
When you use a decorator, you're replacing one function with another. In other words, if you have a decorator ``` def logged(func): def with_logging(*args, **kwargs): print(func.__name__ + " was called") return func(*args, **kwargs) return with_logging ``` then when you say ``` @logged def f...
309,014
<p>I am currently using osql with nant by calling a batch file with arguments. Here are the properties that are defined in my nant script (no, not real username/password values):</p> <pre><code>&lt;property name="project.config" value="debug" /&gt; &lt;property name="server" value="(local)" /&gt; &lt;property name="da...
[ { "answer_id": 309050, "author": "Brett Veenstra", "author_id": 307, "author_profile": "https://Stackoverflow.com/users/307", "pm_score": 0, "selected": false, "text": "<p>I think you might want to experiment with the ORDER of your parameters... I seem to remember being bitten in the pas...
2008/11/21
[ "https://Stackoverflow.com/questions/309014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2779/" ]
I am currently using osql with nant by calling a batch file with arguments. Here are the properties that are defined in my nant script (no, not real username/password values): ``` <property name="project.config" value="debug" /> <property name="server" value="(local)" /> <property name="database" value="Test" /> <prop...
Here are a few suggestions 1. To help diagnose the problem with the nant/batch script it would be helpful to echo out the full osql command (from the batch script) that is being executed. This is of course to make sure the osql.connection is being expanded properly when a username/pass is provided. 2. There maybe othe...
309,023
<p>We have a Java application that needs to be brought to the foreground when a telecontrol mechanism activates something in the application.</p> <p>In order to get this, we have realized in the called method of the class which represents the frame of our application (extension of a <code>JFrame</code>) following impl...
[ { "answer_id": 309092, "author": "Brendan Cashman", "author_id": 5814, "author_profile": "https://Stackoverflow.com/users/5814", "pm_score": 0, "selected": false, "text": "<p>There are numerous <a href=\"http://java.sun.com/javase/6/docs/api/java/awt/Window.html#toFront()\" rel=\"nofollo...
2008/11/21
[ "https://Stackoverflow.com/questions/309023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15108/" ]
We have a Java application that needs to be brought to the foreground when a telecontrol mechanism activates something in the application. In order to get this, we have realized in the called method of the class which represents the frame of our application (extension of a `JFrame`) following implementation: ``` setV...
A possible solution is: ``` java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { myFrame.toFront(); myFrame.repaint(); } }); ```
309,035
<p>I created a GridView in an ASP.NET application and used the Auto Format tool to apply an attractive style. Now I'm moving the style markup to the CSS sheet and I'm having a weird problem where the text in the header row isn't the correct color (it should be white but it shows up a bright blue). <strong>This proble...
[ { "answer_id": 309064, "author": "user39603", "author_id": 39603, "author_profile": "https://Stackoverflow.com/users/39603", "pm_score": 0, "selected": false, "text": "<p>The header color in the stylesheet is correct: #507CD1 is bright blue. Where does it show up as white, then? In Visua...
2008/11/21
[ "https://Stackoverflow.com/questions/309035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3161/" ]
I created a GridView in an ASP.NET application and used the Auto Format tool to apply an attractive style. Now I'm moving the style markup to the CSS sheet and I'm having a weird problem where the text in the header row isn't the correct color (it should be white but it shows up a bright blue). **This problem only show...
I'm guessing the bright blue is very similar to the color of a hyperlink. Making the gridview sortable means you'll have an a tag inside your header instead of just plain text. This should sort it: ``` .grid-header a { color: White; background-color: #507CD1; font-weight: bold; } ```
309,040
<p>I've compiled a java project into a Jar file, and am having issues running it.</p> <p>When I run:</p> <pre><code>java -jar myJar.jar </code></pre> <p>I get the following error</p> <pre><code>Could not find the main class: myClass </code></pre> <p>The class file is not in the root directory of the jar so I've tr...
[ { "answer_id": 309058, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 4, "selected": true, "text": "<p>In your manifest file, make sure you have the attribute <code>Main-Class</code> set to the name of the class containing y...
2008/11/21
[ "https://Stackoverflow.com/questions/309040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20400/" ]
I've compiled a java project into a Jar file, and am having issues running it. When I run: ``` java -jar myJar.jar ``` I get the following error ``` Could not find the main class: myClass ``` The class file is not in the root directory of the jar so I've tried changing the path of the main class to match the pat...
In your manifest file, make sure you have the attribute `Main-Class` set to the name of the class containing your `main()` method. For example, if the package-qualified name of the class is `my.cool.Class`, then, in your JAR manifest, `Main-Class` should be set to `my.cool.Class`. Also made sure that you have a packag...
309,049
<p>I have a small ajax php application, which outputs data from a mysql db into a table. The rows are links, which when clicked will call an ajax function, which in turn will call another php file, which displays a different query from the same database in a layer without reloading the page.</p> <p>I would like to kno...
[ { "answer_id": 309090, "author": "Mischa Kroon", "author_id": 30600, "author_profile": "https://Stackoverflow.com/users/30600", "pm_score": 0, "selected": false, "text": "<p>You don't want it displayed, does that mean for security issues or something else. </p>\n\n<p>If you want to lose ...
2008/11/21
[ "https://Stackoverflow.com/questions/309049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I have a small ajax php application, which outputs data from a mysql db into a table. The rows are links, which when clicked will call an ajax function, which in turn will call another php file, which displays a different query from the same database in a layer without reloading the page. I would like to know how to s...
with jQuery it's very simple, and I would definitely recommend using it in ajax calls and etc. Let's say you have a table like this; ``` <table> <?php // I'm using mysqli class by the way. $ga = $DB->query("SELECT something FROM table"); for ($a = 0; $a < $ga->num_rows; $a++) { $aa = $DB->fetch_assoc($ga); // I'...
309,071
<p>I'd like to find all the types inheriting from a base/interface. Anyone have a good method to do this? Ideas?</p> <p>I know this is a strange request but its something I'm playing with none-the-less.</p>
[ { "answer_id": 309076, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>Use Assembly.GetTypes() to get all the types, and Type.IsAssignableFrom() to check for inheritance. Let me know if you...
2008/11/21
[ "https://Stackoverflow.com/questions/309071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1946/" ]
I'd like to find all the types inheriting from a base/interface. Anyone have a good method to do this? Ideas? I know this is a strange request but its something I'm playing with none-the-less.
Use Assembly.GetTypes() to get all the types, and Type.IsAssignableFrom() to check for inheritance. Let me know if you need code - and also whether or not you're using .NET 3.5. (A lot of reflection tasks like this are simpler with LINQ to Objects.) EDIT: As requested, here's an example - it finds everything in `mscor...
309,081
<p>I want to create a toggle button in html using css. I want it so that when you click on it , it stays pushed in and than when you click it on it again it pops out. </p> <p>If theres no way of doing it just using css. Is there a way to do it using jQuery?</p>
[ { "answer_id": 309085, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 2, "selected": false, "text": "<p>I would be inclined to use a class in your css that alters the border style or border width when the button is depresse...
2008/11/21
[ "https://Stackoverflow.com/questions/309081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1231/" ]
I want to create a toggle button in html using css. I want it so that when you click on it , it stays pushed in and than when you click it on it again it pops out. If theres no way of doing it just using css. Is there a way to do it using jQuery?
The good semantic way would be to use a checkbox, and then style it in different ways if it is checked or not. But there are no good ways do to it. You have to add extra span, extra div, and, for a really nice look, add some javascript. So the best solution is to use a small jQuery function and two background images f...
309,101
<p>How do I get the <code>GridView</code> control to render the <code>&lt;thead&gt;</code> <code>&lt;tbody&gt;</code> tags? I know <code>.UseAccessibleHeaders</code> makes it put <code>&lt;th&gt;</code> instead of <code>&lt;td&gt;</code>, but I cant get the <code>&lt;thead&gt;</code> to appear.</p>
[ { "answer_id": 309119, "author": "Phil Jenkins", "author_id": 35496, "author_profile": "https://Stackoverflow.com/users/35496", "pm_score": 9, "selected": true, "text": "<p>This should do it:</p>\n\n<pre><code>gv.HeaderRow.TableSection = TableRowSection.TableHeader;\n</code></pre>\n" }...
2008/11/21
[ "https://Stackoverflow.com/questions/309101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28543/" ]
How do I get the `GridView` control to render the `<thead>` `<tbody>` tags? I know `.UseAccessibleHeaders` makes it put `<th>` instead of `<td>`, but I cant get the `<thead>` to appear.
This should do it: ``` gv.HeaderRow.TableSection = TableRowSection.TableHeader; ```
309,115
<p>I am creating a small app to teach myself ASP.NET MVC and JQuery, and one of the pages is a list of items in which some can be selected. Then I would like to press a button and send a List (or something equivalent) to my controller containing the ids of the items that were selected, using JQuery's Post function.</p>...
[ { "answer_id": 309688, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 3, "selected": false, "text": "<p>Don't post the data as an array. <a href=\"http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx\" rel...
2008/11/21
[ "https://Stackoverflow.com/questions/309115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/79101/" ]
I am creating a small app to teach myself ASP.NET MVC and JQuery, and one of the pages is a list of items in which some can be selected. Then I would like to press a button and send a List (or something equivalent) to my controller containing the ids of the items that were selected, using JQuery's Post function. I man...
I modified my response to include the code for a test app I did. **Update: I have updated the jQuery to set the 'traditional' setting to true so this will work again (per @DustinDavis' answer).** First the javascript: ``` function test() { var stringArray = new Array(); stringArray[0] = "item1"; stringAr...
309,129
<p>I got the following class :</p> <pre><code>class ConstraintFailureSet(dict, Exception) : """ Container for constraint failures. It act as a constraint failure itself but can contain other constraint failures that can be accessed with a dict syntax. """ def __init__(self, **failures) : ...
[ { "answer_id": 309196, "author": "Dave Costa", "author_id": 6568, "author_profile": "https://Stackoverflow.com/users/6568", "pm_score": 2, "selected": false, "text": "<p>What version of Python?</p>\n\n<p>In 2.5.1, I can't even define a class the inherits from both <code>dict</code> and <...
2008/11/21
[ "https://Stackoverflow.com/questions/309129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9951/" ]
I got the following class : ``` class ConstraintFailureSet(dict, Exception) : """ Container for constraint failures. It act as a constraint failure itself but can contain other constraint failures that can be accessed with a dict syntax. """ def __init__(self, **failures) : dict.__...
Both `Exception` and `dict` are implemented in C. I think you can test this the follwing way: ``` >>> class C(object): pass ... >>> '__module__' in C.__dict__ True >>> '__module__' in dict.__dict__ False >>> '__module__' in Exception.__dict__ False ``` Since `Exception` and `dict` have different ideas of how to sto...
309,149
<p>When generating graphs and showing different sets of data it usually a good idea to difference the sets by color. So one line is red and the next is green and so on. The problem is then that when the number of datasets is unknown one needs to randomly generate these colors and often they end up very close to each ot...
[ { "answer_id": 309190, "author": "mmiika", "author_id": 6846, "author_profile": "https://Stackoverflow.com/users/6846", "pm_score": 1, "selected": false, "text": "<p>I would start with a set brightness 100% and go around primary colors first:</p>\n\n<p>FF0000, 00FF00, 0000FF</p>\n\n<p>th...
2008/11/21
[ "https://Stackoverflow.com/questions/309149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/298/" ]
When generating graphs and showing different sets of data it usually a good idea to difference the sets by color. So one line is red and the next is green and so on. The problem is then that when the number of datasets is unknown one needs to randomly generate these colors and often they end up very close to each other...
You have three colour channels 0 to 255 R, G and B. First go through ``` 0, 0, 255 0, 255, 0 255, 0, 0 ``` Then go through ``` 0, 255, 255 255, 0, 255 255, 255, 0 ``` Then divide by 2 => 128 and start again: ``` 0, 0, 128 0, 128, 0 128, 0, 0 0, 128, 128 128, 0, 128 128, 128, 0 ``` Divide by 2 => 64 Next time...
309,153
<p>Is there a way to link to a chm file, and therein to a certain topic, from a Microsoft Word docx document? Something in the lines of:</p> <blockquote> <p>"For more information about this Property see [link ref="./SomeDirectory/somedocument.chm!Sometopic.Somesubtopic" text="MyClass.MyProperty"]</p> </blockquote>
[ { "answer_id": 310510, "author": "Frank V", "author_id": 18196, "author_profile": "https://Stackoverflow.com/users/18196", "pm_score": 0, "selected": false, "text": "<p>You should be able to do it by setting the hyperlink to the file and use the &quot;#&quot; header anchor (I'm not sure ...
2008/11/21
[ "https://Stackoverflow.com/questions/309153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4227/" ]
Is there a way to link to a chm file, and therein to a certain topic, from a Microsoft Word docx document? Something in the lines of: > > "For more information about this Property see [link ref="./SomeDirectory/somedocument.chm!Sometopic.Somesubtopic" text="MyClass.MyProperty"] > > >
I don't think that simply a file link to the .chm file will do the job. For me, the following link format works (note that the .chm file must be in a trusted location, network shares will not work per default): mk:@MSITStore:C:\SomeDirectory\help.chm::/helppage.htm EDIT > > For relative paths it seems the > follo...
309,159
<p>I'm trying to do some abstraction in Haskell98 but doen't know how to do it.</p> <p>What I want to do is to define a class for types that may be converted into lists.</p> <pre><code>toList :: a -&gt; [b] </code></pre> <p>But I don't know how to define a class for this method. I brought up the following three idea...
[ { "answer_id": 310202, "author": "Chris", "author_id": 8415, "author_profile": "https://Stackoverflow.com/users/8415", "pm_score": 2, "selected": false, "text": "<p>I'd recommend <a href=\"http://www.ninebynine.org/Software/Learning-Haskell-Notes.html#type-class-misuse\" rel=\"nofollow n...
2008/11/21
[ "https://Stackoverflow.com/questions/309159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9632/" ]
I'm trying to do some abstraction in Haskell98 but doen't know how to do it. What I want to do is to define a class for types that may be converted into lists. ``` toList :: a -> [b] ``` But I don't know how to define a class for this method. I brought up the following three ideas: ``` class ToList a b where t...
See also [Data.Foldable](http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Foldable.html) in the standard library, which provides a `toList` function for any `Foldable` instance. `Foldable` takes a bit of sophistication to instantiate, but it would be good practice. As a bonus, your `HTree` type is almost...
309,161
<p>Is it a simple case of just never using the this.XYZ construct?</p>
[ { "answer_id": 309182, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 4, "selected": true, "text": "<p>It's only considered poor style if it violates your style guidelines. Sometimes using <code>this</code> is necessary...
2008/11/21
[ "https://Stackoverflow.com/questions/309161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11538/" ]
Is it a simple case of just never using the this.XYZ construct?
It's only considered poor style if it violates your style guidelines. Sometimes using `this` is necessary to qualify a member variable over a local variable: ``` public MyType(int arg) { this.arg = arg; } ``` This problem can also be mitigated with style guidelines. For example, prefix members with "\_": ``` pu...
309,165
<p>Let's say I have an int with the value of 1. How can I convert that int to a zero padded string, such as <code>00000001</code>?</p>
[ { "answer_id": 309194, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 5, "selected": false, "text": "<p>Another way is:</p>\n\n<pre><code>DECLARE @iVal int = 1\nselect REPLACE(STR(@iVal, 8, 0), ' ', '0')\n</code></pre>\...
2008/11/21
[ "https://Stackoverflow.com/questions/309165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/470/" ]
Let's say I have an int with the value of 1. How can I convert that int to a zero padded string, such as `00000001`?
``` Declare @MyInt integer Set @MyInt = 123 Declare @StrLen TinyInt Set @StrLen = 8 Select Replace(Str(@MyInt, @StrLen), ' ' , '0') ```
309,205
<p>Since C# is strongly typed, do we really need to prefix variables anymore?</p> <p>e.g.</p> <pre><code>iUserAge iCounter strUsername </code></pre> <p>I used to prefix in the past, but <b>going forward I don't see any benefit</b>.</p>
[ { "answer_id": 309216, "author": "Andrew Cowenhoven", "author_id": 12281, "author_profile": "https://Stackoverflow.com/users/12281", "pm_score": 3, "selected": false, "text": "<p>Nope. Did we <a href=\"http://www.joelonsoftware.com/articles/Wrong.html\" rel=\"noreferrer\">ever</a> need t...
2008/11/21
[ "https://Stackoverflow.com/questions/309205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
Since C# is strongly typed, do we really need to prefix variables anymore? e.g. ``` iUserAge iCounter strUsername ``` I used to prefix in the past, but **going forward I don't see any benefit**.
> > Are variable prefixes ( Hungarian ) really necessary anymore? > > > NO! === In fact, Microsoft's own [style guidelines](http://msdn.microsoft.com/en-us/library/ms229042.aspx) (where the practice originated) now recommend against it. In particular, see the section on [General Naming Conventions](http://msdn.mi...
309,206
<p>At the risk of becoming the village idiot, can someone explain to me why generics are called generics? I understand their usage and benefits, but if the <a href="http://dictionary.reference.com/browse/generic" rel="noreferrer">definition of generic</a> is "general" and generic collections are type safe, then why is...
[ { "answer_id": 309214, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 0, "selected": false, "text": "<p>If they called it \"type parameter(s)\" people would confuse it with parameters of type Type.</p>\n\n<p>Also, ArrayList isn...
2008/11/21
[ "https://Stackoverflow.com/questions/309206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2034/" ]
At the risk of becoming the village idiot, can someone explain to me why generics are called generics? I understand their usage and benefits, but if the [definition of generic](http://dictionary.reference.com/browse/generic) is "general" and generic collections are type safe, then why isn't this a misnomer? For exampl...
"Generic" is talking about the implementation. You write a single "Generic" list implementation that works with any type, instead of having to write specific implementations for each type you want to use.
309,303
<p>Currently this expression <code>"I ([a-zA-z]\d]{3} "</code> returns when the following pattern is true:</p> <pre> I AAA I Z99 </pre> <p>I need to modify this so it will return a range of alphanumerics after the I from 2 to 13 that do not have a space.</p> <p>Example:</p> <pre> I AAA I A321 I ASHG310310 </pr...
[ { "answer_id": 309317, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 4, "selected": true, "text": "<p>Without the quotes:</p>\n\n<pre>\n\"I ([a-zA-Z\\d]{2,13}) \"\n</pre>\n" }, { "answer_id": 309335, "author": ...
2008/11/21
[ "https://Stackoverflow.com/questions/309303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38349/" ]
Currently this expression `"I ([a-zA-z]\d]{3} "` returns when the following pattern is true: ``` I AAA I Z99 ``` I need to modify this so it will return a range of alphanumerics after the I from 2 to 13 that do not have a space. Example: ``` I AAA I A321 I ASHG310310 ``` Thanks, Dave
Without the quotes: ``` "I ([a-zA-Z\d]{2,13}) " ```
309,333
<p>I have an enum construct like this:</p> <pre><code>public enum EnumDisplayStatus { None = 1, Visible = 2, Hidden = 3, MarkedForDeletion = 4 } </code></pre> <p>In my database, the enumerations are referenced by value. My question is, how can I turn the number representation of the enum back to t...
[ { "answer_id": 309339, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 10, "selected": true, "text": "<p>You can convert the <code>int</code> back to an enumeration member with a simple cast, and then call <code>ToString...
2008/11/21
[ "https://Stackoverflow.com/questions/309333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39655/" ]
I have an enum construct like this: ``` public enum EnumDisplayStatus { None = 1, Visible = 2, Hidden = 3, MarkedForDeletion = 4 } ``` In my database, the enumerations are referenced by value. My question is, how can I turn the number representation of the enum back to the string name. For exam...
You can convert the `int` back to an enumeration member with a simple cast, and then call `ToString()`: ``` int value = GetValueFromDb(); var enumDisplayStatus = (EnumDisplayStatus)value; string stringValue = enumDisplayStatus.ToString(); ```
309,334
<p>What features do you wish were in common languages? More precisely, I mean features which generally don't exist at all but would be nice to see, rather than, "I wish dynamic typing was popular."</p>
[ { "answer_id": 309340, "author": "Brian", "author_id": 18192, "author_profile": "https://Stackoverflow.com/users/18192", "pm_score": 2, "selected": false, "text": "<p>To start things off, I wish the standard for strings was to use a prefix if you wanted to use escape codes, rather than t...
2008/11/21
[ "https://Stackoverflow.com/questions/309334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18192/" ]
What features do you wish were in common languages? More precisely, I mean features which generally don't exist at all but would be nice to see, rather than, "I wish dynamic typing was popular."
I've often thought that "observable" would make a great field modifier (like public, private, static, etc.) ``` GameState { observable int CurrentScore; } ``` Then, other classes could declare an observer of that property: ``` ScoreDisplay { observe GameState.CurrentScore(int oldValue, int newValue) { ....
309,364
<p>SQL Server 2000 Guru's,</p> <p>I've setup SQL 2000 to accept HTTP Queries i.e. <a href="http://74.22.98.66/MYDATABASE?sql=" rel="nofollow noreferrer">http://74.22.98.66/MYDATABASE?sql=</a>{CALL+sp_XMLDATA}+&amp;root=root (ficticious url) It works great and returns the following XML via I.E.7 url -</p> <pre><code>...
[ { "answer_id": 560838, "author": "Maksym Gontar", "author_id": 67407, "author_profile": "https://Stackoverflow.com/users/67407", "pm_score": 0, "selected": false, "text": "<p>What I have found out: in common case content-length is not a XML header attribute, <a href=\"http://www.w3.org/P...
2008/11/21
[ "https://Stackoverflow.com/questions/309364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
SQL Server 2000 Guru's, I've setup SQL 2000 to accept HTTP Queries i.e. <http://74.22.98.66/MYDATABASE?sql=>{CALL+sp\_XMLDATA}+&root=root (ficticious url) It works great and returns the following XML via I.E.7 url - ``` <?xml version="1.0" encoding="utf-8" ?> <root> <g c="15" /> <g c="8" /> <g c="19" /> ...
This may be a job for [XML Templates](http://tutorials.freeskills.com/sql-server-2000-and-xml-part-5-xml-templates.htm). When using a template you can control the header and make it exactly the way you want it.
309,382
<p>Say I have a xml document that looks like this</p> <pre><code>&lt;foo&gt; &lt;bar id="9" /&gt; &lt;bar id="4" /&gt; &lt;bar id="3" /&gt; &lt;/foo&gt; </code></pre> <p>I would like to use linq to reset the id's to 0, 1 ,2. What would be the easiest way to do this?</p> <p>Thanks</p>
[ { "answer_id": 309407, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "<pre><code>XElement xml = GetXml();\nvar i = 0;\nforeach (var e in xml.Elements(\"bar\"))\n e.SetAttributeValue(\"id\", i++);\...
2008/11/21
[ "https://Stackoverflow.com/questions/309382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29961/" ]
Say I have a xml document that looks like this ``` <foo> <bar id="9" /> <bar id="4" /> <bar id="3" /> </foo> ``` I would like to use linq to reset the id's to 0, 1 ,2. What would be the easiest way to do this? Thanks
``` XElement xml = GetXml(); var i = 0; foreach (var e in xml.Elements("bar")) e.SetAttributeValue("id", i++); ```
309,396
<p>I've got a few methods that should call <code>System.exit()</code> on certain inputs. Unfortunately, testing these cases causes JUnit to terminate! Putting the method calls in a new Thread doesn't seem to help, since <code>System.exit()</code> terminates the JVM, not just the current thread. Are there any common pat...
[ { "answer_id": 309415, "author": "flolo", "author_id": 36472, "author_profile": "https://Stackoverflow.com/users/36472", "pm_score": 2, "selected": false, "text": "<p>A quick look at the api, shows that System.exit can throw an exception esp. if a securitymanager forbids the shutdown of ...
2008/11/21
[ "https://Stackoverflow.com/questions/309396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
I've got a few methods that should call `System.exit()` on certain inputs. Unfortunately, testing these cases causes JUnit to terminate! Putting the method calls in a new Thread doesn't seem to help, since `System.exit()` terminates the JVM, not just the current thread. Are there any common patterns for dealing with th...
Indeed, [Derkeiler.com](http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2008-04/msg02603.html) suggests: * Why `System.exit()` ? > > Instead of terminating with System.exit(whateverValue), why not throw an unchecked exception? In normal use it will drift all the way out to the JVM's last-ditch cat...
309,402
<p>In my php script which connects to mysql, I have to query 2 databases in the same script to get different information. More specifically Faxarchives in one database and Faxusers in the other. </p> <p>In my code I query faxusers and then foreach user, I query Faxarchives to get the user history. </p> <p>I might d...
[ { "answer_id": 309441, "author": "ChrisInEdmonton", "author_id": 16266, "author_profile": "https://Stackoverflow.com/users/16266", "pm_score": 3, "selected": false, "text": "<p>You have several problems. First, your function, getUserarchive, pulls back all rows all the time. Looks like...
2008/11/21
[ "https://Stackoverflow.com/questions/309402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18853/" ]
In my php script which connects to mysql, I have to query 2 databases in the same script to get different information. More specifically Faxarchives in one database and Faxusers in the other. In my code I query faxusers and then foreach user, I query Faxarchives to get the user history. I might do something like: ...
You have several problems. First, your function, getUserarchive, pulls back all rows all the time. Looks like you forgot to restrict your SQL to only a specific userid. That's a big cause of your speed issues. Another option would be to pass in all userids you are interested in. Rewrite the SQL as SELECT sent, receive...
309,424
<p>If you have a <code>java.io.InputStream</code> object, how should you process that object and produce a <code>String</code>?</p> <hr /> <p>Suppose I have an <code>InputStream</code> that contains text data, and I want to convert it to a <code>String</code>, so for example I can write that to a log file.</p> <p>What ...
[ { "answer_id": 309448, "author": "Harry Lime", "author_id": 21590, "author_profile": "https://Stackoverflow.com/users/21590", "pm_score": 12, "selected": true, "text": "<p>A nice way to do this is using <a href=\"http://commons.apache.org/\" rel=\"noreferrer\">Apache commons</a> <code><a...
2008/11/21
[ "https://Stackoverflow.com/questions/309424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16616/" ]
If you have a `java.io.InputStream` object, how should you process that object and produce a `String`? --- Suppose I have an `InputStream` that contains text data, and I want to convert it to a `String`, so for example I can write that to a log file. What is the easiest way to take the `InputStream` and convert it t...
A nice way to do this is using [Apache commons](http://commons.apache.org/) `[IOUtils](https://commons.apache.org/proper/commons-io/javadocs/api-release/org/apache/commons/io/IOUtils.html)` to copy the `InputStream` into a `StringWriter`... something like ``` StringWriter writer = new StringWriter(); IOUtils.copy(inpu...
309,485
<p>I recently have been moving a bunch of MP3s from various locations into a repository. I had been constructing the new file names using the ID3 tags (thanks, TagLib-Sharp!), and I noticed that I was getting a <code>System.NotSupportedException</code>: </p> <blockquote> <p><em>"The given path's format is not suppor...
[ { "answer_id": 309603, "author": "Brian", "author_id": 18192, "author_profile": "https://Stackoverflow.com/users/18192", "pm_score": 0, "selected": false, "text": "<p>Your code would be cleaner if you appended the directory and filename together and sanitized that rather than sanitizing ...
2008/11/21
[ "https://Stackoverflow.com/questions/309485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2683/" ]
I recently have been moving a bunch of MP3s from various locations into a repository. I had been constructing the new file names using the ID3 tags (thanks, TagLib-Sharp!), and I noticed that I was getting a `System.NotSupportedException`: > > *"The given path's format is not supported."* > > > This was generate...
To clean up a file name you could do this ``` private static string MakeValidFileName( string name ) { string invalidChars = System.Text.RegularExpressions.Regex.Escape( new string( System.IO.Path.GetInvalidFileNameChars() ) ); string invalidRegStr = string.Format( @"([{0}]*\.+$)|([{0}]+)", invalidChars ); r...
309,491
<p>I'm using the following code to try to read the results of a <code>df</code> command in Linux using <code>popen</code>.</p> <pre><code>#include &lt;iostream&gt; // file and std I/O functions int main(int argc, char** argv) { FILE* fp; char * buffer; long bufSize; size_t ret_code; fp = popen("d...
[ { "answer_id": 309505, "author": "flolo", "author_id": 36472, "author_profile": "https://Stackoverflow.com/users/36472", "pm_score": 0, "selected": false, "text": "<p>check your bufSize. <code>ftell</code> can return -1 on error, and this can lead to nonallocation by malloc with buffer h...
2008/11/21
[ "https://Stackoverflow.com/questions/309491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
I'm using the following code to try to read the results of a `df` command in Linux using `popen`. ``` #include <iostream> // file and std I/O functions int main(int argc, char** argv) { FILE* fp; char * buffer; long bufSize; size_t ret_code; fp = popen("df", "r"); if(fp == NULL) { // head off...
Why would `std::malloc()` fail? The obvious reason is "because `std::ftell()` returned a negative signed number, which was then treated as a huge unsigned number". According to [the documentation](http://en.cppreference.com/w/cpp/io/c/ftell), `std::ftell()` returns -1 on failure. One obvious reason it would fail is t...
309,494
<p>I'm trying to make a program in Visual C# that has my one created class, and at application launch it creates an array of my class object, and this array of my object can be used all over the program. So any function, or a control's event can access the array of objects and their member variables. I created my class...
[ { "answer_id": 309519, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Only static objects are available in all contexts. While your design lacks... er, just lacks in general, the way you could...
2008/11/21
[ "https://Stackoverflow.com/questions/309494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/117494/" ]
I'm trying to make a program in Visual C# that has my one created class, and at application launch it creates an array of my class object, and this array of my object can be used all over the program. So any function, or a control's event can access the array of objects and their member variables. I created my class as...
Your problem is that you are defining it within the main function, hence it will only exist inside the main function. you need to define it inside the class, not inside the function ``` public partial class Form1:Form { MyClass[] MyArrayObject; // declare it here and it will be available everywhere public Form1() { ...
309,495
<p>I'm currently using <code>Win32ShellFolderManager2</code> and <code>ShellFolder.getLinkLocation</code> to resolve windows shortcuts in Java. Unfortunately, if the Java program is running as a service under Vista, <code>getLinkLocation</code>, this does not work. Specifically, I get an exception stating "Could not ge...
[ { "answer_id": 352738, "author": "Sam Brightman", "author_id": 2492, "author_profile": "https://Stackoverflow.com/users/2492", "pm_score": 2, "selected": false, "text": "<p>The code plan9assembler linked to appears to work with minor modification. I think it's just the \"<code>&amp; 0xff...
2008/11/21
[ "https://Stackoverflow.com/questions/309495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15255/" ]
I'm currently using `Win32ShellFolderManager2` and `ShellFolder.getLinkLocation` to resolve windows shortcuts in Java. Unfortunately, if the Java program is running as a service under Vista, `getLinkLocation`, this does not work. Specifically, I get an exception stating "Could not get shell folder ID list". Searching ...
Added comments (some explanation as well as credit to each contributor so far),additional check on the file magic, a quick test to see if a given file might be a valid link (without reading all of the bytes), a fix to throw a ParseException with appropriate message instead of ArrayIndexOutOfBoundsException if the file ...
309,496
<p>How can I initialize a const / static array of structs as clearly as possible?</p> <pre><code>class SomeClass { struct MyStruct { public string label; public int id; }; const MyStruct[] MyArray = { {"a", 1} {"b", 5} {"q", 29} }; }; </code></pre>
[ { "answer_id": 309528, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>Firstly, do you <em>really</em> have to have a mutable struct? They're almost always a bad idea. Likewise public field...
2008/11/21
[ "https://Stackoverflow.com/questions/309496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4066/" ]
How can I initialize a const / static array of structs as clearly as possible? ``` class SomeClass { struct MyStruct { public string label; public int id; }; const MyStruct[] MyArray = { {"a", 1} {"b", 5} {"q", 29} }; }; ```
Firstly, do you *really* have to have a mutable struct? They're almost always a bad idea. Likewise public fields. There are some very occasional contexts in which they're reasonable (usually both parts together, as with `ValueTuple`) but they're pretty rare in my experience. Other than that, I'd just create a construc...
309,506
<p>I want to reveal a div with an input inside when you click a button, and set its focus.</p> <p>If I use show(), it works, but if I use slideDown() <strong>the focus is lost after the animation completes</strong>. How can I prevent this from happening?</p> <p>Sample code:</p> <pre><code>$("document").ready(functio...
[ { "answer_id": 309525, "author": "Pim Jager", "author_id": 35197, "author_profile": "https://Stackoverflow.com/users/35197", "pm_score": 1, "selected": false, "text": "<p>I think you can only focus the element once the DIV has fully stopped sliding?<br>\nnot sure...</p>\n" }, { "...
2008/11/21
[ "https://Stackoverflow.com/questions/309506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1842/" ]
I want to reveal a div with an input inside when you click a button, and set its focus. If I use show(), it works, but if I use slideDown() **the focus is lost after the animation completes**. How can I prevent this from happening? Sample code: ``` $("document").ready(function(){ $("#MyButton").click(function(e)...
Try this: ``` $(function(){ $("#MyButton").click(function(e){ e.preventDefault(); $(".SlidingDiv").slideDown(function(){ // Callback function - will occur when sliding is complete. $("#MyInput").focus(); }); }); }); ```
309,522
<p>(This is related to <a href="https://stackoverflow.com/questions/85373/floor-a-date-in-sql-server">Floor a date in SQL server</a>.)</p> <p>Does a deterministic expression exist to floor a DATETIME? When I use this as a computed column formula:</p> <pre><code>DATEADD(dd, DATEDIFF(dd, 0, [datetime_column]), 0) </cod...
[ { "answer_id": 309555, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 2, "selected": false, "text": "<p>Does your column [datetime_column] have a default value set to \"getDate()\" ?? </p>\n\n<p>If so, since getdate...
2008/11/21
[ "https://Stackoverflow.com/questions/309522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18771/" ]
(This is related to [Floor a date in SQL server](https://stackoverflow.com/questions/85373/floor-a-date-in-sql-server).) Does a deterministic expression exist to floor a DATETIME? When I use this as a computed column formula: ``` DATEADD(dd, DATEDIFF(dd, 0, [datetime_column]), 0) ``` the I get an error when I place...
My guess is that this is a bug of some sorts. In SQL 2005 I was able to create such an indexed view without a problem (code is below). When I tried to run it on SQL 2000 though I got the same error as you are getting. The following seems to work on SQL 2000, but I get a warning that the index will be ignored AND you w...
309,533
<p>I have a webservice @ <a href="http://recpushdata.cyndigo.com/Jobs.asmx" rel="nofollow noreferrer">http://recpushdata.cyndigo.com/Jobs.asmx</a> but I'm not able to access it though I am adding it as a WebReference properly.</p> <p>Any Help would be great.</p>
[ { "answer_id": 309555, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 2, "selected": false, "text": "<p>Does your column [datetime_column] have a default value set to \"getDate()\" ?? </p>\n\n<p>If so, since getdate...
2008/11/21
[ "https://Stackoverflow.com/questions/309533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a webservice @ <http://recpushdata.cyndigo.com/Jobs.asmx> but I'm not able to access it though I am adding it as a WebReference properly. Any Help would be great.
My guess is that this is a bug of some sorts. In SQL 2005 I was able to create such an indexed view without a problem (code is below). When I tried to run it on SQL 2000 though I got the same error as you are getting. The following seems to work on SQL 2000, but I get a warning that the index will be ignored AND you w...
309,539
<p>I would like to generate a list of files within a directory. Some of the filenames contain Chinese characters.</p> <p>eg: [试验].Test.txt</p> <p>I am using the following code:</p> <pre><code>require 'find' dirs = ["TestDir"] for dir in dirs Find.find(dir) do |path| if FileTest.directory?(path) else ...
[ { "answer_id": 309707, "author": "rpattabi", "author_id": 15139, "author_profile": "https://Stackoverflow.com/users/15139", "pm_score": 3, "selected": true, "text": "<p>Ruby needs to know that you are dealing with unicode in your code. Set appropriate character encoding using KCODE, as b...
2008/11/21
[ "https://Stackoverflow.com/questions/309539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39731/" ]
I would like to generate a list of files within a directory. Some of the filenames contain Chinese characters. eg: [试验].Test.txt I am using the following code: ``` require 'find' dirs = ["TestDir"] for dir in dirs Find.find(dir) do |path| if FileTest.directory?(path) else p path end end e...
Ruby needs to know that you are dealing with unicode in your code. Set appropriate character encoding using KCODE, as below: ``` $KCODE = 'utf-8' ``` I think utf-8 is good enough for chinese characters.
309,553
<p>I commonly find myself extracting common behavior out of classes into helper/utility classes that contain nothing but a set of static methods. I've often wondered if I should be declaring these classes as abstract, since I can't really think of a valid reason to ever instantiate these? </p> <p>What would the Pros...
[ { "answer_id": 309567, "author": "Paul Sonier", "author_id": 28053, "author_profile": "https://Stackoverflow.com/users/28053", "pm_score": 2, "selected": false, "text": "<p>By declaring them as abstract, you are in effect indicating to other coders that you intended for these classes to ...
2008/11/21
[ "https://Stackoverflow.com/questions/309553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/292/" ]
I commonly find myself extracting common behavior out of classes into helper/utility classes that contain nothing but a set of static methods. I've often wondered if I should be declaring these classes as abstract, since I can't really think of a valid reason to ever instantiate these? What would the Pros and Cons be...
You could just declare a private constructor that does nothing. The problem with declaring the class "abstract" is that the abstract keyword usually means that class is intended to be subclassed and extended. That's definitely not what you want here.
309,565
<p>I'm using the StAX event based API's to modify an XML stream. The stream represents an HTML document, complete with DTD declaration. I would like to copy this DTD declaration into the output document (written using an <code>XMLEventWriter</code>). When I ask the factory to disregard DTD's it will not download the DT...
[ { "answer_id": 309643, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 3, "selected": true, "text": "<p>You should be able to implement a custom XMLResolver that redirects attempts to fetch external DTDs to a local resource (...
2008/11/21
[ "https://Stackoverflow.com/questions/309565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4100/" ]
I'm using the StAX event based API's to modify an XML stream. The stream represents an HTML document, complete with DTD declaration. I would like to copy this DTD declaration into the output document (written using an `XMLEventWriter`). When I ask the factory to disregard DTD's it will not download the DTD, but remove ...
You should be able to implement a custom XMLResolver that redirects attempts to fetch external DTDs to a local resource (if your code parses only a specific doc type, this is often a class resource right in a JAR). ``` class CustomResolver implements javax.xml.stream.XMLResolver { public Object resolveEntity(String...
309,604
<p>I need to do the following for hundreds of files: Append the name of the file (which may contain spaces) to the end of each line in the file.</p> <p>It seems to me there should be some way to do this:</p> <pre><code>sed -e 's/$/FILENAME/' * </code></pre> <p>where <code>FILENAME</code> represents the name of the c...
[ { "answer_id": 309616, "author": "Tyler McHenry", "author_id": 39375, "author_profile": "https://Stackoverflow.com/users/39375", "pm_score": 2, "selected": false, "text": "<p>You could do it with a bash script</p>\n\n<pre><code>for i in * \ndo\n sed -e \"s/\\$/$i/\" \"$i\" \ndone\n</cod...
2008/11/21
[ "https://Stackoverflow.com/questions/309604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1094969/" ]
I need to do the following for hundreds of files: Append the name of the file (which may contain spaces) to the end of each line in the file. It seems to me there should be some way to do this: ``` sed -e 's/$/FILENAME/' * ``` where `FILENAME` represents the name of the current file. Is there a sed variable represe...
I'm sure there are other ways to do it, I'd use perl: ``` perl -p -i -e 's/$/$ARGV/;' * ```
309,615
<p>I'd like to establish an ssh tunnel over ssh to my mysql server.</p> <p>Ideally I'd return a mysqli db pointer just like I was connecting directly.</p> <p>I'm on a shared host that doesn't have the <a href="http://ca.php.net/ssh2" rel="noreferrer">SSH2</a> libraries but I might be able to get them installed locall...
[ { "answer_id": 309772, "author": "jpm", "author_id": 35478, "author_profile": "https://Stackoverflow.com/users/35478", "pm_score": 2, "selected": true, "text": "<p>Eric,</p>\n\n<p>I think you are out of luck on this one. You can either use the ssh extension in your PHP code, or if you ha...
2008/11/21
[ "https://Stackoverflow.com/questions/309615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1430/" ]
I'd like to establish an ssh tunnel over ssh to my mysql server. Ideally I'd return a mysqli db pointer just like I was connecting directly. I'm on a shared host that doesn't have the [SSH2](http://ca.php.net/ssh2) libraries but I might be able to get them installed locally using PECL. If there's a way that uses nat...
Eric, I think you are out of luck on this one. You can either use the ssh extension in your PHP code, or if you have access to the server, you could try to create a ssh tunnel on the command-line. You probably need special permissions to do that, though. It also looks like you don't have ssh access to this hosting ac...
309,631
<p>In what cases is it necessary to synchronize access to instance members? I understand that access to static members of a class always needs to be synchronized- because they are shared across all object instances of the class.</p> <p>My question is when would I be incorrect if I do not synchronize instance members?...
[ { "answer_id": 309636, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>It depends on whether you want your class to be thread-safe. Most classes shouldn't be thread-safe (for simplicity) in...
2008/11/21
[ "https://Stackoverflow.com/questions/309631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39732/" ]
In what cases is it necessary to synchronize access to instance members? I understand that access to static members of a class always needs to be synchronized- because they are shared across all object instances of the class. My question is when would I be incorrect if I do not synchronize instance members? for exa...
It depends on whether you want your class to be thread-safe. Most classes shouldn't be thread-safe (for simplicity) in which case you don't need synchronization. If you need it to be thread-safe, you should synchronize access *or* make the variable volatile. (It avoids other threads getting "stale" data.)
309,639
<p>The following questions are about XML serialization/deserialization and schema validation for a .net library of types which are to be used for data exchange.</p> <hr> <p>First question, if I have a custom xml namespace say "<a href="http://mydomain/mynamespace" rel="nofollow noreferrer">http://mydomain/mynamespace...
[ { "answer_id": 309699, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>1) XmlRoot can only be set at the class/struct/interface level (or on return values). So you can't use it on the assembly ...
2008/11/21
[ "https://Stackoverflow.com/questions/309639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21566/" ]
The following questions are about XML serialization/deserialization and schema validation for a .net library of types which are to be used for data exchange. --- First question, if I have a custom xml namespace say "<http://mydomain/mynamespace>" do I have to add a ``` [XmlRoot(Namespace = "http://mydomain/mynamespa...
Just to add - the "xsi" etc is there to support things like xsi:nil on values later on - a well-known pattern for nullable values. It has to write the stream "forwards only", and it doesn't know (when it writes the first bit) whether it will need nil or not, so it assumes that writing it unnecessarily once is better th...
309,668
<p>Our web team has been asked to build some user interfaces in Sharepoint. The UI's would primarily be forms that would need to write to a SQL Server database.</p> <p>Is ASP.NET the best way to do this? If so what's the best way to integrate the ASP.NET application into Sharepoint?</p>
[ { "answer_id": 309684, "author": "Mauro", "author_id": 2208, "author_profile": "https://Stackoverflow.com/users/2208", "pm_score": 3, "selected": true, "text": "<p>You have 4 options:</p>\n\n<pre><code>1. Build web parts \n2. build user controls , and use smart part to display them.\n3. ...
2008/11/21
[ "https://Stackoverflow.com/questions/309668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67719/" ]
Our web team has been asked to build some user interfaces in Sharepoint. The UI's would primarily be forms that would need to write to a SQL Server database. Is ASP.NET the best way to do this? If so what's the best way to integrate the ASP.NET application into Sharepoint?
You have 4 options: ``` 1. Build web parts 2. build user controls , and use smart part to display them. 3. use infopath 4. host the asp.net in an iframe (page viewer web part). ``` I would go with building web parts, however user controls and smart part are probably quicker, and quickest still is infopath, but inf...
309,680
<p>I have the following code that creates two objects (ProfileManager and EmployerManager) where the object EmployerManager is supposed to inherit from the object ProfileManager. However, when I do alert(pm instanceof ProfileManager); it returns false.</p> <pre><code>function ProfileFactory(profileType) { switch(...
[ { "answer_id": 309716, "author": "EndangeredMassa", "author_id": 106, "author_profile": "https://Stackoverflow.com/users/106", "pm_score": 2, "selected": false, "text": "<p>I've been using something similar to Dean Edward's Base.js model.\n<a href=\"http://dean.edwards.name/weblog/2006/0...
2008/11/21
[ "https://Stackoverflow.com/questions/309680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20178/" ]
I have the following code that creates two objects (ProfileManager and EmployerManager) where the object EmployerManager is supposed to inherit from the object ProfileManager. However, when I do alert(pm instanceof ProfileManager); it returns false. ``` function ProfileFactory(profileType) { switch(profileType) ...
Thanks for all of the comments. However, the solution to the problem was found in making this change to the declaration of the EmployerManager: ``` function EmployerManager() { this.controller = 'eprofile.php'; this.anchors = new Array('Industries', 'Employer Profiles', 'Employer Profile'); this.actions =...
309,682
<p>I'm writing a HTML form that's divided in fieldsets, and I need to get the form fields from a specific fiedset in a function.<br> Currently it's like this: </p> <pre><code>function conta(Fieldset){ var Inputs = Fieldset.getElementsByTagName("input"); var Selects = Fieldset.getElementsByTagName("select"...
[ { "answer_id": 309691, "author": "Ryan Eastabrook", "author_id": 105, "author_profile": "https://Stackoverflow.com/users/105", "pm_score": 0, "selected": false, "text": "<p>Haven't tested this and don't know how it would work, but you could use JQuery here to select all the elements into...
2008/11/21
[ "https://Stackoverflow.com/questions/309682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9835/" ]
I'm writing a HTML form that's divided in fieldsets, and I need to get the form fields from a specific fiedset in a function. Currently it's like this: ``` function conta(Fieldset){ var Inputs = Fieldset.getElementsByTagName("input"); var Selects = Fieldset.getElementsByTagName("select"); /* Doin...
@Ryan is on the right track if you want to use jQuery (and I would), but I'd suggest something more along the lines of: ``` $('fieldset#fieldset1 > input[type=text]').each( function() { ... do something for text inputs } ); $('fieldset#fieldset1 > input[type=radio]').each( function() { ... do something f...
309,683
<p>I have a page with a few fields and a runtime-generated image on it. The contents of this page are inside an UpdatePanel. There is a button to take the user to a secondary page, which has a button that calls javascript:history.go(-1) when clicked.</p> <p>The problem is, the first page does a full request instead of...
[ { "answer_id": 309691, "author": "Ryan Eastabrook", "author_id": 105, "author_profile": "https://Stackoverflow.com/users/105", "pm_score": 0, "selected": false, "text": "<p>Haven't tested this and don't know how it would work, but you could use JQuery here to select all the elements into...
2008/11/21
[ "https://Stackoverflow.com/questions/309683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a page with a few fields and a runtime-generated image on it. The contents of this page are inside an UpdatePanel. There is a button to take the user to a secondary page, which has a button that calls javascript:history.go(-1) when clicked. The problem is, the first page does a full request instead of a postbac...
@Ryan is on the right track if you want to use jQuery (and I would), but I'd suggest something more along the lines of: ``` $('fieldset#fieldset1 > input[type=text]').each( function() { ... do something for text inputs } ); $('fieldset#fieldset1 > input[type=radio]').each( function() { ... do something f...
309,706
<p>So i'm not really sure why this is happening but I'm running through some DataRows where I have the control name, property, and value that I want to set. Everything works fine except when I set the TEXT property of a button. For some reason, the click event is called...</p> <p>Here's some of the code I've got:</p> ...
[ { "answer_id": 309766, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "<p>I can't reproduce this with a simple short but complete program:</p>\n\n<pre><code>using System;\nusing System.Drawing...
2008/11/21
[ "https://Stackoverflow.com/questions/309706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21828/" ]
So i'm not really sure why this is happening but I'm running through some DataRows where I have the control name, property, and value that I want to set. Everything works fine except when I set the TEXT property of a button. For some reason, the click event is called... Here's some of the code I've got: ``` string co...
I can't reproduce this with a simple short but complete program: ``` using System; using System.Drawing; using System.Reflection; using System.Windows.Forms; class Test { static void Main() { Button goButton = new Button { Text = "Go!", Location = new Point(5, 5) }; ...
309,713
<p>I'm using a Flash TextField control to display some HTML content inside a Flash presentation to be shown on a large touch-screen kiosk. Unfortunately, if any image tag in the displayed HTML content points to a non-existent image, a dialogue is shown with the error message </p> <pre><code>Error #2044: Unhandled IOEr...
[ { "answer_id": 329881, "author": "aaaidan", "author_id": 26331, "author_profile": "https://Stackoverflow.com/users/26331", "pm_score": -1, "selected": false, "text": "<p>This is a problem I'm also dealing with: it's a real annoyance. I'd really like to be able to catch all the errors. I ...
2008/11/21
[ "https://Stackoverflow.com/questions/309713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7526/" ]
I'm using a Flash TextField control to display some HTML content inside a Flash presentation to be shown on a large touch-screen kiosk. Unfortunately, if any image tag in the displayed HTML content points to a non-existent image, a dialogue is shown with the error message ``` Error #2044: Unhandled IOErrorEvent:. tex...
You can add ID's to images ``` html.htmlText = "Bogus image: <img src=\"foo.jpg\" id="image" />"; ``` And then setup IOErrorEvent handler to each image in HTML ``` var loader:Loader = html.getImageReference("image") as Loader; if(loader){ loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, functi...
309,723
<p>Is there a way to view the list of <em>recent documents</em> you've opened in Vim?</p> <p>I realize I could view the cursor <em>jump list</em>, <code>:ju</code>, and then go to a cursor position in the list but this is not ideal because there will be multiple listings of the same document in the list.</p> <p>Is ther...
[ { "answer_id": 309738, "author": "Craig Lebakken", "author_id": 33130, "author_profile": "https://Stackoverflow.com/users/33130", "pm_score": 5, "selected": false, "text": "<p>The Most Recently Used (MRU) plugin provides an easy access to a list of \nrecently opened/edited files in Vim. ...
2008/11/21
[ "https://Stackoverflow.com/questions/309723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16973/" ]
Is there a way to view the list of *recent documents* you've opened in Vim? I realize I could view the cursor *jump list*, `:ju`, and then go to a cursor position in the list but this is not ideal because there will be multiple listings of the same document in the list. Is there another command which would do what I'...
Don't use a plugin, unless you want a nice menu. From [Vim Documentation: Starting](http://vimdoc.sourceforge.net/htmldoc/starting.html#:oldfiles) (or `:help old`): ``` :ol[dfiles] ``` Then to open one of the listed files, use: `'0`, `'1`, `'2`, ... `'9` --- List the files that have marks stored in the `viminfo` f...
309,734
<p>I need to be able to take an arbitrary text input that may have a byte order marker (BOM) on it to mark its encoding, and output it as ASCII. We have some old tools that don't understand BOM's and I need to send them ASCII-only data.</p> <p>Now, I just got done writing this code and I just can't quite believe the i...
[ { "answer_id": 309791, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": true, "text": "<p>If you've got i_fileBytes in memory already, you can just check whether or not it starts with a BOM, and then convert ...
2008/11/21
[ "https://Stackoverflow.com/questions/309734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14582/" ]
I need to be able to take an arbitrary text input that may have a byte order marker (BOM) on it to mark its encoding, and output it as ASCII. We have some old tools that don't understand BOM's and I need to send them ASCII-only data. Now, I just got done writing this code and I just can't quite believe the inefficienc...
If you've got i\_fileBytes in memory already, you can just check whether or not it starts with a BOM, and then convert either the whole of it or just the bit after the BOM using `Encoding.Unicode.GetString`. (Use the overload which lets you specify an index and length.) So as code: ``` int start = (i_fileBytes[0] == ...
309,737
<p>I'm using the Apache Commons EqualsBuilder to build the equals method for a non-static Java inner class. For example:</p> <pre><code>import org.apache.commons.lang.builder.EqualsBuilder; public class Foo { public class Bar { private Bar() {} public Foo getMyFoo() { return Foo.this ...
[ { "answer_id": 309847, "author": "Dave DiFranco", "author_id": 30547, "author_profile": "https://Stackoverflow.com/users/30547", "pm_score": 4, "selected": true, "text": "<p>No. </p>\n\n<p>The best way is probably what you suggested: add a getFoo() method to your inner class.</p>\n" },...
2008/11/21
[ "https://Stackoverflow.com/questions/309737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/390636/" ]
I'm using the Apache Commons EqualsBuilder to build the equals method for a non-static Java inner class. For example: ``` import org.apache.commons.lang.builder.EqualsBuilder; public class Foo { public class Bar { private Bar() {} public Foo getMyFoo() { return Foo.this } ...
No. The best way is probably what you suggested: add a getFoo() method to your inner class.
309,740
<p>I read about this ages ago but never tried it now I can't remember if this is possible or not. Is it possible to extend a class from two parents on php5 e.g.</p> <p>class_d extends class_c and class_b</p> <p>moreover can you do this if class_c and class_b are themselves extended from class_a ... so you get somethi...
[ { "answer_id": 309847, "author": "Dave DiFranco", "author_id": 30547, "author_profile": "https://Stackoverflow.com/users/30547", "pm_score": 4, "selected": true, "text": "<p>No. </p>\n\n<p>The best way is probably what you suggested: add a getFoo() method to your inner class.</p>\n" },...
2008/11/21
[ "https://Stackoverflow.com/questions/309740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I read about this ages ago but never tried it now I can't remember if this is possible or not. Is it possible to extend a class from two parents on php5 e.g. class\_d extends class\_c and class\_b moreover can you do this if class\_c and class\_b are themselves extended from class\_a ... so you get something like thi...
No. The best way is probably what you suggested: add a getFoo() method to your inner class.
309,744
<p>Is there a basic php method that accepts a URL and retrieves the date last modified from the header? </p> <p>It would seem like something php can do, but I'm not sure which object to check.</p> <p>Thanks</p>
[ { "answer_id": 309770, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 3, "selected": false, "text": "<p>Give this a go.. using <a href=\"http://www.php.net/curl\" rel=\"nofollow noreferrer\">cURL</a>.</p>\n\n<pre><code>$c = cu...
2008/11/21
[ "https://Stackoverflow.com/questions/309744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26577/" ]
Is there a basic php method that accepts a URL and retrieves the date last modified from the header? It would seem like something php can do, but I'm not sure which object to check. Thanks
Give this a go.. using [cURL](http://www.php.net/curl). ``` $c = curl_init('http://...'); curl_setopt($c, CURLOPT_HEADER, 1); // Include the header curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); // Return the result instead of printing it $result = curl_exec($c); if (curl_errno($c)) die(curl_error($c)); // $result ...
309,745
<p>How do I check to see if a variable is a number, or contains a number, in UNIX shell?</p>
[ { "answer_id": 309789, "author": "Piotr Lesnicki", "author_id": 38796, "author_profile": "https://Stackoverflow.com/users/38796", "pm_score": 4, "selected": false, "text": "<p>Shell variables have no type, so the simplest way is to use the return type <code>test</code> command:</p>\n\n<p...
2008/11/21
[ "https://Stackoverflow.com/questions/309745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I check to see if a variable is a number, or contains a number, in UNIX shell?
``` if echo $var | egrep -q '^[0-9]+$'; then # $var is a number else # $var is not a number fi ```
309,769
<p>What's the most common way to deal with a series of block elements that need to be on a line (if javascript needs to be able to modify their widths, for example)? What are the pros and cons to applying float:left to each of them vs. using positioning to place them?</p>
[ { "answer_id": 309793, "author": "Sebastian Hoitz", "author_id": 9535, "author_profile": "https://Stackoverflow.com/users/9535", "pm_score": 1, "selected": false, "text": "<p>The parent container does not stretch with them unless it is also assigned a float tag or there is a br with clea...
2008/11/21
[ "https://Stackoverflow.com/questions/309769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32771/" ]
What's the most common way to deal with a series of block elements that need to be on a line (if javascript needs to be able to modify their widths, for example)? What are the pros and cons to applying float:left to each of them vs. using positioning to place them?
Floating would be my choice, but it really depends on what you wish to achieve. If you can provide a more specific example I would be able to give you a clear reason as to what and why I think you should use. However here is a brief set of pros and cons that I have come accross (I'm assuming that by positioning you mea...
309,775
<p>I want to design a class that will parse a string into tokens that are meaningful to my application.</p> <p>How do I design it?</p> <ol> <li>Provide a ctor that accepts a string, provide a Parse method and provide methods (let's call them "minor") that return individual tokens, count of tokens etc. OR</li> <li>Pro...
[ { "answer_id": 309806, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 2, "selected": false, "text": "<p>I would have a separate class with a Parse method that takes a string and converts it into a separate new object wi...
2008/11/21
[ "https://Stackoverflow.com/questions/309775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to design a class that will parse a string into tokens that are meaningful to my application. How do I design it? 1. Provide a ctor that accepts a string, provide a Parse method and provide methods (let's call them "minor") that return individual tokens, count of tokens etc. OR 2. Provide a ctor that accepts n...
I would have a separate class with a Parse method that takes a string and converts it into a separate new object with a property for each value from the string. ``` ValueObject values = parsingClass.Parse(theString); ```
309,784
<p>I have a table with a TEXT column where the contents is just strings of CSV numbers. Example ",1,76,77,115," Each string can have an arbitrary number of numbers.</p> <p>I am trying to set up Full Text Indexing so that I can search this column rapidly. This works great. Instead of running queries with</p> <pre><cod...
[ { "answer_id": 312815, "author": "galuvian", "author_id": 39755, "author_profile": "https://Stackoverflow.com/users/39755", "pm_score": 0, "selected": false, "text": "<p>I fixed my own problem, although I'm not exactly sure what fixed it.</p>\n\n<p>I dropped my table and populated a new ...
2008/11/21
[ "https://Stackoverflow.com/questions/309784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39755/" ]
I have a table with a TEXT column where the contents is just strings of CSV numbers. Example ",1,76,77,115," Each string can have an arbitrary number of numbers. I am trying to set up Full Text Indexing so that I can search this column rapidly. This works great. Instead of running queries with ``` where MY_COL LIKE '...
Working with relational databases that way is going to hurt. Use a proper schema. Either store the values in different rows or use an array datatype for the column. That will make solving the problem trivial.
309,790
<p>In Java, what is the difference between the twin methods?</p> <pre><code>public void methodA() throws AnException { //do something throw new AnException(); } public void methodA() { //do the same thing throw new AnException(); } </code></pre> <p>I have a intuition that it has something to do with ...
[ { "answer_id": 309829, "author": "Dave DiFranco", "author_id": 30547, "author_profile": "https://Stackoverflow.com/users/30547", "pm_score": 4, "selected": false, "text": "<p>If AnException is a checked exception (in other words, if it doesn't extend RuntimeException) then methodA won't ...
2008/11/21
[ "https://Stackoverflow.com/questions/309790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8203/" ]
In Java, what is the difference between the twin methods? ``` public void methodA() throws AnException { //do something throw new AnException(); } public void methodA() { //do the same thing throw new AnException(); } ``` I have a intuition that it has something to do with being a well-designed meth...
If AnException is a checked exception (in other words, if it doesn't extend RuntimeException) then methodA won't compile. Checked exceptions must always be declated. If AnException is an unchecked exception (if it does extend RuntimeException), then either is allowed by the java compiler, and either is interpreted equ...
309,815
<p>How do you control the column width in a gridview control in ASP.NET 2.0?</p>
[ { "answer_id": 309863, "author": "DCNYAM", "author_id": 30419, "author_profile": "https://Stackoverflow.com/users/30419", "pm_score": 2, "selected": false, "text": "<p>I do it using the header style for the column:</p>\n\n<pre><code>&lt;asp:BoundField HeaderText=\"Name\" DataField=\"Last...
2008/11/21
[ "https://Stackoverflow.com/questions/309815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do you control the column width in a gridview control in ASP.NET 2.0?
You can use the HeaderStyle-Width, ItemStyle-Width or FooterStyle-Width properties. These can be applied to all the columns or per-column basis. ``` <asp:GridView ID="GridView1" runat="server"> <HeaderStyle Width="10%" /> <RowStyle Width="10%" /> <FooterStyle Width="10%" /> <Columns...
309,818
<p>I'm try to extract info from a MySQL DB into a MS SQL DB. The DB is a mess and the developer is no longer available.</p> <p>All dates are in char fields, and I use </p> <pre><code>SELECT concat( mid(DueDate, 7, 4), mid(DueDate, 4, 2), mid(DueDate, 1, 2)) as DueDate FROM TableName </code></pre> <p>to get the date ...
[ { "answer_id": 309823, "author": "Dónal", "author_id": 2648, "author_profile": "https://Stackoverflow.com/users/2648", "pm_score": 5, "selected": true, "text": "<p>In MySQL you can convert a string to a date using the <a href=\"http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functio...
2008/11/21
[ "https://Stackoverflow.com/questions/309818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2385/" ]
I'm try to extract info from a MySQL DB into a MS SQL DB. The DB is a mess and the developer is no longer available. All dates are in char fields, and I use ``` SELECT concat( mid(DueDate, 7, 4), mid(DueDate, 4, 2), mid(DueDate, 1, 2)) as DueDate FROM TableName ``` to get the date field in a format so MS sql serve...
In MySQL you can convert a string to a date using the [STR\_TO\_DATE](http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_str-to-date) function. An example usage is: ``` mysql> SELECT STR_TO_DATE('04/31/2004', '%m/%d/%Y'); -> '2004-04-31' ``` To get the current date in MySQL simply ...
309,834
<p>I have a read query that I execute within a transaction so that I can specify the isolation level. Once the query is complete, what should I do?</p> <ul> <li>Commit the transaction </li> <li>Rollback the transaction</li> <li>Do nothing (which will cause the transaction to be rolled back at the end of the using blo...
[ { "answer_id": 309843, "author": "Brett McCann", "author_id": 9293, "author_profile": "https://Stackoverflow.com/users/9293", "pm_score": 0, "selected": false, "text": "<p>Given that a READ does not change state, I would do nothing. Performing a commit will do nothing, except waste a cy...
2008/11/21
[ "https://Stackoverflow.com/questions/309834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8739/" ]
I have a read query that I execute within a transaction so that I can specify the isolation level. Once the query is complete, what should I do? * Commit the transaction * Rollback the transaction * Do nothing (which will cause the transaction to be rolled back at the end of the using block) What are the implications...
You commit. Period. There's no other sensible alternative. If you started a transaction, you should close it. Committing releases any locks you may have had, and is equally sensible with ReadUncommitted or Serializable isolation levels. Relying on implicit rollback - while perhaps technically equivalent - is just poor ...
309,880
<p>I'm trying to create a custom transition, to serve as a replacement for a default transition you would get here, for example:</p> <pre><code>[self.navigationController pushViewController:someController animated:YES]; </code></pre> <p>I have prepared an OpenGL-based view that performs an effect on some static textu...
[ { "answer_id": 312112, "author": "Jeffrey Forbes", "author_id": 28019, "author_profile": "https://Stackoverflow.com/users/28019", "pm_score": 3, "selected": true, "text": "<p>While I cannot completely answer your question without doing some more research of my own, I can help a bit:</p>\...
2008/11/21
[ "https://Stackoverflow.com/questions/309880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9804/" ]
I'm trying to create a custom transition, to serve as a replacement for a default transition you would get here, for example: ``` [self.navigationController pushViewController:someController animated:YES]; ``` I have prepared an OpenGL-based view that performs an effect on some static texture mapped to a plane (let'...
While I cannot completely answer your question without doing some more research of my own, I can help a bit: -In order to get the view of a UINavigationController, you need to take a screenshot. The easiest way to do this is by grabbing it into a UIImage: ``` UIGraphicsBeginImageContext(self.view.frame.size); [[self....
309,884
<p>The code golf series seem to be fairly popular. I ran across some code that converts a number to its word representation. Some examples would be (powers of 2 for programming fun):</p> <ul> <li>2 -> Two</li> <li>1024 -> One Thousand Twenty Four</li> <li>1048576 -> One Million Forty Eight Thousand Five Hundred Seve...
[ { "answer_id": 309894, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 1, "selected": false, "text": "<p>I can't find the file now, but this was an Intro to Programming problem (late in the term) where I went to school. ...
2008/11/21
[ "https://Stackoverflow.com/questions/309884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2470/" ]
The code golf series seem to be fairly popular. I ran across some code that converts a number to its word representation. Some examples would be (powers of 2 for programming fun): * 2 -> Two * 1024 -> One Thousand Twenty Four * 1048576 -> One Million Forty Eight Thousand Five Hundred Seventy Six The algorithm my co-w...
Lisp, using only standard functions: ``` (format nil "~r" 1234) ==> "one thousand two hundred thirty-four" ``` Bonus: ``` (format nil "~@r" 1234) ==> "MCCXXXIV" ```
309,892
<p>I ran into an interesting behavior recently. It seems that if I override .equals() to take a parameter other than Object, it doesn't get called. Can anyone explain to me why this is happening? It seems to violate my understanding of polymorphism in OOP, but maybe I'm missing something.</p> <p>Here's much simpler...
[ { "answer_id": 309920, "author": "p3t0r", "author_id": 16685, "author_profile": "https://Stackoverflow.com/users/16685", "pm_score": 4, "selected": false, "text": "<p>equals(Object) is overriding a super method; you can <em>not</em> override a super method without using the exact same si...
2008/11/21
[ "https://Stackoverflow.com/questions/309892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18511/" ]
I ran into an interesting behavior recently. It seems that if I override .equals() to take a parameter other than Object, it doesn't get called. Can anyone explain to me why this is happening? It seems to violate my understanding of polymorphism in OOP, but maybe I'm missing something. Here's much simpler code that sh...
You're mixing up "overriding" and "overloading". Overriding -- adding a replacement definition of an existing method for purposes of polymorphism. The method must have the same signature. The signature consists of the name and argument types. Overridden methods are selected at runtime based on the runtime type of the ...
309,897
<p>I have HTML that includes symbols such as the Trademark "TM" as superscript (&trade;). In normal HTML, I would use <code>"&amp;trade;"</code> or <code>&amp;#153;</code> to display the Trademark TM. However, I can find no way to import HTML like this into Flex and have it displayed correctly. I am having similar issu...
[ { "answer_id": 315040, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": true, "text": "<p>Okay, this is a tricky one. I just finished a project where we used this open-source library to display HTML: <a href=\"ht...
2008/11/21
[ "https://Stackoverflow.com/questions/309897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31298/" ]
I have HTML that includes symbols such as the Trademark "TM" as superscript (™). In normal HTML, I would use `"&trade;"` or `&#153;` to display the Trademark TM. However, I can find no way to import HTML like this into Flex and have it displayed correctly. I am having similar issues with the `<li>` tag. My HTML: ``` ...
Okay, this is a tricky one. I just finished a project where we used this open-source library to display HTML: <http://code.google.com/p/flex-htmlfilter> It handles lists, tables, etc, and is pretty easy to work with. But, I don't think it supports the trademark symbol. It does support some of the others, though. I'm ...
309,921
<p>Wondering how to open many new windows with Javascript. I have found plenty of places on the internet that show you how to open a new browser window with Javascript, but I want to open a new UNIQUE window. For Example.</p> <p>I have two links on a page. the user clicks on both links and they are both opened in t...
[ { "answer_id": 309926, "author": "Gavin Miller", "author_id": 33226, "author_profile": "https://Stackoverflow.com/users/33226", "pm_score": 3, "selected": true, "text": "<pre><code>window.open('page.html','WindowTitle','width=400,height=200')\n</code></pre>\n" }, { "answer_id": 3...
2008/11/21
[ "https://Stackoverflow.com/questions/309921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7644/" ]
Wondering how to open many new windows with Javascript. I have found plenty of places on the internet that show you how to open a new browser window with Javascript, but I want to open a new UNIQUE window. For Example. I have two links on a page. the user clicks on both links and they are both opened in the same windo...
``` window.open('page.html','WindowTitle','width=400,height=200') ```
309,930
<p>I've got a database with three tables: Books (with book details, PK is CopyID), Keywords (list of keywords, PK is ID) and KeywordsLink which is the many-many link table between Books and Keywords with the fields ID, BookID and KeywordID.</p> <p>I'm trying to make an advanced search form in my app where you can sear...
[ { "answer_id": 309942, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 1, "selected": false, "text": "<pre><code>SELECT * FROM books WHERE title LIKE'%Joel%' OR bookid IN \n (SELECT bookid FROM keywordslink WHERE ...
2008/11/21
[ "https://Stackoverflow.com/questions/309930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1912/" ]
I've got a database with three tables: Books (with book details, PK is CopyID), Keywords (list of keywords, PK is ID) and KeywordsLink which is the many-many link table between Books and Keywords with the fields ID, BookID and KeywordID. I'm trying to make an advanced search form in my app where you can search on vari...
What you've done here is made a cartesian result set by having the tables joined with the commas but not having any join criteria. Switch your statements to use outer join statements and that should allow you to reference the keywords. I don't know your schema, but maybe something like this would work: ``` SELECT *...
309,939
<p>I have a class library with all my database logic. My DAL/BLL. </p> <p>I have a few web projects which will use the same database and classes, so I thought it was a good idea to abstract the data layer into its own project.</p> <p>However, when it comes to adding functionality to classes for certain projects I w...
[ { "answer_id": 309944, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 8, "selected": true, "text": "<p>You can't write a partial class across projects. A partial class is a compile-time-only piece of syntactic sugar - the...
2008/11/21
[ "https://Stackoverflow.com/questions/309939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26931/" ]
I have a class library with all my database logic. My DAL/BLL. I have a few web projects which will use the same database and classes, so I thought it was a good idea to abstract the data layer into its own project. However, when it comes to adding functionality to classes for certain projects I want to add methods ...
You can't write a partial class across projects. A partial class is a compile-time-only piece of syntactic sugar - the whole type ends up in a single assembly, i.e. one project. (Your original DAL file would have to declare the class to be partial as well, by the way.)
309,943
<p>Need to an expression that returns only things with an "I" followed by either a "J" or a "V" (No Quotes) and then a minimum of 1 number up to 3 numbers.</p> <p>I J### <br /> I V### <br /> I J## <br /> I V## <br /> I J# <br /> I v# <br /></p>
[ { "answer_id": 309952, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 3, "selected": true, "text": "<p>Depends on your flavor</p>\n\n<pre><code>I(J|V)[0-9]{1,3}\n</code></pre>\n\n<p>Do you also need a space after an \"I\"?</p...
2008/11/21
[ "https://Stackoverflow.com/questions/309943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38349/" ]
Need to an expression that returns only things with an "I" followed by either a "J" or a "V" (No Quotes) and then a minimum of 1 number up to 3 numbers. I J### I V### I J## I V## I J# I v#
Depends on your flavor ``` I(J|V)[0-9]{1,3} ``` Do you also need a space after an "I"? ``` I (J|V)[0-9]{1,3} ```
309,945
<p>For some reasons, I would like to do an explicit quoting of a string value (becoming a part of constructed SQL query) instead of waiting for implicit quotation performed by <code>cursor.execute</code> method on contents of its second parameter.</p> <p>By "implicit quotation" I mean:</p> <pre><code>value = "Unsafe ...
[ { "answer_id": 310011, "author": "davidavr", "author_id": 8247, "author_profile": "https://Stackoverflow.com/users/8247", "pm_score": 0, "selected": false, "text": "<p>This is going to be DB dependent. In the case of MySQLdb, for example, the <code>connection</code> class has a <code>lit...
2008/11/21
[ "https://Stackoverflow.com/questions/309945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26141/" ]
For some reasons, I would like to do an explicit quoting of a string value (becoming a part of constructed SQL query) instead of waiting for implicit quotation performed by `cursor.execute` method on contents of its second parameter. By "implicit quotation" I mean: ``` value = "Unsafe string" query = "SELECT * FROM s...
Ok, so I was curious and went and looked at the source of psycopg2. Turns out I didn't have to go further than the examples folder :) And yes, this is psycopg2-specific. Basically, if you just want to quote a string you'd do this: ``` from psycopg2.extensions import adapt print adapt("Hello World'; DROP DATABASE Wor...
309,953
<p>Is it possible to catch an error when using JSONP with jQuery? I've tried both the $.getJSON and $.ajax methods but neither will catch the 404 error I'm testing. Here is what I've tried (keep in mind that these all work successfully, but I want to handle the case when it fails):</p> <pre><code>jQuery.ajax({ typ...
[ { "answer_id": 310084, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 7, "selected": true, "text": "<p>It seems that JSONP requests that don't return a successful result never trigger any event, success or failure, an...
2008/11/21
[ "https://Stackoverflow.com/questions/309953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12367/" ]
Is it possible to catch an error when using JSONP with jQuery? I've tried both the $.getJSON and $.ajax methods but neither will catch the 404 error I'm testing. Here is what I've tried (keep in mind that these all work successfully, but I want to handle the case when it fails): ``` jQuery.ajax({ type: "GET", ...
It seems that JSONP requests that don't return a successful result never trigger any event, success or failure, and for better or worse that's apparently by design. After searching their bug tracker, there's [a patch](http://dev.jquery.com/attachment/ticket/3442/jsonabort.patch) which may be a possible solution using ...
309,979
<p>I have a LinkButton that has to postback to perform some logic.</p> <p>Once it is finished, instead of loading the page back up in the browser, I want to leave it alone and pop open a new window.</p> <p>So far, the best idea I've had is to put the LinkButton in an UpdatePanel, and have it render some JavaScript ou...
[ { "answer_id": 309994, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 1, "selected": false, "text": "<p>One thing you could try is to have your LinkButton OnClick event do its processing, then register a Page.ClientScript.Regist...
2008/11/21
[ "https://Stackoverflow.com/questions/309979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
I have a LinkButton that has to postback to perform some logic. Once it is finished, instead of loading the page back up in the browser, I want to leave it alone and pop open a new window. So far, the best idea I've had is to put the LinkButton in an UpdatePanel, and have it render some JavaScript out when it reloads...
Use LinkButton.PostBackUrl to set a different page to POST to, and some client script to get a new window (and the old target restored so that future postbacks work normally). The 2nd page can use PreviousPage to get access to any needed state from the original page. ``` <script runat="server"> void lnk_Click(objec...
309,991
<p>I have a just one table mapped in a datacontext. Here's the property and attribute on the column of interest:</p> <pre><code>[Column(Storage="_CustomerNumber", DbType="VarChar(25)")] public string CustomerNumber { </code></pre> <p>This column is, in fact, a varchar(25) and has an index.</p> <p>I've got some simp...
[ { "answer_id": 310024, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 0, "selected": false, "text": "<p>Here's what I've got as a possible work around. I'm interested in seeing other solutions as well:</p>\n\n<pre><code>List&l...
2008/11/21
[ "https://Stackoverflow.com/questions/309991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8155/" ]
I have a just one table mapped in a datacontext. Here's the property and attribute on the column of interest: ``` [Column(Storage="_CustomerNumber", DbType="VarChar(25)")] public string CustomerNumber { ``` This column is, in fact, a varchar(25) and has an index. I've got some simple code: ``` DataClasses1DataCont...
Here's the way I solve this problem now-a-days. This converts the parameters to the desired type and then runs the query. It generates the same sql as originally generated, just with different parameter types. ``` DbCommand myCommand = myDataContext.GetCommand(query); foreach (DbParameter dbParameter in myCommand.Par...
310,002
<p>Yes, there is a similar question <a href="https://stackoverflow.com/questions/42554/cant-get-my-event-to-fire">here</a>. However, that question doesn't seem to have code attached to it (though it might have at some point; I see answers alluding to code), and the accepted answer (and other advice) on it aren't gettin...
[ { "answer_id": 310038, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": "<p>What do you mean by “cfront tool”? Cfront was the first C++ compiler. But since failure to add exception support, ...
2008/11/21
[ "https://Stackoverflow.com/questions/310002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14048/" ]
Yes, there is a similar question [here](https://stackoverflow.com/questions/42554/cant-get-my-event-to-fire). However, that question doesn't seem to have code attached to it (though it might have at some point; I see answers alluding to code), and the accepted answer (and other advice) on it aren't getting me where I n...
What do you mean by “cfront tool”? Cfront was the first C++ compiler. But since failure to add exception support, [it has been discontinued](http://en.wikipedia.org/wiki/Cfront). Modern C++ is way beyond the scope of Cfront. > > For any other modern languages? > > > And what do you mean by that? If you mean wheth...
310,017
<p>I see two types of examples in various places. One uses form fields like</p> <blockquote> <p>curl -X PUT -d "phone=123.456.7890" "<a href="http://127.0.0.1/services/rest/user/123" rel="nofollow noreferrer">http://127.0.0.1/services/rest/user/123</a>"</p> </blockquote> <p>and the other uses an XML content like (s...
[ { "answer_id": 310172, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 0, "selected": false, "text": "<p>In the second example URL does not refer to a specific resource, so IMHO it's not RESTful.</p>\n\n<p>If you fix that, th...
2008/11/21
[ "https://Stackoverflow.com/questions/310017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39784/" ]
I see two types of examples in various places. One uses form fields like > > curl -X PUT -d "phone=123.456.7890" "<http://127.0.0.1/services/rest/user/123>" > > > and the other uses an XML content like (some variation of) this > > echo "<user><id>123</id><phone>123.456.7890</phone></user>" | curl -X PUT -d @- "...
It could be something like JSON(P)? (I'm not sure about exact syntax): ``` $ echo '{user: {id: 123, phone: 123.456.7890}}' |\ > curl -X PUT -d @- 'http://127.0.0.1/services/rest/user/' ``` Or ``` $ echo '{phone: 123.456.7890}' |\ > curl -X PUT -d @- 'http://127.0.0.1/services/rest/user/123.json' ```
310,018
<p>Is there any GUI-based tools to assist you with writing and maintaining the configuration file? Any code tools to codegen the config file? What are the best ways to make this a little bit easier? Are most people just using Castle ActiveRecord now?</p>
[ { "answer_id": 310050, "author": "Howard Pinsley", "author_id": 7961, "author_profile": "https://Stackoverflow.com/users/7961", "pm_score": 1, "selected": false, "text": "<p>I'm just learning NHibernate myself (from the <a href=\"http://www.summerofnhibernate.com/\" rel=\"nofollow norefe...
2008/11/21
[ "https://Stackoverflow.com/questions/310018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36590/" ]
Is there any GUI-based tools to assist you with writing and maintaining the configuration file? Any code tools to codegen the config file? What are the best ways to make this a little bit easier? Are most people just using Castle ActiveRecord now?
For code/mapping generation there are a number of templates for [MyGeneration](http://www.mygenerationsoftware.com) for creating configuration files and/or classes from a database. [CodeSmith](http://www.codesmithtools.com/) has NHibernate templates as well, but CodeSmith is not free, so MyGeneration has an advantage t...
310,032
<p>When printing a single character in a C program, must I use "%1s" in the format string? Can I use something like "%c"?</p>
[ { "answer_id": 310040, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 7, "selected": false, "text": "<p>yes, <code>%c</code> will print a single char:</p>\n\n<pre><code>printf(\"%c\", 'h');\n</code></pre>\n\n<p>also, <co...
2008/11/21
[ "https://Stackoverflow.com/questions/310032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37952/" ]
When printing a single character in a C program, must I use "%1s" in the format string? Can I use something like "%c"?
yes, `%c` will print a single char: ``` printf("%c", 'h'); ``` also, `putchar`/`putc` will work too. From "man putchar": ``` #include <stdio.h> int fputc(int c, FILE *stream); int putc(int c, FILE *stream); int putchar(int c); * fputc() writes the character c, cast to an unsigned char, to stream. * putc() is equi...
310,035
<p>Is tilde a legitimate character in an XML SOAP message? I get a <code>SAXParseException:Content not allowed in prolog</code>. I included most of the SOAP message just in case I'm barking up the wrong tree.</p> <pre><code>POST /... HTTP/1.0 Content-Type: text/xml; charset=utf-8 Accept: application/soap+xml, applica...
[ { "answer_id": 310052, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p>Is tilde a legitimate character in an XML SOAP message?</p>\n</blockquote>\n\n<p>Yes. The error me...
2008/11/21
[ "https://Stackoverflow.com/questions/310035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39787/" ]
Is tilde a legitimate character in an XML SOAP message? I get a `SAXParseException:Content not allowed in prolog`. I included most of the SOAP message just in case I'm barking up the wrong tree. ``` POST /... HTTP/1.0 Content-Type: text/xml; charset=utf-8 Accept: application/soap+xml, application/dime, multipart/relat...
I'm not sure about SOAP messages, but when processing XML files, one other possible reason for this error message is if there is a [BOM (byte order marker)](http://en.wikipedia.org/wiki/Byte_Order_Mark) at the beginning of the file - some XML parsers can't handle that if not configured or invoked correctly. Check for t...
310,036
<p>Evidently hash keys are compared in a case-sensitive manner.</p> <pre><code>$ perl -e '%hash = ( FOO =&gt; 1 ); printf "%s\n", ( exists $hash{foo} ) ? "Yes" : "No";' No $ perl -e '%hash = ( FOO =&gt; 1 ); printf "%s\n", ( exists $hash{FOO} ) ? "Yes" : "No";' Yes </code></pre> <p>Is there a setting to change that ...
[ { "answer_id": 310051, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 3, "selected": false, "text": "<p>The hash of a string and the same string with the case changed are not equal. So you can't do what you want, short ...
2008/11/21
[ "https://Stackoverflow.com/questions/310036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39153/" ]
Evidently hash keys are compared in a case-sensitive manner. ``` $ perl -e '%hash = ( FOO => 1 ); printf "%s\n", ( exists $hash{foo} ) ? "Yes" : "No";' No $ perl -e '%hash = ( FOO => 1 ); printf "%s\n", ( exists $hash{FOO} ) ? "Yes" : "No";' Yes ``` Is there a setting to change that for the current script?
You will have to use a tied hash. For example [Hash::Case::Preserve](http://search.cpan.org/~markov/Hash-Case/lib/Hash/Case/Preserve.pod).
310,062
<p>I can handle the process that file part, but before I go crazy, has someone built a simple wcf service &amp; client (running under windows services or IIS) that I can use to upload a file, and download that file back? with the fewest lines of code? (C# or VB)</p> <p>compression &amp; encryption would be cool, but i...
[ { "answer_id": 310955, "author": "Mitch Baker", "author_id": 37896, "author_profile": "https://Stackoverflow.com/users/37896", "pm_score": 3, "selected": true, "text": "<p>You should be able to do this fairly easily. The service contract would probably look like this: </p>\n\n<pre><code...
2008/11/21
[ "https://Stackoverflow.com/questions/310062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3522/" ]
I can handle the process that file part, but before I go crazy, has someone built a simple wcf service & client (running under windows services or IIS) that I can use to upload a file, and download that file back? with the fewest lines of code? (C# or VB) compression & encryption would be cool, but i'll layer that on ...
You should be able to do this fairly easily. The service contract would probably look like this: ``` [ServiceContract] public interface IFileService { [OperationContract] byte[] ProcessFile(byte[] FileData); } ``` The encryption part could be handled natively by WCF using transport level security. I don't belie...
310,090
<p>For 2 child template files inheriting a block, the <code>{{ block.super }}</code> does not resolve</p> <p>Python 2.5.2, Django 1.0, Windows XP SP3</p> <p>Sample skeleton code for files involved:</p> <ol> <li><code>base.html</code></li> <li><code>item_base.html</code></li> <li><code>show_info_for_all_items.html</c...
[ { "answer_id": 310123, "author": "David Arcos", "author_id": 30300, "author_profile": "https://Stackoverflow.com/users/30300", "pm_score": 4, "selected": true, "text": "<blockquote>\n <p>Does Django offer something like\n INCLUDE (...)</p>\n</blockquote>\n\n<p>Yes!, just take a look at...
2008/11/21
[ "https://Stackoverflow.com/questions/310090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11452/" ]
For 2 child template files inheriting a block, the `{{ block.super }}` does not resolve Python 2.5.2, Django 1.0, Windows XP SP3 Sample skeleton code for files involved: 1. `base.html` 2. `item_base.html` 3. `show_info_for_all_items.html` 4. `show_info_for_single_item.html` FILE : `base.html` ``` {% block content ...
> > Does Django offer something like > INCLUDE (...) > > > Yes!, just take a look at the documentation: [include](http://docs.djangoproject.com/en/dev/ref/templates/builtins/#include) Put the common code block in *foo.html*, and then, in each template: ``` {% include 'foo.html' %} ```
310,094
<p>In the tradition of <a href="https://stackoverflow.com/questions/309492/user-defined-functions-sql-server-2005-flagged-incorrectly-as-non-deterministic">this question</a> and in light of <a href="http://msdn.microsoft.com/en-us/library/ms178091(SQL.90).aspx" rel="nofollow noreferrer">the documentation</a>, how does ...
[ { "answer_id": 310113, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 3, "selected": false, "text": "<p>From the articles you linked:</p>\n\n<blockquote>\n <p>To be deterministic, the style parameter must be a constant. Additi...
2008/11/21
[ "https://Stackoverflow.com/questions/310094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18255/" ]
In the tradition of [this question](https://stackoverflow.com/questions/309492/user-defined-functions-sql-server-2005-flagged-incorrectly-as-non-deterministic) and in light of [the documentation](http://msdn.microsoft.com/en-us/library/ms178091(SQL.90).aspx), how does one make this function deterministic: ``` ALTER FU...
BOL says that `CONVERT` *is* deterministic with datetimes if the *style* parameter is specified. So if you change the first UDF to: ``` RETURN CONVERT(datetime, CONVERT(varchar, @DATA_DT_ID), 112) ``` Then it *should* be deterministic, if I understand the docs correctly. Presumably, the same trick could be used in ...
310,105
<p>I've been discussing a code style issue with a friend. We have a series of packages that implement an interface by returning a specific type of value via a named subroutine. For example:</p> <pre><code>package Foo::Type::Bar; sub generate_foo { # about 5-100 lines of code return stuff here; } </code></pre> ...
[ { "answer_id": 310127, "author": "nicerobot", "author_id": 23056, "author_profile": "https://Stackoverflow.com/users/23056", "pm_score": 2, "selected": false, "text": "<p>In my opinion, it depends on scale and is very subjective. The larger a system becomes, the more advantageous it is t...
2008/11/21
[ "https://Stackoverflow.com/questions/310105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31100/" ]
I've been discussing a code style issue with a friend. We have a series of packages that implement an interface by returning a specific type of value via a named subroutine. For example: ``` package Foo::Type::Bar; sub generate_foo { # about 5-100 lines of code return stuff here; } ``` So you can go: ``` my...
I think you should upgrade to Moose if you are asking these questions. There you'll be able to define your interface by creating a role or class with appropriate abstract methods. I agree with you that doing this can add valuable information. In Java there is the concept of a "marker interface," which is an empty inte...
310,108
<p>Following is some obviously-defective code for which I think the compiler should emit a diagnostic. But neither <code>gcc</code> nor <code>g++</code> does, even with all the warnings options I could think of: <code>-pedantic -Wall -Wextra</code></p> <pre><code>#include &lt;stdio.h&gt; short f(short x) { retur...
[ { "answer_id": 310163, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 0, "selected": false, "text": "<p>I would strongly suggest investing in PC-lint/FlexeLint from <a href=\"http://gimpel.com/\" rel=\"nofollow norefe...
2008/11/21
[ "https://Stackoverflow.com/questions/310108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4323/" ]
Following is some obviously-defective code for which I think the compiler should emit a diagnostic. But neither `gcc` nor `g++` does, even with all the warnings options I could think of: `-pedantic -Wall -Wextra` ``` #include <stdio.h> short f(short x) { return x; } int main() { long x = 0x10000007; /* big...
Use -Wconversion -- the problem is an implicit cast (conversion) from long x to short when the function f(short x) is called [not printf], and -Wconversion will say something like "cast from long to short may alter value". .. Edit: just saw your note. -Wconversion results in a warning for me, using g++ 4.3.2 on Linux...
310,115
<p>I am writing a script which is likely to be modified by users. Currently I am storing the configuration settings inside the script. It exists in the form of a hash-of-hashes.</p> <p>I would like to guard against people accidentally using lowercase characters in the hash keys, because that will break my script.</p> ...
[ { "answer_id": 310134, "author": "Andy Lester", "author_id": 8454, "author_profile": "https://Stackoverflow.com/users/8454", "pm_score": 4, "selected": false, "text": "<p>Walk through the hash and replace any lowercase keys with their uppercase equivalents, and delete the old ones. Roug...
2008/11/21
[ "https://Stackoverflow.com/questions/310115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39153/" ]
I am writing a script which is likely to be modified by users. Currently I am storing the configuration settings inside the script. It exists in the form of a hash-of-hashes. I would like to guard against people accidentally using lowercase characters in the hash keys, because that will break my script. It would be s...
Andy's answer is a good answer, except he `uc`s every key, and then `uc`s it again if it doesn't match. This `uc`s it once: ``` %hash = map { uc $_ => $hash{$_} } keys %hash; ``` But since you spoke of users *storing keys*, a tie is a much more sure way, even if slower. ``` package UCaseHash; require Tie::Hash; ...
310,117
<p><strong>Caveat:</strong> I try all the posibilities listed here: <a href="https://stackoverflow.com/questions/254002/how-can-i-ignore-everything-under-a-folder-in-mercurial">How can I ignore everything under a folder in Mercurial</a>.<br> None works as I hope. </p> <p>I want to ignore every thing under the folder ...
[ { "answer_id": 310416, "author": "Nathan Kitchen", "author_id": 31000, "author_profile": "https://Stackoverflow.com/users/31000", "pm_score": 2, "selected": false, "text": "<p>You can use zero-width negative look-ahead and look-behind assertions to specify that you want to ignore <code>t...
2008/11/21
[ "https://Stackoverflow.com/questions/310117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1356709/" ]
**Caveat:** I try all the posibilities listed here: [How can I ignore everything under a folder in Mercurial](https://stackoverflow.com/questions/254002/how-can-i-ignore-everything-under-a-folder-in-mercurial). None works as I hope. I want to ignore every thing under the folder `test`. But not ignore `srcProject\t...
Try it without the slash after the caret in the regexp version. ``` ^test/ ``` Here's a test: ``` ~$ mkdir hg-folder-ignore ~$ cd hg-folder-ignore ~/hg-folder-ignore$ echo '^test/' > .hgignore ~/hg-folder-ignore$ hg init ~/hg-folder-ignore$ mkdir test ~/hg-folder-ignore$ touch test/ignoreme ~/hg-folder-ignore$ mkdi...
310,121
<p>In HTML in the td of a table you can break text by using <code>&lt;BR&gt;</code> between the words. This also works in the HeaderText of a TemplateItem but not the HeaderText of a BoundField. How do I break up the Header text of a BoundField.</p>
[ { "answer_id": 310145, "author": "Aleris", "author_id": 20417, "author_profile": "https://Stackoverflow.com/users/20417", "pm_score": 6, "selected": true, "text": "<p>Set <code>HtmlEncode = false</code> inside the <code>BoundField</code></p>\n\n<pre><code> &lt;asp:BoundField DataField=\"...
2008/11/21
[ "https://Stackoverflow.com/questions/310121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4491/" ]
In HTML in the td of a table you can break text by using `<BR>` between the words. This also works in the HeaderText of a TemplateItem but not the HeaderText of a BoundField. How do I break up the Header text of a BoundField.
Set `HtmlEncode = false` inside the `BoundField` ``` <asp:BoundField DataField="SomeDataField" HeaderText="SomeHeader<br />(OtherData)" HtmlEncode="false" /> ``` `BoundField.HtmlEncode` is true by default which means that if HTML is added in the text it will be encoded. If HtmlEncode is set to ...
310,126
<p>I have a project with a post build event:</p> <pre><code>copy $(ProjectDir)DbVerse\Lunaverse.DbVerse.*.exe $(TargetDir) </code></pre> <p>It works fine every time on my machine. I have a new developer who always gets the "exited with code 1" error. I had her run the same command in a DOS prompt, and it worked fi...
[ { "answer_id": 310148, "author": "Asher", "author_id": 38265, "author_profile": "https://Stackoverflow.com/users/38265", "pm_score": 4, "selected": false, "text": "<p>Get <a href=\"http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx\" rel=\"noreferrer\">process monitor from Sys...
2008/11/21
[ "https://Stackoverflow.com/questions/310126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29493/" ]
I have a project with a post build event: ``` copy $(ProjectDir)DbVerse\Lunaverse.DbVerse.*.exe $(TargetDir) ``` It works fine every time on my machine. I have a new developer who always gets the "exited with code 1" error. I had her run the same command in a DOS prompt, and it worked fine. What could be causing th...
She had a space in one of the folder names in her path, and no quotes around it.
310,160
<p>I'm experimenting with WCF Services, and have come across a problem with passing Interfaces.</p> <p>This works:</p> <pre><code>[ServiceContract] public interface IHomeService { [OperationContract] string GetString(); } </code></pre> <p>but this doesn't:</p> <pre><code>[ServiceContract] public interface I...
[ { "answer_id": 310179, "author": "Brian Genisio", "author_id": 36687, "author_profile": "https://Stackoverflow.com/users/36687", "pm_score": 5, "selected": true, "text": "<p>You need to tell the WCF serializer which class to use to serialize the interface</p>\n\n<pre><code>[ServiceKnownT...
2008/11/21
[ "https://Stackoverflow.com/questions/310160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33431/" ]
I'm experimenting with WCF Services, and have come across a problem with passing Interfaces. This works: ``` [ServiceContract] public interface IHomeService { [OperationContract] string GetString(); } ``` but this doesn't: ``` [ServiceContract] public interface IHomeService { [OperationContract] ID...
You need to tell the WCF serializer which class to use to serialize the interface ``` [ServiceKnownType(typeof(ConcreteDeviceType)] ```
310,161
<p>Is there a way to determine (.NET preferably) if the current user is a domain user account or local user account?</p> <p>Ahead of time - I don not know the domain name this is running on so I can't just look for DOMAIN\Username v COMPUTER\Username. </p> <p>Part of the answer could be determining the DOMAIN or COMP...
[ { "answer_id": 310170, "author": "DCNYAM", "author_id": 30419, "author_profile": "https://Stackoverflow.com/users/30419", "pm_score": 0, "selected": false, "text": "<p>You could look at the full username, which is either &lt;domain name&gt;\\&lt;username&gt; or &lt;machine name&gt;\\&lt;...
2008/11/21
[ "https://Stackoverflow.com/questions/310161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20198/" ]
Is there a way to determine (.NET preferably) if the current user is a domain user account or local user account? Ahead of time - I don not know the domain name this is running on so I can't just look for DOMAIN\Username v COMPUTER\Username. Part of the answer could be determining the DOMAIN or COMPUTER name from co...
you can use [Environment.UserDomainName](http://msdn.microsoft.com/en-us/library/system.environment.userdomainname.aspx) the MSDN documentation explains the exact behavior of this property in each case (domain/local account) You can use this property in conjunction with other properties like Environment.MachineName to...
310,167
<p>At the XmlSerializer constructor line the below causes an InvalidOperationException which also complains about not having a default accesor implemented for the generic type.</p> <pre><code>Queue&lt;MyData&gt; myDataQueue = new Queue&lt;MyData&gt;(); // Populate the queue here XmlSerializer mySerializer = new X...
[ { "answer_id": 310171, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "<p>It would be easier (and more appropriate IMO) to serialize the <em>data</em> from the queue - perhaps in a flat arr...
2008/11/21
[ "https://Stackoverflow.com/questions/310167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16260/" ]
At the XmlSerializer constructor line the below causes an InvalidOperationException which also complains about not having a default accesor implemented for the generic type. ``` Queue<MyData> myDataQueue = new Queue<MyData>(); // Populate the queue here XmlSerializer mySerializer = new XmlSerializer(myDataQueue.Ge...
It would be easier (and more appropriate IMO) to serialize the *data* from the queue - perhaps in a flat array or `List<T>`. Since `Queue<T>` implements `IEnumerable<T>`, you should be able to use: ``` List<T> list = new List<T>(queue); ```
310,178
<p>I need to design a SOAP api (my first one!). What are the best practices regarding errors returned to the caller.</p> <p>Assuming an api as follow</p> <pre><code>[WebMethod] public List&lt;someClass&gt; GetList(String param1) { } </code></pre> <p>Should I</p> <ul> <li>Throw an exception. Let the SOAP infrastruct...
[ { "answer_id": 310356, "author": "Guy Starbuck", "author_id": 2194, "author_profile": "https://Stackoverflow.com/users/2194", "pm_score": 2, "selected": false, "text": "<p>Probably the most appropriate SOA pattern to follow would be a Fault Contract, which is essentially a Data Contract ...
2008/11/21
[ "https://Stackoverflow.com/questions/310178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37955/" ]
I need to design a SOAP api (my first one!). What are the best practices regarding errors returned to the caller. Assuming an api as follow ``` [WebMethod] public List<someClass> GetList(String param1) { } ``` Should I * Throw an exception. Let the SOAP infrastructure generate a SOAP fault -- and the caller would ...
Probably the most appropriate SOA pattern to follow would be a Fault Contract, which is essentially a Data Contract that is wrapped in the SOAPException. I am posting examples in .NET, since it looks like that is what you are using (and that is what I know :) ) In WCF, you can define a DataContract, then decorate you...
310,191
<p>My log file is:</p> <pre><code> Wed Nov 12 blah blah blah blah cat1 Wed Nov 12 blah blah blah blah Wed Nov 12 blah blah blah blah Wed Nov 12 blah blah blah blah cat2 more blah blah even more blah blah Wed Nov 12 blah blah blah blah cat3 Wed Nov 12 blah blah blah blah cat4 </code></pre> <p>I want to...
[ { "answer_id": 310266, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 1, "selected": false, "text": "<p>Assuming your log file does not contain the control characters <code>'\\01'</code> and <code>'\\02'</code>, and t...
2008/11/21
[ "https://Stackoverflow.com/questions/310191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39529/" ]
My log file is: ``` Wed Nov 12 blah blah blah blah cat1 Wed Nov 12 blah blah blah blah Wed Nov 12 blah blah blah blah Wed Nov 12 blah blah blah blah cat2 more blah blah even more blah blah Wed Nov 12 blah blah blah blah cat3 Wed Nov 12 blah blah blah blah cat4 ``` I want to parse out the full multil...
if you say every line that starts with space is a continuation of the folling its easy with (g)awk (this is from my memory, so maybe it contains some minor typos, and for better readability with some additional linebreaks): ``` awk " BEGIN { multiline = 0;} ! /^ / { if (whatever) { print; mult...
310,199
<p>I am battling regular expressions now as I type. </p> <p>I would like to determine a pattern for the following example file: <code>b410cv11_test.ext</code>. I want to be able to do a search for files that match the pattern of the example file aforementioned. Where do I start (so lost and confused) and what is the b...
[ { "answer_id": 310211, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 2, "selected": false, "text": "<p>To avoid confusion, read the following, in order.</p>\n\n<p>First, you have the <a href=\"http://www.python.org/doc/2.5....
2008/11/21
[ "https://Stackoverflow.com/questions/310199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37804/" ]
I am battling regular expressions now as I type. I would like to determine a pattern for the following example file: `b410cv11_test.ext`. I want to be able to do a search for files that match the pattern of the example file aforementioned. Where do I start (so lost and confused) and what is the best way of arriving a...
Now that you have a human readable description of your file name, it's quite straight forward to translate it into a regular expression (at least in this case ;) > > must start with > > > The caret (`^`) anchors a regular expression to the beginning of what you want to match, so your re has to start with this sym...
310,226
<p>We currently have a heated internal debate as to whether the actual .NET assembly name should include the code's version number (e.g. CodeName02.exe or CompanyName.CodeName02.dll). Does anyone know of an authoritative source, like Microsoft, that provides guidance on this issue?</p>
[ { "answer_id": 310233, "author": "ahockley", "author_id": 8209, "author_profile": "https://Stackoverflow.com/users/8209", "pm_score": 2, "selected": false, "text": "<p>I'm not aware of anything authoritative, but it would seem to me that using a consistent name would simplify everything ...
2008/11/21
[ "https://Stackoverflow.com/questions/310226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21410/" ]
We currently have a heated internal debate as to whether the actual .NET assembly name should include the code's version number (e.g. CodeName02.exe or CompanyName.CodeName02.dll). Does anyone know of an authoritative source, like Microsoft, that provides guidance on this issue?
This is what the Properties/AssemblyInfo.cs file is for. There are two versions within that file, the file version and the assembly version: ``` [assembly: AssemblyVersion("1.1.0.256"] [assembly: AssemblyFileVersion("1.1.0.256")] ``` Once these are set you can use them to track the versions of you binaries. It is e...
310,245
<p>I'm trying to get a stored procedure to work for a co-worker who is out sick (and thus can't be asked for guidance).</p> <p>I have a SQL Server 2005 database that has this exact procedure, and I'm trying to make the scripts to convert a test database to match this dev database. My script has several lines like:</p...
[ { "answer_id": 315330, "author": "thursdaysgeek", "author_id": 22523, "author_profile": "https://Stackoverflow.com/users/22523", "pm_score": 1, "selected": true, "text": "<p>(I can't accept my own answer, but this was the solution that worked for me.)</p>\n\n<p>If I change the one offend...
2008/11/21
[ "https://Stackoverflow.com/questions/310245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22523/" ]
I'm trying to get a stored procedure to work for a co-worker who is out sick (and thus can't be asked for guidance). I have a SQL Server 2005 database that has this exact procedure, and I'm trying to make the scripts to convert a test database to match this dev database. My script has several lines like: ``` CAST(REL...
(I can't accept my own answer, but this was the solution that worked for me.) If I change the one offending line from ``` CAST(TRACER_YIELD AS FLOAT(10,3)), ``` to ``` CAST(TRACER_YIELD AS FLOAT), ``` it works. Will it work properly? *Update:* It was an error by the original programmer. So the change to not ...