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 |
|---|---|---|---|---|---|---|
519,543 | <p>I am using GDI+ Bitmap class to convert an IStream to HBITMAP. I have included the gliplus lib file in the Linker inputs and also have the dll in the build path. But using the statement</p>
<pre><code>Bitmap bm(lpStream,FALSE);
</code></pre>
<p>gives me an error <b>C2065: 'Bitmap' : undeclared identifier</b></p>
... | [
{
"answer_id": 519549,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 3,
"selected": true,
"text": "<p>You also need to include the relevant header file. At a guess, it would probably have a name like \"Bitmap.h\" or... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46297/"
] | I am using GDI+ Bitmap class to convert an IStream to HBITMAP. I have included the gliplus lib file in the Linker inputs and also have the dll in the build path. But using the statement
```
Bitmap bm(lpStream,FALSE);
```
gives me an error **C2065: 'Bitmap' : undeclared identifier**
Can someone please tell me what I... | You also need to include the relevant header file. At a guess, it would probably have a name like "Bitmap.h" or "gdi+.h".
There is some more detail on the [Bitmap class here](http://msdn.microsoft.com/en-us/library/ms536314(VS.85).aspx). The correct header file is "gdiplus.h". In short:
```
#include "gdiplus.h"
Cons... |
519,572 | <p>I'm looking for a way to perform a regex match on a string in Ruby and have it short-circuit on the first match.</p>
<p>The string I'm processing is long and from what it looks like the standard way (<code>match</code> method) would process the whole thing, collect each match, and return a MatchData object containi... | [
{
"answer_id": 519593,
"author": "Presidenten",
"author_id": 15763,
"author_profile": "https://Stackoverflow.com/users/15763",
"pm_score": 8,
"selected": true,
"text": "<p>You could try <a href=\"https://ruby-doc.org/core-3.0.0/String.html#method-i-5B-5D\" rel=\"noreferrer\"><code>String... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13216/"
] | I'm looking for a way to perform a regex match on a string in Ruby and have it short-circuit on the first match.
The string I'm processing is long and from what it looks like the standard way (`match` method) would process the whole thing, collect each match, and return a MatchData object containing all matches.
```
... | You could try [`String#[]`](https://ruby-doc.org/core-3.0.0/String.html#method-i-5B-5D) (as in `variableName[/regular expression/]`).
This is an example output from IRB:
```
names = "erik kalle johan anders erik kalle johan anders"
# => "erik kalle johan anders erik kalle johan anders"
names[/kalle/]
# => "kalle"
``... |
519,588 | <p>I'm trying to generate a new button item when I click on a button generator. It is able to generate but it will only show up on the screen after I relaunch the application. But I want it to be generated instantly and show up in the current view. Any suggestions? I know it's related to the <code>viewDidLoad</code> fu... | [
{
"answer_id": 519655,
"author": "Alex Wayne",
"author_id": 62076,
"author_profile": "https://Stackoverflow.com/users/62076",
"pm_score": 3,
"selected": true,
"text": "<p>Lets say this is your view controller method that creates buttons:</p>\n\n<pre><code>-(void)generateButton:(id)sender... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to generate a new button item when I click on a button generator. It is able to generate but it will only show up on the screen after I relaunch the application. But I want it to be generated instantly and show up in the current view. Any suggestions? I know it's related to the `viewDidLoad` function. Anyway... | Lets say this is your view controller method that creates buttons:
```
-(void)generateButton:(id)sender {
UIButton *button = [UIbutton alloc] initWithFrame:CGRectMake(50, 50, 100, 40)];
[self.view addSubview:button];
[button release];
}
```
In order to be visible you have to add the button as a subview of a cu... |
519,600 | <p>I have a method that varies by a single method call inside, and I'd like to pass the method/signature of the method that it varies by as an argument... is this possible in Objective C or is that too much to hope for?</p>
| [
{
"answer_id": 519637,
"author": "Alex Wayne",
"author_id": 62076,
"author_profile": "https://Stackoverflow.com/users/62076",
"pm_score": 6,
"selected": true,
"text": "<p>NSInvocation is a class for wrapping up a method calls in an object. You can set a selector (method signature), set ... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63240/"
] | I have a method that varies by a single method call inside, and I'd like to pass the method/signature of the method that it varies by as an argument... is this possible in Objective C or is that too much to hope for? | NSInvocation is a class for wrapping up a method calls in an object. You can set a selector (method signature), set arguments by index. You can then set a target and call invoke to trigger the call, or leave the target unset and use invokeWithTarget: in a loop of some sort to call this on many objects.
I think it work... |
519,619 | <p>Recently I came to know about SHTML when I saw a site with .shtml extensions.</p>
<p>What is the purpose of SHTML, and in what ways does it differ from HTML and DHTML?</p>
| [
{
"answer_id": 519625,
"author": "Gumbo",
"author_id": 53114,
"author_profile": "https://Stackoverflow.com/users/53114",
"pm_score": 5,
"selected": false,
"text": "<p>It’s just HTML with <a href=\"http://en.wikipedia.org/wiki/Server_Side_Includes\" rel=\"noreferrer\">Server Side Includes... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22162/"
] | Recently I came to know about SHTML when I saw a site with .shtml extensions.
What is the purpose of SHTML, and in what ways does it differ from HTML and DHTML? | SHTML is a file extension that lets the web server know the file should be processed as using Server Side Includes (SSI).
(HTML is...you know what it is, and DHTML is Microsoft's name for Javascript+HTML+CSS or something).
You can use SSI to include a common header and footer in your pages, so you don't have to repea... |
519,633 | <p>I have a very big file 4GB and when I try to read it my computer hangs.
So I want to read it piece by piece and after processing each piece store the processed piece into another file and read next piece.</p>
<p>Is there any method to <code>yield</code> these pieces ?</p>
<p>I would love to have a <strong>lazy met... | [
{
"answer_id": 519653,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 10,
"selected": true,
"text": "<p>To write a lazy function, just use <a href=\"http://docs.python.org/tutorial/classes.html#generators\" rel=\"noreferrer\... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58737/"
] | I have a very big file 4GB and when I try to read it my computer hangs.
So I want to read it piece by piece and after processing each piece store the processed piece into another file and read next piece.
Is there any method to `yield` these pieces ?
I would love to have a **lazy method**. | To write a lazy function, just use [`yield`](http://docs.python.org/tutorial/classes.html#generators):
```
def read_in_chunks(file_object, chunk_size=1024):
"""Lazy function (generator) to read a file piece by piece.
Default chunk size: 1k."""
while True:
data = file_object.read(chunk_size)
... |
519,662 | <p>I'm trying to make a feature to upload a new publishing page in "Pages" library but it doesn't works the way I want. If I see the library using SharePoint Designer my publishing page appears, but it doesn't if I use Internet Explorer.</p>
<p>In the feature I configure the properties: ContentTypeId, ContentTye, Auth... | [
{
"answer_id": 817239,
"author": "Øyvind Skaar",
"author_id": 49194,
"author_profile": "https://Stackoverflow.com/users/49194",
"pm_score": 0,
"selected": false,
"text": "<p>I had a similar problem. It turned out i had to publish the uploaded file to make it visible.</p>\n"
},
{
... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/444077/"
] | I'm trying to make a feature to upload a new publishing page in "Pages" library but it doesn't works the way I want. If I see the library using SharePoint Designer my publishing page appears, but it doesn't if I use Internet Explorer.
In the feature I configure the properties: ContentTypeId, ContentTye, Author, Title,... | I use the following code to create a publishing page based on a page layout which is considered to be already provisioned and based on a content type. The code runs in the FeatureActivated event handler for your feature:
```
using (SPWeb ParentWeb = properties.Feature.Parent as SPWeb)
{
PublishingW... |
519,675 | <p>I need to maintain a legacy VB.NET web application. Data typing is, I would say, inconsistent. Especially, there are data that is stored sometimes as integers and sometimes as strings, and I have to parse strings to integers reliably. If parsing goes wrong it should always return 0.</p>
<p>The problem is, I can't u... | [
{
"answer_id": 519682,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "<p>Use <a href=\"http://msdn.microsoft.com/en-us/library/system.int32.tryparse.aspx\" rel=\"nofollow noreferrer\"><code>I... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13460/"
] | I need to maintain a legacy VB.NET web application. Data typing is, I would say, inconsistent. Especially, there are data that is stored sometimes as integers and sometimes as strings, and I have to parse strings to integers reliably. If parsing goes wrong it should always return 0.
The problem is, I can't use any of ... | Use [`Int32.TryParse`](http://msdn.microsoft.com/en-us/library/system.int32.tryparse.aspx) and ignore the return value - just use the value in the `out` parameter. |
519,677 | <p>We have 2 tables called <strong>TableToUpdate</strong> and <strong>Dates</strong>.
We need to update <strong>TableToUpdate</strong>'s EndTimeKey column by looking from other table <strong>Dates</strong>. We run sql below to do this, but it takes to long to finish.</p>
<p>Table <strong>TableToUpdate</strong> has 6M ... | [
{
"answer_id": 519697,
"author": "Gambrinus",
"author_id": 42386,
"author_profile": "https://Stackoverflow.com/users/42386",
"pm_score": 0,
"selected": false,
"text": "<p>you can set some indices on the relevant fields (in relevant order) i.e.: endtimekey and endtime. do not expect to mu... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55351/"
] | We have 2 tables called **TableToUpdate** and **Dates**.
We need to update **TableToUpdate**'s EndTimeKey column by looking from other table **Dates**. We run sql below to do this, but it takes to long to finish.
Table **TableToUpdate** has 6M records.
Table **Dates** has 5000 records.
How can we optimize it ?
Thank... | You are updating potentially 6 million records, this is not going to be terribly speedy in any event. However, look at your execution plan and see if it using indexes.
Also run this in batches, that is generally faster when updating large numbers of records. Do the update during off hours when there is little load on... |
519,689 | <p>I found that after setting the</p>
<pre><code>[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]
</code></pre>
<p>at <code>viewDidLoad</code>, then if I want to align an image to the top, I will need to set its position as .y = -20;</p>
<p>Is there anyway to make the y coordinate of the <em>to... | [
{
"answer_id": 519712,
"author": "epatel",
"author_id": 842,
"author_profile": "https://Stackoverflow.com/users/842",
"pm_score": 2,
"selected": false,
"text": "<p>I imagine you should add a UIStatusBarHidden item to the Info.plist if you want the status bar to be removed from start.</p>... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63226/"
] | I found that after setting the
```
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]
```
at `viewDidLoad`, then if I want to align an image to the top, I will need to set its position as .y = -20;
Is there anyway to make the y coordinate of the *top position* to *0* ? or is it doomed to be -20 ... | I had a similar problem at one point and this bit of code fixed it for me:
```
[viewController.view setFrame: [viewController.view bounds]];
``` |
519,699 | <p>Is it possible to use MONTH in a CreateCriteria-statement? </p>
<p>Does NHibernate support YEAR and/or MONTH? </p>
<p>I have a sql-statement like
select obs2.Lopnr from Obs obs2 where MONTH(obs2.Datum)=11) </p>
<p>Best Regards from </p>
<p>Mats</p>
| [
{
"answer_id": 520960,
"author": "jweber",
"author_id": 10067,
"author_profile": "https://Stackoverflow.com/users/10067",
"pm_score": 0,
"selected": false,
"text": "<p>I don't believe it's possible in a criteria statement. The date functions (year, month, day) are supported in HQL querie... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it possible to use MONTH in a CreateCriteria-statement?
Does NHibernate support YEAR and/or MONTH?
I have a sql-statement like
select obs2.Lopnr from Obs obs2 where MONTH(obs2.Datum)=11)
Best Regards from
Mats | ICriteria supports [arbitrary SQL as a restriction](http://nhforge.org/doc/nh/en/index.html#querycriteria-narrowing). Therefore you could do:
```
var criteria = session.CreateCriteria(typeof(Obs))
.Add(Expression.Sql("MONTH({alias}.Datum) = ?", 11, NHibernateUtil.Int32);
var results = criteria.List<Obs>();
```
T... |
519,710 | <p>I embed a youtube video in my air application. It loaded and played well, but I cannot play more than one video at the time, only one video is played at the time, do you know why?
The code is:</p>
<pre><code>url:String = "http://in.youtube.com/v/fVGk5qm6Mac&hl=en&fs=1";
//texturl.text=url;
... | [
{
"answer_id": 519735,
"author": "PetriW",
"author_id": 1604,
"author_profile": "https://Stackoverflow.com/users/1604",
"pm_score": 3,
"selected": false,
"text": "<p>You could use GraphicEx by Mike Lischke to load the Tiff images:<br />\n<a href=\"http://www.soft-gems.net/index.php?optio... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I embed a youtube video in my air application. It loaded and played well, but I cannot play more than one video at the time, only one video is played at the time, do you know why?
The code is:
```
url:String = "http://in.youtube.com/v/fVGk5qm6Mac&hl=en&fs=1";
//texturl.text=url;
swfloader.... | [ImageMagick](http://www.imagemagick.org/script/index.php) is a command line application that can do such kind of operations on different image file formats including tiff.
The API seems to be usable from Delphi, see [PascalMagick](http://www.imagemagick.org/script/api.php#pascal). |
519,719 | <p>Is it possible via any Unix utility to read chunks of a remote file (like say 'head' does) instead of transferring the whole file ?</p>
| [
{
"answer_id": 519726,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 3,
"selected": true,
"text": "<p>You can execute remote commands through SSH</p>\n\n<pre><code>ssh user@server.com \"head <filename>\"\n</code></... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it possible via any Unix utility to read chunks of a remote file (like say 'head' does) instead of transferring the whole file ? | You can execute remote commands through SSH
```
ssh user@server.com "head <filename>"
``` |
519,725 | <p>I'm writing a Swing application, and further to <a href="https://stackoverflow.com/questions/496233/what-are-your-best-swing-design-patterns-and-tips">my previous question</a>, have settled on using the <a href="http://en.wikipedia.org/wiki/Model_View_Presenter" rel="nofollow noreferrer">Model-View-Presenter</a> pat... | [
{
"answer_id": 520979,
"author": "DJClayworth",
"author_id": 19276,
"author_profile": "https://Stackoverflow.com/users/19276",
"pm_score": 1,
"selected": false,
"text": "<p>My advice would be to think about what these 'preferences' fundamentally are. Are they part of the underlying busin... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40581/"
] | I'm writing a Swing application, and further to [my previous question](https://stackoverflow.com/questions/496233/what-are-your-best-swing-design-patterns-and-tips), have settled on using the [Model-View-Presenter](http://en.wikipedia.org/wiki/Model_View_Presenter) pattern to separate the user interface from the busine... | Although it is not uncommon to have "nested" design patterns it is not necessary in your case. Drawing on the other answers:
**Model**
- Contains all the real data, variables, objects
- knows how to set its stored data values to the new values
- responds to orders (method calls)
- has method setPrefere... |
519,752 | <p>In C#, if you want a method to have an indeterminate number of parameters, you can make the final parameter in the method signature a <code>params</code> so that the method parameter looks like an array but allows everyone using the method to pass as many parameters of that type as the caller wants.</p>
<p>I'm fair... | [
{
"answer_id": 519756,
"author": "David Grant",
"author_id": 40581,
"author_profile": "https://Stackoverflow.com/users/40581",
"pm_score": 9,
"selected": true,
"text": "<p>In Java it's called <a href=\"http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html\" rel=\"noreferrer\">v... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20400/"
] | In C#, if you want a method to have an indeterminate number of parameters, you can make the final parameter in the method signature a `params` so that the method parameter looks like an array but allows everyone using the method to pass as many parameters of that type as the caller wants.
I'm fairly sure Java supports... | In Java it's called [varargs](http://java.sun.com/j2se/1.5.0/docs/guide/language/varargs.html), and the syntax looks like a regular parameter, but with an ellipsis ("...") after the type:
```
public void foo(Object... bar) {
for (Object baz : bar) {
System.out.println(baz.toString());
}
}
```
The var... |
519,753 | <p>I have a custom XML file format which can contain blocks of code within certain tags.</p>
<p>For example:</p>
<pre><code><Root>
<Sql> select * from foo </Sql>
<MoreJunk> ... </MoreJunk>
<Python><![CDATA[
def Bar(*args):
return False
]]></Python... | [
{
"answer_id": 519768,
"author": "Simon B. Jensen",
"author_id": 46128,
"author_profile": "https://Stackoverflow.com/users/46128",
"pm_score": 2,
"selected": false,
"text": "<p>This <a href=\"http://vimdoc.sourceforge.net/htmldoc/usr_44.html\" rel=\"nofollow noreferrer\">document</a> des... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/618/"
] | I have a custom XML file format which can contain blocks of code within certain tags.
For example:
```
<Root>
<Sql> select * from foo </Sql>
<MoreJunk> ... </MoreJunk>
<Python><![CDATA[
def Bar(*args):
return False
]]></Python>
</Root>
```
How can I get Vim to use SQL syntax highlighting... | For your XML with python example you would have to do something like this:
```
runtime! syntax/xml.vim
unlet b:current_syntax
syntax include @Python syntax/python.vim
syntax region pythonCode start=+<Python>+ keepend end=+/</Python>+ contains=@Python
```
These lines will include the XML syntax and the python synta... |
519,755 | <p>Right now resharper formats our code like this:</p>
<pre><code>private readonly List<Folder> folders = new List<Folder>
{
new Folder()
};
</code></pre>
<p>but I want it to look li... | [
{
"answer_id": 519809,
"author": "Quibblesome",
"author_id": 1143,
"author_profile": "https://Stackoverflow.com/users/1143",
"pm_score": 5,
"selected": false,
"text": "<p>I had the same issue with anonymous delegates. The fix for anonymous delegate formatting is <a href=\"http://blog.exc... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Right now resharper formats our code like this:
```
private readonly List<Folder> folders = new List<Folder>
{
new Folder()
};
```
but I want it to look like this:
```
private readonly List<Fo... | I had the same issue with anonymous delegates. The fix for anonymous delegate formatting is [here](http://blog.excastle.com/2007/02/07/resharper-day-7-code-formatting/):
>
> I did finally find the way to fix
> this. The options for formatting
> anonymous methods are spread across
> two separate pages in ReSharper
... |
519,769 | <p>I was wondering how I can pass either an ArrayList, List<code><int</code>> or StringBuilder comma delimited list to a stored procedure such that I find a list of IDs using IN():</p>
<pre><code>@myList varchar(50)
SELECT *
FROM tbl
WHERE Id IN (@myList)
</code></pre>
<p>In C# I am currently building the l... | [
{
"answer_id": 519859,
"author": "kgiannakakis",
"author_id": 24054,
"author_profile": "https://Stackoverflow.com/users/24054",
"pm_score": 0,
"selected": false,
"text": "<p>Have a look <a href=\"http://docs.jboss.org/jbossas/guides/j2eeguide/r2/en/html/ch3.chapter.html\" rel=\"nofollow ... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57591/"
] | I was wondering how I can pass either an ArrayList, List`<int`> or StringBuilder comma delimited list to a stored procedure such that I find a list of IDs using IN():
```
@myList varchar(50)
SELECT *
FROM tbl
WHERE Id IN (@myList)
```
In C# I am currently building the list as a string which is comma delimeted... | Found these two links that can help...
create a file called filename-service.xml under $CATALINA\_BASE$/deploy directory with contents as indicated in these links
<http://www.redhat.com/docs/manuals/jboss/jboss-eap-4.2/doc/Server_Configuration_Guide/Additional_Naming_MBeans-JNDI_Binding_Manager.html>
check a jboss j... |
519,774 | <p>What is the best way to crop an image in HTML?</p>
<p>It would be something like the following:</p>
<pre><code><img src="something.gif" x1="10" y1="10" x2="20" y2="20">
</code></pre>
<p>If that doesn't work, then I'll just use GIMP. Any thoughts on how I can get this to work programmatically?</p>
| [
{
"answer_id": 519780,
"author": "Georg Schölly",
"author_id": 24587,
"author_profile": "https://Stackoverflow.com/users/24587",
"pm_score": 5,
"selected": true,
"text": "<p>That's called sprites, you can read this fantastic article of <a href=\"http://www.alistapart.com/articles/sprites... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26004/"
] | What is the best way to crop an image in HTML?
It would be something like the following:
```
<img src="something.gif" x1="10" y1="10" x2="20" y2="20">
```
If that doesn't work, then I'll just use GIMP. Any thoughts on how I can get this to work programmatically? | That's called sprites, you can read this fantastic article of [A List Apart](http://www.alistapart.com/articles/sprites/).
In the end it boils down to:
```
#panel2b {
width:50px;
height:30px;
background: transparent url(test-3.jpg) -96px -200px no-repeat;
}
``` |
519,787 | <p>I'm using the following set of values to create a 9 character long base 31 value:<br>
0123456789ABCDEFGHJKLMNPQRTUWXY</p>
<p>I was looking at modifying the Luhn algorithm to work with my base.</p>
<p>My question is:</p>
<p>In base 10, the Luhn algorithm doubles each value in an even position and then if the resul... | [
{
"answer_id": 519841,
"author": "David Grant",
"author_id": 40581,
"author_profile": "https://Stackoverflow.com/users/40581",
"pm_score": 2,
"selected": false,
"text": "<p>Don't reinvent the wheel - use <a href=\"http://en.wikipedia.org/wiki/Luhn_mod_N_algorithm\" rel=\"nofollow norefer... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59754/"
] | I'm using the following set of values to create a 9 character long base 31 value:
0123456789ABCDEFGHJKLMNPQRTUWXY
I was looking at modifying the Luhn algorithm to work with my base.
My question is:
In base 10, the Luhn algorithm doubles each value in an even position and then if the result is >10 the individual d... | I looked into the Luhn mod N algorithm, but it is very limited in what it can validate against.
I decided to use a modified version of the Freight Container system.
The shipping container system multiples each value by 2^[position] (position starting from 0) and then performs a modulus 11 on the result to get a base... |
519,788 | <p>An enum in Java implements the <code>Comparable</code> interface. It would have been nice to override <code>Comparable</code>'s <code>compareTo</code> method, but here it's marked as final. The default natural order on <code>Enum</code>'s <code>compareTo</code> is the listed order.</p>
<p>Does anyone know why a J... | [
{
"answer_id": 519799,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 1,
"selected": false,
"text": "<p>If you want to change the natural order of your enum’s elements, change their order in the source code.</p>\n"
},
{
... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13365/"
] | An enum in Java implements the `Comparable` interface. It would have been nice to override `Comparable`'s `compareTo` method, but here it's marked as final. The default natural order on `Enum`'s `compareTo` is the listed order.
Does anyone know why a Java enums have this restriction? | For consistency I guess... when you see an `enum` type, you know *for a fact* that its natural ordering is the order in which the constants are declared.
To workaround this, you can easily create your own `Comparator<MyEnum>` and use it whenever you need a different ordering:
```
enum MyEnum
{
DOG("woof"),
CA... |
519,808 | <p>How can I call a constructor on a memory region that is already allocated?</p>
| [
{
"answer_id": 519812,
"author": "Anteru",
"author_id": 39912,
"author_profile": "https://Stackoverflow.com/users/39912",
"pm_score": 7,
"selected": true,
"text": "<p>You can use the placement new constructor, which takes an address.</p>\n\n<pre><code>Foo* foo = new (your_memory_address_... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38924/"
] | How can I call a constructor on a memory region that is already allocated? | You can use the placement new constructor, which takes an address.
```
Foo* foo = new (your_memory_address_here) Foo ();
```
Take a look at a more detailed explanation at the [C++ FAQ lite](https://isocpp.org/wiki/faq/dtors#placement-new) or the [MSDN](http://msdn.microsoft.com/en-us/library/kewsb8ba.aspx). The only... |
519,816 | <p>I've got a Java web application (using Spring), deployed with Jetty. If I try to run it on a Windows machine everything works as expected, but if I try to run the same code on my Linux machine, it fails like this:</p>
<pre>[normal startup output]
11:16:39.657 INFO [main] org.mortbay.jetty.servlet.ServletHandler$C... | [
{
"answer_id": 519858,
"author": "Eduard Wirch",
"author_id": 17428,
"author_profile": "https://Stackoverflow.com/users/17428",
"pm_score": 0,
"selected": false,
"text": "<p>You're using the same WAR on both machines? Have you checked if the WAR files are identical (no transfer errors oc... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62143/"
] | I've got a Java web application (using Spring), deployed with Jetty. If I try to run it on a Windows machine everything works as expected, but if I try to run the same code on my Linux machine, it fails like this:
```
[normal startup output]
11:16:39.657 INFO [main] org.mortbay.jetty.servlet.ServletHandler$Context.l... | You must understand that a classloader can't see everything; they can only see what a parent classloader has loaded or what they have loaded themselves. So if you have two classloaders, say one for Jetty and another for your webapp, your webapp can see log4j (since the JAR is the WEB-INF/lib) but Jetty's classloader ca... |
519,849 | <p>How can we bookmark a page on clicking a button or a link button in flex using actionscript</p>
| [
{
"answer_id": 520008,
"author": "Christophe Herreman",
"author_id": 17255,
"author_profile": "https://Stackoverflow.com/users/17255",
"pm_score": 0,
"selected": false,
"text": "<p>You'll have to use javascript for that. Just create a javascript function to bookmark a page in your html f... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can we bookmark a page on clicking a button or a link button in flex using actionscript | A working example based on the information in previous answers:
**bookmarks.js** (add this to your html-template directory):
```
function CreateBookmarkLink(title, url)
{
if (window.sidebar) { // Mozilla Firefox Bookmark
window.sidebar.addPanel(title, url,"");
} else if( window.external ) { // IE F... |
519,854 | <p>I need to create a stored procedure that upon exceution checks if any new rows have been added to a table within the past 12 hours. If not, an warning email must be sent to a recipient.</p>
<p>I have the procedures for sending the email, but the problem is the query itself. I imagine I'd have to make an sql command... | [
{
"answer_id": 519865,
"author": "John Sansom",
"author_id": 60308,
"author_profile": "https://Stackoverflow.com/users/60308",
"pm_score": 3,
"selected": false,
"text": "<p>Something like this should do what you wish.</p>\n\n<pre><code>Select ID\nfrom TableName\nwhere CreatedDate >= d... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to create a stored procedure that upon exceution checks if any new rows have been added to a table within the past 12 hours. If not, an warning email must be sent to a recipient.
I have the procedures for sending the email, but the problem is the query itself. I imagine I'd have to make an sql command that uses... | Say your date field in the table is 'CreateDate' and it's of type DateTime.
Your time to compare with is: GETDATE()
(which returns date + time)
To get the datetime value of 12 hours before that, is done using DATEADD:
DATEADD(hour, -12, GETDATE())
so if we want the # of rows added in the last 12 hours, we'll do:
`... |
519,868 | <p>I have an asp button on my page, in the Page_Load on the code behind, I am binding some javascript calls as follows.</p>
<pre><code>btnExample.OnClientClicking = "functionOne(1,2);"+"function2()";
</code></pre>
<p>The problem is I would like to be able to pass the EventArgs passed to the Page_Load as in function2(... | [
{
"answer_id": 519867,
"author": "Anton Gogolev",
"author_id": 60188,
"author_profile": "https://Stackoverflow.com/users/60188",
"pm_score": -1,
"selected": false,
"text": "<p>Second option is more appropriate. Abstract away PSMP and hide it behind <code>IPortalSiteMapProvider</code> and... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28871/"
] | I have an asp button on my page, in the Page\_Load on the code behind, I am binding some javascript calls as follows.
```
btnExample.OnClientClicking = "functionOne(1,2);"+"function2()";
```
The problem is I would like to be able to pass the EventArgs passed to the Page\_Load as in function2() I wish to call...
```... | The Microsoft Patterns and Practices dudes recommend TypeMock to help unit test Sharepoint
<http://msdn.microsoft.com/en-us/library/dd203468.aspx>
<http://www.typemock.com/sharepointpage.php>
Not a free solution unfortunately. |
519,872 | <p>I have a control that I'm writing where I want to turn off .NET's inbuilt request validation that prevents XSS attacks and similiar sort of nasties.</p>
<p>The control allows the owner of a web-site to adjust the content on that page. They can potentially enter markup if they want to. Since it's their site to edit,... | [
{
"answer_id": 519923,
"author": "cgreeno",
"author_id": 6088,
"author_profile": "https://Stackoverflow.com/users/6088",
"pm_score": 3,
"selected": true,
"text": "<p>In the System.Web.Configuration</p>\n\n<pre><code>PagesSection pageSection = new PagesSection();\npageSection.ValidateRequ... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/854/"
] | I have a control that I'm writing where I want to turn off .NET's inbuilt request validation that prevents XSS attacks and similiar sort of nasties.
The control allows the owner of a web-site to adjust the content on that page. They can potentially enter markup if they want to. Since it's their site to edit, they must... | In the System.Web.Configuration
```
PagesSection pageSection = new PagesSection();
pageSection.ValidateRequest = false;
```
[Reference](http://msdn.microsoft.com/en-us/library/system.web.configuration.pagessection.validaterequest.aspx) |
519,876 | <p>In my last job, we worked on a very database-heavy application, and I developed some formatting standards so that we would all write SQL with a common layout. We also developed coding standards, but these are more platform-specific so I'll not go into them here.</p>
<p>I'm interested to know what other people use f... | [
{
"answer_id": 519902,
"author": "John Sansom",
"author_id": 60308,
"author_profile": "https://Stackoverflow.com/users/60308",
"pm_score": 5,
"selected": true,
"text": "<p>I am of the opinion that so long as you can read the source code easily, the formatting is secondary. So long as thi... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20992/"
] | In my last job, we worked on a very database-heavy application, and I developed some formatting standards so that we would all write SQL with a common layout. We also developed coding standards, but these are more platform-specific so I'll not go into them here.
I'm interested to know what other people use for SQL for... | I am of the opinion that so long as you can read the source code easily, the formatting is secondary. So long as this objective is achieved, there are a number of good layout styles that can be adopted.
The only other aspect that is important to me is that whatever coding layout/style you choose to adopt in your shop,... |
519,881 | <p>In an array first we have to find whether a desired number exists in that or not?
If not then how will I find nearer number to the given desired number in Java?</p>
| [
{
"answer_id": 519892,
"author": "Anton Gogolev",
"author_id": 60188,
"author_profile": "https://Stackoverflow.com/users/60188",
"pm_score": 0,
"selected": false,
"text": "<p><code>Array.indexOf()</code> to find out wheter element exists or not. If it does not, iterate over an array and ... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In an array first we have to find whether a desired number exists in that or not?
If not then how will I find nearer number to the given desired number in Java? | An idea:
```
int nearest = -1;
int bestDistanceFoundYet = Integer.MAX_INTEGER;
// We iterate on the array...
for (int i = 0; i < array.length; i++) {
// if we found the desired number, we return it.
if (array[i] == desiredNumber) {
return array[i];
} else {
// else, we consider the difference between the... |
519,882 | <p>I have a 'complex item' that is in XML, Then a 'workitem' (in xml) that contains lots of other info, and i would like this to contain a string that contains the complex item in xml.</p>
<p>for example:</p>
<pre><code><inouts name="ClaimType" type="complex" value="<xml string here>"/>
</code></pre>
<p>... | [
{
"answer_id": 519906,
"author": "Kothar",
"author_id": 37416,
"author_profile": "https://Stackoverflow.com/users/37416",
"pm_score": 3,
"selected": false,
"text": "<p>Possibly the easiest solution would be to use a <a href=\"http://www.w3schools.com/XML/xml_cdata.asp\" rel=\"nofollow no... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51582/"
] | I have a 'complex item' that is in XML, Then a 'workitem' (in xml) that contains lots of other info, and i would like this to contain a string that contains the complex item in xml.
for example:
```
<inouts name="ClaimType" type="complex" value="<xml string here>"/>
```
However, trying SAX and other java parsers I ... | I think you'll find that the XML you're dealing with won't parse with a lot of parsers since it's invalid. If you have control over the XML, you'll at a bare minimum need to escape the attribute so it's something like:
```
<inouts name="ClaimType" type="complex" value="<xml string here>" />
```
Then, once you'... |
519,891 | <p>I have a list of objects and I would like to access the objects in a random order continuously.</p>
<p>I was wondering if there was a way of ensuring that the random value were not always similar.</p>
<p>Example.</p>
<p>My list is a list of Queues, and I am trying to interleave the values to produce a real-world ... | [
{
"answer_id": 519917,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "<p>Well, it isn't entire clear what the scenario is, but the thing with random is <em>you never can tell ;-p</em>. Any... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47026/"
] | I have a list of objects and I would like to access the objects in a random order continuously.
I was wondering if there was a way of ensuring that the random value were not always similar.
Example.
My list is a list of Queues, and I am trying to interleave the values to produce a real-world scenario for testing.
I... | Well, it isn't entire clear what the scenario is, but the thing with random is *you never can tell ;-p*. Anything you try to do to "guarantee" thins will probably reduce the randomness.
How are you doing it? Personally I'd do something like:
```
static IEnumerable<T> GetItems<T>(IEnumerable<Queue<T>> queues)
{
in... |
519,899 | <p>What would be a nice algorithm to remove dupes on an array like below...</p>
<pre><code> var allwords = [
['3-hidroxitiramina', '3-hidroxitiramina'],
['3-hidroxitiramina', '3-hidroxitiramina'],
['3-in-1 block', 'bloqueo 3 en 1'],
['abacterial', 'abacteriano'],
['abacteriano', 'abacterian... | [
{
"answer_id": 519917,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "<p>Well, it isn't entire clear what the scenario is, but the thing with random is <em>you never can tell ;-p</em>. Any... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3193/"
] | What would be a nice algorithm to remove dupes on an array like below...
```
var allwords = [
['3-hidroxitiramina', '3-hidroxitiramina'],
['3-hidroxitiramina', '3-hidroxitiramina'],
['3-in-1 block', 'bloqueo 3 en 1'],
['abacterial', 'abacteriano'],
['abacteriano', 'abacteriano'],
['ab... | Well, it isn't entire clear what the scenario is, but the thing with random is *you never can tell ;-p*. Anything you try to do to "guarantee" thins will probably reduce the randomness.
How are you doing it? Personally I'd do something like:
```
static IEnumerable<T> GetItems<T>(IEnumerable<Queue<T>> queues)
{
in... |
519,900 | <p>I usually have more then 10 opened application windows. When I write code I need to switch fast between a browser, an IDE and terminal windows. Alt + tab is too slow, too many windows to choose from.</p>
<p>Virtual desktop is a work around for me. On a first desktop I keep browser, on a second IDE, etc. So I am abl... | [
{
"answer_id": 520310,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Just use Win32 api KBS.</p>\n"
},
{
"answer_id": 523902,
"author": "slicedlime",
"author_id": 11230,
"a... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3315/"
] | I usually have more then 10 opened application windows. When I write code I need to switch fast between a browser, an IDE and terminal windows. Alt + tab is too slow, too many windows to choose from.
Virtual desktop is a work around for me. On a first desktop I keep browser, on a second IDE, etc. So I am able to switc... | [Autohotkey](http://www.autohotkey.com/) I've found to be very powerful. Here is a part of my test script.
```
SetTitleMatchMode, 2
#z::Run http://stackoverflow.com/
^!n::
IfWinExist Notepad
WinActivate
else
Run Notepad
return
!F1::
IfWinExist Firefox
WinActivate
else
Run Firefox
return
!F2::
IfWin... |
519,916 | <p>my application opens files does transformations and saves the data out to another file..or possible the same file.. the file size changes but i dont know how big or small its gona be untill i see the data inside the first file..</p>
<p>At the moment i load the file into a dynamic array do all that i need to do in t... | [
{
"answer_id": 519924,
"author": "jpfollenius",
"author_id": 62391,
"author_profile": "https://Stackoverflow.com/users/62391",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think you'll get a \"more direct\" file access. Do you use all the data in the file? Otherwise you could pe... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53915/"
] | my application opens files does transformations and saves the data out to another file..or possible the same file.. the file size changes but i dont know how big or small its gona be untill i see the data inside the first file..
At the moment i load the file into a dynamic array do all that i need to do in there then ... | You can also map parts of file directly into memory. That's definitely the most direct way. See [What is the fastest way to Parse a line in Delphi](https://stackoverflow.com/questions/287789/what-is-the-fastest-way-to-parse-a-line-in-delphi/289774#289774) for an example. |
519,918 | <p>is there any sort of XY-Layout to Java? </p>
<p>So I can set a Button at the X and Y cordinate and that it is suppose to be that big etc.... Because this border layout and grid and panel thing is driven me crazy. :) </p>
<p>They are flowing every were and getting strecht up. And to make them small you have to put ... | [
{
"answer_id": 519959,
"author": "Zarkonnen",
"author_id": 15255,
"author_profile": "https://Stackoverflow.com/users/15255",
"pm_score": 2,
"selected": false,
"text": "<p>If you really want to do this, use</p>\n\n<pre><code>setLayout(null);\n</code></pre>\n\n<p>on the component you're pu... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43209/"
] | is there any sort of XY-Layout to Java?
So I can set a Button at the X and Y cordinate and that it is suppose to be that big etc.... Because this border layout and grid and panel thing is driven me crazy. :)
They are flowing every were and getting strecht up. And to make them small you have to put panel in panel in... | When setting the container's layout to null (no LayoutManager), you can set the component's bounds individually with component.setBounds(x,y,w,h).
**Fixed layouts are** in 99% of all cases **bad UI design** (if your labels, for example, don't get their preferred size you run into mayor problems when your application s... |
519,925 | <p>I get a transmission over the network that's an array of chars/bytes. It contains a header and some data. I'd like to map the header onto a struct. Here's an example:</p>
<pre><code>#pragma pack(1)
struct Header
{
unsigned short bodyLength;
int msgID;
unsigned short someOtherValue;
unsigned short p... | [
{
"answer_id": 519982,
"author": "Anonymous",
"author_id": 61574,
"author_profile": "https://Stackoverflow.com/users/61574",
"pm_score": 3,
"selected": false,
"text": "<p>Some processors require that certain types are properly aligned. They will not accept the specified packing and gener... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52844/"
] | I get a transmission over the network that's an array of chars/bytes. It contains a header and some data. I'd like to map the header onto a struct. Here's an example:
```
#pragma pack(1)
struct Header
{
unsigned short bodyLength;
int msgID;
unsigned short someOtherValue;
unsigned short protocolVersion... | Some processors require that certain types are properly aligned. They will not accept the specified packing and generate a hardware trap.
And even on common x86 packed structures can cause the code to run more slowly.
Also you will have to take care when working with different endianness platforms.
By the way, if yo... |
519,938 | <p>I know that jQuery.extend can be used to add by own custom methods to an object such as a DOM element but Prototype's Element.extend adds all the DOM element helper methods to the object. It is that functionality that I am after.</p>
<p>For instance</p>
<pre><code>this.panel = document.createElement('div');
</code... | [
{
"answer_id": 519974,
"author": "Pim Jager",
"author_id": 35197,
"author_profile": "https://Stackoverflow.com/users/35197",
"pm_score": 0,
"selected": false,
"text": "<p>You can select one element in the jQuery object using:</p>\n\n<pre><code>$(selector).eq(0): //this will select the fi... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63286/"
] | I know that jQuery.extend can be used to add by own custom methods to an object such as a DOM element but Prototype's Element.extend adds all the DOM element helper methods to the object. It is that functionality that I am after.
For instance
```
this.panel = document.createElement('div');
```
I want this.panel to ... | jQuery policy is to never extend native DOM objects.
Wrapping an element inside a jQuery is the way to go. The result is not an array, it is a jQuery object (similar to an array) but with the extended jQuery methods available.
As a hint, if you want to create elements, you can use jQuery HTML parsing feature, it all... |
519,964 | <p>I am using this line to obtain and save an image from a URL.</p>
<pre><code>file_put_contents("./images/".$pk.".jpg", file_get_contents($PIC_URL))
</code></pre>
<p>I am unsure what the best way to deal with an error is. At the moment it is failing because there is no permission, which will be remedied shortly, but... | [
{
"answer_id": 519997,
"author": "chuckg",
"author_id": 63193,
"author_profile": "https://Stackoverflow.com/users/63193",
"pm_score": 5,
"selected": true,
"text": "<p>I'm not talented enough to claim this is the best method, but I would just test along the way:</p>\n\n<pre><code>$imageDi... | 2009/02/06 | [
"https://Stackoverflow.com/questions/519964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | I am using this line to obtain and save an image from a URL.
```
file_put_contents("./images/".$pk.".jpg", file_get_contents($PIC_URL))
```
I am unsure what the best way to deal with an error is. At the moment it is failing because there is no permission, which will be remedied shortly, but I would like it to be abl... | I'm not talented enough to claim this is the best method, but I would just test along the way:
```
$imageDir = "/path/to/images/dir/";
$imagePath = "$imageDir$pk.jpg";
if (!is_dir($imageDir) or !is_writable($imageDir)) {
// Error if directory doesn't exist or isn't writable.
} elseif (is_file($imagePath) and !is_w... |
520,013 | <p>I'm having headache with Time values and multiple time zones.
I'm storing new DateTime values in UTC time, but I face problem when I try to modify them using LinqDataSource and GridView.</p>
<p>I can easily show correct time in</p>
<pre><code><ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='... | [
{
"answer_id": 520039,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "<p>The way I've handled this sort of thing in the past is to use Eval in the EditItemTemplate as well. Let the user ed... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59791/"
] | I'm having headache with Time values and multiple time zones.
I'm storing new DateTime values in UTC time, but I face problem when I try to modify them using LinqDataSource and GridView.
I can easily show correct time in
```
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# TimeManager.ToLocalTime((D... | Have you considered making the change to your model? Let's assume that the name of the object you are binding to is CustomerOrder. You could add the following class to your project (in the same namespace as your Linq objects):
```
public partial class CustomerOrder
{
public DateTime LocalOrderDate
{
ge... |
520,015 | <p>Building on:
<a href="http://www.reddit.com/r/Python/comments/7v5ra/whats_your_favorite_gui_toolkit_and_why/" rel="noreferrer">http://www.reddit.com/r/Python/comments/7v5ra/whats_your_favorite_gui_toolkit_and_why/</a></p>
<h1>Merits:</h1>
<p>1 - ease of design / integration - learning curve</p>
<p>2 - support / avai... | [
{
"answer_id": 520055,
"author": "Georg Schölly",
"author_id": 24587,
"author_profile": "https://Stackoverflow.com/users/24587",
"pm_score": 6,
"selected": false,
"text": "<p>Please don't hesitate to expand this answer.</p>\n\n<h1><a href=\"http://wiki.python.org/moin/TkInter\" rel=\"nor... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61314/"
] | Building on:
<http://www.reddit.com/r/Python/comments/7v5ra/whats_your_favorite_gui_toolkit_and_why/>
Merits:
=======
1 - ease of design / integration - learning curve
2 - support / availability for \*nix, Windows, Mac, extra points for native l&f, support for mobile or web
3 - pythonic API
4 - quality of document... | Please don't hesitate to expand this answer.
[Tkinter](http://wiki.python.org/moin/TkInter)
==============================================
Tkinter is the toolkit that comes with python. That means you already have everything you need to write a GUI. What that also means is that if you choose to distribute your progra... |
520,019 | <p>I have created a 'control' using jQuery and used jQuery.extend to assist in making it as OO as possible.</p>
<p>During the initialisation of my control I wire up various click events like so</p>
<pre><code>jQuery('#available input',
this.controlDiv).bind('click', this, this.availableCategoryClick);
</... | [
{
"answer_id": 520370,
"author": "Ferdinand Beyer",
"author_id": 34855,
"author_profile": "https://Stackoverflow.com/users/34855",
"pm_score": 4,
"selected": false,
"text": "<p>I don't think jQuery has a built-in feature for that. But you could use a helper construct like the following:<... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63286/"
] | I have created a 'control' using jQuery and used jQuery.extend to assist in making it as OO as possible.
During the initialisation of my control I wire up various click events like so
```
jQuery('#available input',
this.controlDiv).bind('click', this, this.availableCategoryClick);
```
Notice that I am ... | You can use [`jQuery.proxy()`](http://api.jquery.com/jQuery.proxy/) with anonymous function, just a little awkward that 'context' is the second parameter.
```
$("#button").click($.proxy(function () {
//use original 'this'
},this));
``` |
520,020 | <p>Using DQL I want to return all the documents under the Cabinet <em>test</em>. How would I go about writing a query to do this?</p>
| [
{
"answer_id": 520071,
"author": "heeen",
"author_id": 38893,
"author_profile": "https://Stackoverflow.com/users/38893",
"pm_score": 3,
"selected": true,
"text": "<pre><code>select r_object_id, object_name from dm_document(all) where folder('/NameOfCabinet', descend);\n</code></pre>\n"
... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Using DQL I want to return all the documents under the Cabinet *test*. How would I go about writing a query to do this? | ```
select r_object_id, object_name from dm_document(all) where folder('/NameOfCabinet', descend);
``` |
520,030 | <p>I want to get the distinct values in a list, but not by the standard equality comparison.</p>
<p>What I want to do is something like this:</p>
<pre><code>return myList.Distinct( (x, y) => x.Url == y.Url );
</code></pre>
<p>I can't, there's no extension method in Linq that will do this - just one that takes an ... | [
{
"answer_id": 520046,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": true,
"text": "<p>It's annoying, certainly. It's also part of my \"MoreLINQ\" project which I must pay some attention to at some point :... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | I want to get the distinct values in a list, but not by the standard equality comparison.
What I want to do is something like this:
```
return myList.Distinct( (x, y) => x.Url == y.Url );
```
I can't, there's no extension method in Linq that will do this - just one that takes an `IEqualityComparer`.
I can hack aro... | It's annoying, certainly. It's also part of my "MoreLINQ" project which I must pay some attention to at some point :) There are plenty of other operations which make sense when acting on a projection, but returning the original - MaxBy and MinBy spring to mind.
As you say, it's easy to write - although I prefer the na... |
520,033 | <p>I would like to create a lookup table in OCaml. The table will have 7000+ entries that, upon lookup (by int), return a string. What is an appropriate data structure to use for this task? Should the table be externalized from the base code and if so, how does one go about "including" the lookup table to be accessible... | [
{
"answer_id": 520591,
"author": "Chris Conway",
"author_id": 1412,
"author_profile": "https://Stackoverflow.com/users/1412",
"pm_score": 3,
"selected": false,
"text": "<pre><code>let table : (int,string) Hashtbl.t = Hashtbl.create 8192\n</code></pre>\n"
},
{
"answer_id": 520695,... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25985/"
] | I would like to create a lookup table in OCaml. The table will have 7000+ entries that, upon lookup (by int), return a string. What is an appropriate data structure to use for this task? Should the table be externalized from the base code and if so, how does one go about "including" the lookup table to be accessible fr... | If the strings are addressed using consecutive integers you could use an array.
Otherwise you can use a hash table (non-functional) or a Map (functional). To get started with the Map try:
```
module Int =
struct
type t = int
let compare = compare
end ;;
module IntMap = Map.Make(Int) ;;
```
If the table is too ... |
520,035 | <p>It would be very useful to be able to overload the . operator in C++ and return a reference to an object.</p>
<p>You can overload <code>operator-></code> and <code>operator*</code> but not <code>operator.</code></p>
<p>Is there a technical reason for this?</p>
| [
{
"answer_id": 520059,
"author": "mfazekas",
"author_id": 27048,
"author_profile": "https://Stackoverflow.com/users/27048",
"pm_score": 5,
"selected": false,
"text": "<p>Stroustrup <a href=\"http://www.stroustrup.com/bs_faq2.html#overload-dot\" rel=\"noreferrer\">has an answer for this ... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4086/"
] | It would be very useful to be able to overload the . operator in C++ and return a reference to an object.
You can overload `operator->` and `operator*` but not `operator.`
Is there a technical reason for this? | See [this quote from Bjarne Stroustrup](http://www.stroustrup.com/bs_faq2.html#overload-dot):
>
> Operator . (dot) could in principle be overloaded using the same
> technique as used for ->. However, doing so can lead to questions
> about whether an operation is meant for the object overloading . or an
> object re... |
520,043 | <p>There is a question regarding usage of functional programming techiques in C# code. Example</p>
<p>Let we have interface</p>
<pre><code>interface IGraph { /*contains vertices and edges*/}
</code></pre>
<p>Suppose we need to layout graph's vertices (assign Point to each vertex).</p>
<pre><code>interface ILayoutIn... | [
{
"answer_id": 520059,
"author": "mfazekas",
"author_id": 27048,
"author_profile": "https://Stackoverflow.com/users/27048",
"pm_score": 5,
"selected": false,
"text": "<p>Stroustrup <a href=\"http://www.stroustrup.com/bs_faq2.html#overload-dot\" rel=\"noreferrer\">has an answer for this ... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | There is a question regarding usage of functional programming techiques in C# code. Example
Let we have interface
```
interface IGraph { /*contains vertices and edges*/}
```
Suppose we need to layout graph's vertices (assign Point to each vertex).
```
interface ILayoutInfo {
Point GetVertexPoint(vertex);
}
```
... | See [this quote from Bjarne Stroustrup](http://www.stroustrup.com/bs_faq2.html#overload-dot):
>
> Operator . (dot) could in principle be overloaded using the same
> technique as used for ->. However, doing so can lead to questions
> about whether an operation is meant for the object overloading . or an
> object re... |
520,051 | <p>I get a DataTable from a DataSet and then bind that DataTable to a DataGridView. Once the user edits the information on the DataGridView how do I take those changes and put them back into a DataTable that was used that I can then put back into my DataSet?</p>
<p>I want to make a Save Button on my DataGrid that when... | [
{
"answer_id": 520075,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "<p>If you are using data-binding to a <code>DataGridView</code>, then you are <em>already</em> updating the <code>Data... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60615/"
] | I get a DataTable from a DataSet and then bind that DataTable to a DataGridView. Once the user edits the information on the DataGridView how do I take those changes and put them back into a DataTable that was used that I can then put back into my DataSet?
I want to make a Save Button on my DataGrid that when pressed a... | If you are using data-binding to a `DataGridView`, then you are *already* updating the `DataTable` / `DataSet`. If you mean changes down to the database, then that is where adapters come into play.
Here's an example:
```
using System;
using System.Data;
using System.Linq;
using System.Windows.Forms;
static class Prog... |
520,083 | <p>I read <a href="http://jacobcarpenter.wordpress.com/2008/01/02/c-abuse-of-the-day-functional-library-implemented-with-lambdas/" rel="noreferrer">This article</a> and i found it interesting.</p>
<p>To sum it up for those who don't want to read the entire post. The author implements a higher order function named Curr... | [
{
"answer_id": 520101,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 5,
"selected": true,
"text": "<p>Its easier to first consider fn(x,y,z). This could by curried using fn(x,y) giving you a function that only takes... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35128/"
] | I read [This article](http://jacobcarpenter.wordpress.com/2008/01/02/c-abuse-of-the-day-functional-library-implemented-with-lambdas/) and i found it interesting.
To sum it up for those who don't want to read the entire post. The author implements a higher order function named Curry like this (refactored by me without ... | Its easier to first consider fn(x,y,z). This could by curried using fn(x,y) giving you a function that only takes one parameter, the z. Whatever needs to be done with x and y alone can be done and stored by a closure that the returned function holds on to.
Now you call the returned function several times with various ... |
520,099 | <p>Ruby is preinstalled on my Mac and so I wanted to have a look at it. First thing I noticed, is that irb prompts >> instead of irb(main):001:0>. I can't find anything on how to change this with Google because everyone is using irb(main):001:0> in their code ;-)</p>
<p>Can you help me out?</p>
<p>PS: It's not that I... | [
{
"answer_id": 520122,
"author": "troelskn",
"author_id": 18180,
"author_profile": "https://Stackoverflow.com/users/18180",
"pm_score": 5,
"selected": true,
"text": "<pre><code>$ irb --help\nUsage: irb.rb [options] [programfile] [arguments]\n --prompt prompt-mode\n --prompt-mode promp... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60974/"
] | Ruby is preinstalled on my Mac and so I wanted to have a look at it. First thing I noticed, is that irb prompts >> instead of irb(main):001:0>. I can't find anything on how to change this with Google because everyone is using irb(main):001:0> in their code ;-)
Can you help me out?
PS: It's not that I think Ruby is br... | ```
$ irb --help
Usage: irb.rb [options] [programfile] [arguments]
--prompt prompt-mode
--prompt-mode prompt-mode
Switch prompt mode. Pre-defined prompt modes are
`default', `simple', `xmp' and `inf-ruby'
$ irb --prompt inf-ruby
irb(main):001:0>
``` |
520,102 | <p>For example my table is here>></p>
<pre><code>CREATE TABLE tProject(
name nvarchar(1000),
Goal ntext,
Activities ntext,
Result ntext,
MonName nvarchar(1000),
MonGoal ntext,
MonActivities ntext,
MonResult ntext,
TotalFund nvarchar(100))
</code></pre>
<p>how to search from all ntext and nvarchar fields in onetime... | [
{
"answer_id": 520122,
"author": "troelskn",
"author_id": 18180,
"author_profile": "https://Stackoverflow.com/users/18180",
"pm_score": 5,
"selected": true,
"text": "<pre><code>$ irb --help\nUsage: irb.rb [options] [programfile] [arguments]\n --prompt prompt-mode\n --prompt-mode promp... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60200/"
] | For example my table is here>>
```
CREATE TABLE tProject(
name nvarchar(1000),
Goal ntext,
Activities ntext,
Result ntext,
MonName nvarchar(1000),
MonGoal ntext,
MonActivities ntext,
MonResult ntext,
TotalFund nvarchar(100))
```
how to search from all ntext and nvarchar fields in onetime.
help me please | ```
$ irb --help
Usage: irb.rb [options] [programfile] [arguments]
--prompt prompt-mode
--prompt-mode prompt-mode
Switch prompt mode. Pre-defined prompt modes are
`default', `simple', `xmp' and `inf-ruby'
$ irb --prompt inf-ruby
irb(main):001:0>
``` |
520,107 | <p>I implemented threading in my application for scraping websites. After all the sites are scraped I want to process them.</p>
<p>form creates queueworker(which creates 2 workers and processes tasks).
After all the tasks are done I want to process them baack in the formthread.
At this point I accieved this with</p>
<p... | [
{
"answer_id": 520130,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "<p>Why are you doing the Join? I would raise a callback at the end of each thread - perhaps decrementing a counter. Wh... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47351/"
] | I implemented threading in my application for scraping websites. After all the sites are scraped I want to process them.
form creates queueworker(which creates 2 workers and processes tasks).
After all the tasks are done I want to process them baack in the formthread.
At this point I accieved this with
```
public voi... | Why are you doing the Join? I would raise a callback at the end of each thread - perhaps decrementing a counter. When the counter gets to 0, *then* call back to the UI thread and do the "all done" code; something like:
```
using System.Windows.Forms;
using System.Threading;
using System;
class MyForm : Form
{
pub... |
520,115 | <p>In WPF 3.5SP1 i use the last feature StringFormat in DataBindings:</p>
<pre><code> <TextBlock Text="{Binding Path=Model.SelectedNoteBook.OriginalDate, StringFormat='f'}"
FontSize="20" TextTrimming="CharacterEllipsis" />
</code></pre>
<p>The problem I face is that the date is always format... | [
{
"answer_id": 520334,
"author": "loraderon",
"author_id": 22092,
"author_profile": "https://Stackoverflow.com/users/22092",
"pm_score": 8,
"selected": false,
"text": "<pre><code>// Ensure the current culture passed into bindings is the OS culture.\n// By default, WPF uses en-US as the c... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In WPF 3.5SP1 i use the last feature StringFormat in DataBindings:
```
<TextBlock Text="{Binding Path=Model.SelectedNoteBook.OriginalDate, StringFormat='f'}"
FontSize="20" TextTrimming="CharacterEllipsis" />
```
The problem I face is that the date is always formatted in English...although my sys... | ```
// Ensure the current culture passed into bindings is the OS culture.
// By default, WPF uses en-US as the culture, regardless of the system settings.
FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement),
new FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(CultureInf... |
520,131 | <p>I'm having some problems translating this query to use ZF's <code>Zend_Db_Select</code>:</p>
<pre><code>SELECT b.id, b.title, b.description
FROM memberships AS m
JOIN blogs AS b ON b.id = m.blog_id
WHERE m.user_id = ?
ORDER BY m.created
LIMIT 0, 30
</code></pre>
<p>(this query works and returns results)</p>
<p><c... | [
{
"answer_id": 520156,
"author": "cg.",
"author_id": 52439,
"author_profile": "https://Stackoverflow.com/users/52439",
"pm_score": 4,
"selected": true,
"text": "<p>When retrieved from your table object, the statement will be limited to that table I think. The <code>Zend_Db_Table::select(... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2025/"
] | I'm having some problems translating this query to use ZF's `Zend_Db_Select`:
```
SELECT b.id, b.title, b.description
FROM memberships AS m
JOIN blogs AS b ON b.id = m.blog_id
WHERE m.user_id = ?
ORDER BY m.created
LIMIT 0, 30
```
(this query works and returns results)
`Memberships` is a link table between `blog... | When retrieved from your table object, the statement will be limited to that table I think. The `Zend_Db_Table::select()` methods returns a `Zend_Db_Table_Select` object which is a subclass of `Zend_Db_Select` and imposes this restriction. Try this instead:
```
$db = Zend_Db::factory( ...options... );
$select = new Ze... |
520,132 | <h2>Static variable gotcha in php</h2>
<p>I am from Java background and have switched to php for one project recently.
I have found one unexpected behaviour in php. </p>
<blockquote>
<p><strong>Value set to some static variable is</strong>
<strong>not staying persistent across the</strong>
<strong>requests.</st... | [
{
"answer_id": 520139,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 6,
"selected": true,
"text": "<p>No, while a static variable will stay for the current request you'll need to add it to a session to persist it's value across... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45232/"
] | Static variable gotcha in php
-----------------------------
I am from Java background and have switched to php for one project recently.
I have found one unexpected behaviour in php.
>
> **Value set to some static variable is**
> **not staying persistent across the**
> **requests.**
>
>
>
I am not sure if this ... | No, while a static variable will stay for the current request you'll need to add it to a session to persist it's value across requests.
Example:
```
session_start();
class Car {
public static $make;
public function __construct($make) {
self::$make = $make;
}
}
$c = new Car('Bugatti');
echo '<p>'... |
520,138 | <p>I do some type analysis in runtime using Reflection. If I have a MethodInfo instance,
how can I figure out if this is a "real" method or is a getter/setter method of a property? And if it is a property, how can I find the its hosting PropertyInfo back?</p>
| [
{
"answer_id": 520155,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": false,
"text": "<p>Well, the method behind a getter and setter <em>are</em> \"real\" methods.</p>\n\n<p>Re tracking back to a propert... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24451/"
] | I do some type analysis in runtime using Reflection. If I have a MethodInfo instance,
how can I figure out if this is a "real" method or is a getter/setter method of a property? And if it is a property, how can I find the its hosting PropertyInfo back? | Ecma 335 specifies (but does not demand) that compilers use the get\_/set\_ prefixes (chapter 22.28). I don't know any language that breaks that recommendation. Making it easy:
```
public static PropertyInfo GetPropFromMethod(Type t, MethodInfo method) {
if (!method.IsSpecialName) return null;
return t.GetProperty... |
520,143 | <p>I have a number of slots and pegs arranged in a straight line. The pegs can be moved and need to be moved to a slot each. A slot can be left empty only if all pegs are taken. When a peg is moved, it is not allowed to go past another peg. In other words the order of the pegs must be maintained. Preferably, the total ... | [
{
"answer_id": 520171,
"author": "alphadogg",
"author_id": 59494,
"author_profile": "https://Stackoverflow.com/users/59494",
"pm_score": -1,
"selected": false,
"text": "<p>Queueing theory or mathematics...</p>\n"
},
{
"answer_id": 520183,
"author": "Konrad Rudolph",
"auth... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45603/"
] | I have a number of slots and pegs arranged in a straight line. The pegs can be moved and need to be moved to a slot each. A slot can be left empty only if all pegs are taken. When a peg is moved, it is not allowed to go past another peg. In other words the order of the pegs must be maintained. Preferably, the total dis... | I think this is classic fodder for a [dynamic programming](http://en.wikipedia.org/wiki/Dynamic_programming) solution. In fact, have a look a "sequence alignment" which might be another good search term on that wikipedia page.
The key insight is this:
Imagine you have your pegs as a list of peg positions (peg1:more ... |
520,150 | <p>Do you know any way that I could programmatically or via scrirpt transform a set of text files saved in ansi character encoding, to unicode encoding?</p>
<p>I would like to do the same as I do when I open the file with notepad and choose to save it as an unicode file.</p>
| [
{
"answer_id": 520176,
"author": "Lonzo",
"author_id": 47342,
"author_profile": "https://Stackoverflow.com/users/47342",
"pm_score": 0,
"selected": false,
"text": "<p>Use the System.IO.StreamReader(To read the file contents) class together with the System.Text.Encoding.Encoding(To create... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37783/"
] | Do you know any way that I could programmatically or via scrirpt transform a set of text files saved in ansi character encoding, to unicode encoding?
I would like to do the same as I do when I open the file with notepad and choose to save it as an unicode file. | You can use iconv. On Windows you can use it under Cygwin.
```
iconv -f from_encoding -t to_encoding file
``` |
520,163 | <p>How can i learn next wednesday, monday in a week? Forexample Today 06.02.2009 next Monday 09.02.2009 or wednesday 11.02.2009 there is any algorithm? </p>
<p>i need :</p>
<p>which day monday in comingweek?</p>
<p>findDay("Monday")</p>
<p>it must return 09.02.2009</p>
<p>=========================================... | [
{
"answer_id": 520170,
"author": "Michaël Carpentier",
"author_id": 63081,
"author_profile": "https://Stackoverflow.com/users/63081",
"pm_score": 2,
"selected": false,
"text": "<pre><code>DateTime now = DateTime.Now;\nDateTime nextMonday = now.AddDays((int)now.DayOfWeek - (int)DayOfWeek.... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52420/"
] | How can i learn next wednesday, monday in a week? Forexample Today 06.02.2009 next Monday 09.02.2009 or wednesday 11.02.2009 there is any algorithm?
i need :
which day monday in comingweek?
findDay("Monday")
it must return 09.02.2009
=====================================================
findDay("Tuesday")
it ... | ```
DateTime now = DateTime.Now;
DateTime nextMonday = now.AddDays((int)now.DayOfWeek - (int)DayOfWeek.Monday);
```
Hum it seems that I answered too quickly. Actually there are more checking to do. Have a look at nobugz or peterchen answers. |
520,165 | <p>I have been trying to access a .NET Assembly that I have created in classic ASP using</p>
<pre><code>dim foo
set foo = Server.CreateObject("TestAssembly.MyClass")
</code></pre>
<p>The problem is I'm getting an error:</p>
<pre><code>Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/test.asp, ... | [
{
"answer_id": 520175,
"author": "Chris Ballance",
"author_id": 1551,
"author_profile": "https://Stackoverflow.com/users/1551",
"pm_score": 0,
"selected": false,
"text": "<p>This error means \"Invalid class string\" -- in other words the call to CreateObject failed because the name objec... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459159/"
] | I have been trying to access a .NET Assembly that I have created in classic ASP using
```
dim foo
set foo = Server.CreateObject("TestAssembly.MyClass")
```
The problem is I'm getting an error:
```
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/test.asp, line 4
Invalid class string
```
I ... | Another thing to check: make sure your .Net assembly is set to be COM Visible. |
520,168 | <p>I have used Collections in my code with Generics. When try to compile that java file in build.xml, its showing error at generics and its saying its not a statement. I am using Apache-Ant-1.6.5 and i have installed JDK 1.5 only . I know generic will support in jdk1.5 but its showing error. The below is the error i a... | [
{
"answer_id": 520177,
"author": "Vinze",
"author_id": 26859,
"author_profile": "https://Stackoverflow.com/users/26859",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe you can check the version of your compilator with :</p>\n\n<pre><code><echo>JVM version is ${ant.java.version... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51659/"
] | I have used Collections in my code with Generics. When try to compile that java file in build.xml, its showing error at generics and its saying its not a statement. I am using Apache-Ant-1.6.5 and i have installed JDK 1.5 only . I know generic will support in jdk1.5 but its showing error. The below is the error i am ge... | Have you tried explicitly setting the `source` and `target` attributes for your [javac](http://ant.apache.org/manual/Tasks/javac.html) task?
```
<target name="compile">
<javac .....
source="1.6"
target="1.6" />
</target>
``` |
520,187 | <p>Let's say I have definied a User object using GORM. Each user can have zero or more Login:s. Each Login has a timestamp. When retrieving user.logins I want the logins to be sorted based on the value of login.date. What is the correct Grails way to achieve this?</p>
<p>Example: I want the following code to list all ... | [
{
"answer_id": 520326,
"author": "Siegfried Puchbauer",
"author_id": 46301,
"author_profile": "https://Stackoverflow.com/users/46301",
"pm_score": 4,
"selected": false,
"text": "<p>Just make the Login Class implement the Comparable interface:</p>\n\n<pre><code>class Login implements Comp... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58394/"
] | Let's say I have definied a User object using GORM. Each user can have zero or more Login:s. Each Login has a timestamp. When retrieving user.logins I want the logins to be sorted based on the value of login.date. What is the correct Grails way to achieve this?
Example: I want the following code to list all the user's... | The handling of default sort order in Grails/GORM seems to have been radically simplified in Grails 1.1:
* [Grails 1.1 release notes](http://www.grails.org/1.1+Release+Notes) (search for "Default Sort Order") |
520,196 | <p>Is there a way to check if a file is already open in Perl?
I want to have a read file access, so don't require <code>flock</code>.</p>
<pre><code> open(FH, "<$fileName") or die "$!\n" if (<FILE_IS_NOT_ALREADY_OPEN>);
# or something like
close(FH) if (<FILE_IS_OPEN>);
</code></pre>
| [
{
"answer_id": 520215,
"author": "chaos",
"author_id": 47529,
"author_profile": "https://Stackoverflow.com/users/47529",
"pm_score": 6,
"selected": true,
"text": "<p>Please see the <a href=\"https://stackoverflow.com/a/5993224/47529\">answer regarding <code>openhandle()</code> from <code... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there a way to check if a file is already open in Perl?
I want to have a read file access, so don't require `flock`.
```
open(FH, "<$fileName") or die "$!\n" if (<FILE_IS_NOT_ALREADY_OPEN>);
# or something like
close(FH) if (<FILE_IS_OPEN>);
``` | Please see the [answer regarding `openhandle()` from `Scalar::Util`](https://stackoverflow.com/a/5993224/47529). The answer I originally wrote here was once the best we could do, but it's now badly outdated. |
520,199 | <p>I can easily select all comments from XML by </p>
<pre><code>select @XML.query('comment()')
</code></pre>
<p>but can't find how to delete them. Is there appropriate syntax for @XML.modify('delete ...')?</p>
| [
{
"answer_id": 520283,
"author": "Alsin",
"author_id": 63312,
"author_profile": "https://Stackoverflow.com/users/63312",
"pm_score": 2,
"selected": true,
"text": "\n\n<pre class=\"lang-xquery prettyprint-override\"><code>set @XML.modify('delete comment()')\nselect @XML\n</code></pre>\n\n... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63312/"
] | I can easily select all comments from XML by
```
select @XML.query('comment()')
```
but can't find how to delete them. Is there appropriate syntax for @XML.modify('delete ...')? | ```xquery
set @XML.modify('delete comment()')
select @XML
```
Here it is. |
520,237 | <p>I need to keep a session alive for 30 minutes and then destroy it. </p>
| [
{
"answer_id": 520258,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 6,
"selected": false,
"text": "<p>Is this to log the user out after a set time? Setting the session creation time (or an expiry time) when it is registered, a... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45350/"
] | I need to keep a session alive for 30 minutes and then destroy it. | You should implement a session timeout of your own. Both options mentioned by others ([*session.gc\_maxlifetime*](http://php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime) and [*session.cookie\_lifetime*](http://php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime)) are not relia... |
520,241 | <p>How do I find the cosine similarity between vectors?</p>
<p>I need to find the similarity to measure the relatedness between two lines of text.</p>
<p>For example, I have two sentences like:</p>
<blockquote>
<p>system for user interface</p>
<p>user interface machine</p>
</blockquote>
<p>… and their respective vector... | [
{
"answer_id": 520263,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 5,
"selected": false,
"text": "<p>Have a look at: <a href=\"http://en.wikipedia.org/wiki/Cosine_similarity\" rel=\"noreferrer\">http://en.wikipedia.... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I find the cosine similarity between vectors?
I need to find the similarity to measure the relatedness between two lines of text.
For example, I have two sentences like:
>
> system for user interface
>
>
> user interface machine
>
>
>
… and their respective vectors after tF-idf, followed by normalisati... | ```
public class CosineSimilarity extends AbstractSimilarity {
@Override
protected double computeSimilarity(Matrix sourceDoc, Matrix targetDoc) {
double dotProduct = sourceDoc.arrayTimes(targetDoc).norm1();
double eucledianDist = sourceDoc.normF() * targetDoc.normF();
return dotProduct / eucledianDist;... |
520,250 | <p>In jQuery I need to do an if statement to see if $this doesn't contain the class '.selected'.</p>
<pre><code>$(".thumbs").hover(function(){
$(this).stop().fadeTo("normal", 1.0);
},function(){
$(this).stop().fadeTo("slow", 0.3);
});
</code></pre>
<p>Basically when this function is run (on hover) I don't want to p... | [
{
"answer_id": 520271,
"author": "alphadogg",
"author_id": 59494,
"author_profile": "https://Stackoverflow.com/users/59494",
"pm_score": 10,
"selected": true,
"text": "<p>Use the <a href=\"http://docs.jquery.com/Selectors/not#selector\" rel=\"noreferrer\">\"not</a>\" selector.</p>\n\n<p>... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26823/"
] | In jQuery I need to do an if statement to see if $this doesn't contain the class '.selected'.
```
$(".thumbs").hover(function(){
$(this).stop().fadeTo("normal", 1.0);
},function(){
$(this).stop().fadeTo("slow", 0.3);
});
```
Basically when this function is run (on hover) I don't want to perform the fades if the cl... | Use the ["not](http://docs.jquery.com/Selectors/not#selector)" selector.
For example, instead of:
`$(".thumbs").hover()`
try:
`$(".thumbs:not(.selected)").hover()` |
520,252 | <p>Is there a regular expression to find two different words in a sentence? Extra credit for an expression that works in MS Visual Studio 2008 :)</p>
<p>For example:</p>
<pre><code>reg_ex_match(A, B, "A sentence with A and B") = true
reg_ex_match(C, D, "A sentence with A and B") = false
</code></pre>
<p>See also th... | [
{
"answer_id": 520269,
"author": "Kon",
"author_id": 22303,
"author_profile": "https://Stackoverflow.com/users/22303",
"pm_score": -1,
"selected": false,
"text": "<p>Try searching <a href=\"http://regexlib.com\" rel=\"nofollow noreferrer\">regexlib</a>, a regular expression repository.</... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15985/"
] | Is there a regular expression to find two different words in a sentence? Extra credit for an expression that works in MS Visual Studio 2008 :)
For example:
```
reg_ex_match(A, B, "A sentence with A and B") = true
reg_ex_match(C, D, "A sentence with A and B") = false
```
See also this related [question](https://stac... | For real words:
```
\bA\b.+\bB\b|\bB\b.+\bA\b
``` |
520,284 | <p>Ok, so I'm using Java ME to connect to a PHP script on my server, but for some odd reason the networking will only work the first time the app is run on the phone after installation. Any other time, it won't even ask permission to use the network. Here's the method in question:</p>
<pre><code>private static String ... | [
{
"answer_id": 520287,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 0,
"selected": false,
"text": "<p>Testing of internal classes should happen through testing your public methods.</p>\n"
},
{
"answer_id": 520... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Ok, so I'm using Java ME to connect to a PHP script on my server, but for some odd reason the networking will only work the first time the app is run on the phone after installation. Any other time, it won't even ask permission to use the network. Here's the method in question:
```
private static String defaultURL = "... | You can friend two assemblies together. Then one can see the "internal" in the other. Still can't see private.
MSDN - <http://msdn.microsoft.com/en-us/library/0tke9fxk(VS.80).aspx> |
520,290 | <p>I know the "default" keyword returns the default value of a statically determined type, as shown for instance in <a href="https://stackoverflow.com/questions/367378/returning-a-default-value-c">this question</a>.</p>
<p>However, given an instance of a type, is there a simple way to get the default value of this typ... | [
{
"answer_id": 520306,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>Why do you want to avoid Activator? Basically that <em>is</em> the way of doing it.</p>\n\n<p>I mean, you could write... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47916/"
] | I know the "default" keyword returns the default value of a statically determined type, as shown for instance in [this question](https://stackoverflow.com/questions/367378/returning-a-default-value-c).
However, given an instance of a type, is there a simple way to get the default value of this type, dynamically ?
The ... | This is likely your best route.
I wouldn't be afraid of using the Activator class here. This is a pretty standard class that is depended on by the compilers. For instance this VB code
```
Public Sub Example(Of T as New)()
Dim x = new T()
End Sub
```
Translates into roughly this code
```
Public Sub Example(Of T... |
520,328 | <p>Is it possible to find all classes or interfaces in a given package? (Quickly looking at e.g. <a href="http://java.sun.com/javase/6/docs/api/java/lang/Package.html" rel="noreferrer"><code>Package</code></a>, it would seem like no.)</p>
| [
{
"answer_id": 520335,
"author": "Marko",
"author_id": 31141,
"author_profile": "https://Stackoverflow.com/users/31141",
"pm_score": -1,
"selected": false,
"text": "<p>It is not possible, since all classes in the package might not be loaded, while you always knows package of a class.</p... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56285/"
] | Is it possible to find all classes or interfaces in a given package? (Quickly looking at e.g. [`Package`](http://java.sun.com/javase/6/docs/api/java/lang/Package.html), it would seem like no.) | Due to the dynamic nature of class loaders, this is not possible. Class loaders are not required to tell the VM which classes it can provide, instead they are just handed requests for classes, and have to return a class or throw an exception.
However, if you write your own class loaders, or examine the classpaths and ... |
520,347 | <p>What is the best way to determine if there is a network connection available?</p>
| [
{
"answer_id": 520352,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 8,
"selected": true,
"text": "<p>You can check for a network connection in .NET 2.0 using <a href=\"http://msdn.microsoft.com/en-us/library/system.ne... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54009/"
] | What is the best way to determine if there is a network connection available? | You can check for a network connection in .NET 2.0 using [`GetIsNetworkAvailable()`](http://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface.getisnetworkavailable.aspx):
```
System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()
```
To monitor changes in IP address or c... |
520,348 | <p>I have a servlet which processes a request for a long time. It suppose
to keep doing stuff in the loop inside doPost and send data through
response's out writer. Effectively that continuously appends data in
the clients browser .
But the problems accures when client just closes the browser. Inspite
of the broken con... | [
{
"answer_id": 520389,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 3,
"selected": true,
"text": "<p>The only real way of dealing with this is to have the browser constantly tell you that it's still there, say every 5-10 s... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20390/"
] | I have a servlet which processes a request for a long time. It suppose
to keep doing stuff in the loop inside doPost and send data through
response's out writer. Effectively that continuously appends data in
the clients browser .
But the problems accures when client just closes the browser. Inspite
of the broken connec... | The only real way of dealing with this is to have the browser constantly tell you that it's still there, say every 5-10 seconds. If you go for a minute without hearing anything, you assume the client is gone and forget what you're doing.
There are several ways to implement this:
* Meta refresh: I don't like this beca... |
520,399 | <p>I am new to jQuery and I am using ajax request to get an xml as response,</p>
<pre><code> $.get("testurl",pars,function(data){
xml = data;
$(xml).find("element").each(function(i,item){
if(($(this).attr("id"))!= undefined){
tab_str += "<tr><td>'id'</td><td>"+$(this... | [
{
"answer_id": 520419,
"author": "jacobangel",
"author_id": 31318,
"author_profile": "https://Stackoverflow.com/users/31318",
"pm_score": 2,
"selected": false,
"text": "<p>I would guess your response isn't returning quickly enough? Have you tried setting the xml using the success: parame... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am new to jQuery and I am using ajax request to get an xml as response,
```
$.get("testurl",pars,function(data){
xml = data;
$(xml).find("element").each(function(i,item){
if(($(this).attr("id"))!= undefined){
tab_str += "<tr><td>'id'</td><td>"+$(this).attr("id")+"</td></tr>";
}
... | If you copied-n-pasted the code in your example, you have `async` misspelled `aysnc`. Without that option, it will run asynchronously. |
520,400 | <p>How would I test a property of a type to see if it is a specified type?</p>
<p>EDIT: My goal is to examine an assembly to see if any of the types in that assembly contain properties that are MyType (or inherited from MyType).</p>
<p>Here is the track I've gone down...</p>
<pre><code>AssemblyName n = new Assembly... | [
{
"answer_id": 520413,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": true,
"text": "<p>What type are you interested in? The return type of the method/property/event etc?</p>\n\n<p>If so, I don't think ther... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4200/"
] | How would I test a property of a type to see if it is a specified type?
EDIT: My goal is to examine an assembly to see if any of the types in that assembly contain properties that are MyType (or inherited from MyType).
Here is the track I've gone down...
```
AssemblyName n = new AssemblyName();
n.CodeBase = "file://... | What type are you interested in? The return type of the method/property/event etc?
If so, I don't think there's anything in `MemberInfo` to let you get at it directly - you'll need to cast and use `MethodInfo.ReturnType`, `PropertyInfo.PropertyType`, `FieldInfo.FieldType`, `EventInfo.EventHandlerType` and any others I... |
520,405 | <p>One of the ncie things about PHP is that if you do an include/require it works off the directory where the file is (or rather the URI of the request). That means that if you want to include further file you don't need to know from where the original script is running. All you need to know is where the current scri... | [
{
"answer_id": 520428,
"author": "Karmic Coder",
"author_id": 36307,
"author_profile": "https://Stackoverflow.com/users/36307",
"pm_score": 1,
"selected": false,
"text": "<p>Define a constant with your desired path to the file, wherever you'd normally put configuration settings. Keeps it... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18393/"
] | One of the ncie things about PHP is that if you do an include/require it works off the directory where the file is (or rather the URI of the request). That means that if you want to include further file you don't need to know from where the original script is running. All you need to know is where the current script is... | You can get the directory associated with the current file using
```
dirname(__FILE__)
```
So you could do something like this:
```
file_get_contents(dirname(__FILE__) . '/foo.txt')
``` |
520,412 | <p>I need to check if a certain post belongs to a category or belongs to a descendant of a certain category.
Is there a WordPress function for this, or do I need to do it myself?</p>
<p>I should have mentioned that the WP version is 2.7.</p>
| [
{
"answer_id": 520554,
"author": "rz.",
"author_id": 7407,
"author_profile": "https://Stackoverflow.com/users/7407",
"pm_score": 4,
"selected": true,
"text": "<pre><code>$post = get_post($id);\n$category = $post->$post_category;\ncat_is_ancestor_of(($parent_category, $category));\n</c... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36047/"
] | I need to check if a certain post belongs to a category or belongs to a descendant of a certain category.
Is there a WordPress function for this, or do I need to do it myself?
I should have mentioned that the WP version is 2.7. | ```
$post = get_post($id);
$category = $post->$post_category;
cat_is_ancestor_of(($parent_category, $category));
```
For more info see the [get\_post](http://codex.wordpress.org/Function_Reference/get_post) and [cat is ancestor of](http://codex.wordpress.org/Function_Reference/cat_is_ancestor_of) references. Also, wh... |
520,429 | <p>I have a couple of classes that I have created for my web project and I am going to store them in the App_Code folder. I don't want to store all the classes in the top level (no namespace) but want to organize them into namespaces. So far this does not seem possible because when I use the "using XXXX;" namespace sta... | [
{
"answer_id": 520444,
"author": "cyberbobcat",
"author_id": 52408,
"author_profile": "https://Stackoverflow.com/users/52408",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried building the project first of all and then try \"using\" them ?</p>\n"
},
{
"answer_id": 520... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62544/"
] | I have a couple of classes that I have created for my web project and I am going to store them in the App\_Code folder. I don't want to store all the classes in the top level (no namespace) but want to organize them into namespaces. So far this does not seem possible because when I use the "using XXXX;" namespace state... | I have figured it out. I am really stupid. Sorry for the worry. It was because I had the namespace and the class name the same so it could not differentiate and needed the fully qualified name. As soon as I changed the class name everything worked as expected. |
520,437 | <p>We have a list of (let's say 50) reports that get dumped into various folders depending on certain conditions. All the reports have standard names eg. D099C.LIS, D18A0.LIS etc.</p>
<p>Sometimes a report can exist in up to 5 different locations, and I need to generate a list of all the locations of the most recent ... | [
{
"answer_id": 520458,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 4,
"selected": true,
"text": "<pre><code>ls -r -fi *.lis | sort @{expression={$_.Name}}, @{expression={$_.LastWriteTime};Descending=$true} | select Directo... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9825/"
] | We have a list of (let's say 50) reports that get dumped into various folders depending on certain conditions. All the reports have standard names eg. D099C.LIS, D18A0.LIS etc.
Sometimes a report can exist in up to 5 different locations, and I need to generate a list of all the locations of the most recent version of ... | ```
ls -r -fi *.lis | sort @{expression={$_.Name}}, @{expression={$_.LastWriteTime};Descending=$true} | select Directory, Name, lastwritetime | Group-Object Name | %{$_.Group | Select -first 1}
``` |
520,467 | <p>For WebApps, web.xml can be used to store application settings. How can I read this file. My servlets run in a GlassFish v2 server.</p>
| [
{
"answer_id": 520534,
"author": "kgiannakakis",
"author_id": 24054,
"author_profile": "https://Stackoverflow.com/users/24054",
"pm_score": 2,
"selected": false,
"text": "<p>Add an init-param:</p>\n\n<pre><code><init-param> \n <param-name>InitParam</param-name> \n ... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56/"
] | For WebApps, web.xml can be used to store application settings. How can I read this file. My servlets run in a GlassFish v2 server. | Not sure I fully understand this question...
Assuming your Servlet extends [`HttpServlet`](http://tomcat.apache.org/tomcat-5.5-doc/servletapi/index.html)?
`HttpServlet` implements `ServletConfig`, so you can find out servlet specific parameters using:
In web.xml
```
<servlet>
<servlet-class>com.acme.Foo</servle... |
520,481 | <p>I have 3 images and have a function so that on mouse rollover they fade in and out. I don't want to do this if the image being rolled over has the class 'selected'.</p>
<p>So far I have this code:</p>
<pre><code>$(".thumbs").hover(function(){
if (!($(this).hasClass(".selected")){
$(this).stop().fadeTo("normal", ... | [
{
"answer_id": 520492,
"author": "Georg Schölly",
"author_id": 24587,
"author_profile": "https://Stackoverflow.com/users/24587",
"pm_score": 3,
"selected": false,
"text": "<p>The problem is that your element has the class \"selected\" not \".selected\". Remove the dot.</p>\n"
},
{
... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26823/"
] | I have 3 images and have a function so that on mouse rollover they fade in and out. I don't want to do this if the image being rolled over has the class 'selected'.
So far I have this code:
```
$(".thumbs").hover(function(){
if (!($(this).hasClass(".selected")){
$(this).stop().fadeTo("normal", 1.0);
},function(){
$... | [The jQuery docs on selectors](http://docs.jquery.com/Selectors) tells you everything you neeed to know.
```
$('.thumbs:not(.selected)').hover(function(){
// ...
})
``` |
520,506 | <p>I am trying to take tables from one Access Database File, add them to another Access Database file with the exact same structure but with different information. I need to overwrite any existing tables. I am almost done with my project this is last my brick wall.</p>
<p>I am using a separate class file named Databas... | [
{
"answer_id": 520513,
"author": "jalf",
"author_id": 33213,
"author_profile": "https://Stackoverflow.com/users/33213",
"pm_score": 1,
"selected": false,
"text": "<p>Traversing a tree without recursion is simple enough. Assuming a binary tree, each node presumably has three references to... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60615/"
] | I am trying to take tables from one Access Database File, add them to another Access Database file with the exact same structure but with different information. I need to overwrite any existing tables. I am almost done with my project this is last my brick wall.
I am using a separate class file named DatabaseHandling.... | Traversing a tree without recursion is simple enough. Assuming a binary tree, each node presumably has three references to other nodes. Left child, right child and parent.
So assuming a depth-first left to right iteration order, you follow the left-child references in a while-lop (pseudocode `while current.left-child !... |
520,509 | <p>I've been upgrading our solutions from VS 2005 to VS 2008; still targeting the .net 2.0 framework. The conversion wizard is simple and I've never had a conversion failure. The only beef that I've had so far is that I can't immediately compile after the upgrade because VS has changed some of my namespaces causing nam... | [
{
"answer_id": 520911,
"author": "Mark A Johnson",
"author_id": 45720,
"author_profile": "https://Stackoverflow.com/users/45720",
"pm_score": 2,
"selected": false,
"text": "<p>I believe that the namespace comes from the location of the xsd file. I think all the way back to 2003 the folde... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59017/"
] | I've been upgrading our solutions from VS 2005 to VS 2008; still targeting the .net 2.0 framework. The conversion wizard is simple and I've never had a conversion failure. The only beef that I've had so far is that I can't immediately compile after the upgrade because VS has changed some of my namespaces causing naming... | You can fix this by providing the namespace the code should be generated in:
Open the properties of the xsd file and put the namespace for the code next to "Custom Tool Namespace". Then click right on your xsd file and select "Run Custom Tool" and you're done. |
520,515 | <p>I am trying to see if a URL exists or not, and if it does not exist reset the variable containing the URL to an error page/image. However my attempt below sets every instance of PIC_URL to noimage.gif, regardless of if it exists and is accessible or not. What am I missing?</p>
<pre><code>if (@fopen($_REQUEST[$PIC_U... | [
{
"answer_id": 520529,
"author": "SilentGhost",
"author_id": 12855,
"author_profile": "https://Stackoverflow.com/users/12855",
"pm_score": 0,
"selected": false,
"text": "<p>use <code>file_exists</code> or is_readable, and don't use raw value</p>\n"
},
{
"answer_id": 520530,
"... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | I am trying to see if a URL exists or not, and if it does not exist reset the variable containing the URL to an error page/image. However my attempt below sets every instance of PIC\_URL to noimage.gif, regardless of if it exists and is accessible or not. What am I missing?
```
if (@fopen($_REQUEST[$PIC_URL],"r"))
{
... | The test on the else part looks redundant, and did you mean `$_REQUEST['PIC_URL']`?
```
if (@fopen($_REQUEST['PIC_URL'],"r"))
{
$status = "1";
}
else
{
$status = "2";
}
```
There's plenty more wrong with it though. To test if a remote file exists, you'd be better off using file\_exists, or even rolling y... |
520,517 | <p>I was searching for ways to change the start-up type of a Windows service and I found 2 ways to do this...</p>
<p><a href="http://www.techbytes.ca/techbyte74.html" rel="nofollow noreferrer">By editing the Registry</a> Or <a href="http://www.codeproject.com/KB/system/extendservicecontroller.aspx" rel="nofollow noref... | [
{
"answer_id": 520529,
"author": "SilentGhost",
"author_id": 12855,
"author_profile": "https://Stackoverflow.com/users/12855",
"pm_score": 0,
"selected": false,
"text": "<p>use <code>file_exists</code> or is_readable, and don't use raw value</p>\n"
},
{
"answer_id": 520530,
"... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520517",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57175/"
] | I was searching for ways to change the start-up type of a Windows service and I found 2 ways to do this...
[By editing the Registry](http://www.techbytes.ca/techbyte74.html) Or [By using the WMI classes](http://www.codeproject.com/KB/system/extendservicecontroller.aspx)
I want to know which one is the best... I want ... | The test on the else part looks redundant, and did you mean `$_REQUEST['PIC_URL']`?
```
if (@fopen($_REQUEST['PIC_URL'],"r"))
{
$status = "1";
}
else
{
$status = "2";
}
```
There's plenty more wrong with it though. To test if a remote file exists, you'd be better off using file\_exists, or even rolling y... |
520,519 | <p>I would like to burn in a c# code behind property into the javascript alert(<%= someProperty%>); . For some reason it is not working. Is there a way you can burn the codebehind property into the javascript? thanks</p>
| [
{
"answer_id": 520524,
"author": "Sergio",
"author_id": 32037,
"author_profile": "https://Stackoverflow.com/users/32037",
"pm_score": 1,
"selected": false,
"text": "<p>I think you are missing the ' try like this -->alert('<%= someProperty%>'); </p>\n"
},
{
"answer_id": 520526,... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like to burn in a c# code behind property into the javascript alert(<%= someProperty%>); . For some reason it is not working. Is there a way you can burn the codebehind property into the javascript? thanks | Not sure if this works in your situation, but I think your best bet might be to attach the javascript to the event dynamically in your code behind on page load and just set the parameter value at that point.
For example:
```
btnSubmit.Attributes.Add("onclick","alert(" + someProperty + ");");
``` |
520,546 | <p>Is there an ANT Task that would execute a block only if a given file exists? I have the problem that I have a generic ant script that should do some special processing but only if a specific configuration file is present.</p>
| [
{
"answer_id": 520567,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 9,
"selected": true,
"text": "<p><a href=\"http://ant.apache.org/manual/Tasks/available.html\" rel=\"noreferrer\">Available</a> and <a href=\"http://ant.ap... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2309/"
] | Is there an ANT Task that would execute a block only if a given file exists? I have the problem that I have a generic ant script that should do some special processing but only if a specific configuration file is present. | [Available](http://ant.apache.org/manual/Tasks/available.html) and [Condition](http://ant.apache.org/manual/Tasks/condition.html)
```
<target name="check-abc">
<available file="abc.txt" property="abc.present"/>
</target>
<target name="do-if-abc" depends="check-abc" if="abc.present">
...
</target>
``` |
520,573 | <p>I have a context menu with a few items. One of the items has a submenu (or whatever it's called) with a few items (depends on what files it finds).</p>
<p>What I want to do is when I left click one of the sub-items I want one thing to happen, and when I right click I want another thing to happen.</p>
<p>My problem... | [
{
"answer_id": 520606,
"author": "BFree",
"author_id": 15861,
"author_profile": "https://Stackoverflow.com/users/15861",
"pm_score": 3,
"selected": true,
"text": "<pre><code> private void button2_Click(object sender, EventArgs e)\n {\n ToolStripMenuItem item1 = new ToolStripMen... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56179/"
] | I have a context menu with a few items. One of the items has a submenu (or whatever it's called) with a few items (depends on what files it finds).
What I want to do is when I left click one of the sub-items I want one thing to happen, and when I right click I want another thing to happen.
My problem is that when I u... | ```
private void button2_Click(object sender, EventArgs e)
{
ToolStripMenuItem item1 = new ToolStripMenuItem("Menu1");
ToolStripMenuItem subMenuitem1 = new ToolStripMenuItem("SubMenu");
item1.DropDownItems.Add(subMenuitem1);
this.contextMenuStrip1.Items.Add(item1);
subMenuit... |
520,593 | <p>I have a problem where my ASP.NET controls are not able to be referenced from the code behind files. </p>
<p>I found a solution in Stack Overflow question <a href="https://stackoverflow.com/questions/38670/asp-net-controls-cannot-be-referenced-in-code-behind-in-visual-studio-2008">ASP.NET controls cannot be re... | [
{
"answer_id": 520684,
"author": "GregD",
"author_id": 38317,
"author_profile": "https://Stackoverflow.com/users/38317",
"pm_score": 7,
"selected": true,
"text": "<p>The accepted answer gave two locations:</p>\n\n<blockquote>\n <p>here</p>\n \n <p>C:\\Documents and Settings\\Administr... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] | I have a problem where my ASP.NET controls are not able to be referenced from the code behind files.
I found a solution in Stack Overflow question [ASP.NET controls cannot be referenced in code-behind in Visual Studio 2008](https://stackoverflow.com/questions/38670/asp-net-controls-cannot-be-referenced-in-code-behind... | The accepted answer gave two locations:
>
> here
>
>
> C:\Documents and Settings\Administrator\Local Settings\Temp\VWDWebCache
>
>
> and possibly here
>
>
> C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\WebsiteCache
>
>
>
Did you try those?
**Edited to add**
On my Windo... |
520,597 | <p>I'm not clear about the interaction between database schema changes and differential backups on sql 2005.</p>
<p>Lets say I do a Full backup right right now.
Then I perform some schema changes.
Then I do a diff backup.</p>
<p>What happens? Do I need to create another FULL backup? Are my schema changes and any da... | [
{
"answer_id": 520684,
"author": "GregD",
"author_id": 38317,
"author_profile": "https://Stackoverflow.com/users/38317",
"pm_score": 7,
"selected": true,
"text": "<p>The accepted answer gave two locations:</p>\n\n<blockquote>\n <p>here</p>\n \n <p>C:\\Documents and Settings\\Administr... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25300/"
] | I'm not clear about the interaction between database schema changes and differential backups on sql 2005.
Lets say I do a Full backup right right now.
Then I perform some schema changes.
Then I do a diff backup.
What happens? Do I need to create another FULL backup? Are my schema changes and any data in those new sch... | The accepted answer gave two locations:
>
> here
>
>
> C:\Documents and Settings\Administrator\Local Settings\Temp\VWDWebCache
>
>
> and possibly here
>
>
> C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\WebsiteCache
>
>
>
Did you try those?
**Edited to add**
On my Windo... |
520,607 | <p>Given the directory structure:</p>
<pre><code>root
build.xml
folderA
file1
file2
folderB
file3
</code></pre>
<p>I'm trying to copy the files in folderA into folderB, when I try, it ends up putting folderA in folderB so I end up with:</p>
<pre><code>folderB
folderA
f... | [
{
"answer_id": 520687,
"author": "Cogsy",
"author_id": 48234,
"author_profile": "https://Stackoverflow.com/users/48234",
"pm_score": 2,
"selected": false,
"text": "<pre><code><copy todir=\"folderB\">\n <fileset dir=\"folderA/\">\n <include name=\"file*\" />\n ... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48234/"
] | Given the directory structure:
```
root
build.xml
folderA
file1
file2
folderB
file3
```
I'm trying to copy the files in folderA into folderB, when I try, it ends up putting folderA in folderB so I end up with:
```
folderB
folderA
file1
file2
file3
```
I ... | ```
<copy todir="folderB">
<fileset dir="folderA/">
<include name="file*" />
</fileset>
</copy>
```
This works. Note the trailing slash in *dir="folderA/"*. |
520,610 | <p>I have a SQL database which i use to store some info and every record has a unique id generated by the database. MY program is written in flash and runs over the web, the program runs fine and it inserts records into the database and pulls the idnumber of the last record and displays it for user, my question is thou... | [
{
"answer_id": 520632,
"author": "Ray Booysen",
"author_id": 42124,
"author_profile": "https://Stackoverflow.com/users/42124",
"pm_score": 1,
"selected": false,
"text": "<p>If your database code returns the Id of the last inserted row, this will definitely cause issues.</p>\n\n<p>If you'... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16458/"
] | I have a SQL database which i use to store some info and every record has a unique id generated by the database. MY program is written in flash and runs over the web, the program runs fine and it inserts records into the database and pulls the idnumber of the last record and displays it for user, my question is though ... | PHP has [`mysql_insert_id()`](http://us3.php.net/manual/en/function.mysql-insert-id.php) to return
>
> The ID generated for an `AUTO_INCREMENT`
> column by the previous INSERT query on
> success, 0 if the previous query does
> not generate an `AUTO_INCREMENT` value,
> or `FALSE` if no MySQL connection was
> est... |
520,611 | <p>I am trying to parse url-encoded strings that are made up of key=value pairs separated by either <code>&</code> or <code>&amp;</code>. </p>
<p>The following will only match the first occurrence, breaking apart the keys and values into separate result elements:</p>
<pre><code>var result = mystring.match(/(?... | [
{
"answer_id": 520617,
"author": "Gumbo",
"author_id": 53114,
"author_profile": "https://Stackoverflow.com/users/53114",
"pm_score": 4,
"selected": false,
"text": "<p>Set the <code>g</code> modifier for a global match:</p>\n\n<pre><code>/…/g\n</code></pre>\n"
},
{
"answer_id": 52... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15872/"
] | I am trying to parse url-encoded strings that are made up of key=value pairs separated by either `&` or `&`.
The following will only match the first occurrence, breaking apart the keys and values into separate result elements:
```
var result = mystring.match(/(?:&|&)?([^=]+)=([^&]+)/)
```
The results for t... | Hoisted from the comments
>
> 2020 comment: rather than using regex, we now have [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams), which does all of this for us, so no custom code, let alone regex, are necessary anymore.
>
>
> – [Mike 'Pomax' Kamermans](https://stackoverflow.co... |
520,631 | <p>Is there anything similar to the following in Windows that will let me know if .NET is installed from the command line?</p>
<pre><code>$ java -version
$ ruby --version
$ python --version
</code></pre>
| [
{
"answer_id": 520654,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 4,
"selected": true,
"text": "<p>What OS and command shell are you using?</p>\n\n<p>With Windows from a batch file</p>\n\n<pre><code>if EXIST %WINDIR%\\... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47110/"
] | Is there anything similar to the following in Windows that will let me know if .NET is installed from the command line?
```
$ java -version
$ ruby --version
$ python --version
``` | What OS and command shell are you using?
With Windows from a batch file
```
if EXIST %WINDIR%\Microsoft.Net\Framework\v1.0.3705\mscorlib.dll
if EXIST %WINDIR%\Microsoft.Net\Framework\v1.1.4322\mscorlib.dll
if EXIST %WINDIR%\Microsoft.Net\Framework\v2.0.50727\mscorlib.dll
```
With Windows from PowerShell
```
if (te... |
520,638 | <p>Recently gmail added some <a href="http://gmailblog.blogspot.com/2009/02/new-ways-to-label-with-move-to-and-auto.html" rel="nofollow noreferrer">custom button and menu widgets</a> in html. They've already <a href="http://stopdesign.com/archive/2009/02/04/recreating-the-button.html" rel="nofollow noreferrer">tipped t... | [
{
"answer_id": 520655,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 0,
"selected": false,
"text": "<p>You can do drop shadows with <a href=\"http://www.webtoolkit.info/css-drop-shadow.html\" rel=\"nofollow noreferrer\">CSS... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41613/"
] | Recently gmail added some [custom button and menu widgets](http://gmailblog.blogspot.com/2009/02/new-ways-to-label-with-move-to-and-auto.html) in html. They've already [tipped their hand](http://stopdesign.com/archive/2009/02/04/recreating-the-button.html) as to how the gradient effect within the button works without i... | The drop down menu is actually a table (the horror!), and the shadows are their own cells (the bottom shadow is a `<tr>` with three cells, one for each corner and one for the bottom edge). These cells are styled with CSS to have PNG backgrounds. The corners and bottom edge are sprites in this image: [icons\_ns5.png](ht... |
520,640 | <p>There have been a few articles recently about Google's new imageless buttons:</p>
<ul>
<li><a href="http://stopdesign.com/archive/2009/02/04/recreating-the-button.html" rel="noreferrer">http://stopdesign.com/archive/2009/02/04/recreating-the-button.html</a></li>
<li><a href="http://stopdesign.com/eg/buttons/3.0/cod... | [
{
"answer_id": 520657,
"author": "David Grant",
"author_id": 40581,
"author_profile": "https://Stackoverflow.com/users/40581",
"pm_score": 3,
"selected": false,
"text": "<p>You could try using the <a href=\"http://getfirebug.com/\" rel=\"nofollow noreferrer\">Firebug</a> plugin for Firef... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36680/"
] | There have been a few articles recently about Google's new imageless buttons:
* <http://stopdesign.com/archive/2009/02/04/recreating-the-button.html>
* <http://stopdesign.com/eg/buttons/3.0/code.html>
* <http://stopdesign.com/eg/buttons/3.1/code.html>
* <http://gmailblog.blogspot.com/2009/02/new-ways-to-label-with-mov... | -- EDIT -- I didn't see the link in the original post. Sorry! Will try and re-write to reflect actual question
StopDesign has an excellent post on this [here](http://stopdesign.com/archive/2009/02/04/recreating-the-button.html). **[edit 20091107] These were released as part of the [closure library](http://code.google.... |
520,642 | <p>I'm customizing a SharePoint application, and I am referencing in my Visual Studio project a dll that also exists in the GAC. The project builds just fine, but when I hit the page I get the following error:</p>
<p>An error occurred during the processing of . c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ... | [
{
"answer_id": 520657,
"author": "David Grant",
"author_id": 40581,
"author_profile": "https://Stackoverflow.com/users/40581",
"pm_score": 3,
"selected": false,
"text": "<p>You could try using the <a href=\"http://getfirebug.com/\" rel=\"nofollow noreferrer\">Firebug</a> plugin for Firef... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm customizing a SharePoint application, and I am referencing in my Visual Studio project a dll that also exists in the GAC. The project builds just fine, but when I hit the page I get the following error:
An error occurred during the processing of . c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Fil... | -- EDIT -- I didn't see the link in the original post. Sorry! Will try and re-write to reflect actual question
StopDesign has an excellent post on this [here](http://stopdesign.com/archive/2009/02/04/recreating-the-button.html). **[edit 20091107] These were released as part of the [closure library](http://code.google.... |
520,645 | <p>So I did some reading of the related questions and had some interesting stuff but did not find my answer, at least did not understand the answer.</p>
<p>I am very new to AJAX, javascript and sclient side scripting in general.</p>
<p>I have been using C# asp.net for a bit and recently added some updatepanels to my ... | [
{
"answer_id": 520683,
"author": "bendewey",
"author_id": 37881,
"author_profile": "https://Stackoverflow.com/users/37881",
"pm_score": 6,
"selected": true,
"text": "<p>the update panel is going to reload the contents of the html. You'll have to listen for the UpdatePanel to complete an... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6486/"
] | So I did some reading of the related questions and had some interesting stuff but did not find my answer, at least did not understand the answer.
I am very new to AJAX, javascript and sclient side scripting in general.
I have been using C# asp.net for a bit and recently added some updatepanels to my side to smooth so... | the update panel is going to reload the contents of the html. You'll have to listen for the UpdatePanel to complete and recreate the datepicker.
Here is a very basic sample. This doesn't take into account multiple update panels on your page or potential memory leaks from not properly destroying your datepicker.
Ano... |
520,650 | <p>I know how to make a new branch that tracks remote branches, but <strong>how do I make an existing branch track a remote branch?</strong></p>
<p>I know I can just edit the <code>.git/config</code> file, but it seems there should be an easier way.</p>
| [
{
"answer_id": 520673,
"author": "mipadi",
"author_id": 28804,
"author_profile": "https://Stackoverflow.com/users/28804",
"pm_score": 5,
"selected": false,
"text": "<p>Editing <code>.git/config</code> is probably the easiest and fastest way. That's what the Git commands for handling remo... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/825/"
] | I know how to make a new branch that tracks remote branches, but **how do I make an existing branch track a remote branch?**
I know I can just edit the `.git/config` file, but it seems there should be an easier way. | Given a branch `foo` and a remote `upstream`:
**As of Git 1.8.0:**
```
git branch -u upstream/foo
```
Or, if local branch `foo` is not the current branch:
```
git branch -u upstream/foo foo
```
Or, if you like to type longer commands, these are equivalent to the above two:
```
git branch --set-upstream-to=upstr... |
520,671 | <p>I'm resizing jpegs by using the Graphics.DrawImage method (see code fragment below). Can anyone confirm that this will not affect the compression of the new image?
I have seen <a href="https://stackoverflow.com/questions/87753/resizing-an-image-without-losing-any-quality">this thread</a>, but I am talking specifical... | [
{
"answer_id": 520715,
"author": "Zebra North",
"author_id": 17440,
"author_profile": "https://Stackoverflow.com/users/17440",
"pm_score": 3,
"selected": false,
"text": "<p>JPEGs have no \"compression\" value saved within them. When you resize and save them, they are compressed with wha... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42119/"
] | I'm resizing jpegs by using the Graphics.DrawImage method (see code fragment below). Can anyone confirm that this will not affect the compression of the new image?
I have seen [this thread](https://stackoverflow.com/questions/87753/resizing-an-image-without-losing-any-quality), but I am talking specifically about compr... | When you call "bmpOut.Save" you have to pass in some EncoderParameters to tell the method what quality level you would like to save it with.
<http://msdn.microsoft.com/en-us/library/system.drawing.imaging.encoderparameters(VS.80).aspx> |
520,680 | <p>Here is the test URL</p>
<p><a href="http://edventures.com/temp/divtest.php" rel="noreferrer">http://edventures.com/temp/divtest.php</a></p>
<p>Procedure:</p>
<ol>
<li>Close all IE instances.</li>
<li>Open the URL in IE7</li>
<li>Open the task manager, look for memory consumed by IE</li>
<li>Now click on Create ... | [
{
"answer_id": 520686,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 0,
"selected": false,
"text": "<p>Yeah - IE has some awful memory leaks.</p>\n\n<p>Check out <a href=\"http://www.outofhanwell.com/ieleak/index.php?title=Main_... | 2009/02/06 | [
"https://Stackoverflow.com/questions/520680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63362/"
] | Here is the test URL
<http://edventures.com/temp/divtest.php>
Procedure:
1. Close all IE instances.
2. Open the URL in IE7
3. Open the task manager, look for memory consumed by IE
4. Now click on Create button,
5. Watch the memory it will jump up by about 2K
6. Now click on Destroy button and the DIV will be destroy... | Here's how to create DOM elements and prevent memory leaks in IE.
```
function createDOMElement(el) {
var el = document.createElement(el);
try {
return el;
}
finally {
el = null;
}
}
```
You can use variations of the try/finally trick to prevent the leaks when doing other DOM operations. |