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 |
|---|---|---|---|---|---|---|
467,364 | <p>I've got a small problem. I've got a good setup which mod rewrites all requests to the site - the only thing is it also rewrites directories which I don't want to be included.</p>
<p>I'm using this code in my .htaccess file:</p>
<pre><code>RewriteEngine on
RewriteRule ^([^/\.]+)/?$ index.php?section=$1 [L]
Rewrite... | [
{
"answer_id": 467377,
"author": "Sean Bright",
"author_id": 21926,
"author_profile": "https://Stackoverflow.com/users/21926",
"pm_score": 2,
"selected": false,
"text": "<p>Use <a href=\"http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond\" rel=\"nofollow noreferrer\">Rewri... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3654/"
] | I've got a small problem. I've got a good setup which mod rewrites all requests to the site - the only thing is it also rewrites directories which I don't want to be included.
I'm using this code in my .htaccess file:
```
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ index.php?section=$1 [L]
RewriteRule ^([^/\.]+)/([^/\... | Use [RewriteCond](http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond)
```
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(access|edit)/
RewriteRule ^([^/\.]+)/?$ index.php?section=$1 [L]
...
```
(This is untested, but it should be close) |
467,365 | <p><a href="http://book.merbist.com" rel="nofollow noreferrer">The Merb Open Source Book</a> has a <a href="http://book.merbist.com/merb-more/authentication" rel="nofollow noreferrer">chapter on authentication</a>. However, the <a href="http://book.merbist.com/merb-more/authentication#testing_an_authenticated_request" ... | [
{
"answer_id": 467377,
"author": "Sean Bright",
"author_id": 21926,
"author_profile": "https://Stackoverflow.com/users/21926",
"pm_score": 2,
"selected": false,
"text": "<p>Use <a href=\"http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond\" rel=\"nofollow noreferrer\">Rewri... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5830/"
] | [The Merb Open Source Book](http://book.merbist.com) has a [chapter on authentication](http://book.merbist.com/merb-more/authentication). However, the [testing an authenticated request section](http://book.merbist.com/merb-more/authentication#testing_an_authenticated_request) example only shows what you can do for form... | Use [RewriteCond](http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond)
```
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(access|edit)/
RewriteRule ^([^/\.]+)/?$ index.php?section=$1 [L]
...
```
(This is untested, but it should be close) |
467,367 | <p>I want to write a console or Click Once WinForms app that will programmatically stop and/or start a windows service on a remote box.</p>
<p>Both boxes are running .NET 3.5 - what .NET API's are available to accomplish this?</p>
| [
{
"answer_id": 467387,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 2,
"selected": false,
"text": "<p>You can use <code>System.Management</code> APIs (WMI) to control services remotely. WMI is the generic API to do administra... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | I want to write a console or Click Once WinForms app that will programmatically stop and/or start a windows service on a remote box.
Both boxes are running .NET 3.5 - what .NET API's are available to accomplish this? | in C#:
```
var sc = new System.ServiceProcess.ServiceController("MyService", "MyRemoteMachine");
sc.Start();
sc.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Running);
sc.Stop();
sc.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Stopped);
``` |
467,375 | <p>One thing I like about <a href="http://www.eclipse.org/eclipselink/" rel="noreferrer">EclipseLink</a> has this great thing called the <a href="http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#Batch" rel="noreferrer">batch query hint</a>, which I'm yet to find a Hibernate equivalent of.</p>
<p>Basical... | [
{
"answer_id": 467675,
"author": "Stephen Denne",
"author_id": 11721,
"author_profile": "https://Stackoverflow.com/users/11721",
"pm_score": 0,
"selected": false,
"text": "<p>There are two things I know of that might help:</p>\n\n<p>1) <code>hibernate.default_batch_fetch_size</code></p>\... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18393/"
] | One thing I like about [EclipseLink](http://www.eclipse.org/eclipselink/) has this great thing called the [batch query hint](http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#Batch), which I'm yet to find a Hibernate equivalent of.
Basically doing a whole bunch of joins gets messy real quick and you end ... | There isn't one. |
467,389 | <p>While trying to get to all green, i got the following suggestion by Resharper.</p>
<p>Original code:</p>
<pre><code> static public string ToNonNullString(this XmlAttribute attr)
{
if (attr != null)
return attr.Value;
else
return string.Empty;
}
</code></pre>
<p>S... | [
{
"answer_id": 467406,
"author": "cbp",
"author_id": 21966,
"author_profile": "https://Stackoverflow.com/users/21966",
"pm_score": 3,
"selected": false,
"text": "<p>I agree that the first version of your code is more readable.</p>\n\n<p>I've found Resharper suggestions in these cases to ... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9382/"
] | While trying to get to all green, i got the following suggestion by Resharper.
Original code:
```
static public string ToNonNullString(this XmlAttribute attr)
{
if (attr != null)
return attr.Value;
else
return string.Empty;
}
```
Suggestion: remove redundant 'else... | Technically Resharper is correct in that the "else" is unnecessary, I prefer the former version though as the intent is more obvious.
Having said that, I'd rather go with:
```
return attr != null ? attr.Value : string.Empty;
``` |
467,396 | <p>I am using Berkeley sockets (both: Internet domain and Unix domain) and I was wondering if the server can use the same sockets for reading the request and writing a response to the client. Or should the client create an other socket to wait for the replay and the server connect to it after processing the message rec... | [
{
"answer_id": 467413,
"author": "Rowland Shaw",
"author_id": 50447,
"author_profile": "https://Stackoverflow.com/users/50447",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried it? It looks like it should work when you actually put the code in where indicated</p>\n"
},
{
... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26699/"
] | I am using Berkeley sockets (both: Internet domain and Unix domain) and I was wondering if the server can use the same sockets for reading the request and writing a response to the client. Or should the client create an other socket to wait for the replay and the server connect to it after processing the message receiv... | You can use the same socket BUT your program is set up to have the server read EVERYTHING the client sends before attempting to reply. So the loop in the server won't complete until the client closes the write side of its socket so the server gets an EOF (0 bytes read), and thus the server will never send back its resp... |
467,410 | <p>I am load testing my website. The site calls to a WCF service running on the same box using clientCredentialType="Windows". Everything works until I reach a certain load (which is not even very high), then I get the following error:</p>
<blockquote>
<p>System.ServiceModel.Security.MessageSecurityException:
Th... | [
{
"answer_id": 467462,
"author": "Tad Donaghe",
"author_id": 1572436,
"author_profile": "https://Stackoverflow.com/users/1572436",
"pm_score": 1,
"selected": false,
"text": "<p>Is your Service a Sessionful Service or do you not worry about keeping state between calls? If you don't have ... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29493/"
] | I am load testing my website. The site calls to a WCF service running on the same box using clientCredentialType="Windows". Everything works until I reach a certain load (which is not even very high), then I get the following error:
>
> System.ServiceModel.Security.MessageSecurityException:
> The HTTP request was fo... | The problem was, argh, that I was running the test on my dev box, which is XP, which uses IIS 5, which has a limit of 10 connections. |
467,438 | <p>If I'm not mistaken - the conventions of ASP.NET MVC seem to want me to do the following for a controller view.</p>
<p>Thats to day I create 'Products' directory into which I place my 'Index' view. I then create a 'ProductsController' and create an 'Index' method on it which returns a View. Returning just View() wi... | [
{
"answer_id": 467466,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 0,
"selected": false,
"text": "<p>It's just a pattern. Use the pattern, but make it work for you. Personally, I like to have my Views named by their... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | If I'm not mistaken - the conventions of ASP.NET MVC seem to want me to do the following for a controller view.
Thats to day I create 'Products' directory into which I place my 'Index' view. I then create a 'ProductsController' and create an 'Index' method on it which returns a View. Returning just View() with no argu... | Having the default action for each controller have the same name just simplifies the routing (check global.asax). Also, it all things (Products, Books, Contacts, ...) use actions/views with the same name for the same function, then the code becomes much easier to navigate and understand. This use of convention is espec... |
467,446 | <p>What exactly do I need delegates, and threads for?</p>
| [
{
"answer_id": 467456,
"author": "BBetances",
"author_id": 53599,
"author_profile": "https://Stackoverflow.com/users/53599",
"pm_score": 2,
"selected": false,
"text": "<p>Delegates are used to add methods to events dynamically.</p>\n\n<p>Threads run inside of processes, and allow you to ... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56555/"
] | What exactly do I need delegates, and threads for? | Delegates act as the logical (but safe) equivalent to function-pointers; they allow you to talk about an operation in an abstract way. The typical example of this is events, but I'm going to use a more "functional programming" example: searching in a list:
```
List<Person> people = ...
Person fred = people.Find( x => ... |
467,449 | <p>(With reference to <a href="https://stackoverflow.com/questions/467223/in-drupal-how-to-make-login-state-consistent-between-browser-pages-and-embedded#467405">this answer</a>:)</p>
<p>When I POST with a URLRequest, does it automatically include cookies from the browser session in which Flash is hosted? If not, how... | [
{
"answer_id": 467559,
"author": "Christian Nunciato",
"author_id": 32129,
"author_profile": "https://Stackoverflow.com/users/32129",
"pm_score": 4,
"selected": true,
"text": "<p>Provided the cookie domains (of the page hosting the Flash control and the URL to which you're posting) match... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4540/"
] | (With reference to [this answer](https://stackoverflow.com/questions/467223/in-drupal-how-to-make-login-state-consistent-between-browser-pages-and-embedded#467405):)
When I POST with a URLRequest, does it automatically include cookies from the browser session in which Flash is hosted? If not, how can I make it include... | Provided the cookie domains (of the page hosting the Flash control and the URL to which you're posting) match, then yes, the browser cookies get sent with the request by default. As a quick example ([working version here](http://test.enunciato.org/cookietest.cfm)), I've thrown together a simple ColdFusion page hosting ... |
467,452 | <p>I'd like to avoid mysqldump since that outputs in a form that is only convenient for mysql to read. CSV seems more universal (one file per table is fine). But if there are advantages to mysqldump, I'm all ears. Also, I'd like something I can run from the command line (linux). If that's a mysql script, pointers t... | [
{
"answer_id": 467465,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 8,
"selected": true,
"text": "<p>If you can cope with table-at-a-time, and your data is not binary, use the <code>-B</code> option to the <code>mysql</code... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] | I'd like to avoid mysqldump since that outputs in a form that is only convenient for mysql to read. CSV seems more universal (one file per table is fine). But if there are advantages to mysqldump, I'm all ears. Also, I'd like something I can run from the command line (linux). If that's a mysql script, pointers to how t... | If you can cope with table-at-a-time, and your data is not binary, use the `-B` option to the `mysql` command. With this option it'll generate TSV (tab separated) files which can import into Excel, etc, quite easily:
```
% echo 'SELECT * FROM table' | mysql -B -uxxx -pyyy database
```
Alternatively, if you've got di... |
467,467 | <p>I have multiple lists of strings, <code>IList<string></code>, that I want to consolidate in one list showing distinct string and count for each item (like a dictionary). what is the most efficient way to do this? </p>
| [
{
"answer_id": 467476,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 2,
"selected": true,
"text": "<pre><code>Dictionary<string, int> count = new Dictionary<string, int>();\n\nforeach(IList<int> list in lists... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49632/"
] | I have multiple lists of strings, `IList<string>`, that I want to consolidate in one list showing distinct string and count for each item (like a dictionary). what is the most efficient way to do this? | ```
Dictionary<string, int> count = new Dictionary<string, int>();
foreach(IList<int> list in lists)
foreach(int item in list) {
int value;
if (count.TryGetValue(item, out value))
count[item] = value + 1;
else
count[item] = 1;
}
``` |
467,482 | <p>Any pointers on how I can programmatically get exactly the identical stored procedure source from SQL Server 2005, as when I right-click on that stored procedure in SQL Server Management Studio and select modify?</p>
<p>I'm trying using SMO, but there are some textual differences. The procedure always has CREATE, ... | [
{
"answer_id": 467491,
"author": "keithwarren7",
"author_id": 40714,
"author_profile": "https://Stackoverflow.com/users/40714",
"pm_score": 3,
"selected": false,
"text": "<p>Use the following select statement to get the whole definition:</p>\n<pre><code>select ROUTINE_DEFINITION \n from... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49251/"
] | Any pointers on how I can programmatically get exactly the identical stored procedure source from SQL Server 2005, as when I right-click on that stored procedure in SQL Server Management Studio and select modify?
I'm trying using SMO, but there are some textual differences. The procedure always has CREATE, not ALTER, ... | ```
EXEC sp_helptext 'your procedure name';
```
This avoids the problem with INFORMATION\_SCHEMA approach wherein the stored procedure gets cut off if it is too long.
Update: David writes that this isn't identical to his sproc...perhaps because it returns the lines as 'records' to preserve formatting? If you want to... |
467,516 | <p>I have the following ActiveRecord classes:</p>
<pre><code>class User < ActiveRecord::Base
cattr_accessor :current_user
has_many :batch_records
end
class BatchRecord < ActiveRecord::Base
belongs_to :user
named_scope :current_user, lambda {
{ :conditions => { :user_id => User.current_user &a... | [
{
"answer_id": 467629,
"author": "Chris Lloyd",
"author_id": 42413,
"author_profile": "https://Stackoverflow.com/users/42413",
"pm_score": 2,
"selected": true,
"text": "<p>I think you are going about this the wrong way. Firstly, why do you need to use a named scope? Wont this just do?</p... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14142/"
] | I have the following ActiveRecord classes:
```
class User < ActiveRecord::Base
cattr_accessor :current_user
has_many :batch_records
end
class BatchRecord < ActiveRecord::Base
belongs_to :user
named_scope :current_user, lambda {
{ :conditions => { :user_id => User.current_user && User.current_user.id } }
... | I think you are going about this the wrong way. Firstly, why do you need to use a named scope? Wont this just do?
```
class BatchRecord < ActiveRecord::Base
belongs_to :user
def current_user
self.user.class.current_user
end
end
```
In which case it would be trivial to test. BUT! WTF are you defining `curr... |
467,535 | <p>I'm implementing a prototype of a RESTful API using ASP.NET MVC and apart from the odd bug here and there I've achieve all the requirements I set out at the start, apart from callers being able to use the <code>X-HTTP-Method-Override</code> custom header to override the HTTP method.</p>
<p>What I'd like is that the... | [
{
"answer_id": 467574,
"author": "Kevin",
"author_id": 26620,
"author_profile": "https://Stackoverflow.com/users/26620",
"pm_score": 0,
"selected": false,
"text": "<p>The <code>X-HTTP-Method-Override</code> is a custom header and most likely isn't supported by your web container. </p>\n... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13552/"
] | I'm implementing a prototype of a RESTful API using ASP.NET MVC and apart from the odd bug here and there I've achieve all the requirements I set out at the start, apart from callers being able to use the `X-HTTP-Method-Override` custom header to override the HTTP method.
What I'd like is that the following request...... | You won't be able to use the [AcceptVerbs] attribute as-is since it's tied to the request's actual HTTP verb. Fortunately the [AcceptVerbs] attribute is very simple; you can see the source for yourself at [<http://www.codeplex.com/aspnet/SourceControl/changeset/view/21528#266431>](http://www.codeplex.com/aspnet/SourceC... |
467,579 | <p>Just starting out with Rhino Mocks and im having a very simple problem, how do I mock a class with a void which sets a property?</p>
<pre><code>class SomeClass : ISomeClass
{
private bool _someArg;
public bool SomeProp { get; set; }
public SomeClass(bool someArg)
{
_someArg = someArg;
... | [
{
"answer_id": 467647,
"author": "Scott Pedersen",
"author_id": 16002,
"author_profile": "https://Stackoverflow.com/users/16002",
"pm_score": 2,
"selected": false,
"text": "<p>Depends on how much fidelity you'd like in your mock object. The easy way to do it is to not worry about it and... | 2009/01/21 | [
"https://Stackoverflow.com/questions/467579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38722/"
] | Just starting out with Rhino Mocks and im having a very simple problem, how do I mock a class with a void which sets a property?
```
class SomeClass : ISomeClass
{
private bool _someArg;
public bool SomeProp { get; set; }
public SomeClass(bool someArg)
{
_someArg = someArg;
}
public... | In your example you won't need RhinoMocks because you're apparently testing the functionality of the class under test. Simple unit testing will do instead:
```
[Test]
public void SomeTest()
{
var sc = new SomeClass();
// Instantiate SomeClass as sc object
sc.SomeMethod();
// Call SomeMethod in ... |
467,583 | <p>Assume a listening socket on localhost:80 and a client connecting using: telnet localhost 80</p>
<p>The problem is that I want only to accept a limited number of concurrent clients, assume only one.
After that I simply don't accept any.</p>
<p>The problem that I saw using: netstat -a is that next client connectio... | [
{
"answer_id": 467594,
"author": "Adam Peck",
"author_id": 26658,
"author_profile": "https://Stackoverflow.com/users/26658",
"pm_score": 1,
"selected": false,
"text": "<p>If you stop listening on that port it should not be allowing any more incoming connections. Make sure the listener c... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53294/"
] | Assume a listening socket on localhost:80 and a client connecting using: telnet localhost 80
The problem is that I want only to accept a limited number of concurrent clients, assume only one.
After that I simply don't accept any.
The problem that I saw using: netstat -a is that next client connection was established.... | The `listen()` function has a `backlog` parameter that specifies how many outstanding sockets are allowed to hang around in the operating system kernel waiting for the server to `accept()` them.
On my Linux system the man page for `listen()` says that most of the time the client will get a `connection refused` error -... |
467,603 | <p>I have an HTML table that I use as column headers to a grid view. Clicking on a column header triggers javascript that makes the grid view sort, and an icon showing that the column is sorted shows up next to the column text, similar to below:</p>
<pre><code>|--------------------------------------------------------... | [
{
"answer_id": 467608,
"author": "jerebear",
"author_id": 42979,
"author_profile": "https://Stackoverflow.com/users/42979",
"pm_score": 3,
"selected": true,
"text": "<p>I'm not sure what floats you're adding to the image, but have you tried floating to the right and adding a right-margin... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55992/"
] | I have an HTML table that I use as column headers to a grid view. Clicking on a column header triggers javascript that makes the grid view sort, and an icon showing that the column is sorted shows up next to the column text, similar to below:
```
|-----------------------------------------------------------------------... | I'm not sure what floats you're adding to the image, but have you tried floating to the right and adding a right-margin of about 5 px? That would push it inside. |
467,613 | <p>What is the difference between Parse() and TryParse()?</p>
<pre><code>int number = int.Parse(textBoxNumber.Text);
// The Try-Parse Method
int.TryParse(textBoxNumber.Text, out number);
</code></pre>
<p>Is there some form of error-checking like a Try-Catch Block?</p>
| [
{
"answer_id": 467617,
"author": "M4N",
"author_id": 19635,
"author_profile": "https://Stackoverflow.com/users/19635",
"pm_score": 5,
"selected": false,
"text": "<p>If the string can not be converted to an integer, then</p>\n\n<ul>\n<li><code>int.Parse()</code> will throw an exception</l... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56555/"
] | What is the difference between Parse() and TryParse()?
```
int number = int.Parse(textBoxNumber.Text);
// The Try-Parse Method
int.TryParse(textBoxNumber.Text, out number);
```
Is there some form of error-checking like a Try-Catch Block? | `Parse` throws an exception if it cannot parse the value, whereas `TryParse` returns a `bool` indicating whether it succeeded.
`TryParse` does not just `try`/`catch` internally - the whole point of it is that it is implemented without exceptions so that it is fast. In fact the way it is most likely implemented is that... |
467,622 | <p>I have an FLA file with objects in the library which I have set to be "classes" (In CS3, right click an item in the library select properties, make sure it's set to export for action-script, and has a class name)</p>
<p>For this exercise, let's call the class "MyClass"</p>
<p>If I publish that FLA to an SWC and SW... | [
{
"answer_id": 468169,
"author": "Christian Nunciato",
"author_id": 32129,
"author_profile": "https://Stackoverflow.com/users/32129",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://newmovieclip.wordpress.com/2007/08/23/access-load-library-assets-from-another-swf-in-flash-... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16258/"
] | I have an FLA file with objects in the library which I have set to be "classes" (In CS3, right click an item in the library select properties, make sure it's set to export for action-script, and has a class name)
For this exercise, let's call the class "MyClass"
If I publish that FLA to an SWC and SWF:
I can load th... | To complete Christian's answer:
```
var cls : Class = loader.contentLoaderInfo.applicationDomain.getDefinition("ClassName");
var instance : Object = new cls();
```
Additionally, it's worth noting that you won't get strong typing (ie. it must be declared as Object) unless the class implements interface which is also... |
467,642 | <p>Consider:</p>
<pre><code>public static T GetValueOrDefault<T>(this IDataReader reader, string columnName)
T returnValue = default(T);
</code></pre>
<p>I want to implement something like <a href="http://weblogs.asp.net/skillet/archive/2008/06/18/idatareader-extension-methods.aspx" rel="nofollow noreferrer">... | [
{
"answer_id": 467655,
"author": "Adam Peck",
"author_id": 26658,
"author_profile": "https://Stackoverflow.com/users/26658",
"pm_score": 0,
"selected": false,
"text": "<p>What you are looking at is not \"static T\", but two separate parts.</p>\n\n<ul>\n<li>public denotes the method as pu... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28647/"
] | Consider:
```
public static T GetValueOrDefault<T>(this IDataReader reader, string columnName)
T returnValue = default(T);
```
I want to implement something like [this](http://weblogs.asp.net/skillet/archive/2008/06/18/idatareader-extension-methods.aspx) to check DBNull. I can follow the code fine, but I don't qui... | The equivalent of `static` in VB in `Shared`. Shared methods are usually put in Helper classes, because they do not require an instance of the class to run.
The type T indicates that this is a generic method (this is a new feature in VB 9 and C# 3). A generic method effectively takes a type as an argument or returns a... |
467,649 | <p>I have this Code:</p>
<pre><code>cout << "Your Value is: ";
for ( int x = nStart + 1; x < sBuffer.length(); x++ )
{
if ( sBuffer[ x ] == ',' )
{
nStart = x;
break;
}
cout << sBuffer[ x ]... | [
{
"answer_id": 467676,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 0,
"selected": false,
"text": "<p>You probably want <a href=\"http://www.cplusplus.com/reference/iostream/manipulators/fixed.html\" rel=\"nofollow norefe... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40120/"
] | I have this Code:
```
cout << "Your Value is: ";
for ( int x = nStart + 1; x < sBuffer.length(); x++ )
{
if ( sBuffer[ x ] == ',' )
{
nStart = x;
break;
}
cout << sBuffer[ x ];
}
// setprecision... | It looks like sBuffer is a string or an array of chars, so when you print sBuffer[x], it's treating it as a character instead of a floating point number.
You need to convert the string representation of the number into a double. You can use the `atof` or `strtod` functions from C, or `boost::lexical_cast<double>`. |
467,656 | <p>I've got a multiline textbox and a button below it.</p>
<p>VB.NET, WinForms, .NET 2.0</p>
<p>System.Windows.Forms.Textbox</p>
<p>Multiline = True</p>
<p>AcceptsReturn = True</p>
<p>AcceptsTab = False</p>
<p>CausesValidation = False</p>
<p>No Events explicitly coded.</p>
<p>I'd like the Enter key to insert li... | [
{
"answer_id": 467699,
"author": "Christopher Edwards",
"author_id": 29411,
"author_profile": "https://Stackoverflow.com/users/29411",
"pm_score": 0,
"selected": false,
"text": "<p>It definitely shouldn't do that. The only thing I can think is it's not got enough height to accomodate mu... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57744/"
] | I've got a multiline textbox and a button below it.
VB.NET, WinForms, .NET 2.0
System.Windows.Forms.Textbox
Multiline = True
AcceptsReturn = True
AcceptsTab = False
CausesValidation = False
No Events explicitly coded.
I'd like the Enter key to insert line-feeds and never move the focus to the next control (the ... | Turns out that I had forgotten that I had done this (below) elsewhere on the same form:
```
'http://duncanmackenzie.net/blog/Enter-Instead-of-Tab/default.aspx
Protected Overrides Sub OnKeyUp(ByVal e As System.Windows.Forms.KeyEventArgs)
If e.KeyCode = Keys.Enter Then
e.Handled = True
Me.ProcessTabK... |
467,661 | <p>If I have a table with two foreign key fields to another table, I.E.</p>
<pre><code>Table: User
Field: FK_PrimaryItem_ID
Field: FK_SecondaryItem_ID
Table: Item
Field: ItemID
</code></pre>
<p>When I'm using the entity framework, the generated objects become:</p>
<p>User.Item
and
User.Item1</p>
<p>and I can't d... | [
{
"answer_id": 468533,
"author": "Zhaph - Ben Duguid",
"author_id": 33051,
"author_profile": "https://Stackoverflow.com/users/33051",
"pm_score": 3,
"selected": true,
"text": "<p>I've not found any problems with updating my model once I'd changed the name of the Navigation Properties on ... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11908/"
] | If I have a table with two foreign key fields to another table, I.E.
```
Table: User
Field: FK_PrimaryItem_ID
Field: FK_SecondaryItem_ID
Table: Item
Field: ItemID
```
When I'm using the entity framework, the generated objects become:
User.Item
and
User.Item1
and I can't differentiate between the two of them. I ... | I've not found any problems with updating my model once I'd changed the name of the Navigation Properties on the design surface.
In general, User.Item would be represent the first column the model came to with that foreign key, and User.Item1 would represent the second column.
But as I said, I just went into the mode... |
467,692 | <p>I am looping through some code using a For loop. The iterative variable is "i". I have dimensioned the following variables prior to the For Loop. L1, L2, L3, L4 as strings. I want to reference these strings inside the For loop by somehow referring to "L" & char(i). So like a comparison of a value "Foo" <> "L"... | [
{
"answer_id": 467708,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "<p>What you really want is an array, like this:</p>\n\n<pre><code>Dim L(3) As String ''// index begins at 0, 4 total ... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am looping through some code using a For loop. The iterative variable is "i". I have dimensioned the following variables prior to the For Loop. L1, L2, L3, L4 as strings. I want to reference these strings inside the For loop by somehow referring to "L" & char(i). So like a comparison of a value "Foo" <> "L" & Char(i)... | Instead of creating 4 variables, I would suggest that you create an array. Ex:
```
Dim L(1 To 4) As String
For i = 1 to 4
L(i) = "Whatever"
Next
``` |
467,704 | <p>Are there daily builds of Hibernate that I can download? I need the latest version for a <a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-3636" rel="nofollow noreferrer">bug fix</a> that isn't in the released versions. I'm currently trying to build the latest version but am running in to all s... | [
{
"answer_id": 467708,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "<p>What you really want is an array, like this:</p>\n\n<pre><code>Dim L(3) As String ''// index begins at 0, 4 total ... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24396/"
] | Are there daily builds of Hibernate that I can download? I need the latest version for a [bug fix](http://opensource.atlassian.com/projects/hibernate/browse/HHH-3636) that isn't in the released versions. I'm currently trying to build the latest version but am running in to all sorts of test case failures. If would be f... | Instead of creating 4 variables, I would suggest that you create an array. Ex:
```
Dim L(1 To 4) As String
For i = 1 to 4
L(i) = "Whatever"
Next
``` |
467,738 | <p>I'm writing a log collection / analysis application in Python and I need to write a "rules engine" to match and act on log messages.</p>
<p>It needs to feature:</p>
<ul>
<li>Regular expression matching for the message itself</li>
<li>Arithmetic comparisons for message severity/priority</li>
<li>Boolean operators</... | [
{
"answer_id": 467752,
"author": "Darius Bacon",
"author_id": 27024,
"author_profile": "https://Stackoverflow.com/users/27024",
"pm_score": 0,
"selected": false,
"text": "<p>The only place that's different from Python syntax itself is the <code>message ~ \"program\\\\[\\d+\\\\]: message\... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15061/"
] | I'm writing a log collection / analysis application in Python and I need to write a "rules engine" to match and act on log messages.
It needs to feature:
* Regular expression matching for the message itself
* Arithmetic comparisons for message severity/priority
* Boolean operators
I envision An example rule would pr... | Do not invent yet another rules language.
Either use Python or use some other existing, already debugged and working language like BPEL.
Just write your rules in Python, import them and execute them. Life is simpler, far easier to debug, and you've actually solved the actual log-reading problem without creating anoth... |
467,739 | <p>I'm getting back in touch with my inner (g)vim due to an unscheduled MacBook mother(board) of a meltdown (my emergency backup Linux box won't run TextMate). All told I'm happy with vim's efficiency and power, but I'm mortified at how hard it is to get the kind of word wrap that even stupid HTML textareas achieve wit... | [
{
"answer_id": 467753,
"author": "pixelbeat",
"author_id": 4421,
"author_profile": "https://Stackoverflow.com/users/4421",
"pm_score": 4,
"selected": false,
"text": "<p>To turn on word wrapping:</p>\n\n<pre><code>:set wrap\n:set linebreak\n</code></pre>\n\n<p>To copy & paste the orig... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57750/"
] | I'm getting back in touch with my inner (g)vim due to an unscheduled MacBook mother(board) of a meltdown (my emergency backup Linux box won't run TextMate). All told I'm happy with vim's efficiency and power, but I'm mortified at how hard it is to get the kind of word wrap that even stupid HTML textareas achieve with n... | To turn on word wrapping:
```
:set wrap
:set linebreak
```
To copy & paste the original text and not any padding works for gvim.
For vim in an xterm though, it copies the space padding at EOL (though not the newline).
I thought this should work but it doesn't:
```
:set mouse=a
``` |
467,763 | <p><strong>Note</strong>:</p>
<ul>
<li>No MFC</li>
<li>No ATL</li>
<li>Using Visual C++</li>
</ul>
<p>While attempting a connection between the connection point and the caller's sink, an <b>E_NOTIMPL</b> (0x80004001) was returned.</p>
<p>Illustrated below:</p>
<pre><code>hresult = pConnection->Advise(
... | [
{
"answer_id": 468009,
"author": "Andy",
"author_id": 3857,
"author_profile": "https://Stackoverflow.com/users/3857",
"pm_score": 0,
"selected": false,
"text": "<p>That sounds to me like the connection and/or the object that you want the events of doesn't implement the events interface t... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51078/"
] | **Note**:
* No MFC
* No ATL
* Using Visual C++
While attempting a connection between the connection point and the caller's sink, an **E\_NOTIMPL** (0x80004001) was returned.
Illustrated below:
```
hresult = pConnection->Advise(
pSinkUnk,
&dwAdvise);
```
**... | According to [MSDN](http://msdn.microsoft.com/en-us/library/ms694318(VS.85).aspx), it states that connection points that only allow one connection can return `E_NOTIMPL` from its `EnumConnections()` method. Would it be possible that a connection has already been made for this connection point? Maybe this particular imp... |
467,791 | <p>I know I'm not asking this quite right, either. Please help me better form my question.</p>
<p>I'm having a bit of a hard time getting my mind wrapped around handles -- in some ways, it looks like pointers. But unlike pointers, it seems like I can assign values directly to the handle variable, and it affects the... | [
{
"answer_id": 467845,
"author": "Joe",
"author_id": 21950,
"author_profile": "https://Stackoverflow.com/users/21950",
"pm_score": 2,
"selected": false,
"text": "<p>Side effect of using WriteLine.</p>\n\n<p>just 'y' is being treated like an 'object reference' and probably being interroga... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22329/"
] | I know I'm not asking this quite right, either. Please help me better form my question.
I'm having a bit of a hard time getting my mind wrapped around handles -- in some ways, it looks like pointers. But unlike pointers, it seems like I can assign values directly to the handle variable, and it affects the underlying d... | It's a bit sad that C++/CLI allows this syntax. The int type is a value type, the hat is used for reference types. Your "y" variable does not store an int, it stores System::Object. The compiler automatically generates a boxing instruction when you assign it. Console::WriteLine() has otherwise no problem displaying the... |
467,793 | <p>What libraries, extensions etc. would be required to render a portion of a PDF document to an image file?</p>
<p>Most PHP PDF libraries that I have found center around creating PDF documents, but is there a simple way to render a document to an image format suitable for web use?</p>
<p>Our environment is a LAMP st... | [
{
"answer_id": 467805,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 9,
"selected": true,
"text": "<p>You need <a href=\"http://us3.php.net/imagick\" rel=\"noreferrer\"><code>ImageMagick</code></a> and <a href=\"h... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10942/"
] | What libraries, extensions etc. would be required to render a portion of a PDF document to an image file?
Most PHP PDF libraries that I have found center around creating PDF documents, but is there a simple way to render a document to an image format suitable for web use?
Our environment is a LAMP stack. | You need [`ImageMagick`](http://us3.php.net/imagick) and [`GhostScript`](https://www.ghostscript.com/download.html)
```
<?php
$im = new imagick('file.pdf[0]');
$im->setImageFormat('jpg');
header('Content-Type: image/jpeg');
echo $im;
?>
```
The `[0]` means `page 1`. |
467,794 | <p>XML-RPC unfortunately doesn't support 64-bit ints in the official standard. It seems there are several extensions that add this support.</p>
<p>Do any of them seem to be more popular or better supported? Which extension do you use?</p>
<p>Answers for all languages appreciated.</p>
| [
{
"answer_id": 467839,
"author": "Will Hartung",
"author_id": 13663,
"author_profile": "https://Stackoverflow.com/users/13663",
"pm_score": 0,
"selected": false,
"text": "<p>Does this matter? If you're talking about an \"incompatible\" change, then you're talking about two systems that a... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] | XML-RPC unfortunately doesn't support 64-bit ints in the official standard. It seems there are several extensions that add this support.
Do any of them seem to be more popular or better supported? Which extension do you use?
Answers for all languages appreciated. | Well it seems there's no great answer for this, so we're just making an internal extension that says "integer types are unbounded."
In our python library, I'm commenting out this check:
```
def dump_int(self, value, write):
# in case ints are > 32 bits
## extension: ints can be arbitrarily sized
## if val... |
467,813 | <p>I have the following code:</p>
<pre><code>if(pickedUp == true){
trace("released and picked up" + pickedUpNum);
this.storedClick = false;
this.onMouseMove = null;
this.onMouseDown = null;
this.onMouseUp = null;
this.onEnterFrame = this.refresh;
pickedUpNum++;
if( pickedUpNum > 60) ... | [
{
"answer_id": 467852,
"author": "Luke",
"author_id": 21406,
"author_profile": "https://Stackoverflow.com/users/21406",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not sure I fully understand what you're trying to accomplish because you're not explaining what you expect to happen. ... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55124/"
] | I have the following code:
```
if(pickedUp == true){
trace("released and picked up" + pickedUpNum);
this.storedClick = false;
this.onMouseMove = null;
this.onMouseDown = null;
this.onMouseUp = null;
this.onEnterFrame = this.refresh;
pickedUpNum++;
if( pickedUpNum > 60) pickedUp = false;... | If the code you wrote is in a loop, somehow pickedUp is being set to true AFTER the check for (pickedUp == false). So, what would happen is the next time through the loop (say when pickedUpNum == 61), pickedUp would be true, the true statements would run, and then pickedUp would be set to false again (at the end of the... |
467,815 | <pre><code>class Test {
bool isVal() const {
return isVal;
}
private:
bool isVal;
};
</code></pre>
<p>On Compiling this file it says </p>
<blockquote>
<p>testClass.cpp:9: declaration of `bool
Test::isVal'</p>
<p>testClass.cpp:3: conflicts with
previous declaration `bool
T... | [
{
"answer_id": 467830,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 7,
"selected": true,
"text": "<p>Because C++ is not Java. You can take the address of a member:</p>\n\n<pre><code>&Test::isVal\n</code... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43756/"
] | ```
class Test {
bool isVal() const {
return isVal;
}
private:
bool isVal;
};
```
On Compiling this file it says
>
> testClass.cpp:9: declaration of `bool
> Test::isVal'
>
>
> testClass.cpp:3: conflicts with
> previous declaration `bool
> Test::isVal()'
>
>
>
Although the ... | Because C++ is not Java. You can take the address of a member:
```
&Test::isVal
```
So you can't have two members have the same name, except that you can overload member functions. Even if you could disambiguate that by some kind of cast, the next problem would already arise at other places.
In C++, a lot of peopl... |
467,843 | <p>What are the differences between the following constructs? Why prefer one over the other?</p>
<p>Number one:</p>
<pre><code>Dim byteArray(20) as Byte
</code></pre>
<p>Number two:</p>
<pre><code>Dim byteArray() as Byte = new Byte(20) {}
</code></pre>
<p>Any help would be appreciated. </p>
<p>Thank you.</p>
<... | [
{
"answer_id": 467848,
"author": "Spencer Ruport",
"author_id": 52551,
"author_profile": "https://Stackoverflow.com/users/52551",
"pm_score": 1,
"selected": false,
"text": "<p>There's no difference. Redim is carryover syntax that vb 6 developers are familiar with.</p>\n"
},
{
"an... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50612/"
] | What are the differences between the following constructs? Why prefer one over the other?
Number one:
```
Dim byteArray(20) as Byte
```
Number two:
```
Dim byteArray() as Byte = new Byte(20) {}
```
Any help would be appreciated.
Thank you.
**Edit** - I corrected some code. "ReDim" should be "Dim". | They both allocate 20 bytes on the managed heap.
They both set the identifier 'byteArray' to point to those bytes.
The statement with the "new" operator (clause) allows initialization of the array elements.
```
Dim byteArray() as Byte = new Byte(20) { 1, 2, 3, 4, 5, 6, ... }
```
Incidentally, to allocate an arra... |
467,844 | <p>I have a Flash sprite in my Director project. Under the Properties of that sprite, under both the Member and the Sprite tabs, it has as its name "Assessment". In my Lingo script, I have the following call:</p>
<pre><code>sprite("Assessment").displayGrade(75, 3, 4)
</code></pre>
<p>where displayGrade is a function ... | [
{
"answer_id": 476417,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Try this:</p>\n\n<p>set up a container-content reference to your swf, \nthat is the Flash main timeline:</p>\n\n<pre><code>... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23249/"
] | I have a Flash sprite in my Director project. Under the Properties of that sprite, under both the Member and the Sprite tabs, it has as its name "Assessment". In my Lingo script, I have the following call:
```
sprite("Assessment").displayGrade(75, 3, 4)
```
where displayGrade is a function defined in the Flash objec... | I browsed a little and I found this one:
<http://groups.google.com/group/macromedia.director.basics/browse_thread/thread/85203d2879267fe1?pli=1>
and this too:
<http://dreamweaverforum.info/director/23160-director-11-actionscript-3-a.html>
Of course, you should verify by browsing the Director 11 docs.
Regards,
Vyge... |
467,851 | <p>E,g </p>
<pre><code>class Test {
public:
void setVal(const std::string& str) {
this.isVal = str; //This will error out
}
private:
string isVal;
};
</code></pre>
| [
{
"answer_id": 467853,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 6,
"selected": true,
"text": "<p>In C++, <code>this</code> is a pointer (as opposed to a reference). So you have to say <code>this->isVal</code> instead... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43756/"
] | E,g
```
class Test {
public:
void setVal(const std::string& str) {
this.isVal = str; //This will error out
}
private:
string isVal;
};
``` | In C++, `this` is a pointer (as opposed to a reference). So you have to say `this->isVal` instead. |
467,855 | <p>I've been playing around with ASP.NET MVC with a site containing a Master Page.</p>
<p>I created an MVC user control called <code>ProductThumbnailControl</code>. The user control displays a product and a small thumbnail image. The View is a <code>ViewProduct</code> view which displays full product information - the ... | [
{
"answer_id": 468014,
"author": "Odd",
"author_id": 11908,
"author_profile": "https://Stackoverflow.com/users/11908",
"pm_score": 3,
"selected": true,
"text": "<p>Our master page takes data from the view. We use <a href=\"http://oddiandeveloper.blogspot.com/2008/11/strongly-typed-view-... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | I've been playing around with ASP.NET MVC with a site containing a Master Page.
I created an MVC user control called `ProductThumbnailControl`. The user control displays a product and a small thumbnail image. The View is a `ViewProduct` view which displays full product information - the usercontrol just being a UI ele... | Our master page takes data from the view. We use [strongly typed view names](http://oddiandeveloper.blogspot.com/2008/11/strongly-typed-view-names.html) for our views and in the methods for that implementation we also add standard view data that every page needs from our persistent objects (like the application menu st... |
467,859 | <p>I am trying to get the path to a folder in my website root and save it to a class property when my controller constructor is called:</p>
<pre><code>public TestController:Controller{
string temp;
public TestController(){
temp = "";
}
}
</code></pre>
<p>I have tried the following:</p>
... | [
{
"answer_id": 468175,
"author": "liammclennan",
"author_id": 2785,
"author_profile": "https://Stackoverflow.com/users/2785",
"pm_score": 6,
"selected": true,
"text": "<p>AppDomain.CurrentDomain.BaseDirectory will give you the root of your site. So:</p>\n\n<pre><code>temp = Path.Combine(... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1153/"
] | I am trying to get the path to a folder in my website root and save it to a class property when my controller constructor is called:
```
public TestController:Controller{
string temp;
public TestController(){
temp = "";
}
}
```
I have tried the following:
```
temp = Server.MapPath("~/T... | AppDomain.CurrentDomain.BaseDirectory will give you the root of your site. So:
```
temp = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TheFolder");
```
(Update thanks to Marc Gravell's comment) |
467,879 | <p>I'm attempting to upgrade from Hibernate 3.2 to 3.4, which apparently uses slf4j. Our project currently uses log4j. So my assumption is that I should be using the slf4j-log4j12 wrapped implementation.</p>
<p>The Maven slf4j dependency is:</p>
<pre><code><dependency>
<groupId>org.slf4j</groupId&g... | [
{
"answer_id": 467931,
"author": "duffymo",
"author_id": 37213,
"author_profile": "https://Stackoverflow.com/users/37213",
"pm_score": 0,
"selected": false,
"text": "<p>A Google search found this:</p>\n\n<p><a href=\"http://marc.info/?l=slf4j-user&m=122218775201271&w=2\" rel=\"no... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24396/"
] | I'm attempting to upgrade from Hibernate 3.2 to 3.4, which apparently uses slf4j. Our project currently uses log4j. So my assumption is that I should be using the slf4j-log4j12 wrapped implementation.
The Maven slf4j dependency is:
```
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</arti... | i have no problems with
```
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.1.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3... |
467,881 | <p>I am trying to do something I thought would be simple.</p>
<p>I have a form with two UITextFields on it. I am using the UIReturnKeyNext style on the first. The idea is that when the user fills in the first field, they click Next and I transition them to the next UITextField. I've seen other apps that do this and it... | [
{
"answer_id": 468110,
"author": "Brad The App Guy",
"author_id": 42323,
"author_profile": "https://Stackoverflow.com/users/42323",
"pm_score": 4,
"selected": true,
"text": "<p>Simple. send a becomeFirstResponder message to your other textfield. When the other textfield accepts first r... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37992/"
] | I am trying to do something I thought would be simple.
I have a form with two UITextFields on it. I am using the UIReturnKeyNext style on the first. The idea is that when the user fills in the first field, they click Next and I transition them to the next UITextField. I've seen other apps that do this and it works rea... | Simple. send a becomeFirstResponder message to your other textfield. When the other textfield accepts first responder status, it will receive the information from the keyboard.
For Example:
```
//called when the next button is pressed
//Assume textField1, 2, and 3 are instances of UITextField
-(IBAction) nextPressed:... |
467,882 | <p>I'm trying to decide whether it is better to use static methods for loading/saving objects, or use constructor/instance methods instead.</p>
<p>So, say for object <code>Project</code>, the instance version would be</p>
<pre><code>public Project(path) { // Load project here }
public void Save(path) { // Save projec... | [
{
"answer_id": 467890,
"author": "geowa4",
"author_id": 50214,
"author_profile": "https://Stackoverflow.com/users/50214",
"pm_score": 1,
"selected": false,
"text": "<p>If there is no state to be maintained, only behavior, then use the static approach. However, if the Project object need... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3820/"
] | I'm trying to decide whether it is better to use static methods for loading/saving objects, or use constructor/instance methods instead.
So, say for object `Project`, the instance version would be
```
public Project(path) { // Load project here }
public void Save(path) { // Save project here }
```
And the static ve... | Neither. Favor extracting persistence logic from your domain model and into a separate layer of classes.
(from a comment left in ChrisW's answer) Regarding the details of the domain object leaking into another class: you can restrict the visibility of those details, if your language permits, by using package-privacy/i... |
467,897 | <p>I am using HTML, and I'd like to hide the <code>script</code> tag from the user's view. When the user views the page source, the definitions should not appear. How do I accomplish this?</p>
<h3>Example</h3>
<pre><code><script type="text/javascript" src="My1.js"></script>
<script ty... | [
{
"answer_id": 467901,
"author": "Bjorn",
"author_id": 66475,
"author_profile": "https://Stackoverflow.com/users/66475",
"pm_score": 5,
"selected": true,
"text": "<p>You cannot hide HTML. If you want a closed-source solution, use a proprietary format, such as <a href=\"http://en.wikipedi... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] | I am using HTML, and I'd like to hide the `script` tag from the user's view. When the user views the page source, the definitions should not appear. How do I accomplish this?
### Example
```
<script type="text/javascript" src="My1.js"></script>
<script type="text/javascript" src="My2.js"></script>
<script type="text/... | You cannot hide HTML. If you want a closed-source solution, use a proprietary format, such as [Flash](http://en.wikipedia.org/wiki/Adobe_Flash) or [Flex](http://en.wikipedia.org/wiki/Adobe_Flex).
You can, however, obfuscate your JavaScript code (you should shrinkwrap or minify it anyhow) which makes reading it harder. |
467,899 | <p>What are the advantages of <a href="http://en.wikipedia.org/wiki/Const_correctness" rel="noreferrer">const</a> in C++ (and C) for the uninitiated?</p>
| [
{
"answer_id": 467905,
"author": "Mark Ransom",
"author_id": 5987,
"author_profile": "https://Stackoverflow.com/users/5987",
"pm_score": 3,
"selected": false,
"text": "<p>Seems pretty obvious - it keeps you from modifying things that shouldn't be modified.</p>\n\n<p>Edit: for more guidan... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10578/"
] | What are the advantages of [const](http://en.wikipedia.org/wiki/Const_correctness) in C++ (and C) for the uninitiated? | When used as a const reference in a function, it lets the *caller* know that the thing being passed in won't be modified.
```
void f(Foo &foo, const Bar &bar) { ... }
```
In this case the caller will know that the `foo` might be modified, but the `bar` will not. The compiler will enforce this when compiling the body... |
467,903 | <p>I have a MySql database with three tables I need to combine in a query: schedule, enrolled and waitlist. They are implementing a basic class enrollment system.</p>
<p>Schedule contains the scheduled classes. When a user enrolls in a class, their user account id and the id of the scheduled class are stored in enroll... | [
{
"answer_id": 467930,
"author": "kyle",
"author_id": 2993381,
"author_profile": "https://Stackoverflow.com/users/2993381",
"pm_score": 0,
"selected": false,
"text": "<p>Two quick ways:</p>\n\n<p>1- Use <code>COUNT(DISTINCT e.id), COUNT(DISTINCT w.id)</code> to get the number of unique i... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1249/"
] | I have a MySql database with three tables I need to combine in a query: schedule, enrolled and waitlist. They are implementing a basic class enrollment system.
Schedule contains the scheduled classes. When a user enrolls in a class, their user account id and the id of the scheduled class are stored in enrolled. If a c... | I would do it with another left join and two inline count(distincts)
```
select s.id, s.classDate, s.instructor ,
count(distinct e.id) as enrolled,
count(distinct w.id) as waiting
from schedule as s
left outer join enrolled as e
on s.id = e.scheduleID
left outer join waitlist as w
on s.id = w.scheduleID
group by s.id
... |
467,927 | <p>Normally you have an image tage with the <b> src </b> as the source of the image and the <b>alt </b> as the alternative text:</p>
<pre><code><img src="image1.gif" alt="Image 1" />
</code></pre>
<p>Can you have something like is?:</p>
<pre><code><img src="image1.gif" alt="image2.gif" />
</code></pre>
... | [
{
"answer_id": 467935,
"author": "Sam",
"author_id": 37575,
"author_profile": "https://Stackoverflow.com/users/37575",
"pm_score": 3,
"selected": false,
"text": "<p><code>alt</code> is text that is displayed when the image can't be loaded or the user's browser doesn't support images (e.g... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52300/"
] | Normally you have an image tage with the **src** as the source of the image and the **alt** as the alternative text:
```
<img src="image1.gif" alt="Image 1" />
```
Can you have something like is?:
```
<img src="image1.gif" alt="image2.gif" />
```
So that means the **src** has an image source and the **alt** ... | The
```
<a href="image2.gif" ><img src="image1.gif"/></a>
```
technique has always worked for me. I used it to good effect in my Super Bowl diary, but I see that the scripts I used are broken. Once I get them fixed I will edit in the URL. |
467,951 | <p>I'm looking to connect or glue together two shapes or objects with a Line. These shapes will be generated dynamically, meaning I'll be calling a Web service on the backend to determine how many objects/shapes need to be created. Once this is determined, I'll need to have the objects/shapes connected together.</p>
<... | [
{
"answer_id": 468276,
"author": "Michael S. Scherotter",
"author_id": 27306,
"author_profile": "https://Stackoverflow.com/users/27306",
"pm_score": 4,
"selected": true,
"text": "<ol>\n<li>Use a Path or a Line below the shapes in stacking order or z index</li>\n<li>Use instance.Transform... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30649/"
] | I'm looking to connect or glue together two shapes or objects with a Line. These shapes will be generated dynamically, meaning I'll be calling a Web service on the backend to determine how many objects/shapes need to be created. Once this is determined, I'll need to have the objects/shapes connected together.
The meth... | 1. Use a Path or a Line below the shapes in stacking order or z index
2. Use instance.TransformToVisual() to get the transform of each shape
3. Use the transform to transform the centerpoint of each shape
4. Draw a line between the two centerpoints.
---
```
var transform1 = shape1.TransformToVisual(shape1.Parent as U... |
467,952 | <p>I have 3 Lists in Sharepoint.</p>
<p>I want to create a dataview that is a join of 3 tables.</p>
<p>Table1 is joined with Table2 on FieldA
Table 2 is joined to Table3 on FieldB</p>
<p>Table1 has duplicate values in FieldA so I need to only return one value to join with Table2.</p>
<p>In Access my query looks lik... | [
{
"answer_id": 468331,
"author": "Muhammedh",
"author_id": 57416,
"author_profile": "https://Stackoverflow.com/users/57416",
"pm_score": 0,
"selected": false,
"text": "<p>you want to show the query result in SharePoint Designer? I believe, SPD has merged data sources. Look into that. </... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24912/"
] | I have 3 Lists in Sharepoint.
I want to create a dataview that is a join of 3 tables.
Table1 is joined with Table2 on FieldA
Table 2 is joined to Table3 on FieldB
Table1 has duplicate values in FieldA so I need to only return one value to join with Table2.
In Access my query looks like this:
SELECT DISTINCT WRK\_In... | Your question is more of an ADO.NET question. Unfortunately ADO.NET doesn't have an easy way to do this, which is why companies like bamboo Solutions builds theirCross List Web Part:
<http://store.bamboosolutions.com/pc-42-1-cross-list-web-part.aspx>
Otherwise I would attempt to use LINQ to query the tables. You might... |
467,965 | <p>I got this question from <a href="https://stackoverflow.com/questions/466048/array-find-method-problem">this discussion</a>. A method call like <code>object.m</code> does not always mean the class of "object" has a "m" method, just like the find method to a Array object is not directly originated from Array object, ... | [
{
"answer_id": 468190,
"author": "Greg Fairbrother",
"author_id": 48548,
"author_profile": "https://Stackoverflow.com/users/48548",
"pm_score": 1,
"selected": false,
"text": "<p>maybe you use caller() to give you the backtrace see:</p>\n\n<p><a href=\"http://www.ruby-doc.org/core/classes... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44512/"
] | I got this question from [this discussion](https://stackoverflow.com/questions/466048/array-find-method-problem). A method call like `object.m` does not always mean the class of "object" has a "m" method, just like the find method to a Array object is not directly originated from Array object, but from the mixed-in Enu... | Any class/object method is an object in Ruby, and has some methods of it's own.
So you can do this:
```
[].method(:count).inspect
=> "#<Method: Array#count>"
[].method(:detect).inspect
=> "#<Method: Array(Enumerable)#detect>"
```
Quick bit of RegEx and you're done. |
467,985 | <p>I have two models, <code>Room</code> and <code>Image</code>. <code>Image</code> is a generic model that can tack onto any other model. I want to give users a form to upload an image when they post information about a room. I've written code that works, but I'm afraid I've done it the hard way, and specifically in... | [
{
"answer_id": 468787,
"author": "David Arcos",
"author_id": 30300,
"author_profile": "https://Stackoverflow.com/users/30300",
"pm_score": 2,
"selected": false,
"text": "<p>Why don't you just use <code>ImageField</code>? I don't see the need for the <code>Image</code> class.</p>\n\n<pre>... | 2009/01/22 | [
"https://Stackoverflow.com/questions/467985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27462/"
] | I have two models, `Room` and `Image`. `Image` is a generic model that can tack onto any other model. I want to give users a form to upload an image when they post information about a room. I've written code that works, but I'm afraid I've done it the hard way, and specifically in a way that violates DRY.
Was hoping s... | You don't have to use the Image class. As [DZPM](https://stackoverflow.com/users/30300/dzpm) suggested, convert the image field to an ImageField. You also need to make some changes to the view.
Instead of using an upload handler, you can create a Image object with the uploaded data and attach the Image object to the R... |
468,015 | <p>I am currently working on rewriting an application to use Data Mappers that completely abstract the database from the Domain layer. However, I am now wondering which is the better approach to handling relationships between Domain objects:</p>
<ol>
<li>Call the necessary find() method from the related data mapper di... | [
{
"answer_id": 468034,
"author": "Scott Muc",
"author_id": 1894,
"author_profile": "https://Stackoverflow.com/users/1894",
"pm_score": 3,
"selected": false,
"text": "<p>Yes. Ask yourself why would a domain object know about such a thing? Not even why, but how? You're going to inject your... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20178/"
] | I am currently working on rewriting an application to use Data Mappers that completely abstract the database from the Domain layer. However, I am now wondering which is the better approach to handling relationships between Domain objects:
1. Call the necessary find() method from the related data mapper directly within... | I'm afraid you've slightly misunderstood the intention of the Repository pattern.
The Repository is meant to behave like an in-memory collection of a particular domain object, usually an aggregate root:
```
interface EmployeeRepository
{
List<Employee> retrieveBy(Criteria someCriteria);
void store(Employee so... |
468,038 | <p>So I've tried to work with the pure-CSS, never-use-tables-for-layout gospel, I really have. But after an incredible amount of pain and anguish, I'm just about ready to give up. I'm willing to go to some effort to accomplish things in CSS, don't get me wrong. But when it seems like some of the most asininely simpl... | [
{
"answer_id": 468041,
"author": "Scott Muc",
"author_id": 1894,
"author_profile": "https://Stackoverflow.com/users/1894",
"pm_score": 4,
"selected": false,
"text": "<p>Is <a href=\"http://www.dynamicdrive.com/style/layouts/item/css-liquid-layout-21-fixed-fluid/\" rel=\"nofollow noreferr... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47529/"
] | So I've tried to work with the pure-CSS, never-use-tables-for-layout gospel, I really have. But after an incredible amount of pain and anguish, I'm just about ready to give up. I'm willing to go to some effort to accomplish things in CSS, don't get me wrong. But when it seems like some of the most asininely simple thin... | ```
<div style="width: 200px;background-color: #FFFFCC; float: left;">
Left column
</div>
<div style="margin-left: 200px; background-color: #CCFFFF">
Right column
</div>
```
That should do it (obviously implementation will vary based on where it is in the page, but I think that's the concept you're looking for). |
468,043 | <p>And hopefully with as little loss as possible, as I've heard the implementation put forward by a guy named Guido Vollbeding. Standard GDI+ doesn't seem to have this capability, and all I've found so far are either specs or fully-integrated tools. A lean, pluggable .NET component would be highly desirable. What are c... | [
{
"answer_id": 468070,
"author": "Jim Mischel",
"author_id": 56778,
"author_profile": "https://Stackoverflow.com/users/56778",
"pm_score": 2,
"selected": false,
"text": "<p>This is pretty easy using the .NET Bitmap class:</p>\n\n<pre><code>void ResizeImage(string inFname, string outFname... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56979/"
] | And hopefully with as little loss as possible, as I've heard the implementation put forward by a guy named Guido Vollbeding. Standard GDI+ doesn't seem to have this capability, and all I've found so far are either specs or fully-integrated tools. A lean, pluggable .NET component would be highly desirable. What are comm... | This is pretty easy using the .NET Bitmap class:
```
void ResizeImage(string inFname, string outFname, float scale)
{
Bitmap bmpOrig = new Bitmap(inFname);
int w = (int)(scale * bmpOrig.Width);
int h = (int)(scale * bmpOrig.Height);
Bitmap bmpNew = new Bitmap(bmpOrig, new Size(w, h));
bmpNew.Save(o... |
468,045 | <p>I've been using this piece of code I've written and it's working in this most unclear manner. I wish to insert a row into the database which includes two columns of DateTime:</p>
<pre><code>myrow.ApprovalDate = DateTime.Now
myrow.ProposedDate = DateTime.Now
</code></pre>
<p>And yet, when I update the database I re... | [
{
"answer_id": 468087,
"author": "Turnkey",
"author_id": 13144,
"author_profile": "https://Stackoverflow.com/users/13144",
"pm_score": 2,
"selected": false,
"text": "<p>That usually means a null is being posted to the query instead of your desired value, you might try to run the SQL Prof... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've been using this piece of code I've written and it's working in this most unclear manner. I wish to insert a row into the database which includes two columns of DateTime:
```
myrow.ApprovalDate = DateTime.Now
myrow.ProposedDate = DateTime.Now
```
And yet, when I update the database I receive this error:
>
> Sq... | A `DateTime` in C# is a value type, not a reference type, and therefore cannot be null. It can however be the constant `DateTime.MinValue` which is outside the range of Sql Servers `DATETIME` data type.
Value types are guaranteed to always have a (default) value (of zero) without always needing to be explicitly set (... |
468,048 | <p>What's the best way in PHP to sort an array of arrays based on array length?</p>
<p>e.g.</p>
<pre><code>$parent[0] = array(0, 0, 0);
$parent[2] = array("foo", "bar", "b", "a", "z");
$parent[1] = array(4, 2);
$sorted = sort_by_length($parent)
$sorted[0] = array(4, 2);
$sorted[1] = array(0, 0, 0);
$sorted[2] = arr... | [
{
"answer_id": 468055,
"author": "too much php",
"author_id": 28835,
"author_profile": "https://Stackoverflow.com/users/28835",
"pm_score": 3,
"selected": true,
"text": "<p>This will work:</p>\n\n<pre><code>function sort_by_length($arrays) {\n $lengths = array_map('count', $arrays);\n... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What's the best way in PHP to sort an array of arrays based on array length?
e.g.
```
$parent[0] = array(0, 0, 0);
$parent[2] = array("foo", "bar", "b", "a", "z");
$parent[1] = array(4, 2);
$sorted = sort_by_length($parent)
$sorted[0] = array(4, 2);
$sorted[1] = array(0, 0, 0);
$sorted[2] = array("foo", "bar", "b",... | This will work:
```
function sort_by_length($arrays) {
$lengths = array_map('count', $arrays);
asort($lengths);
$return = array();
foreach(array_keys($lengths) as $k)
$return[$k] = $arrays[$k];
return $return;
}
```
Note that this function will preserve the numerical keys. If you want to ... |
468,059 | <p>I have a jFrame with a Canvas on it. When I run my program in Windows XP/Vista and resize the window the canvas resizes proportionately along with the window.</p>
<p>However, in Ubuntu linux, when I compile the same java application and resize my window, the Canvas stays the same size.</p>
<p>What do I need to do... | [
{
"answer_id": 468065,
"author": "Dave Ray",
"author_id": 40310,
"author_profile": "https://Stackoverflow.com/users/40310",
"pm_score": 2,
"selected": false,
"text": "<p>Use a border layout instead:</p>\n\n<pre><code>frame.getContentPane().setLayout(new BorderLayout());\nBallCanvas ballC... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a jFrame with a Canvas on it. When I run my program in Windows XP/Vista and resize the window the canvas resizes proportionately along with the window.
However, in Ubuntu linux, when I compile the same java application and resize my window, the Canvas stays the same size.
What do I need to do to make my Canvas... | Use a border layout instead:
```
frame.getContentPane().setLayout(new BorderLayout());
BallCanvas ballCanvas = new BallCanvas();
frame.getContentPane().add(ballCanvas, BorderLayout.CENTER);
frame.getContentPane().add(controlPanel, BorderLayout.SOUTH);
```
Also get rid of setPreferredSize() in favor of fr... |
468,089 | <p>I have an ASP page written in JScript that sends e-mails using CDO.Message. For specifying an SMTP server (and other options) I'm doing something like this:</p>
<pre><code>mail.Configuration.Fields.Item(
"http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtp.example.com";
</code></pre>
<p>Now... | [
{
"answer_id": 470058,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 3,
"selected": true,
"text": "<p>I figured out the answer when looking at the C++ code example at <a href=\"http://msdn.microsoft.com/en-us/library/ms... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23501/"
] | I have an ASP page written in JScript that sends e-mails using CDO.Message. For specifying an SMTP server (and other options) I'm doing something like this:
```
mail.Configuration.Fields.Item(
"http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtp.example.com";
```
Now, here comes the catch. I ... | I figured out the answer when looking at the C++ code example at [http://msdn.microsoft.com/en-us/library/ms526318(EXCHG.10).aspx](http://msdn.microsoft.com/en-us/library/ms526318%28EXCHG.10%29.aspx).
The solution is to make the assignment explicitly to the `Value` property:
```
mail.Configuration.Fields.Item(
"h... |
468,090 | <p>I've got a game engine where I'm splitting off the physics simulation from the game object functionality. So I've got a pure virtual class for a physical body</p>
<pre><code>class Body
</code></pre>
<p>from which I'll be deriving various implementations of a physics simulation. My game object class then looks lik... | [
{
"answer_id": 468107,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 2,
"selected": false,
"text": "<p>One approach you could take is to split the <code>Body</code> interface into multiple interfaces, each with a differ... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/112/"
] | I've got a game engine where I'm splitting off the physics simulation from the game object functionality. So I've got a pure virtual class for a physical body
```
class Body
```
from which I'll be deriving various implementations of a physics simulation. My game object class then looks like
```
class GameObject {
p... | The idea of the law of Demeter is that your `GameObject` isn't supposed to have functions like `GetPosition()`. Instead it's supposed to have `MoveForward(int)` or `TurnLeft()` functions that may call `GetPosition()` (along with other functions) internally. Essentially they translate one interface into another.
If you... |
468,106 | <p>Is there a way to make git give me output like svn ls -v does. Basically a list of each file and who last edited that file? Like this:</p>
<pre><code>filea.txt Someone Else
fileb.txt Another Person
</code></pre>
<p>Maybe even with the SHA to identify the commit the change happened in?</p>
| [
{
"answer_id": 468152,
"author": "dylanfm",
"author_id": 38795,
"author_profile": "https://Stackoverflow.com/users/38795",
"pm_score": 3,
"selected": false,
"text": "<p>You want to play around with <a href=\"http://git-scm.com/docs/git-log\" rel=\"noreferrer\">git log</a> and its pretty ... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9594/"
] | Is there a way to make git give me output like svn ls -v does. Basically a list of each file and who last edited that file? Like this:
```
filea.txt Someone Else
fileb.txt Another Person
```
Maybe even with the SHA to identify the commit the change happened in? | It's not a very natural question to ask in git, but you can probably achieve something like what you want with something like this.
```
for a in $(ls); do git log --pretty=format:"%h%x09%an%x09%ad%x09$a" -1 -- "$a"; done
```
This goes through each file in the current directory and performs a `git log` on it to find ... |
468,119 | <p>I've written the following routine to manually traverse through a directory and calculate its size in C#/.NET:</p>
<pre>
<code>
protected static float CalculateFolderSize(string folder)
{
float folderSize = 0.0f;
try
{
//Checks if the path is valid or not
if (!Directory.Exists(folder))
... | [
{
"answer_id": 468131,
"author": "hao",
"author_id": 3963,
"author_profile": "https://Stackoverflow.com/users/3963",
"pm_score": 6,
"selected": false,
"text": "<p>No, this looks like the <a href=\"https://msdn.microsoft.com/en-us/library/system.io.directory(v=vs.100).aspx\" rel=\"norefer... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3429/"
] | I've written the following routine to manually traverse through a directory and calculate its size in C#/.NET:
```
protected static float CalculateFolderSize(string folder)
{
float folderSize = 0.0f;
try
{
//Checks if the path is valid or not
if (!Directory.Exists(folder))
retu... | I do not believe there is a Win32 API to calculate the space consumed by a directory, although I stand to be corrected on this. If there were then I would assume Explorer would use it. If you get the Properties of a large directory in Explorer, the time it takes to give you the folder size is proportional to the number... |
468,134 | <p>Alright, so I'm trying out C++ for the first time, as it looks like I'll have to use it for an upcoming course in college. I have a couple years of programming under my belt, but not much in the non-garbage-collected world.</p>
<p>I have a class, a Node for use in a doubly linked list. So basically it has a value a... | [
{
"answer_id": 468163,
"author": "Mark James",
"author_id": 56134,
"author_profile": "https://Stackoverflow.com/users/56134",
"pm_score": 2,
"selected": false,
"text": "<p>Usually \"deep copy\" involves traversing the data structure and copying the entire thing. In your case, given a No... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38803/"
] | Alright, so I'm trying out C++ for the first time, as it looks like I'll have to use it for an upcoming course in college. I have a couple years of programming under my belt, but not much in the non-garbage-collected world.
I have a class, a Node for use in a doubly linked list. So basically it has a value and two poi... | First of all, I'm not really sure how the objective of the exercise should be understood. How deep should the copy be? In a solution like yours, `this->next->next` and `other.next->next` would be still the same thing. Should this object also be duplicated? And the rest of the list? Where does it end? One could of cours... |
468,139 | <p>I am writing my form validation class using CodeIgniter. Is there any way so that I can get error messages in name value pair? For example, in a sample form there are four fields: <code>user_name</code>, <code>password</code>, <code>password_conf</code>, and <code>timezone</code>. Among them <code>user_name</code> a... | [
{
"answer_id": 468741,
"author": "roborourke",
"author_id": 42147,
"author_profile": "https://Stackoverflow.com/users/42147",
"pm_score": 0,
"selected": false,
"text": "<p>Seeing as code igniter validation gives you the error messages on a normal page refresh wouldn't it be better to use... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48625/"
] | I am writing my form validation class using CodeIgniter. Is there any way so that I can get error messages in name value pair? For example, in a sample form there are four fields: `user_name`, `password`, `password_conf`, and `timezone`. Among them `user_name` and `password` validation has failed after executing the fo... | I have found one way myself by looking into the CodeIgniter code:
I have extended the library CI\_Form\_validation like: -
```
class MY_Form_validation extends CI_Form_validation
{
public function getErrorsArray()
{
return $this->_error_array;
}
}
```
I know, this is a hack, but will serve my nee... |
468,145 | <p>What makes a type different from class and vice versa?</p>
<p>(In the general language-agnostic sense)</p>
| [
{
"answer_id": 468159,
"author": "Lawrence Dol",
"author_id": 8946,
"author_profile": "https://Stackoverflow.com/users/8946",
"pm_score": 2,
"selected": false,
"text": "<p>Type is conceptually a superset of class. In the broader sense, a class is one form of type.</p>\n\n<p>Closely rela... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22076/"
] | What makes a type different from class and vice versa?
(In the general language-agnostic sense) | The following answer is from Gof book ([Design Patterns](https://amazon.co.uk/dp/0201633612))
>
> An object's **class** defines how the
> object is implemented. The class
> defines object's internal state and
> the implementation of its
> operations.
>
>
>
>
> In contrast, an object's
> **type** only refers to i... |
468,155 | <p>What is the best way of taking a query and transforming it into a nested class list without doing a subselect for each row?</p>
<p>eg.</p>
<pre><code>1 aaaa
1 bbbb
1 cccc
2 dddd
3 eeee
</code></pre>
<p>into </p>
<pre><code>1
aaaa
bbbb
cccc
2
dddd
3
eeee
</code></pre>
| [
{
"answer_id": 468165,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p>This question seems a bit weird... what do you mean by \"sandbox\"?</p>\n\n<p>Usually you simply practice writing HTML by u... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29376/"
] | What is the best way of taking a query and transforming it into a nested class list without doing a subselect for each row?
eg.
```
1 aaaa
1 bbbb
1 cccc
2 dddd
3 eeee
```
into
```
1
aaaa
bbbb
cccc
2
dddd
3
eeee
``` | [start here](http://www.w3schools.com/) at w3schools.com. They provide a niftly little sandbox with sample code for all your web design element questions. |
468,170 | <p>Currentaly I am using a gridView and on RowCommand event of gridview the details of selected row are displayed below the Gridview. But now I have to display the details just below the row clicked. Means it will be displayed in between the selected row and next row of it. The gridview code is as </p>
<pre><code> ... | [
{
"answer_id": 468237,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "<p>You probably want to use a Repeater and build the table yourself. I don't think that you'll be able to get a GridVi... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43886/"
] | Currentaly I am using a gridView and on RowCommand event of gridview the details of selected row are displayed below the Gridview. But now I have to display the details just below the row clicked. Means it will be displayed in between the selected row and next row of it. The gridview code is as
```
<asp:GridView ... | Please refer to the following artice, that describes exactly what you want:
[DataGrid and Details Using
ASP.NET, C#, and JavaScript (Expand / Collapse Rows)](http://www.progtalk.com/ViewArticle.aspx?ArticleID=1) |
468,185 | <p>On my Drupal powered website, I want to list available downloads at the top of a node page (within a narrow float:right <code><div></code>), not at the bottom where they normally appear.</p>
<p>Within my theme, I've overridden the <code>theme_upload_attachments()</code> function to generate a <code><div>... | [
{
"answer_id": 469664,
"author": "Eaton",
"author_id": 19411,
"author_profile": "https://Stackoverflow.com/users/19411",
"pm_score": 4,
"selected": true,
"text": "<p>You'll need a module to do this, not just a theme. A module can implement hook_nodeapi(), which will give it a chance to c... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30280/"
] | On my Drupal powered website, I want to list available downloads at the top of a node page (within a narrow float:right `<div>`), not at the bottom where they normally appear.
Within my theme, I've overridden the `theme_upload_attachments()` function to generate a `<div>` of width 40%, but this is showing up at the bo... | You'll need a module to do this, not just a theme. A module can implement hook\_nodeapi(), which will give it a chance to change the contents of that $node->content array before it's rendered. If your module is named 'upload\_tweaker' for example, you'd use the following function:
```
function upload_tweaker_nodeapi(&... |
468,198 | <p>I have to admit the last time I programmed in Java was a data structures class in high school. So please be kind to this Java noob.</p>
<p>I have spent a good deal of time putting together a C# COM library at work. This library relies heavily on some new .Net technologies (WPF being the big one) so translating it... | [
{
"answer_id": 468227,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 1,
"selected": false,
"text": "<p>You can use <a href=\"http://danadler.com/jacob/\" rel=\"nofollow noreferrer\">JACOB</a></p>\n\n<p>From the site:</p>\... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57788/"
] | I have to admit the last time I programmed in Java was a data structures class in high school. So please be kind to this Java noob.
I have spent a good deal of time putting together a C# COM library at work. This library relies heavily on some new .Net technologies (WPF being the big one) so translating it into anothe... | You can use [JACOB](http://danadler.com/jacob/)
From the site:
>
> *JACOB is a JAVA-COM Bridge that allows you to call COM Automation components from Java. It uses JNI to make native calls into the COM and Win32 libraries.*
>
>
>
Sound like the kind of thing you're looking for. |
468,220 | <p>Currently I'm running instrumentations tests from the command line this way:</p>
<pre><code>adb shell am instrument -w com.blah.blah/android.test.InstrumentationTestRunner
</code></pre>
<p>Is there a way to run them from Eclipse (with automatic installation of the application)?</p>
| [
{
"answer_id": 559828,
"author": "James A Wilson",
"author_id": 13892,
"author_profile": "https://Stackoverflow.com/users/13892",
"pm_score": 4,
"selected": true,
"text": "<p>I was not able to determine automatic deployment to the emulator. However, you can take that same \"adb shell\" ... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] | Currently I'm running instrumentations tests from the command line this way:
```
adb shell am instrument -w com.blah.blah/android.test.InstrumentationTestRunner
```
Is there a way to run them from Eclipse (with automatic installation of the application)? | I was not able to determine automatic deployment to the emulator. However, you can take that same "adb shell" command and create an external launch configuration. I blogged on this same topic [here](http://stuffikeepforgettinghowtodo.blogspot.com/2009/01/unit-testing-android-applications.html). Launching this way is a ... |
468,224 | <p>please tell me best to achieve Search Engine Optimization (SEO) & Friendly URLs using ASP.Net</p>
| [
{
"answer_id": 559828,
"author": "James A Wilson",
"author_id": 13892,
"author_profile": "https://Stackoverflow.com/users/13892",
"pm_score": 4,
"selected": true,
"text": "<p>I was not able to determine automatic deployment to the emulator. However, you can take that same \"adb shell\" ... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | please tell me best to achieve Search Engine Optimization (SEO) & Friendly URLs using ASP.Net | I was not able to determine automatic deployment to the emulator. However, you can take that same "adb shell" command and create an external launch configuration. I blogged on this same topic [here](http://stuffikeepforgettinghowtodo.blogspot.com/2009/01/unit-testing-android-applications.html). Launching this way is a ... |
468,238 | <p>A lot of modules I use import entire files into memory or trickle a file's contents in while they process it. I'm wondering if there's any way to track this sort of loading progress? Possibly a wrapper class that takes a callback?</p>
| [
{
"answer_id": 468349,
"author": "Evan Fosmark",
"author_id": 49701,
"author_profile": "https://Stackoverflow.com/users/49701",
"pm_score": 4,
"selected": true,
"text": "<p>I would do by this by determining the size of the file, and then simply dividing the total by the number of bytes r... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46914/"
] | A lot of modules I use import entire files into memory or trickle a file's contents in while they process it. I'm wondering if there's any way to track this sort of loading progress? Possibly a wrapper class that takes a callback? | I would do by this by determining the size of the file, and then simply dividing the total by the number of bytes read. Like this:
```
import os
def show_progress(file_name, chunk_size=1024):
fh = open(file_name, "r")
total_size = os.path.getsize(file_name)
total_read = 0
while True:
chunk = f... |
468,262 | <p>If for example I should not use standard library functions like <code>printf()</code>, <code>putchar()</code> then how can I print a character to the screen?</p>
<p>Is there an easy way of doing it. I dont know much about system calls and if I have to use them then how do I use them?
So can any one advice an easy wa... | [
{
"answer_id": 468268,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 3,
"selected": false,
"text": "<p>In linux, you can use the <code>write</code> system-call:</p>\n\n<pre><code>write(1, \"hello\\n\", 6); /... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31116/"
] | If for example I should not use standard library functions like `printf()`, `putchar()` then how can I print a character to the screen?
Is there an easy way of doing it. I dont know much about system calls and if I have to use them then how do I use them?
So can any one advice an easy way of printing without using lib... | Well thank u all for ur answers.I found one simple answer by a comment from Mr. Hao below the question. his answer is simple program like this
Turbo C(DOS program):
```
char far* src = (char far*) 0xB8000000L;
*src = 'M';
src += 2;
*src = 'D';
```
or try this: <http://en.wikipedia.org/wiki/Brainfuck> :) – //Hao... |
468,266 | <p>I have created a program which searches for files in a source folder. If it finds any file, it processes that file and moves it to a destination folder, then looks for a new file in the source folder. It has to keep on checking the source folder for a file.</p>
<p>I have used a thread to look for files in the sourc... | [
{
"answer_id": 468278,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": false,
"text": "<p>If a thread is dying due to an uncaught exception, the answer is simple: catch the exception at an appropriate place ... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51659/"
] | I have created a program which searches for files in a source folder. If it finds any file, it processes that file and moves it to a destination folder, then looks for a new file in the source folder. It has to keep on checking the source folder for a file.
I have used a thread to look for files in the source folder. ... | If a thread is dying due to an uncaught exception, the answer is simple: catch the exception at an appropriate place so that you can keep going. Either catch the exception within your searchfile method, or make the run method call searchfile in a loop. |
468,279 | <p>If the search query contains a leading wildcard character (<code>*</code> or <code>?</code>), the <code>QueryParser</code>'s <code>Parse</code> function throws an error.</p>
<pre><code>Dim q As String = "*abc"
Dim qp As New QueryParser("text", New StandardAnalyzer())
Dim query As Query = qp.Parse(q)
</code></pre>
... | [
{
"answer_id": 468307,
"author": "Xn0vv3r",
"author_id": 42475,
"author_profile": "https://Stackoverflow.com/users/42475",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe you have to use a <a href=\"http://incubator.apache.org/lucene.net/docs/2.1/Lucene.Net.Search.WildcardQuery.html\... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57175/"
] | If the search query contains a leading wildcard character (`*` or `?`), the `QueryParser`'s `Parse` function throws an error.
```
Dim q As String = "*abc"
Dim qp As New QueryParser("text", New StandardAnalyzer())
Dim query As Query = qp.Parse(q)
```
Is there any way to solve this problem in Lucene.NET v2.0.0.4? | Set [QueryParser.SetAllowLeadingWildcard Method](http://incubator.apache.org/lucene.net/docs/2.1/Lucene.Net.QueryParsers.QueryParser.SetAllowLeadingWildcard.html) to true. The API page states that "this can produce very slow queries on big indexes" though. |
468,286 | <p>I have an HTML table which is built dynamically. To the table I have an event handler attached, which sorts a column when the column is clicked. I wish to force a column sort (i.e. sort the table by a specific column) once the page has finished loading.</p>
<p>Currently, I use <code>document.getElementById(ElementN... | [
{
"answer_id": 468322,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "<p>Instead of calling the click handler, just invoke the handler function directly. Assuming that your handler is on a... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an HTML table which is built dynamically. To the table I have an event handler attached, which sorts a column when the column is clicked. I wish to force a column sort (i.e. sort the table by a specific column) once the page has finished loading.
Currently, I use `document.getElementById(ElementName).click();`
... | Instead of calling the click handler, just invoke the handler function directly. Assuming that your handler is on a span containing the column name, it might look something like:
```
<span id='defaultColumn' onclick='sortBy(this);'>Column</span>
```
So you would do:
```
sortBy( document.getElementById('defaultColum... |
468,291 | <p>I need to merge a whole bunch of docx files programatically. Imagine they are numbered 1 to 10. I essentially need a final.docx file that contains all 10 documents in it.
If I can append the second to the first somehow, then I can repeat it for the third, then fourth, etc.</p>
<p>Note that I do NOT need to rebuild ... | [
{
"answer_id": 468949,
"author": "Sumit Ghosh",
"author_id": 56150,
"author_profile": "https://Stackoverflow.com/users/56150",
"pm_score": 3,
"selected": true,
"text": "<p>I had made an application in C# to merge RTF files into one doc,Iam hopeful it should work for DOC and DOCX files as... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51948/"
] | I need to merge a whole bunch of docx files programatically. Imagine they are numbered 1 to 10. I essentially need a final.docx file that contains all 10 documents in it.
If I can append the second to the first somehow, then I can repeat it for the third, then fourth, etc.
Note that I do NOT need to rebuild a table of... | I had made an application in C# to merge RTF files into one doc,Iam hopeful it should work for DOC and DOCX files as well.
```
Word._Application wordApp;
Word._Document wordDoc;
object outputFile = outputFileName;
object missing = System.Type.Missing;
object vk_false = false;
... |
468,297 | <p>Let's say I want to draw a simple quad like this:</p>
<pre><code>glBegin(GL_QUADS);
glVertex2f(-1.0,-1.0);
glVertex2f(1.0,-1.0);
glVertex2f(1.0, 1.0);
glVertex2f(-1.0, 1.0);
glEnd();
</code></pre>
<p>Is there a way to draw this such that it appears behind all 3D objects and fills up the whole screen? My camera mo... | [
{
"answer_id": 468350,
"author": "Rolf Anders",
"author_id": 40628,
"author_profile": "https://Stackoverflow.com/users/40628",
"pm_score": 0,
"selected": false,
"text": "<p>Cant you just place it in the background, box yourself in if you want it all around you. You need to draw it first ... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Let's say I want to draw a simple quad like this:
```
glBegin(GL_QUADS);
glVertex2f(-1.0,-1.0);
glVertex2f(1.0,-1.0);
glVertex2f(1.0, 1.0);
glVertex2f(-1.0, 1.0);
glEnd();
```
Is there a way to draw this such that it appears behind all 3D objects and fills up the whole screen? My camera moves with the mouse, so this... | It sounds like what you want to do is similar to what you would when drawing a 2D HUD in a simple game, or just a background that is persistent. I'm no expert, but I did just that relatively recently. What you want to do is change the projection matrix to an orthographic projection, render your quad, and then switch ba... |
468,329 | <p>I am include a huge javascript file(500K) in my HTML. Is there a smart way to know if it has been loaded. One way I can think of is to have a variable in its constructor to initialize and inform me . The loading is asynchronous and I cannot proceed until function s of that JS are included. </p>
<p>Thanks</p>
| [
{
"answer_id": 468366,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 0,
"selected": false,
"text": "<pre><code><SCRIPT LANGUAGE=\"JavaScript\" SRC=\"filename\">\n</SCRIPT>\n</code></pre>\n\n<p>??</p>\n"
},
... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50851/"
] | I am include a huge javascript file(500K) in my HTML. Is there a smart way to know if it has been loaded. One way I can think of is to have a variable in its constructor to initialize and inform me . The loading is asynchronous and I cannot proceed until function s of that JS are included.
Thanks | By using jQuery you can handle a callback function that runs when the script file is loaded:
```
$.getScript("yourScriptFile.js", function(){
// What to do when the script is loaded
});
```
[Docs](http://docs.jquery.com/Ajax/jQuery.getScript) |
468,370 | <p>I'm trying to match SHA1's in generic text with a regular expression.</p>
<p>Ideally I want to avoid matching words. </p>
<p>It's safe to say that full SHA1's have a distinctive pattern (they're long and a consistent length) - so I can match these reliably - but what about abbreviated SHA1's?</p>
<p>Can I rely on... | [
{
"answer_id": 468378,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 7,
"selected": true,
"text": "<p>You can consider the SHA1 hashes to be completely random, so this reduces to a matter of probabilities. The probability... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52416/"
] | I'm trying to match SHA1's in generic text with a regular expression.
Ideally I want to avoid matching words.
It's safe to say that full SHA1's have a distinctive pattern (they're long and a consistent length) - so I can match these reliably - but what about abbreviated SHA1's?
Can I rely on the presence of numbers... | You can consider the SHA1 hashes to be completely random, so this reduces to a matter of probabilities. The probability that a given digit is not a number is 6/16, or 0.375. The probability that three SHA1 digits are all not numbers is 0.375 \*\* 3, or 0.0527 (5% ish). At six digits, this reduces again to 0.00278 (0.2%... |
468,383 | <p>Python 2.5.1</p>
<p><a href="http://www.cgsecurity.org/wiki/After_Using_PhotoRec" rel="nofollow noreferrer">http://www.cgsecurity.org/wiki/After_Using_PhotoRec</a></p>
<p>I've just run PhotoRec and the code given as a way to sort file types into their own folder is coming back with this error. Any suggestions on h... | [
{
"answer_id": 468395,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 3,
"selected": true,
"text": "<p>It simply means that the program is expecting two command line arguments: source and destination. If you wish to use t... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13007/"
] | Python 2.5.1
<http://www.cgsecurity.org/wiki/After_Using_PhotoRec>
I've just run PhotoRec and the code given as a way to sort file types into their own folder is coming back with this error. Any suggestions on how to alter? Thanks :
[EDIT2: Two points:
1. This question was voted down because it was a 'usage' of cod... | It simply means that the program is expecting two command line arguments: source and destination. If you wish to use the same code in another function, replace sys.argv[1] and [2] with your own variables. |
468,403 | <p>I have a self upgrade process implemented where my main application exe launches an updater exe passing a handle to itself on the command line. The application exe then calls ExitProcess to exit, and the updater calls WaitForSingleObject on the passed in handle to wait for the application exe to terminate.</p>
<p>T... | [
{
"answer_id": 468415,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 2,
"selected": false,
"text": "<p>The process signals when the application code exits. It may take the OS a little more time to unload the process... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27491/"
] | I have a self upgrade process implemented where my main application exe launches an updater exe passing a handle to itself on the command line. The application exe then calls ExitProcess to exit, and the updater calls WaitForSingleObject on the passed in handle to wait for the application exe to terminate.
The WaitFor... | As another answer points out, the process handle gets signalled when the process has stopped execution, and the operating system might take a bit longer to release DLLs.
You are right that relying on Sleep(100) is a bad idea. You should rather wrap overwriting your DLLs in a loop like this:
```
BOOL UpdateDll(LPCTSTR... |
468,405 | <pre><code>Dim qp1 As New QueryParser("filename", New StandardAnalyzer())
Dim qp2 As New QueryParser("filetext", New StandardAnalyzer())
.
.
</code></pre>
<p>I am using the 'Lucene.Net' library and have the following question.</p>
<p>Instead of creating two separate <code>QueryParser</code> objects and using them to ... | [
{
"answer_id": 472483,
"author": "Doug",
"author_id": 695,
"author_profile": "https://Stackoverflow.com/users/695",
"pm_score": 1,
"selected": false,
"text": "<p>for each field create a query from the above queryparsers, then add the query to a booleanquery stating that it \"must\" occur... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57175/"
] | ```
Dim qp1 As New QueryParser("filename", New StandardAnalyzer())
Dim qp2 As New QueryParser("filetext", New StandardAnalyzer())
.
.
```
I am using the 'Lucene.Net' library and have the following question.
Instead of creating two separate `QueryParser` objects and using them to obtain two Hits objects, is it possib... | There are 3 ways to do this.
The first way is to construct a query manually, this is what `QueryParser` is doing internally. This is the most powerful way to do it, and means that you don't have to parse the user input if you want to prevent access to some of the more exotic features of `QueryParser`:
```
IndexReader... |
468,421 | <p>In Python we can "dir" a module, like this:</p>
<pre><code>>>> import re
>>> dir(re)
</code></pre>
<p>And it lists all functions in the module. Is there a similar way to do this in Ruby?</p>
| [
{
"answer_id": 468433,
"author": "Jonas Elfström",
"author_id": 44620,
"author_profile": "https://Stackoverflow.com/users/44620",
"pm_score": 6,
"selected": false,
"text": "<p>As far as I know not exactly but you get somewhere with</p>\n\n<pre><code>object.methods.sort\n</code></pre>\n"
... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In Python we can "dir" a module, like this:
```
>>> import re
>>> dir(re)
```
And it lists all functions in the module. Is there a similar way to do this in Ruby? | As far as I know not exactly but you get somewhere with
```
object.methods.sort
``` |
468,456 | <p>Is there a windows call to get the baud base frequency, like this one in linux.</p>
<pre><code>struct serial_struct ser;
ioctl(com, TIOCGSERIAL, &ser);
base = ser.baud_base;
</code></pre>
| [
{
"answer_id": 469104,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 2,
"selected": true,
"text": "<p>You can use a UIWebView and HTML, or draw it yourself using the NSString + UIKit additions, or CoreGraphics.</p>\n"
... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there a windows call to get the baud base frequency, like this one in linux.
```
struct serial_struct ser;
ioctl(com, TIOCGSERIAL, &ser);
base = ser.baud_base;
``` | You can use a UIWebView and HTML, or draw it yourself using the NSString + UIKit additions, or CoreGraphics. |
468,458 | <p>What query do I need to run in PHP to get the structure of a given table in the database? And what query do I need to run to get a list of all the tables?</p>
| [
{
"answer_id": 468467,
"author": "MrValdez",
"author_id": 1599,
"author_profile": "https://Stackoverflow.com/users/1599",
"pm_score": 7,
"selected": true,
"text": "<p>To get a list of columns for a table, use the DESCRIBE SQL statement. The syntax is as follows:</p>\n\n<pre><code>DESCRIB... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | What query do I need to run in PHP to get the structure of a given table in the database? And what query do I need to run to get a list of all the tables? | To get a list of columns for a table, use the DESCRIBE SQL statement. The syntax is as follows:
```
DESCRIBE TableName
```
To get a list of tables on the database, use this SQL statement:
```
SHOW TABLES
``` |
468,469 | <p>How do you programmatically upload a file to a document library in sharepoint?</p>
<p>I am currently making a Windows application using C# that will add documents to a document library list.</p>
| [
{
"answer_id": 468685,
"author": "Henrique Zacchi",
"author_id": 55503,
"author_profile": "https://Stackoverflow.com/users/55503",
"pm_score": 7,
"selected": true,
"text": "<p>You can upload documents to SharePoint libraries using the Object Model or <a href=\"http://msdn.microsoft.com/e... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23491/"
] | How do you programmatically upload a file to a document library in sharepoint?
I am currently making a Windows application using C# that will add documents to a document library list. | You can upload documents to SharePoint libraries using the Object Model or [SharePoint Webservices](http://msdn.microsoft.com/en-us/library/lists.lists.aspx).
Upload using Object Model:
```
String fileToUpload = @"C:\YourFile.txt";
String sharePointSite = "http://yoursite.com/sites/Research/";
String documentLibraryN... |
468,523 | <p>I have two routing rules in an ASP.NET MVC application :</p>
<pre><code> routes.MapRoute(
"Products AJAX",
"Products/Ajax/{action}",
new { controller = "Products" }
);
routes.MapRoute(
"Product", ... | [
{
"answer_id": 468726,
"author": "Damien_The_Unbeliever",
"author_id": 15498,
"author_profile": "https://Stackoverflow.com/users/15498",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, that's the point of the ActionLink helper and the routing - if you change your entire routing struct... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | I have two routing rules in an ASP.NET MVC application :
```
routes.MapRoute(
"Products AJAX",
"Products/Ajax/{action}",
new { controller = "Products" }
);
routes.MapRoute(
"Product", ... | Since you have a named route, why not use it? Use Ajax.RouteLink, instead, and specify the route name. Then you do not have to worry about ASP.NET "guessing" the wrong route. It won't hurt anything that [this is faster, too](http://weblogs.asp.net/leftslipper/archive/2008/12/17/optimizing-your-route-collection-for-url-... |
468,541 | <p>I have an class which has a enum property and a boolean property, based on that it calls a specific method with specific parameters. I use a switch statement for the enum and an if for the boolean within each case of the switch. It is a long list and doesn't feel to me to be the most elegant solution. Anyone got a m... | [
{
"answer_id": 468552,
"author": "gkrogers",
"author_id": 54501,
"author_profile": "https://Stackoverflow.com/users/54501",
"pm_score": 2,
"selected": false,
"text": "<p>Replace the enum with classes:<br>\n<a href=\"http://www.refactoring.com/catalog/replaceTypeCodeWithClass.html\" rel=\... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53236/"
] | I have an class which has a enum property and a boolean property, based on that it calls a specific method with specific parameters. I use a switch statement for the enum and an if for the boolean within each case of the switch. It is a long list and doesn't feel to me to be the most elegant solution. Anyone got a more... | An often used convention is that a timeout of zero means no timeout. Maybe you could drop the UseTimeout (property?) and use the value zero instead. That'd eliminate some stuff. |
468,556 | <p>I've got a number of directories with a large number of files in them (~10,000). I want to create a list of these files in my app, and have already threaded the io access so that the app doesn't freeze while they load. However if I exit the app before all files are loaded, the thread doesn't respond to the .Join()... | [
{
"answer_id": 468601,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 1,
"selected": false,
"text": "<p>You should use a Thread from the ThreadPool class. This will make it a background thread and it should receive a... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11801/"
] | I've got a number of directories with a large number of files in them (~10,000). I want to create a list of these files in my app, and have already threaded the io access so that the app doesn't freeze while they load. However if I exit the app before all files are loaded, the thread doesn't respond to the .Join() unti... | You can call [Thread.Abort()](http://msdn.microsoft.com/en-us/library/ty8d3wta.aspx) when your application is about to close (before the *Join*).
```
myThread.Abort();
// Wait for myThread to end.
myThread.Join();
```
Also, you might want to catch the `ThreadAbortException` in the thread method and do some finalizat... |
468,562 | <p>I'm doing some performance tuning on my application and would like to know a good way of measuring the size of the object that I am sending over RMI.</p>
<p>The aim is to make my object leaner.</p>
| [
{
"answer_id": 468631,
"author": "Fortyrunner",
"author_id": 16828,
"author_profile": "https://Stackoverflow.com/users/16828",
"pm_score": 0,
"selected": false,
"text": "<p>Because your object is serializable already - you can use the size() method on ObjectOutputStream to do this. </p>\... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7412/"
] | I'm doing some performance tuning on my application and would like to know a good way of measuring the size of the object that I am sending over RMI.
The aim is to make my object leaner. | the easiest way to do this is to put in some test code which writes the object to a file. then, look at the size of the file.
or, if you don't want to write to disk (and your objects are not going to blow out memory):
```
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOut... |
468,605 | <p>We have runned into a problem with an sp.</p>
<p>We have a pretty simple sp containing a declared table and a couple of outer joins that in the end returns between 20 and 100 rows.</p>
<p>Since querying this sp has been giving us poor performance both in production and in testenvironment we recently rewrote it to ... | [
{
"answer_id": 468629,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 0,
"selected": false,
"text": "<p>Make sure your production database has up-to-date stats and the indexes are in good condition (if possible consid... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57842/"
] | We have runned into a problem with an sp.
We have a pretty simple sp containing a declared table and a couple of outer joins that in the end returns between 20 and 100 rows.
Since querying this sp has been giving us poor performance both in production and in testenvironment we recently rewrote it to be more efficient... | I think that your problem might be "Parameter sniffing".
It is a process when SQL Server's execution environment "sniffs" the sp's parameter values during compilation or recompile to generate faster execution plans. But sometimes it gets a combination of parameters which together with the current data the sp will retur... |
468,608 | <p>I have a problem with XSLT and unparsed entity in XML. Here is a fictional scenario. First I got an XML file named doc.xml:</p>
<pre><code><?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE document [
<!ELEMENT document (employee)*>
<!ELEMENT employee (lastname, firstname)>
<!... | [
{
"answer_id": 469439,
"author": "Dimitre Novatchev",
"author_id": 36305,
"author_profile": "https://Stackoverflow.com/users/36305",
"pm_score": 3,
"selected": true,
"text": "<p><strong>The solution in XSLT 2.0</strong>:</p>\n\n<pre><code><xsl:stylesheet xmlns:xsl=\"http://www.w3.org/... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54060/"
] | I have a problem with XSLT and unparsed entity in XML. Here is a fictional scenario. First I got an XML file named doc.xml:
```
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE document [
<!ELEMENT document (employee)*>
<!ELEMENT employee (lastname, firstname)>
<!ELEMENT lastname (#PCDATA)>
<!ELEMENT ... | **The solution in XSLT 2.0**:
```
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="document">
<Document>
<xsl:apply-templates select="employee"/>
</Document>
</xsl:template>
<xsl:template match="employee">
Employee is... |
468,611 | <p>I have a function that takes pointer to pointer to struct.</p>
<p>struct ABC;</p>
<pre><code>void func(ABC ** ptr); //func is provided by someone else and i don't know about the implementation.
{
}
</code></pre>
<p>Now, i have following code.</p>
<pre><code>ABC xyz[2];
ABC * ptr = xyz;
ABC **dptr1 = &ptr... | [
{
"answer_id": 468630,
"author": "Filip Ekberg",
"author_id": 39106,
"author_profile": "https://Stackoverflow.com/users/39106",
"pm_score": 1,
"selected": false,
"text": "<p>I've written a guide on how to use Pointers and Double Pointers, you can find it <a href=\"http://fekberg.wordpres... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39615/"
] | I have a function that takes pointer to pointer to struct.
struct ABC;
```
void func(ABC ** ptr); //func is provided by someone else and i don't know about the implementation.
{
}
```
Now, i have following code.
```
ABC xyz[2];
ABC * ptr = xyz;
ABC **dptr1 = &ptr; //pointer to ponter
ABC ** dptr2 = (ABC **... | When you pass `ptr1` to `func`, you are actually passing a pointer to the memory occupied by `ptr`. The problem is that `func` seems to be assuming that `ptr1` is actually pointing the beginning of an array of pointers, but you've passed it a pointer to an "array" of only one pointer, `ptr`. `func` will probably do maj... |
468,615 | <p>A colleague and I designed a system for our customer, and in our opinion we created a nice clean design. But I'm having problems with some coupling we've introduced. I could try to create an example design which includes the same problems as our design, but if you forgive me I'll create an extract of our design to s... | [
{
"answer_id": 468621,
"author": "Davy Landman",
"author_id": 11098,
"author_profile": "https://Stackoverflow.com/users/11098",
"pm_score": 1,
"selected": false,
"text": "<p>For the BLL my idea was to add a property on Medicine like this:</p>\n\n<pre><code>public Boolean IsSoluble\n{\n ... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11098/"
] | A colleague and I designed a system for our customer, and in our opinion we created a nice clean design. But I'm having problems with some coupling we've introduced. I could try to create an example design which includes the same problems as our design, but if you forgive me I'll create an extract of our design to supp... | My understanding of consequences of the Law of Demeter seems to be different to DrJokepu's - whenever I've applied it to object oriented code it's resulted in tighter encapsulation and cohesion, rather than the addition of extra getters to contract paths in procedural code.
Wikipedia has the rule as
>
> More formall... |
468,616 | <p>On the interface.js website (<a href="http://interface.eyecon.ro/" rel="nofollow noreferrer">http://interface.eyecon.ro/</a>) they propose to download <code>interface.js</code> with jQuery 1.1.2. I would like to know if interface.js is still compliant with the new version of jQuery and if there will be a new release... | [
{
"answer_id": 468621,
"author": "Davy Landman",
"author_id": 11098,
"author_profile": "https://Stackoverflow.com/users/11098",
"pm_score": 1,
"selected": false,
"text": "<p>For the BLL my idea was to add a property on Medicine like this:</p>\n\n<pre><code>public Boolean IsSoluble\n{\n ... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56996/"
] | On the interface.js website (<http://interface.eyecon.ro/>) they propose to download `interface.js` with jQuery 1.1.2. I would like to know if interface.js is still compliant with the new version of jQuery and if there will be a new release of this library.
I had some trouble to use jQuery 1.2.x with interface 1.2, an... | My understanding of consequences of the Law of Demeter seems to be different to DrJokepu's - whenever I've applied it to object oriented code it's resulted in tighter encapsulation and cohesion, rather than the addition of extra getters to contract paths in procedural code.
Wikipedia has the rule as
>
> More formall... |
468,617 | <p>i have a textinput field which has autoComplete, i populate its dataprovider from a webservice.</p>
<p>I assign the dataprovider with the result of a webservice call</p>
<pre><code>ac.dataProvider = e.result;
</code></pre>
<p>however i now want to edit each field returned from the ResultEvent so i can add some m... | [
{
"answer_id": 468676,
"author": "kenneth",
"author_id": 53363,
"author_profile": "https://Stackoverflow.com/users/53363",
"pm_score": 2,
"selected": true,
"text": "<p>it will all depend on what e.result is. I'm suspecting that it is some kind of object/xml and as such when you are makin... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24481/"
] | i have a textinput field which has autoComplete, i populate its dataprovider from a webservice.
I assign the dataprovider with the result of a webservice call
```
ac.dataProvider = e.result;
```
however i now want to edit each field returned from the ResultEvent so i can add some more inforamtion, i tried doing som... | it will all depend on what e.result is. I'm suspecting that it is some kind of object/xml and as such when you are making it into an array then into a arrayCollection it is only populating element 0 in the arrayCollection.
What I think you'll need to do is iterate through whatever e.result is and add each of its eleme... |
468,618 | <p>I am trying to connect to a remote mysql database from an iPhone. I have searched many web sites but I did not find any help. If anyone has worked with this please send a solution.</p>
| [
{
"answer_id": 468632,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.google.co.uk/search?q=objective+c+mysql\" rel=\"nofollow noreferrer\">A quick google</a> will show you... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51108/"
] | I am trying to connect to a remote mysql database from an iPhone. I have searched many web sites but I did not find any help. If anyone has worked with this please send a solution. | Assuming you have some experience with server-side programming (like PHP or Rails), you could just create an NSArray from the content of a URL where you establish a connection to the MySQL server and print the results you want in ASCII or XML format.
```
NSURL *myURL = [NSURL URLWithString:@"http://www.myserver.com/re... |
468,641 | <p>I use a view based on a complex query with 17 joins (both inner and left/right outer) and subqueries. All view rows are shown in about 5 seconds. </p>
<pre><code>SELECT * FROM a_view;
</code></pre>
<p>One of the view columns has type BIT. And when I filter view rows comparing it with 1, a query works again about 5... | [
{
"answer_id": 468680,
"author": "Frans Bouma",
"author_id": 44991,
"author_profile": "https://Stackoverflow.com/users/44991",
"pm_score": 1,
"selected": false,
"text": "<p>the SQL Server sql engine places the whole SQL query of the view inside the SQL statement you wrote on the view and... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] | I use a view based on a complex query with 17 joins (both inner and left/right outer) and subqueries. All view rows are shown in about 5 seconds.
```
SELECT * FROM a_view;
```
One of the view columns has type BIT. And when I filter view rows comparing it with 1, a query works again about 5 seconds.
```
SELECT * FR... | Usually there is more than one way to execute a query involving joins. All modern RDBMSs search through different join plans looking for the best plan by estimating costs (CPU and disk access times) for each.
The problem is, each additional join in a query multiplies the number of possible plans by an increasing numbe... |
468,642 | <p>I want to create a static class in PHP and have it behave like it does in C#, so</p>
<ol>
<li>Constructor is automatically called on the first call to the class</li>
<li>No instantiation required</li>
</ol>
<p>Something of this sort...</p>
<pre><code>static class Hello {
private static $greeting = 'Hello';
... | [
{
"answer_id": 468648,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 9,
"selected": true,
"text": "<p>You can have static classes in PHP but they don't call the constructor automatically (if you try and call <code>self::__con... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50475/"
] | I want to create a static class in PHP and have it behave like it does in C#, so
1. Constructor is automatically called on the first call to the class
2. No instantiation required
Something of this sort...
```
static class Hello {
private static $greeting = 'Hello';
private __construct() {
$greeting... | You can have static classes in PHP but they don't call the constructor automatically (if you try and call `self::__construct()` you'll get an error).
Therefore you'd have to create an `initialize()` function and call it in each method:
```
<?php
class Hello
{
private static $greeting = 'Hello';
private stati... |
468,655 | <p>I have some client-side validation against a text box, which only allows numbers up to two decimal places with no other input.</p>
<p>This script was a basis for entering numeric values only, however it needs to be adapted so it can take a decimal point followed by only up to two decimal places.</p>
<p>I've tried ... | [
{
"answer_id": 468677,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 6,
"selected": true,
"text": "<p>The . character has special meaning in RegEx so needs escaping.</p>\n\n<pre><code>/^(?:\\d*\\.\\d{1,2}|\\d+)$/\n</... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39693/"
] | I have some client-side validation against a text box, which only allows numbers up to two decimal places with no other input.
This script was a basis for entering numeric values only, however it needs to be adapted so it can take a decimal point followed by only up to two decimal places.
I've tried things such as `/... | The . character has special meaning in RegEx so needs escaping.
```
/^(?:\d*\.\d{1,2}|\d+)$/
```
This matches 123.45, 123.4, 123 and .2, .24 but not emtpy string, 123., 123.456 |
468,658 | <p>I am facing a weird issue in IIS 7.0:</p>
<p>I have the following virtual directory in IIS:
<a href="https://i.stack.imgur.com/EEhGd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EEhGd.jpg" alt="alt text"></a>
</p>
<p><b>and only Windows Authentication mode is enabled on the virtual directory ... | [
{
"answer_id": 469757,
"author": "Razzie",
"author_id": 38889,
"author_profile": "https://Stackoverflow.com/users/38889",
"pm_score": 0,
"selected": false,
"text": "<p>Does it help if you call RefreshCache() right after the third line?</p>\n\n<pre><code>DirectoryEntry dir = new Directory... | 2009/01/22 | [
"https://Stackoverflow.com/questions/468658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46279/"
] | I am facing a weird issue in IIS 7.0:
I have the following virtual directory in IIS:
[](https://i.stack.imgur.com/EEhGd.jpg)
**and only Windows Authentication mode is enabled on the virtual directory in IIS**
Now if I try to get associated DirectoryEntry for TestV/Fold... | I got the answer to the problem (with some help from one of my colleagues)
Here is the solution:
1. The program needs to add (pseudo?)entries to the IIS metadata before it access the file/folder under the virtual directory, before we access the entry:
```
try
{
// make pseudo entries:
... |