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 |
|---|---|---|---|---|---|---|
74,092 | <p>I have a function in Python which is iterating over the attributes returned from <code>dir(obj)</code>, and I want to check to see if any of the objects contained within is a function, method, built-in function, etc. Normally you could use <code>callable()</code> for this, but I don't want to include classes. The ... | [
{
"answer_id": 74138,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 2,
"selected": false,
"text": "<pre><code>if hasattr(obj, '__call__'): pass\n</code></pre>\n\n<p>This also fits in better with Python's \"duck typing\" philosop... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/156/"
] | I have a function in Python which is iterating over the attributes returned from `dir(obj)`, and I want to check to see if any of the objects contained within is a function, method, built-in function, etc. Normally you could use `callable()` for this, but I don't want to include classes. The best I've come up with so f... | The inspect module has exactly what you want:
```
inspect.isroutine( obj )
```
FYI, the code is:
```
def isroutine(object):
"""Return true if the object is any kind of function or method."""
return (isbuiltin(object)
or isfunction(object)
or ismethod(object)
or ismethodde... |
74,113 | <p>It seems obvious that some people have been able to figure out how to access the iPhone camera through the SDK (Spore Origins, for example). How can this be done?</p>
| [
{
"answer_id": 74255,
"author": "wxs",
"author_id": 12981,
"author_profile": "https://Stackoverflow.com/users/12981",
"pm_score": 7,
"selected": true,
"text": "<p>You need to use the <code>UIImagePickerController</code> class, basically:</p>\n\n<pre><code>UIImagePickerController *picker ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5338/"
] | It seems obvious that some people have been able to figure out how to access the iPhone camera through the SDK (Spore Origins, for example). How can this be done? | You need to use the `UIImagePickerController` class, basically:
```
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = pickerDelegate
picker.sourceType = UIImagePickerControllerSourceTypeCamera
```
The `pickerDelegate` object above needs to implement the following method:
``... |
74,148 | <p>How do you convert between hexadecimal numbers and decimal numbers in C#?</p>
| [
{
"answer_id": 74183,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 2,
"selected": false,
"text": "<pre><code>String stringrep = myintvar.ToString(\"X\");\n\nint num = int.Parse(\"FF\", System.Globalization.NumberStyles.HexN... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3362/"
] | How do you convert between hexadecimal numbers and decimal numbers in C#? | To convert from decimal to hex do...
```
string hexValue = decValue.ToString("X");
```
To convert from hex to decimal do either...
```
int decValue = int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber);
```
or
```
int decValue = Convert.ToInt32(hexValue, 16);
``` |
74,162 | <p>I'm trying to write a query that extracts and transforms data from a table and then insert those data into another table. Yes, this is a data warehousing query and I'm doing it in MS Access. So basically I want some query like this:</p>
<pre><code>INSERT INTO Table2(LongIntColumn2, CurrencyColumn2) VALUES
(SELECT... | [
{
"answer_id": 74196,
"author": "Forgotten Semicolon",
"author_id": 1960,
"author_profile": "https://Stackoverflow.com/users/1960",
"pm_score": 3,
"selected": false,
"text": "<p>Remove <code>VALUES</code> from your SQL.</p>\n"
},
{
"answer_id": 74204,
"author": "pilsetnieks",... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8203/"
] | I'm trying to write a query that extracts and transforms data from a table and then insert those data into another table. Yes, this is a data warehousing query and I'm doing it in MS Access. So basically I want some query like this:
```
INSERT INTO Table2(LongIntColumn2, CurrencyColumn2) VALUES
(SELECT LongIntColumn... | No "VALUES", no parenthesis:
```
INSERT INTO Table2(LongIntColumn2, CurrencyColumn2)
SELECT LongIntColumn1, Avg(CurrencyColumn) as CurrencyColumn1 FROM Table1 GROUP BY LongIntColumn1;
``` |
74,171 | <p>I maintain a Java Swing application.</p>
<p>For backwards compatibility with java 5 (for Apple machines), we maintain two codebases, 1 using features from Java 6, another without those features.</p>
<p>The code is largely the same, except for 3-4 classes that uses Java 6 features.</p>
<p>I wish to just maintain 1... | [
{
"answer_id": 74202,
"author": "chessguy",
"author_id": 1908025,
"author_profile": "https://Stackoverflow.com/users/1908025",
"pm_score": 2,
"selected": false,
"text": "<p>I think the best approach here is probably to use build scripts. You can have all your code in one location, and by... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12944/"
] | I maintain a Java Swing application.
For backwards compatibility with java 5 (for Apple machines), we maintain two codebases, 1 using features from Java 6, another without those features.
The code is largely the same, except for 3-4 classes that uses Java 6 features.
I wish to just maintain 1 codebase. Is there a wa... | Assuming that the classes have similar functionality with 1.5 vs. 6.0 differences in implementation you could merge them into one class. Then, without editing the source to comment/uncomment, you can rely on the optimization that the compiler always do. If an if expression is always false, the code in the if statement ... |
74,188 | <p>I've created a ListBox to display items in groups, where the groups are wrapped right to left when they can no longer fit within the height of the ListBox's panel. So, the groups would appear similar to this in the listbox, where each group's height is arbitrary (group 1, for instance, is twice as tall as group 2):<... | [
{
"answer_id": 74235,
"author": "dcstraw",
"author_id": 10391,
"author_profile": "https://Stackoverflow.com/users/10391",
"pm_score": 0,
"selected": false,
"text": "<p>I would think that you are correct that it has to do with the binding. What happens when you remove the binding? With th... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've created a ListBox to display items in groups, where the groups are wrapped right to left when they can no longer fit within the height of the ListBox's panel. So, the groups would appear similar to this in the listbox, where each group's height is arbitrary (group 1, for instance, is twice as tall as group 2):
``... | By setting the Height property on the WrapPanel to the height of the ScrollContentPresenter, it will never scroll vertically. However, if you remove that Binding, it will never wrap, since in the layout pass, it has infinite height to layout in.
I would suggest creating your own panel class to get the behavior you wa... |
74,206 | <p>I have been playing with this for a while, but the closest I have gotten is a button that opens the <code>Paste Special</code> dialog box and requires another couple of mouse clicks to paste the contents of the clipboard as unformatted text. </p>
<p>So often I am doing a <code>copy-paste</code> from a web site into... | [
{
"answer_id": 74237,
"author": "GSerg",
"author_id": 11683,
"author_profile": "https://Stackoverflow.com/users/11683",
"pm_score": 4,
"selected": true,
"text": "<p>Make the button call the macro:</p>\n\n<pre><code>public sub PasteSpecialUnformatted()\n selection.pastespecial datatype:=... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30018/"
] | I have been playing with this for a while, but the closest I have gotten is a button that opens the `Paste Special` dialog box and requires another couple of mouse clicks to paste the contents of the clipboard as unformatted text.
So often I am doing a `copy-paste` from a web site into a document where I don't want t... | Make the button call the macro:
```
public sub PasteSpecialUnformatted()
selection.pastespecial datatype:=wdpastetext
end sub
``` |
74,218 | <p>Is there a way to restart the Rails app (e.g. when you've changed a plugin/config file) while Mongrel is running. Or alternatively quickly restart Mongrel. Mongrel gives these hints that you can but how do you do it?</p>
<p>** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart).</p>
<p>** Rai... | [
{
"answer_id": 74241,
"author": "Jan Krüger",
"author_id": 12471,
"author_profile": "https://Stackoverflow.com/users/12471",
"pm_score": 2,
"selected": false,
"text": "<p>For example,</p>\n\n<pre><code>killall -USR2 mongrel_rails\n</code></pre>\n"
},
{
"answer_id": 74998,
"au... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6432/"
] | Is there a way to restart the Rails app (e.g. when you've changed a plugin/config file) while Mongrel is running. Or alternatively quickly restart Mongrel. Mongrel gives these hints that you can but how do you do it?
\*\* Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart).
\*\* Rails signals regis... | You can add the -c option if the config for your app's cluster is elsewhere:
```
mongrel_rails cluster::restart -c /path/to/config
``` |
74,248 | <p>On a JSTL/JSP page, I have a java.util.Date object from my application. I need to find the day <em>after</em> the day specified by that object. I can use <jsp:scriptlet> to drop into Java and use java.util.Calendar to do the necessary calculations, but this feels clumsy and inelegant to me.</p>
<p>Is there so... | [
{
"answer_id": 74274,
"author": "sirprize",
"author_id": 12902,
"author_profile": "https://Stackoverflow.com/users/12902",
"pm_score": 2,
"selected": false,
"text": "<p>While this does not answer your initial question, you could perhaps eliminate the hassle of going through java.util.Cal... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2041950/"
] | On a JSTL/JSP page, I have a java.util.Date object from my application. I need to find the day *after* the day specified by that object. I can use <jsp:scriptlet> to drop into Java and use java.util.Calendar to do the necessary calculations, but this feels clumsy and inelegant to me.
Is there some way to use JSP or JS... | I'm not a fan of putting java code in your jsp.
I'd use a static method and a taglib to accomplish this.
Just my idea though. There are many ways to solve this problem.
```
public static Date addDay(Date date){
//TODO you may want to check for a null date and handle it.
Calendar cal = Calendar.getInstance();
... |
74,266 | <p>I have an ext combobox which uses a store to suggest values to a user as they type. </p>
<p>An example of which can be found here: <a href="http://extjs.com/deploy/ext/examples/form/combos.html" rel="nofollow noreferrer">combobox example</a></p>
<p>Is there a way of making it so the <strong>suggested text list</st... | [
{
"answer_id": 74680,
"author": "noah",
"author_id": 12034,
"author_profile": "https://Stackoverflow.com/users/12034",
"pm_score": 0,
"selected": false,
"text": "<p>So clarify, you want the selected text to render somewhere besides directly below the text input. Correct?</p>\n\n<p>ComboB... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3193/"
] | I have an ext combobox which uses a store to suggest values to a user as they type.
An example of which can be found here: [combobox example](http://extjs.com/deploy/ext/examples/form/combos.html)
Is there a way of making it so the **suggested text list** is rendered to an element in the DOM. Please note I do not me... | You can use plugin for this, since you can call or even override private methods from within the plugin:
```
var suggested_text_plugin = {
init: function(o) {
o.onTypeAhead = function() {
// Original code from the sources goes here:
if(this.store.getCount() > 0){
... |
74,267 | <p>I'm trying to script the shutdown of my VM Servers in a .bat.
if one of the vmware-cmd commands fails (as the machine is already shutdown say), I'd like it to continue instead of bombing out.</p>
<pre><code>c:
cd "c:\Program Files\VMWare\VmWare Server"
vmware-cmd C:\VMImages\TCVMDEVSQL01\TCVMDEVSQL01.vmx suspend s... | [
{
"answer_id": 74304,
"author": "Jen A",
"author_id": 12979,
"author_profile": "https://Stackoverflow.com/users/12979",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried using \"start (cmd)\" for each command you are executing?</p>\n"
},
{
"answer_id": 74314,
"auth... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11538/"
] | I'm trying to script the shutdown of my VM Servers in a .bat.
if one of the vmware-cmd commands fails (as the machine is already shutdown say), I'd like it to continue instead of bombing out.
```
c:
cd "c:\Program Files\VMWare\VmWare Server"
vmware-cmd C:\VMImages\TCVMDEVSQL01\TCVMDEVSQL01.vmx suspend soft -q
vmware-... | Run it inside another command instance with `CMD /C`
```
CMD /C vmware-cmd C:\...
```
This should keep the original BAT files running. |
74,350 | <p>I'm trying to implement some drag and drop functionality for a material system being developed at my work. Part of this system includes a 'Material Library' which acts as a repository, divided into groups, of saved materials on the user's hard drive.</p>
<p>As part of some UI polish, I was hoping to implement a 'hi... | [
{
"answer_id": 74501,
"author": "Andy",
"author_id": 3857,
"author_profile": "https://Stackoverflow.com/users/3857",
"pm_score": 0,
"selected": false,
"text": "<p>It almost looks like the CStatic doesn't know that it needs to repaint itself, so the background color of the draggable objec... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1169/"
] | I'm trying to implement some drag and drop functionality for a material system being developed at my work. Part of this system includes a 'Material Library' which acts as a repository, divided into groups, of saved materials on the user's hard drive.
As part of some UI polish, I was hoping to implement a 'highlight' t... | Thanks for the answers guys, ajryan, you seem to always come up with help for my questions so extra thanks.
Thankfully this time the answer was fairly straightforward....
```
ImageList_DragShowNolock(FALSE);
m_pDragDropTargetWnd->SendMessage(WM_USER_DRAG_DROP_OBJECT_DRAG_ENTER, (WPARAM)pDragDropObject, (LPARAM)(&drag... |
74,372 | <p>I am involved in the process of porting a system containing several hundreds of ksh scripts from AIX, Solaris and HPUX to Linux. I have come across the following difference in the way ksh behaves on the two systems:</p>
<pre><code>#!/bin/ksh
flag=false
echo "a\nb" | while read x
do
flag=true
done
echo "flag = $... | [
{
"answer_id": 74421,
"author": "zigdon",
"author_id": 4913,
"author_profile": "https://Stackoverflow.com/users/4913",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know of any particular option to force ksh to be compatible with a particular older version. That said, perhaps yo... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13029/"
] | I am involved in the process of porting a system containing several hundreds of ksh scripts from AIX, Solaris and HPUX to Linux. I have come across the following difference in the way ksh behaves on the two systems:
```
#!/bin/ksh
flag=false
echo "a\nb" | while read x
do
flag=true
done
echo "flag = ${flag}"
exit 0... | After some advice from people in my company we decided to make the following modification to the code. This gives us the same result whether using the "real" ksh's (ksh88, ksh93) or any of the ksh clones (pdksh, MSK ksh). This also works correctly with bash.
```
#!/bin/ksh
echo "a\nb" > junk
flag=false
while read x
do... |
74,385 | <p>I need to convert a value which is in a <code>DateTime</code> variable into a <code>varchar</code> variable formatted as <code>yyyy-mm-dd</code> format (without time part).</p>
<p>How do I do that?</p>
| [
{
"answer_id": 74394,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 8,
"selected": false,
"text": "<p>Try the following:</p>\n\n<pre><code>CONVERT(varchar(10), [MyDateTimecolumn], 20)\n</code></pre>\n\n<p>For a full da... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7604/"
] | I need to convert a value which is in a `DateTime` variable into a `varchar` variable formatted as `yyyy-mm-dd` format (without time part).
How do I do that? | With Microsoft Sql Server:
```
--
-- Create test case
--
DECLARE @myDateTime DATETIME
SET @myDateTime = '2008-05-03'
--
-- Convert string
--
SELECT LEFT(CONVERT(VARCHAR, @myDateTime, 120), 10)
``` |
74,430 | <p>I am trying to use the <code>import random</code> statement in python, but it doesn't appear to have any methods in it to use.</p>
<p>Am I missing something?</p>
| [
{
"answer_id": 74445,
"author": "jamuraa",
"author_id": 9805,
"author_profile": "https://Stackoverflow.com/users/9805",
"pm_score": 2,
"selected": false,
"text": "<p>I think you need to give some more information. It's not really possible to answer why it's not working based on the info... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13050/"
] | I am trying to use the `import random` statement in python, but it doesn't appear to have any methods in it to use.
Am I missing something? | You probably have a file named random.py or random.pyc in your working directory. That's shadowing the built-in random module. You need to rename random.py to something like my\_random.py and/or remove the random.pyc file.
To tell for sure what's going on, do this:
```
>>> import random
>>> print random.__file__
```... |
74,451 | <p>Windows file system is case insensitive. How, given a file/folder name (e.g. "somefile"), I get the <em>actual</em> name of that file/folder (e.g. it should return "SomeFile" if Explorer displays it so)?</p>
<p>Some ways I know, all of which seem quite backwards:</p>
<ol>
<li>Given the full path, search for each f... | [
{
"answer_id": 74563,
"author": "bugmagnet",
"author_id": 426,
"author_profile": "https://Stackoverflow.com/users/426",
"pm_score": 2,
"selected": false,
"text": "<p>Okay, this is VBScript, but even so I'd suggest using the Scripting.FileSystemObject object</p>\n\n<pre><code>Dim fso\nSet... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6799/"
] | Windows file system is case insensitive. How, given a file/folder name (e.g. "somefile"), I get the *actual* name of that file/folder (e.g. it should return "SomeFile" if Explorer displays it so)?
Some ways I know, all of which seem quite backwards:
1. Given the full path, search for each folder on the path (via Find... | And hereby I answer my own question, based on [original answer from *cspirz*](https://stackoverflow.com/questions/74451/getting-actual-file-name-with-proper-casing-on-windows#74588).
Here's a function that given absolute, relative or network path, will return the path with upper/lower case as it would be displayed on ... |
74,461 | <p>I'm currently playing with the Silverlight(Beta 2) Datagrid control. Before I wired up the SelectionChanged event, the grid would sort perfectly by clicking on the header. Now, when the grid is clicked, it will fire the SelectionChanged event when I click the header to sort. Is there any way around this?</p>
<p>... | [
{
"answer_id": 74877,
"author": "Senkwe",
"author_id": 6419,
"author_profile": "https://Stackoverflow.com/users/6419",
"pm_score": 3,
"selected": true,
"text": "<p>That looks like a Silverlight bug to me. I've just tried it and what's happening on my end is that the <strong>SelectionChan... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12413/"
] | I'm currently playing with the Silverlight(Beta 2) Datagrid control. Before I wired up the SelectionChanged event, the grid would sort perfectly by clicking on the header. Now, when the grid is clicked, it will fire the SelectionChanged event when I click the header to sort. Is there any way around this?
In a semi-rel... | That looks like a Silverlight bug to me. I've just tried it and what's happening on my end is that the **SelectionChanged** event fires twice when you click the column header and to make matters worse, the index of the selected item doesn't stay synched with the currently selected item.
I'd suggest you work your way a... |
74,466 | <p>I have a .ico file that is embedded as a resource (build action set to resource). I am trying to create a NotifyIcon. How can I reference my icon?</p>
<pre><code>notifyIcon = new NotifyIcon();
notifyIcon.Icon = ?? // my icon file is called MyIcon.ico and is embedded
</code></pre>
| [
{
"answer_id": 74671,
"author": "user13125",
"author_id": 13125,
"author_profile": "https://Stackoverflow.com/users/13125",
"pm_score": 8,
"selected": true,
"text": "<p>Your icon file should be added to one of your project assemblies and its Build Action should be set to Resource. After ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3047/"
] | I have a .ico file that is embedded as a resource (build action set to resource). I am trying to create a NotifyIcon. How can I reference my icon?
```
notifyIcon = new NotifyIcon();
notifyIcon.Icon = ?? // my icon file is called MyIcon.ico and is embedded
``` | Your icon file should be added to one of your project assemblies and its Build Action should be set to Resource. After adding a reference to the assembly, you can create a NotifyIcon like this:
```
System.Windows.Forms.NotifyIcon icon = new System.Windows.Forms.NotifyIcon();
Stream iconStream = Application.GetResource... |
74,471 | <p>I have a function that takes, amongst others, a parameter declared as <em>int privateCount</em>. When I want to call ToString() on this param, ReSharper greys it out and marks it as a redundant call. So, curious as I am, I remove the ToString(), and the code still builds!</p>
<p>How can a C# compiler allow this, ... | [
{
"answer_id": 74495,
"author": "Haacked",
"author_id": 598,
"author_profile": "https://Stackoverflow.com/users/598",
"pm_score": 5,
"selected": true,
"text": "<p>The + operator for string is overloaded to call String.Concat passing in the left and right side of the expression. Thus:</p>... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8741/"
] | I have a function that takes, amongst others, a parameter declared as *int privateCount*. When I want to call ToString() on this param, ReSharper greys it out and marks it as a redundant call. So, curious as I am, I remove the ToString(), and the code still builds!
How can a C# compiler allow this, where *str* is a st... | The + operator for string is overloaded to call String.Concat passing in the left and right side of the expression. Thus:
```
string x = "123" + 45;
```
Gets compiled to:
```
String.Concat("123", 45);
```
Since String.Concat takes in two objects, the right hand side (45) is boxed and then ToString() is called on ... |
74,514 | <p>Implementing Equals() for reference types is harder than it seems. My current canonical implementation goes like this:</p>
<pre><code>public bool Equals( MyClass obj )
{
// If both refer to the same reference they are equal.
if( ReferenceEquals( obj, this ) )
return true;
// If the other object is null t... | [
{
"answer_id": 74540,
"author": "Peter Ritchie",
"author_id": 5620,
"author_profile": "https://Stackoverflow.com/users/5620",
"pm_score": 0,
"selected": false,
"text": "<p>It depends on whether you're writing a value type or a reference type. For a sortable value type, I recommend this:... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12851/"
] | Implementing Equals() for reference types is harder than it seems. My current canonical implementation goes like this:
```
public bool Equals( MyClass obj )
{
// If both refer to the same reference they are equal.
if( ReferenceEquals( obj, this ) )
return true;
// If the other object is null they are not eq... | I wrote a fairly comprehensive guide to this a while back. For a start your equals implementations should be shared (i.e. the overload taking an object should pass through to the one taking a strongly typed object). Additionally you need to consider things such as your object should be immutable because of the need to ... |
74,570 | <p>I'm maintaining <a href="http://perl-begin.org/" rel="nofollow noreferrer">the Perl Beginners' Site</a> and used a modified template from Open Source Web Designs. Now, the problem is that I still have an undesired artifact: a gray line on the left side of the main frame, to the left of the navigation menu. Here's <a... | [
{
"answer_id": 74610,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 4,
"selected": true,
"text": "<p>It's the <code>background-image</code> on the body showing through. Quick fix (edit style.css or add elsewhere):</p>\n\n<pre><c... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7709/"
] | I'm maintaining [the Perl Beginners' Site](http://perl-begin.org/) and used a modified template from Open Source Web Designs. Now, the problem is that I still have an undesired artifact: a gray line on the left side of the main frame, to the left of the navigation menu. Here's [an image](http://www.shlomifish.org/Files... | It's the `background-image` on the body showing through. Quick fix (edit style.css or add elsewhere):
```
#page-container
{
background-color: white;
}
``` |
74,612 | <p>I have a table inside a div. I want the table to occupy the entire width of the div tag.</p>
<p>In the CSS, I've set the <code>width</code> of the table to <code>100%</code>. Unfortunately, when the div has some <code>margin</code> on it, the table ends up wider than the div it's in.</p>
<p>I need to support IE6 ... | [
{
"answer_id": 74715,
"author": "Nate",
"author_id": 12779,
"author_profile": "https://Stackoverflow.com/users/12779",
"pm_score": 3,
"selected": false,
"text": "<p>The following works for me in Firefox and IE7... a guideline, though is: if you set width on an element, don't set margin o... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/475/"
] | I have a table inside a div. I want the table to occupy the entire width of the div tag.
In the CSS, I've set the `width` of the table to `100%`. Unfortunately, when the div has some `margin` on it, the table ends up wider than the div it's in.
I need to support IE6 and IE7 (as this is an internal app), although I'd ... | Add the below CSS to your `<table>`:
```
table-layout: fixed;
width: 100%;
``` |
74,616 | <p>example:</p>
<pre><code>public static void DoSomething<K,V>(IDictionary<K,V> items) {
items.Keys.Each(key => {
if (items[key] **is IEnumerable<?>**) { /* do something */ }
else { /* do something else */ }
}
</code></pre>
<p>Can this be done without using reflection? How do I say... | [
{
"answer_id": 74648,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 2,
"selected": false,
"text": "<pre><code>if (typeof(IEnumerable).IsAssignableFrom(typeof(V))) {\n</code></pre>\n"
},
{
"answer_id": 74772,
... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12934/"
] | example:
```
public static void DoSomething<K,V>(IDictionary<K,V> items) {
items.Keys.Each(key => {
if (items[key] **is IEnumerable<?>**) { /* do something */ }
else { /* do something else */ }
}
```
Can this be done without using reflection? How do I say IEnumerable in C#? Should I just use IEnumerab... | [The previously accepted answer](https://stackoverflow.com/a/74648/1968) is nice but it is wrong. Thankfully, the error is a small one. Checking for `IEnumerable` is not enough if you really want to know about the generic version of the interface; there are a lot of classes that implement only the nongeneric interface.... |
74,620 | <p>Can't understand why the following takes place:</p>
<pre><code>String date = "06-04-2007 07:05";
SimpleDateFormat fmt = new SimpleDateFormat("MM-dd-yyyy HH:mm");
Date myDate = fmt.parse(date);
System.out.println(myDate); //Mon Jun 04 07:05:00 EDT 2007
long timestamp = myDate.getTime();
System.out.println(timesta... | [
{
"answer_id": 74652,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 5,
"selected": true,
"text": "<p>What milliseconds? You are providing only minutes information in the first example, whereas your second example gra... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10675/"
] | Can't understand why the following takes place:
```
String date = "06-04-2007 07:05";
SimpleDateFormat fmt = new SimpleDateFormat("MM-dd-yyyy HH:mm");
Date myDate = fmt.parse(date);
System.out.println(myDate); //Mon Jun 04 07:05:00 EDT 2007
long timestamp = myDate.getTime();
System.out.println(timestamp); //1180955... | What milliseconds? You are providing only minutes information in the first example, whereas your second example grabs current date from the system with milliseconds, what is it you're looking for?
```
String date = "06-04-2007 07:05:00.999";
SimpleDateFormat fmt = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss.S");
Date my... |
74,649 | <p>What is the syntax to declare a type for my compare-function generator in code like the following?</p>
<pre><code>var colName:String = ""; // actually assigned in a loop
gc.sortCompareFunction = function() : ??WHAT_GOES_HERE??
{
var tmp:String = colName;
return function(a:Object,b:Object):int { return compare... | [
{
"answer_id": 74743,
"author": "Brent",
"author_id": 10680,
"author_profile": "https://Stackoverflow.com/users/10680",
"pm_score": 2,
"selected": true,
"text": "<p>Isn't \"Function\" a data type?</p>\n"
},
{
"answer_id": 125763,
"author": "Brian Hodge",
"author_id": 2062... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4540/"
] | What is the syntax to declare a type for my compare-function generator in code like the following?
```
var colName:String = ""; // actually assigned in a loop
gc.sortCompareFunction = function() : ??WHAT_GOES_HERE??
{
var tmp:String = colName;
return function(a:Object,b:Object):int { return compareGeneral(a,b,tm... | Isn't "Function" a data type? |
74,674 | <p>I need to check CPU and memory usage for the server in java, anyone know how it could be done?</p>
| [
{
"answer_id": 74720,
"author": "Tim Howland",
"author_id": 4276,
"author_profile": "https://Stackoverflow.com/users/4276",
"pm_score": 1,
"selected": false,
"text": "<p>If you are using Tomcat, check out <a href=\"https://code.google.com/p/psi-probe/\" rel=\"nofollow noreferrer\">Psi Pr... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13123/"
] | I need to check CPU and memory usage for the server in java, anyone know how it could be done? | If you are looking specifically for memory in JVM:
```
Runtime runtime = Runtime.getRuntime();
NumberFormat format = NumberFormat.getInstance();
StringBuilder sb = new StringBuilder();
long maxMemory = runtime.maxMemory();
long allocatedMemory = runtime.totalMemory();
long freeMemory = runtime.freeMemory();
sb.appe... |
74,723 | <p>This problem has been afflicting me for quite a while and it's been really annoying.</p>
<p>Every time I login after a reboot/power cycle the explorer takes some time to show up.
I've taken the step of waiting for all the services to boot up and then I login, but it doesn't make any difference.
The result is always... | [
{
"answer_id": 74769,
"author": "Jonathan Sayce",
"author_id": 13153,
"author_profile": "https://Stackoverflow.com/users/13153",
"pm_score": 2,
"selected": false,
"text": "<p>As far as I know that isn't possible Gustavo - it's up to each application to put its notifyicon in the systray, ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8167/"
] | This problem has been afflicting me for quite a while and it's been really annoying.
Every time I login after a reboot/power cycle the explorer takes some time to show up.
I've taken the step of waiting for all the services to boot up and then I login, but it doesn't make any difference.
The result is always the same:... | Take a look at this blog entry: [REFRESHING THE TASKBAR NOTIFICATION AREA](http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2008/02/15/985.aspx). I am using this code to refresh the system tray to get rid of orphaned icons and it works perfectly.
The blog entry is very informative and gives a great expl... |
74,782 | <p>What's the difference between eruby and erb? What considerations would drive me to choose one or the other?</p>
<p>My application is generating config files for network devices (routers, load balancers, firewalls, etc.). My plan is to template the config files, using embedded ruby (via either eruby or erb) within... | [
{
"answer_id": 74807,
"author": "Jordi Bunster",
"author_id": 4272,
"author_profile": "https://Stackoverflow.com/users/4272",
"pm_score": 3,
"selected": false,
"text": "<p>Doesn't really matter, they're both the same. erb is pure ruby, eruby is written in C so it's a bit faster.</p>\n\n<... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13157/"
] | What's the difference between eruby and erb? What considerations would drive me to choose one or the other?
My application is generating config files for network devices (routers, load balancers, firewalls, etc.). My plan is to template the config files, using embedded ruby (via either eruby or erb) within the source ... | Doesn't really matter, they're both the same. erb is pure ruby, eruby is written in C so it's a bit faster.
erubis (a third one) is pure ruby, and faster than both the ones listed above. But I doubt the speed of that is the bottleneck for you, so just use erb. It's part of Ruby Standard Library. |
74,829 | <p>What should I type on the Mac OS X terminal to run a script as root?</p>
| [
{
"answer_id": 74830,
"author": "Bob Wintemberg",
"author_id": 12999,
"author_profile": "https://Stackoverflow.com/users/12999",
"pm_score": 2,
"selected": false,
"text": "<p>sudo ./<em>scriptname</em></p>\n"
},
{
"answer_id": 74833,
"author": "dF.",
"author_id": 3002,
... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/877/"
] | What should I type on the Mac OS X terminal to run a script as root? | As in any unix-based environment, you can use the [`sudo`](http://xkcd.com/149/) command:
```
$ sudo script-name
```
It will ask for your password (your own, not a separate `root` password). |
74,847 | <p>Typically I use <code>E_ALL</code> to see anything that PHP might say about my code to try and improve it.</p>
<p>I just noticed a error constant <code>E_STRICT</code>, but have never used or heard about it, is this a good setting to use for development? The manual says:</p>
<blockquote>
<p>Run-time notices. Ena... | [
{
"answer_id": 74864,
"author": "Tim Boland",
"author_id": 70,
"author_profile": "https://Stackoverflow.com/users/70",
"pm_score": -1,
"selected": false,
"text": "<p>ini_set(\"display_errors\",\"2\");\nERROR_REPORTING(E_ALL);</p>\n"
},
{
"answer_id": 74907,
"author": "Daniel ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5261/"
] | Typically I use `E_ALL` to see anything that PHP might say about my code to try and improve it.
I just noticed a error constant `E_STRICT`, but have never used or heard about it, is this a good setting to use for development? The manual says:
>
> Run-time notices. Enable to have PHP suggest changes to your code whic... | In PHP 5, the things covered by `E_STRICT` are not covered by `E_ALL`, so to get the most information, you need to combine them:
```
error_reporting(E_ALL | E_STRICT);
```
In PHP 5.4, `E_STRICT` will be included in `E_ALL`, so you can use just `E_ALL`.
You can also use
```
error_reporting(-1);
```
which will al... |
74,880 | <p>Conceptually, I would like to accomplish the following but have had trouble understand how to code it properly in C#:</p>
<pre><code>
SomeMethod { // Member of AClass{}
DoSomething;
Start WorkerMethod() from BClass in another thread;
DoSomethingElse;
}
</code></pre>
<p>Then, when WorkerMethod() is comp... | [
{
"answer_id": 74917,
"author": "MagicKat",
"author_id": 8505,
"author_profile": "https://Stackoverflow.com/users/8505",
"pm_score": 1,
"selected": false,
"text": "<p>Check out BackgroundWorker.</p>\n"
},
{
"answer_id": 74948,
"author": "Isak Savo",
"author_id": 8521,
... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10505/"
] | Conceptually, I would like to accomplish the following but have had trouble understand how to code it properly in C#:
```
SomeMethod { // Member of AClass{}
DoSomething;
Start WorkerMethod() from BClass in another thread;
DoSomethingElse;
}
```
Then, when WorkerMethod() is complete, run this:
```
void... | The [BackgroundWorker](http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx) class was added to .NET 2.0 for this exact purpose.
In a nutshell you do:
```
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += delegate { myBClass.DoHardWork(); }
worker.RunWorkerCompleted += ... |
74,883 | <p>I cannot seem to compile mod_dontdothat on Windows. Has anybody managed to achieve this?</p>
<p>Edit:</p>
<p>I've tried compiling the file according to the readme on the site and I've tried to add extra libs to reduce the link errors. Ive got the following installed:</p>
<ol>
<li>Apache 2.2.9</li>
<li>Visual Stud... | [
{
"answer_id": 77964,
"author": "Jason Dagit",
"author_id": 5113,
"author_profile": "https://Stackoverflow.com/users/5113",
"pm_score": 1,
"selected": false,
"text": "<p>Thanks for revising the question.</p>\n\n<p>It looks like a definite linker issue. I see that the first undefined sym... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2822/"
] | I cannot seem to compile mod\_dontdothat on Windows. Has anybody managed to achieve this?
Edit:
I've tried compiling the file according to the readme on the site and I've tried to add extra libs to reduce the link errors. Ive got the following installed:
1. Apache 2.2.9
2. Visual Studio 2008
3. ActivePerl
4. apxs-wi... | I managed to compile the module. Prerequisites:
* Apache 2.2.11
* [apxs-win32](http://www.apachelounge.com/download/apxs_win32.zip) from www.apachelounge.com
* Visual Studio 2005
* [Active Perl 5.8.8](http://www.activestate.com/activeperl/) (you need perl for apxs-win32 installation)
Here is a step-by-step guide.
Dow... |
74,886 | <p>I need to rearrange some content in various directories but it's a bit of a pain. In order to debug the application I'm working on (a ruby app) I need to move my gems into my gem folder one at a time (long story; nutshell: one is broken and I can't figure out which one).</p>
<p>So I need to do something like:</p>
... | [
{
"answer_id": 74920,
"author": "pjz",
"author_id": 8002,
"author_profile": "https://Stackoverflow.com/users/8002",
"pm_score": 4,
"selected": true,
"text": "<p>Put the following into a file named <code>gemmove</code>:</p>\n<pre><code>#!/bin/bash\n\nif [ "x$1" == x ]; then\n e... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10071/"
] | I need to rearrange some content in various directories but it's a bit of a pain. In order to debug the application I'm working on (a ruby app) I need to move my gems into my gem folder one at a time (long story; nutshell: one is broken and I can't figure out which one).
So I need to do something like:
```
sudo mv ba... | Put the following into a file named `gemmove`:
```
#!/bin/bash
if [ "x$1" == x ]; then
echo "Must have an arg"
exit 1
fi
for d in gem doc specification ; do
mv "backup/$d/$1" "$d"
done
```
then do
```
chmod a+x gemmove
```
and then call `sudo /path/to/gemmove foo` to move the foo gem from the backup dirs... |
74,902 | <p>I installed Mono on my iMac last night and I immidiately had a change of heart! I don't think Mono is ready for prime time. </p>
<p>The Mono website says to run the following script to uninstall:</p>
<pre><code>#!/bin/sh -x
#This script removes Mono from an OS X System. It must be run as root
rm -r /Library/Frame... | [
{
"answer_id": 74919,
"author": "Alex Fort",
"author_id": 12624,
"author_profile": "https://Stackoverflow.com/users/12624",
"pm_score": 0,
"selected": false,
"text": "<p>Mono doesn't contain a lot of fluff, so just running those commands will be fine. It's as simple as deleting all the d... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/877/"
] | I installed Mono on my iMac last night and I immidiately had a change of heart! I don't think Mono is ready for prime time.
The Mono website says to run the following script to uninstall:
```
#!/bin/sh -x
#This script removes Mono from an OS X System. It must be run as root
rm -r /Library/Frameworks/Mono.framework
... | The above script simply deletes everything related to Mono on your system -- and since the developers wrote it, I'm sure they didn't miss anything :) Unlike some other operating systems made by software companies that rhyme with "Macrosoft", uninstalling software in OS X is as simple as deleting the files, 99% of the t... |
74,928 | <p>I'm trying to figure out the best way to parse a GE Logician MEL trace file to make it easier to read.</p>
<p>It has segments like </p>
<pre>>{!gDYNAMIC_3205_1215032915_810 = (clYN)}
execute>GDYNAMIC_3205_1215032915_810 = "Yes, No"
results>"Yes, No"
execute>end
results>"Yes, No"
>{!gDYNAMIC_3205_1215032893_294... | [
{
"answer_id": 74942,
"author": "metadave",
"author_id": 7237,
"author_profile": "https://Stackoverflow.com/users/7237",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.antlr.org\" rel=\"nofollow noreferrer\">Antlr</a> would do the trick.</p>\n"
},
{
"answer_id... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2531/"
] | I'm trying to figure out the best way to parse a GE Logician MEL trace file to make it easier to read.
It has segments like
```
>{!gDYNAMIC_3205_1215032915_810 = (clYN)}
execute>GDYNAMIC_3205_1215032915_810 = "Yes, No"
results>"Yes, No"
execute>end
results>"Yes, No"
>{!gDYNAMIC_3205_1215032893_294 = (clYN)}
exec... | Make a grammar using ANTLR. If you're using C, lex/yacc are native. ANTLR creates native parsers in Java, Python and .NET. Your output looks like a repl; try asking the vendor for a spec on the input language. |
74,951 | <p>Flex has built in drag-n-drop for list controls, and allows you to override this. But they don't cover this in examples. The built-in functionality automatically drags the list-item, if you want to override this you find the handlers are being set up on the list itself.
What I specifically want to do, is my TileList... | [
{
"answer_id": 75541,
"author": "Theo",
"author_id": 1109,
"author_profile": "https://Stackoverflow.com/users/1109",
"pm_score": 2,
"selected": false,
"text": "<p>It's not obvious until you've tried it =) I struggled with the same thing just a few weeks ago. This was my solution:</p>\n\n... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13220/"
] | Flex has built in drag-n-drop for list controls, and allows you to override this. But they don't cover this in examples. The built-in functionality automatically drags the list-item, if you want to override this you find the handlers are being set up on the list itself.
What I specifically want to do, is my TileList sh... | It's not obvious until you've tried it =) I struggled with the same thing just a few weeks ago. This was my solution:
The list:
```
<List>
<mouseDown>onListMouseDown(event)</mouseDown>
</Tree>
```
The mouse down handler:
```
private function onMouseDown( event : MouseEvent ) : void {
var list : List = List(eve... |
74,957 | <p>In PowerShell I'm reading in a text file. I'm then doing a Foreach-Object over the text file and am only interested in the lines that do NOT contain strings that are in <code>$arrayOfStringsNotInterestedIn</code>.</p>
<p>What is the syntax for this?</p>
<pre><code> Get-Content $filename | Foreach-Object {$_}
</c... | [
{
"answer_id": 75034,
"author": "Mark Schill",
"author_id": 9482,
"author_profile": "https://Stackoverflow.com/users/9482",
"pm_score": 4,
"selected": false,
"text": "<p>You can use the -notmatch operator to get the lines that don't have the characters you are interested in. </p>\n\n<pre... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | In PowerShell I'm reading in a text file. I'm then doing a Foreach-Object over the text file and am only interested in the lines that do NOT contain strings that are in `$arrayOfStringsNotInterestedIn`.
What is the syntax for this?
```
Get-Content $filename | Foreach-Object {$_}
``` | If $arrayofStringsNotInterestedIn is an [array] you should use -notcontains:
```
Get-Content $FileName | foreach-object { `
if ($arrayofStringsNotInterestedIn -notcontains $_) { $) }
```
or better (IMO)
```
Get-Content $FileName | where { $arrayofStringsNotInterestedIn -notcontains $_}
``` |
74,960 | <p>I'm looking at the SOAP output from a web service I'm developing, and I noticed something curious:</p>
<pre><code><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns1:CreateEntityTypesResponse xmlns:ns1="http://somedomain.com/wsinterface">
... | [
{
"answer_id": 75128,
"author": "Michael Sharek",
"author_id": 1958,
"author_profile": "https://Stackoverflow.com/users/1958",
"pm_score": 3,
"selected": false,
"text": "<h3>Using WSDL2Java</h3>\n\n<p>If you have used the Axis2 WSDL2Java tool you're kind of stuck with what it generates f... | 2008/09/16 | [
"https://Stackoverflow.com/questions/74960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13224/"
] | I'm looking at the SOAP output from a web service I'm developing, and I noticed something curious:
```
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns1:CreateEntityTypesResponse xmlns:ns1="http://somedomain.com/wsinterface">
<newKeys>
<value>1... | ### Using WSDL2Java
If you have used the Axis2 WSDL2Java tool you're kind of stuck with what it generates for you. However you can try to change the skeleton in this section:
```
// create SOAP envelope with that payload
org.apache.axiom.soap.SOAPEnvelope env = null;
env = toEnvelope(
getFactory(_oper... |
75,011 | <p>In a VB6 application, I have a <code>Dictionary</code> whose keys are <code>String</code>s and values are instances of a custom class. If I call <code>RemoveAll()</code> on the <code>Dictionary</code>, will it first free the custom objects? Or do I explicitly need to do this myself?</p>
<pre><code>Dim d as Script... | [
{
"answer_id": 75066,
"author": "Neil C. Obremski",
"author_id": 9642,
"author_profile": "https://Stackoverflow.com/users/9642",
"pm_score": 3,
"selected": true,
"text": "<p>Yes, all objects in the <code>Dictionary</code> will be released after a call to <code>RemoveAll()</code>. From a... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/863/"
] | In a VB6 application, I have a `Dictionary` whose keys are `String`s and values are instances of a custom class. If I call `RemoveAll()` on the `Dictionary`, will it first free the custom objects? Or do I explicitly need to do this myself?
```
Dim d as Scripting.Dictionary
d("a") = New clsCustom
d("b") = New clsCusto... | Yes, all objects in the `Dictionary` will be released after a call to `RemoveAll()`. From a performance (as in speed) standpoint I would say those lines setting the variables to `Nothing` are unnecessary, because the code has to first look them up based on the key names whereas `RemoveAll()` will enumerate and release ... |
75,052 | <p>I have a flash player that has a set of songs loaded via an xml file.</p>
<p>The files dont start getting stream until you pick one.</p>
<p>If I quickly cycle through each of the 8 files, then flash starts trying to download each of the 8 files at the same time.</p>
<p>I'm wondering if there is a way to clear the... | [
{
"answer_id": 75323,
"author": "Jon",
"author_id": 12261,
"author_profile": "https://Stackoverflow.com/users/12261",
"pm_score": 0,
"selected": false,
"text": "<p>If you do something like:</p>\n\n<p>MySoundObject = undefined;</p>\n\n<p>That should do it.</p>\n"
},
{
"answer_id":... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6822/"
] | I have a flash player that has a set of songs loaded via an xml file.
The files dont start getting stream until you pick one.
If I quickly cycle through each of the 8 files, then flash starts trying to download each of the 8 files at the same time.
I'm wondering if there is a way to clear the file that is being down... | Check out [Sound.Close()](http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/Sound.html#close()).
From the docs: "*Closes the stream, causing any download of data to cease. No data may be read from the stream after the close() method is called.*"
This is the [source code example](http://livedocs.ad... |
75,057 | <p>What is the best way of ensuring that a user supplied password is a strong password in a registration or change password form?</p>
<p>One idea I had (in python)</p>
<pre><code>def validate_password(passwd):
conditions_met = 0
conditions_total = 3
if len(passwd) >= 6:
if passwd.lower() != pa... | [
{
"answer_id": 75108,
"author": "Mostlyharmless",
"author_id": 12881,
"author_profile": "https://Stackoverflow.com/users/12881",
"pm_score": -1,
"selected": false,
"text": "<p>Password strength checkers, and if you have time+resources (its justified only if you are checking for more than... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13099/"
] | What is the best way of ensuring that a user supplied password is a strong password in a registration or change password form?
One idea I had (in python)
```
def validate_password(passwd):
conditions_met = 0
conditions_total = 3
if len(passwd) >= 6:
if passwd.lower() != passwd: conditions_met += ... | **1: Eliminate often used passwords**
Check the entered passwords against a list of often used passwords (see e.g. the top 100.000 passwords in the leaked LinkedIn password list: <http://www.adeptus-mechanicus.com/codex/linkhap/combo_not.zip>), make sure to include [leetspeek substitutions](http://www.gamehouse.com/... |
75,076 | <p>I would like to be able to obtain all the parameter values from the stack frame in .NET. A bit like how you're able to see the values in the call stack when in the Visual Studio debugger. My approach has concentrated on using the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.stackframe%28v=vs.7... | [
{
"answer_id": 75297,
"author": "Lars Truijens",
"author_id": 1242,
"author_profile": "https://Stackoverflow.com/users/1242",
"pm_score": 4,
"selected": true,
"text": "<p>It seems it can't be done that way. It will only provide meta information about the method and its parameters. Not th... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2422/"
] | I would like to be able to obtain all the parameter values from the stack frame in .NET. A bit like how you're able to see the values in the call stack when in the Visual Studio debugger. My approach has concentrated on using the [StackFrame class](http://msdn.microsoft.com/en-us/library/system.diagnostics.stackframe%2... | It seems it can't be done that way. It will only provide meta information about the method and its parameters. Not the actual value at the time of the callstack.
Some suggest deriving your classes from [ContextBoundObject](http://msdn.microsoft.com/en-us/library/system.contextboundobject.aspx) and use [IMessageSink](... |
75,123 | <p>I have a DataSet which I get a DataTable from that I am being passed back from a function call. It has 15-20 columns, however I only want 10 columns of the data.</p>
<p>Is there a way to remove those columns that I don't want, copy the DataTable to another that has only the columns defined that I want or is it just... | [
{
"answer_id": 75178,
"author": "Tom Ritter",
"author_id": 8435,
"author_profile": "https://Stackoverflow.com/users/8435",
"pm_score": 9,
"selected": true,
"text": "<p>Aside from limiting the columns selected to reduce bandwidth and memory:</p>\n\n<pre><code>DataTable t;\nt.Columns.Remov... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] | I have a DataSet which I get a DataTable from that I am being passed back from a function call. It has 15-20 columns, however I only want 10 columns of the data.
Is there a way to remove those columns that I don't want, copy the DataTable to another that has only the columns defined that I want or is it just better to... | Aside from limiting the columns selected to reduce bandwidth and memory:
```
DataTable t;
t.Columns.Remove("columnName");
t.Columns.RemoveAt(columnIndex);
``` |
75,127 | <p>I have a bulletin board (punBB based) that I was running out of the root directory for a couple of years. I foolishly decided to do a little gardening and in the process moved the punbb code into it's own subdirectory. The code works great; as long as you point the browser at the new subdirectory. The issue is that ... | [
{
"answer_id": 75144,
"author": "user13270",
"author_id": 13270,
"author_profile": "https://Stackoverflow.com/users/13270",
"pm_score": 1,
"selected": false,
"text": "<p>a PHP file with a 301 HTTP permenant redirect.</p>\n\n<p>Put the following into index.php in the root directory of gua... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a bulletin board (punBB based) that I was running out of the root directory for a couple of years. I foolishly decided to do a little gardening and in the process moved the punbb code into it's own subdirectory. The code works great; as long as you point the browser at the new subdirectory. The issue is that the... | Something like this in .htacces should do it:
```
RewriteEngine On
RewriteRule ^/?$ /punbb/ [R=301,L]
```
The 301 return code is to mark the move as permanentm making it posible for the browser to update bookmarks. |
75,134 | <p>How do I have two effects in jQuery run in <code>sequence</code>, not simultaneously? Take this piece of code for example:</p>
<pre><code>$("#show-projects").click(function() {
$(".page:visible").fadeOut("normal");
$("#projects").fadeIn("normal");
});
</code></pre>
<p>The <code>fadeOut</code> and the <code... | [
{
"answer_id": 75194,
"author": "neuroguy123",
"author_id": 12529,
"author_profile": "https://Stackoverflow.com/users/12529",
"pm_score": 4,
"selected": false,
"text": "<p>What you want is a queue.</p>\n\n<p>Check out the reference page <a href=\"http://api.jquery.com/queue/\" rel=\"nofo... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6967/"
] | How do I have two effects in jQuery run in `sequence`, not simultaneously? Take this piece of code for example:
```
$("#show-projects").click(function() {
$(".page:visible").fadeOut("normal");
$("#projects").fadeIn("normal");
});
```
The `fadeOut` and the `fadeIn` run simultaneously, how do I make them run o... | You can supply a callback to the effects functions that run after the effect has completed.
```
$("#show-projects").click(function() {
$(".page:visible").fadeOut("normal", function() {
$("#projects").fadeIn("normal");
});
});
``` |
75,139 | <p>Google custom search code is provided as a form tag. However, Asp.net only allows a single form tag on a page. What is the best way to implement their code so you can include it on an aspx page (say as part of a Masterpage or navigation element). </p>
| [
{
"answer_id": 75234,
"author": "Chris Van Opstal",
"author_id": 7264,
"author_profile": "https://Stackoverflow.com/users/7264",
"pm_score": 3,
"selected": false,
"text": "<p>You can have multiple form tags on an ASP.NET page. The limitation is on server-side (runat=\"server\") form tags... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Google custom search code is provided as a form tag. However, Asp.net only allows a single form tag on a page. What is the best way to implement their code so you can include it on an aspx page (say as part of a Masterpage or navigation element). | You can have multiple form tags on an ASP.NET page. The limitation is on server-side (runat="server") form tags.
You can implement two form tags (or more) as long as only one has the runat="server" attribute and one is not contained in the other. Example:
```
<body>
<form action="http://www.google.com/cse" id="cse-s... |
75,156 | <p>This is a shared hosting environment. I control the server, but not necessarily the content. I've got a client with a Perl script that seems to run out of control every now and then and suck down 50% of the processor until the process is killed.</p>
<p>With ASP scripts, I'm able to restrict the amount of time the... | [
{
"answer_id": 75875,
"author": "arclight",
"author_id": 13366,
"author_profile": "https://Stackoverflow.com/users/13366",
"pm_score": 1,
"selected": false,
"text": "<p>On a UNIX-style system, I would use a signal handler trapping ALRM events, then use the alarm function to start a timer... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13282/"
] | This is a shared hosting environment. I control the server, but not necessarily the content. I've got a client with a Perl script that seems to run out of control every now and then and suck down 50% of the processor until the process is killed.
With ASP scripts, I'm able to restrict the amount of time the script can ... | On a UNIX-style system, I would use a signal handler trapping ALRM events, then use the alarm function to start a timer before starting an action that I expected might timeout. If the action completed, I'd use alarm(0) to turn off the alarm and exit normally, otherwise the signal handler should pick it up to close ever... |
75,175 | <p>Is it possible to create an instance of a generic type in Java? I'm thinking based on what I've seen that the answer is <code>no</code> (<em>due to type erasure</em>), but I'd be interested if anyone can see something I'm missing:</p>
<pre><code>class SomeContainer<E>
{
E createContents()
{
re... | [
{
"answer_id": 75201,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 0,
"selected": false,
"text": "<p>As you said, you can't really do it because of type erasure. You can sort of do it using reflection, but it requi... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5309/"
] | Is it possible to create an instance of a generic type in Java? I'm thinking based on what I've seen that the answer is `no` (*due to type erasure*), but I'd be interested if anyone can see something I'm missing:
```
class SomeContainer<E>
{
E createContents()
{
return what???
}
}
```
EDIT: It tu... | You are correct. You can't do `new E()`. But you can change it to
```
private static class SomeContainer<E> {
E createContents(Class<E> clazz) {
return clazz.newInstance();
}
}
```
It's a pain. But it works. Wrapping it in the factory pattern makes it a little more tolerable. |
75,180 | <p>If you have a statically allocated array, the Visual Studio debugger can easily display all of the array elements. However, if you have an array allocated dynamically and pointed to by a pointer, it will only display the first element of the array when you click the + to expand it. Is there an easy way to tell the... | [
{
"answer_id": 75202,
"author": "shoosh",
"author_id": 9611,
"author_profile": "https://Stackoverflow.com/users/9611",
"pm_score": 9,
"selected": true,
"text": "<p>Yes, simple.\nsay you have</p>\n\n<pre><code>char *a = new char[10];\n</code></pre>\n\n<p>writing in the debugger:</p>\n\n<p... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9530/"
] | If you have a statically allocated array, the Visual Studio debugger can easily display all of the array elements. However, if you have an array allocated dynamically and pointed to by a pointer, it will only display the first element of the array when you click the + to expand it. Is there an easy way to tell the debu... | Yes, simple.
say you have
```
char *a = new char[10];
```
writing in the debugger:
```
a,10
```
would show you the content as if it were an array. |
75,181 | <p>Here's a very simple Prototype example.</p>
<p>All it does is, on window load, an ajax call which sticks some html into a div.</p>
<pre class="lang-html prettyprint-override"><code><html>
<head>
<script type="text/javascript" src="scriptaculous/lib/prototype.js"><... | [
{
"answer_id": 75228,
"author": "Jan Krüger",
"author_id": 12471,
"author_profile": "https://Stackoverflow.com/users/12471",
"pm_score": 4,
"selected": true,
"text": "<p>The first letter of AJAX stands for \"asynchronous\". This means that the AJAX call is performed in the background, i.... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] | Here's a very simple Prototype example.
All it does is, on window load, an ajax call which sticks some html into a div.
```html
<html>
<head>
<script type="text/javascript" src="scriptaculous/lib/prototype.js"></script>
<script type="text/javascript">
Event.observe(window, 'load', func... | The first letter of AJAX stands for "asynchronous". This means that the AJAX call is performed in the background, i.e. the AJAX request call *immediately returns*. This means that the code immediately after it is normally actually executed *before* the onSuccess handler gets called (and before the AJAX request has even... |
75,213 | <p>In C++, what is the purpose of the scope resolution operator when used without a scope? For instance:</p>
<pre><code>::foo();
</code></pre>
| [
{
"answer_id": 75224,
"author": "shoosh",
"author_id": 9611,
"author_profile": "https://Stackoverflow.com/users/9611",
"pm_score": 2,
"selected": false,
"text": "<p>referring to the global scope</p>\n"
},
{
"answer_id": 75249,
"author": "Drealmer",
"author_id": 12291,
... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1785/"
] | In C++, what is the purpose of the scope resolution operator when used without a scope? For instance:
```
::foo();
``` | It means global scope. You might need to use this operator when you have conflicting functions or variables in the same scope and you need to use a global one. You might have something like:
```
void bar(); // this is a global function
class foo {
void some_func() { ::bar(); } // this function is calling th... |
75,218 | <p>How can I detect when an Exception has been thrown anywhere in my application?</p>
<p>I'm try to auto-magically send myself an email whenever an exception is thrown anywhere in my Java Desktop Application. I figure this way I can be more proactive.</p>
<p>I know I could just explicitly log and notify myself whene... | [
{
"answer_id": 75274,
"author": "toluju",
"author_id": 12457,
"author_profile": "https://Stackoverflow.com/users/12457",
"pm_score": 0,
"selected": false,
"text": "<p>In this case I think your best bet might be to write a custom classloader to handle all classloading in your application,... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] | How can I detect when an Exception has been thrown anywhere in my application?
I'm try to auto-magically send myself an email whenever an exception is thrown anywhere in my Java Desktop Application. I figure this way I can be more proactive.
I know I could just explicitly log and notify myself whenever an exception o... | You probobly don't want to mail on any exception. There are lots of code in the JDK that actaully depend on exceptions to work normally. What I presume you are more inerested in are uncaught exceptions. If you are catching the exceptions you should handle notifications there.
In a desktop app there are two places to w... |
75,245 | <p>Is it possible to reach the individual columns of table2 using HQL with a configuration like this?</p>
<pre><code><hibernate-mapping>
<class table="table1">
<set name="table2" table="table2" lazy="true" cascade="all">
<key column="result_id"/>
<many-to-many column="group... | [
{
"answer_id": 75272,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 1,
"selected": false,
"text": "<p>They're just properties of table1's table2 property.</p>\n\n<pre><code>select t1.table2.property1, t1.table2.property2, ..... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it possible to reach the individual columns of table2 using HQL with a configuration like this?
```
<hibernate-mapping>
<class table="table1">
<set name="table2" table="table2" lazy="true" cascade="all">
<key column="result_id"/>
<many-to-many column="group_id"/>
</set>
</class>
</hibernate-... | They're just properties of table1's table2 property.
```
select t1.table2.property1, t1.table2.property2, ... from table1 as t1
```
You might have to join, like so
```
select t2.property1, t2.property2, ...
from table1 as t1
inner join t1.table2 as t2
```
Here's the relevant part of the [hibernate doc](h... |
75,261 | <p>I got this output when running <code>sudo cpan Scalar::Util::Numeric</code></p>
<pre>
jmm@freekbox:~/bfwsandbox/sa/angel/astroportal/dtu8e/resources$ sudo cpan Scalar::Util::Numeric
[sudo] password for jmm:
CPAN: Storable loaded ok
Going to read /home/jmm/.cpan/Metadata
Database was generated on Tue, 09 Sep 2008 1... | [
{
"answer_id": 75320,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 2,
"selected": false,
"text": "<p>It can't find basic system headers. Either your include path is seriously messed up, or the headers are not instal... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I got this output when running `sudo cpan Scalar::Util::Numeric`
```
jmm@freekbox:~/bfwsandbox/sa/angel/astroportal/dtu8e/resources$ sudo cpan Scalar::Util::Numeric
[sudo] password for jmm:
CPAN: Storable loaded ok
Going to read /home/jmm/.cpan/Metadata
Database was generated on Tue, 09 Sep 2008 16:02:51 GMT
CPAN: ... | You're missing your C library development headers. You should install a package that has them. These are necessary to install this module because it has to compile some non-perl C code and needs to know more about your system.
I can't tell what kind of operating system you're on, but it looks like linux. If it's debia... |
75,273 | <p>I'm in an <strong>ASP.NET UserControl</strong>. When I type Control-K, Control-D to reformat all the markup, I get a series of messages from VS 2008:</p>
<p>"Could not reformat the document. The original format was restored."</p>
<p>"Could not complete the action."</p>
<p>"The operation could not be completed. ... | [
{
"answer_id": 75283,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 4,
"selected": true,
"text": "<p>There's probably some malformed markup somewhere in your document. Have you tried it on a fresh document?</p>\n"
},
... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5486/"
] | I'm in an **ASP.NET UserControl**. When I type Control-K, Control-D to reformat all the markup, I get a series of messages from VS 2008:
"Could not reformat the document. The original format was restored."
"Could not complete the action."
"The operation could not be completed. The parameter is incorrect."
Anybody k... | There's probably some malformed markup somewhere in your document. Have you tried it on a fresh document? |
75,282 | <p>I'm handling the <code>onSelectIndexChanged</code> event. An event is raised when the DropDownList selection changes. the problem is that the DropDownList still returns the old values for <code>SelectedValue</code> and <code>SelectedIndex</code>. What am I doing wrong?</p>
<p>Here is the DropDownList definition fro... | [
{
"answer_id": 75306,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 5,
"selected": true,
"text": "<p>Do you have any code in page load that is by chance re-defaulting the value to the first value?</p>\n\n<p>When th... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] | I'm handling the `onSelectIndexChanged` event. An event is raised when the DropDownList selection changes. the problem is that the DropDownList still returns the old values for `SelectedValue` and `SelectedIndex`. What am I doing wrong?
Here is the DropDownList definition from the aspx file:
```
<div style="margin: 0... | Do you have any code in page load that is by chance re-defaulting the value to the first value?
When the page reloads do you see the new value? |
75,322 | <p>I have an ASP.Net/AJAX control kit project that i am working on. 80% of the time there is no problem. The page runs as it should. If you refresh the page it will sometimes show a javascript error "Sys is undefined".</p>
<p>It doesn't happen all the time, but it is reproducible. When it happens, the user has to ... | [
{
"answer_id": 75460,
"author": "Compulsion",
"author_id": 3675,
"author_profile": "https://Stackoverflow.com/users/3675",
"pm_score": 3,
"selected": false,
"text": "<p>Try setting your ScriptManager to this.</p>\n\n<pre><code><asp:ScriptManager ID=\"ScriptManager1\" runat=\"server\" ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an ASP.Net/AJAX control kit project that i am working on. 80% of the time there is no problem. The page runs as it should. If you refresh the page it will sometimes show a javascript error "Sys is undefined".
It doesn't happen all the time, but it is reproducible. When it happens, the user has to shut down thei... | I fixed my problem by moving the `<script type="text/javascript"></script>` block containing the Sys.\* calls lower down (to the last item before the close of the body's `<asp:Content/>` section) in the HTML on the page. I originally had my the script block in the HEAD `<asp:Content/>` section of my page. I was working... |
75,361 | <p>I have a column containing the strings 'Operator (1)' and so on until 'Operator (600)' so far.</p>
<p>I want to get them numerically ordered and I've come up with</p>
<pre><code>select colname from table order by
cast(replace(replace(colname,'Operator (',''),')','') as int)
</code></pre>
<p>which is very very ug... | [
{
"answer_id": 75398,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 3,
"selected": true,
"text": "<p>It's that, InStr()/SubString(), changing Operator(1) to Operator(001), storing the n in Operator(n) separately, or cr... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5190/"
] | I have a column containing the strings 'Operator (1)' and so on until 'Operator (600)' so far.
I want to get them numerically ordered and I've come up with
```
select colname from table order by
cast(replace(replace(colname,'Operator (',''),')','') as int)
```
which is very very ugly.
Better suggestions? | It's that, InStr()/SubString(), changing Operator(1) to Operator(001), storing the n in Operator(n) separately, or creating a computed column that hides the ugly string manipulation. What you have seems fine. |
75,379 | <p>The problem is simple, but I'm struggling a bit already.</p>
<pre><code>Server server = new Server(8080);
Context context = new Context(server, "/", Context.NO_SESSIONS);
context.addServlet(MainPageView.class, "/");
context.addServlet(UserView.class, "/signup");
server.start();
</code></pre>
<p>That's a pretty s... | [
{
"answer_id": 75424,
"author": "Justin Rudd",
"author_id": 12968,
"author_profile": "https://Stackoverflow.com/users/12968",
"pm_score": 0,
"selected": false,
"text": "<p>Use the <code>Context.addServlet</code> overload that takes a <code>ServletHolder</code>. <code>ServletHolder</code... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3105/"
] | The problem is simple, but I'm struggling a bit already.
```
Server server = new Server(8080);
Context context = new Context(server, "/", Context.NO_SESSIONS);
context.addServlet(MainPageView.class, "/");
context.addServlet(UserView.class, "/signup");
server.start();
```
That's a pretty standard piece of code that... | I'm not sure why using Guice make's Justin's option not work for you. What exactly is getting injected in? I'm not sure if this would help you at all because it is very similar to what Justin wrote above but if you do it this way, Jetty will do the actually instantiating.
```
Context context = new Context(server, "/",... |
75,385 | <p>The Visual Studio compiler does not seem to warn on signed/unsigned assignments, only on comparisons. For example the code below will generate a warning on the if statement but not the initial assignments.</p>
<p>Is there anyway to make it catch these? I'm already at W4 but thought (hoped) there may be another sett... | [
{
"answer_id": 75596,
"author": "quamrana",
"author_id": 4834,
"author_profile": "https://Stackoverflow.com/users/4834",
"pm_score": 4,
"selected": true,
"text": "<p>You need to enable warning 4365 to catch the assignment.</p>\n\n<p>That might be tricky - you need to enable ALL warnings ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1043/"
] | The Visual Studio compiler does not seem to warn on signed/unsigned assignments, only on comparisons. For example the code below will generate a warning on the if statement but not the initial assignments.
Is there anyway to make it catch these? I'm already at W4 but thought (hoped) there may be another setting somewh... | You need to enable warning 4365 to catch the assignment.
That might be tricky - you need to enable ALL warnings - use /Wall which enables lots of warnings, so you may have some trouble seeing the warning occur, but it does. |
75,401 | <p>User <a href="https://stackoverflow.com/users/1065/kokos">kokos</a> answered the wonderful <em><a href="https://stackoverflow.com/questions/9033/hidden-features-of-c">Hidden Features of C#</a></em> question by mentioning the <code>using</code> keyword. Can you elaborate on that? What are the uses of <code>using</cod... | [
{
"answer_id": 75419,
"author": "Joseph Daigle",
"author_id": 507,
"author_profile": "https://Stackoverflow.com/users/507",
"pm_score": 2,
"selected": false,
"text": "<p>When using ADO.NET you can use the keywork for things like your connection object or reader object. That way when the ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13332/"
] | User [kokos](https://stackoverflow.com/users/1065/kokos) answered the wonderful *[Hidden Features of C#](https://stackoverflow.com/questions/9033/hidden-features-of-c)* question by mentioning the `using` keyword. Can you elaborate on that? What are the uses of `using`? | The reason for the `using` statement is to ensure that the object is disposed as soon as it goes out of scope, and it doesn't require explicit code to ensure that this happens.
As in *[Understanding the 'using' statement in C# (codeproject)](https://www.codeproject.com/Articles/6564/Understanding-the-using-statement-i... |
75,440 | <p>What method do I call to get the name of a class?</p>
| [
{
"answer_id": 75456,
"author": "clahey",
"author_id": 8453,
"author_profile": "https://Stackoverflow.com/users/8453",
"pm_score": 5,
"selected": false,
"text": "<p>It's not a method, it's a field. The field is called <code>__name__</code>. <code>class.__name__</code> will give the nam... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8453/"
] | What method do I call to get the name of a class? | ```
In [1]: class Test:
...: pass
...:
In [2]: Test.__name__
Out[2]: 'Test'
``` |
75,441 | <p>As part of the Nant copy task, I would like to change the properties of the files in the target location. For instance make the files "read-write" from "read-only". How would I do this?</p>
| [
{
"answer_id": 75481,
"author": "Phillip Wells",
"author_id": 3012,
"author_profile": "https://Stackoverflow.com/users/3012",
"pm_score": 4,
"selected": true,
"text": "<p>Use the <<a href=\"http://nant.sourceforge.net/release/0.85-rc1/help/tasks/attrib.html\" rel=\"noreferrer\">attrib... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8088/"
] | As part of the Nant copy task, I would like to change the properties of the files in the target location. For instance make the files "read-write" from "read-only". How would I do this? | Use the <[attrib](http://nant.sourceforge.net/release/0.85-rc1/help/tasks/attrib.html)> task. For example, to make the file "test.txt" read/write, you would use
```
<attrib file="test.txt" readonly="false"/>
``` |
75,489 | <p>I am pulling a long timestamp from a database, but want to present it as a Date using Tags only, no embedded java in the JSP.<br><br> I've created my own tag to do this because I was unable to get the parseDate and formatDate tags to work, but that's not to say they don't work.<br>
<br>
Any advice?</p>
<p>Thanks.</... | [
{
"answer_id": 75674,
"author": "ScArcher2",
"author_id": 1310,
"author_profile": "https://Stackoverflow.com/users/1310",
"pm_score": 4,
"selected": true,
"text": "<p>The parseDate and formatDate tags work, but they work with Date objects.\nYou can call new java.util.Date(longvalue) to g... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9450/"
] | I am pulling a long timestamp from a database, but want to present it as a Date using Tags only, no embedded java in the JSP.
I've created my own tag to do this because I was unable to get the parseDate and formatDate tags to work, but that's not to say they don't work.
Any advice?
Thanks. | The parseDate and formatDate tags work, but they work with Date objects.
You can call new java.util.Date(longvalue) to get a date object, then pass that to the standard tag.
somewhere other than the jsp create your date object.
```
long longvalue = ...;//from database.
java.util.Date dateValue = new java.util.Date(lo... |
75,495 | <p>When creating a UserControl in WPF, I find it convenient to give it some arbitrary Height and Width values so that I can view my changes in the Visual Studio designer. When I run the control, however, I want the Height and Width to be undefined, so that the control will expand to fill whatever container I place it i... | [
{
"answer_id": 75527,
"author": "Brian Leahy",
"author_id": 580,
"author_profile": "https://Stackoverflow.com/users/580",
"pm_score": 6,
"selected": false,
"text": "<p>For Blend, a little known trick is to add these attributes to your usercontrol or window:</p>\n\n<pre><code> xmlns:d=\"h... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/317/"
] | When creating a UserControl in WPF, I find it convenient to give it some arbitrary Height and Width values so that I can view my changes in the Visual Studio designer. When I run the control, however, I want the Height and Width to be undefined, so that the control will expand to fill whatever container I place it in. ... | In Visual Studio add the Width and Height attribute to your UserControl XAML, but in the code-behind insert this
```
public UserControl1()
{
InitializeComponent();
if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
{
this.Width = double.NaN; ;
this.Height = double.NaN; ;
}
}
... |
75,500 | <p>I have around 1000 pdf filesand I need to convert them to 300 dpi tiff files. What is the best way to do this? If there is an SDK or something or a tool that can be scripted that would be ideal. </p>
| [
{
"answer_id": 75524,
"author": "JBB",
"author_id": 12332,
"author_profile": "https://Stackoverflow.com/users/12332",
"pm_score": 2,
"selected": false,
"text": "<p>How about pdf2tiff? <a href=\"http://python.net/~gherman/pdf2tiff.html\" rel=\"nofollow noreferrer\">http://python.net/~gher... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/260/"
] | I have around 1000 pdf filesand I need to convert them to 300 dpi tiff files. What is the best way to do this? If there is an SDK or something or a tool that can be scripted that would be ideal. | Use Imagemagick, or better yet, Ghostscript.
<http://www.ibm.com/developerworks/library/l-graf2/#N101C2> has an example for imagemagick:
```
convert foo.pdf pages-%03d.tiff
```
<http://www.asmail.be/msg0055376363.html> has an example for ghostscript:
```
gs -q -dNOPAUSE -sDEVICE=tiffg4 -sOutputFile=a.tif foo.pdf -... |
75,508 | <p>I have 28,000 images I need to convert into a movie.
I tried </p>
<pre><code>mencoder mf://*.jpg -mf w=640:h=480:fps=30:type=jpg -ovc lavc -lavcopts vcodec=msmpeg4v2 -nosound -o ../output-msmpeg4v2.avi
</code></pre>
<p>But it seems to crap out at 7500 frames.</p>
<p>The files are named
webcam_2007-04-16_070804.jp... | [
{
"answer_id": 75566,
"author": "Grank",
"author_id": 12975,
"author_profile": "https://Stackoverflow.com/users/12975",
"pm_score": 0,
"selected": false,
"text": "<p>another alternative is to bypass mencoder and use ffmpeg directly</p>\n"
},
{
"answer_id": 75616,
"author": "D... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11950/"
] | I have 28,000 images I need to convert into a movie.
I tried
```
mencoder mf://*.jpg -mf w=640:h=480:fps=30:type=jpg -ovc lavc -lavcopts vcodec=msmpeg4v2 -nosound -o ../output-msmpeg4v2.avi
```
But it seems to crap out at 7500 frames.
The files are named
webcam\_2007-04-16\_070804.jpg
webcam\_2007-04-16\_071004.jp... | Shove the list of images in a file, one per line. Then use `mf://@filename` |
75,538 | <p>No C++ love when it comes to the "hidden features of" line of questions? Figured I would throw it out there. What are some of the hidden features of C++?</p>
| [
{
"answer_id": 75581,
"author": "neuroguy123",
"author_id": 12529,
"author_profile": "https://Stackoverflow.com/users/12529",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not sure about hidden, but there are some <a href=\"http://en.wikipedia.org/wiki/Duff%27s_device\" rel=\"nofollo... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2328/"
] | No C++ love when it comes to the "hidden features of" line of questions? Figured I would throw it out there. What are some of the hidden features of C++? | You can put URIs into C++ source without error. For example:
```
void foo() {
http://stackoverflow.com/
int bar = 4;
...
}
``` |
75,608 | <p>I'm working on a product feature that will allow the user to export data from a SQL CE database on one copy of my application and re-import it into SQL CE on the other end. This data is not whole tables, but the result of queries.</p>
<p>I had hoped to take advantage of .net's built-in XML-based serialization like ... | [
{
"answer_id": 75651,
"author": "Grank",
"author_id": 12975,
"author_profile": "https://Stackoverflow.com/users/12975",
"pm_score": 0,
"selected": false,
"text": "<p>I would think you could retrieve the data to a DataSet, call WriteXML on it, and then on the other end declare a new DataS... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287/"
] | I'm working on a product feature that will allow the user to export data from a SQL CE database on one copy of my application and re-import it into SQL CE on the other end. This data is not whole tables, but the result of queries.
I had hoped to take advantage of .net's built-in XML-based serialization like in DataTab... | Assuming cmd is your SqlCeCommand....
```
using(var dr = cmd.ExecuteReader())
{
DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add();
dt.Load(dr);
ds.WriteXML(...);
}
``` |
75,614 | <p>The following question answers how to get large memory pages on Windows :<br>
"<a href="https://stackoverflow.com/questions/39059/how-do-i-run-my-app-with-large-pages-in-windows">how do i run my app with large pages in windows</a>".</p>
<p>The problem I'm trying to solve is how do I configure it on Vista and 2008 S... | [
{
"answer_id": 75651,
"author": "Grank",
"author_id": 12975,
"author_profile": "https://Stackoverflow.com/users/12975",
"pm_score": 0,
"selected": false,
"text": "<p>I would think you could retrieve the data to a DataSet, call WriteXML on it, and then on the other end declare a new DataS... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8782/"
] | The following question answers how to get large memory pages on Windows :
"[how do i run my app with large pages in windows](https://stackoverflow.com/questions/39059/how-do-i-run-my-app-with-large-pages-in-windows)".
The problem I'm trying to solve is how do I configure it on Vista and 2008 Server.
Normally you j... | Assuming cmd is your SqlCeCommand....
```
using(var dr = cmd.ExecuteReader())
{
DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add();
dt.Load(dr);
ds.WriteXML(...);
}
``` |
75,621 | <p>I have a web report that uses a Django form (new forms) for fields that control the query used to generate the report (start date, end date, ...). The issue I'm having is that the page should work using the form's initial values (unbound), but I can't access the cleaned_data field unless I call <code>is_valid()</cod... | [
{
"answer_id": 75815,
"author": "Justin Voss",
"author_id": 5616,
"author_profile": "https://Stackoverflow.com/users/5616",
"pm_score": 0,
"selected": false,
"text": "<p>You can pass a dictionary of initial values to your form:</p>\n\n<pre><code>if request.method == \"GET\":\n # calcu... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8247/"
] | I have a web report that uses a Django form (new forms) for fields that control the query used to generate the report (start date, end date, ...). The issue I'm having is that the page should work using the form's initial values (unbound), but I can't access the cleaned\_data field unless I call `is_valid()`. But `is_v... | If you add this method to your form class:
```
def get_cleaned_or_initial(self, fieldname):
if hasattr(self, 'cleaned_data'):
return self.cleaned_data.get(fieldname)
else:
return self[fieldname].field.initial
```
you could then re-write your code as:
```
if request.method == ... |
75,626 | <p>I have a JSP page that contains a scriplet where I instantiate an object. I would like to pass that object to the JSP tag without using any cache. </p>
<p>For example I would like to accomplish this: </p>
<pre><code><%@ taglib prefix="wf" uri="JspCustomTag" %>
<%
Object myObject = new Object();
%>... | [
{
"answer_id": 75745,
"author": "Brian Matthews",
"author_id": 1969,
"author_profile": "https://Stackoverflow.com/users/1969",
"pm_score": 0,
"selected": false,
"text": "<p>Use expression language:</p>\n\n<pre>\n <wf:my-tag obj=\"${myObject}\" />\n</pre>\n"
},
{
"answer_... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13393/"
] | I have a JSP page that contains a scriplet where I instantiate an object. I would like to pass that object to the JSP tag without using any cache.
For example I would like to accomplish this:
```
<%@ taglib prefix="wf" uri="JspCustomTag" %>
<%
Object myObject = new Object();
%>
<wf:my-tag obj=myObject />
```
... | A slightly different question that I looked for here: "How do you pass an object to a tag file?"
Answer: Use the "type" attribute of the attribute directive:
```
<%@ attribute name="field"
required="true"
type="com.mycompany.MyClass" %>
```
The type [defaults to java.lang.String](http:/... |
75,650 | <p>I'm working in a team environment where each developer works from their local desktop and deploys to a virtual machine that they own on the network. What I'm trying to do is set up the Visual Studio solution so that when they build the solution each projects deployment is handled in the post-build event to that dev... | [
{
"answer_id": 75745,
"author": "Brian Matthews",
"author_id": 1969,
"author_profile": "https://Stackoverflow.com/users/1969",
"pm_score": 0,
"selected": false,
"text": "<p>Use expression language:</p>\n\n<pre>\n <wf:my-tag obj=\"${myObject}\" />\n</pre>\n"
},
{
"answer_... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] | I'm working in a team environment where each developer works from their local desktop and deploys to a virtual machine that they own on the network. What I'm trying to do is set up the Visual Studio solution so that when they build the solution each projects deployment is handled in the post-build event to that develop... | A slightly different question that I looked for here: "How do you pass an object to a tag file?"
Answer: Use the "type" attribute of the attribute directive:
```
<%@ attribute name="field"
required="true"
type="com.mycompany.MyClass" %>
```
The type [defaults to java.lang.String](http:/... |
75,675 | <p>How do I dump the data, and only the data, not the schema, of some SQLite3 tables of a database (not all the tables)?
The dump should be in SQL format, as it should be easily re-entered into the database later and should be done from the command line. Something like</p>
<pre><code>sqlite3 db .dump
</code></pre>
<p... | [
{
"answer_id": 75694,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "<p>You could do a select on the tables inserting commas after each field to produce a csv, or use a GUI tool to return all the... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] | How do I dump the data, and only the data, not the schema, of some SQLite3 tables of a database (not all the tables)?
The dump should be in SQL format, as it should be easily re-entered into the database later and should be done from the command line. Something like
```
sqlite3 db .dump
```
but without dumping the s... | You're not saying what you wish to do with the dumped file.
To get a CSV file (which can be imported into almost everything)
```
.mode csv
-- use '.separator SOME_STRING' for something other than a comma.
.headers on
.out file.csv
select * from MyTable;
```
To get an SQL file (which can be reinserted into a diff... |
75,700 | <p>I have one applicationContext.xml file, and it has two org.springframework.orm.jpa.JpaTransactionManager (each with its own persistence unit, different databases) configured in a Spring middleware custom application.
<br><br>I want to use annotation based transactions (@Transactional), to not mess around with Transa... | [
{
"answer_id": 78479,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 4,
"selected": true,
"text": "<p>I guess you have 2 choices</p>\n\n<p>If your use-cases never require updates to both databases within the same transaction,... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13143/"
] | I have one applicationContext.xml file, and it has two org.springframework.orm.jpa.JpaTransactionManager (each with its own persistence unit, different databases) configured in a Spring middleware custom application.
I want to use annotation based transactions (@Transactional), to not mess around with TransactionStatu... | I guess you have 2 choices
If your use-cases never require updates to both databases within the same transaction, then you can use two JpaTransactionManagers, but I'm not sure you will be able to use the @Transactional approach? In this case, you would need to fallback on the older mechanism of using a simple [Transac... |
75,704 | <p>I see that within MySQL there are <code>Cast()</code> and <code>Convert()</code> functions to create integers from values, but is there any way to check to see if a value is an integer? Something like <code>is_int()</code> in PHP is what I am looking for.</p>
| [
{
"answer_id": 75739,
"author": "JBB",
"author_id": 12332,
"author_profile": "https://Stackoverflow.com/users/12332",
"pm_score": 4,
"selected": false,
"text": "<p>Match it against a regular expression.</p>\n<p>c.f. <a href=\"http://forums.mysql.com/read.php?60,1907,38488#msg-38488\" rel... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8224/"
] | I see that within MySQL there are `Cast()` and `Convert()` functions to create integers from values, but is there any way to check to see if a value is an integer? Something like `is_int()` in PHP is what I am looking for. | I'll assume you want to check a string value. One nice way is the REGEXP operator, matching the string to a regular expression. Simply do
```
select field from table where field REGEXP '^-?[0-9]+$';
```
this is reasonably fast. If your field is numeric, just test for
```
ceil(field) = field
```
instead. |
75,705 | <p>I have searched for various techniques on how to read/write dBase III (dbf) files using OLEDB or ODBC with C#/.NET. I have tried almost all of the tecniques posted, but without success. Can someone point me in the right direction?</p>
<p>Thanks for your time.</p>
| [
{
"answer_id": 75846,
"author": "Kearns",
"author_id": 6500,
"author_profile": "https://Stackoverflow.com/users/6500",
"pm_score": 2,
"selected": false,
"text": "<p>FoxPro 2.0 files were exactly the same as dBase III files with an extra bit for any field that was of type \"memo\" (not su... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10333/"
] | I have searched for various techniques on how to read/write dBase III (dbf) files using OLEDB or ODBC with C#/.NET. I have tried almost all of the tecniques posted, but without success. Can someone point me in the right direction?
Thanks for your time. | Something like ... ?
```
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\dBase;Extended Properties=dBase III"
Dim dBaseConnection As New System.Data.OleDb.OleDbConnection(ConnectionString )
dBaseConnection.Open()
```
From: <http://bytes.com/forum/thread112085.html> |
75,713 | <p>I'm trying to bind controls in a WPF form to an interface and I get a runtime error that it can't find the interface's properties.</p>
<p>Here's the class I'm using as a datasource:</p>
<pre><code>public interface IPerson
{
string UserId { get; set; }
string UserName { get; set; }
string Email { get; s... | [
{
"answer_id": 77322,
"author": "Robert Jeppesen",
"author_id": 9436,
"author_profile": "https://Stackoverflow.com/users/9436",
"pm_score": 3,
"selected": true,
"text": "<p>I'm not familiar with entlib's policy injection, but I'm pretty sure that your problem lies there, and not in the f... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6542/"
] | I'm trying to bind controls in a WPF form to an interface and I get a runtime error that it can't find the interface's properties.
Here's the class I'm using as a datasource:
```
public interface IPerson
{
string UserId { get; set; }
string UserName { get; set; }
string Email { get; set; }
}
public class... | I'm not familiar with entlib's policy injection, but I'm pretty sure that your problem lies there, and not in the fact that you're using an interface.
If you were to replace
```
var person = PolicyInjection.Wrap<IPerson>(new Person());
```
with
```
IPerson person = new Person();
```
surely it would work? |
75,714 | <p>Note: I am using .Net 1.1, although I am not completely against answer that use higher versions.</p>
<p>I am displaying some dynamically generated objects in a PropertyGrid. These objects have numeric, text, and enumeration properties. Currently I am having issues setting the default value for the enumerations so t... | [
{
"answer_id": 80194,
"author": "Eric W",
"author_id": 14972,
"author_profile": "https://Stackoverflow.com/users/14972",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not sure how to get the attribute to work, but there is another option that may be easier.</p>\n\n<p>In addition to c... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Note: I am using .Net 1.1, although I am not completely against answer that use higher versions.
I am displaying some dynamically generated objects in a PropertyGrid. These objects have numeric, text, and enumeration properties. Currently I am having issues setting the default value for the enumerations so that they d... | I'm not sure how to get the attribute to work, but there is another option that may be easier.
In addition to checking for the DefaultValueAttribute, the PropertyGrid also uses reflection to look for a method named "ShouldSerializeProperty Name", where [Property Name] is the name of the property in question. This meth... |
75,722 | <p>In C#, if I want to deterministically clean up non-managed resources, I can use the "using" keyword. But for multiple dependent objects, this ends up nesting further and further:</p>
<pre><code>using (FileStream fs = new FileStream("c:\file.txt", FileMode.Open))
{
using (BufferedStream bs = new BufferedStream(... | [
{
"answer_id": 75741,
"author": "Abe Heidebrecht",
"author_id": 9268,
"author_profile": "https://Stackoverflow.com/users/9268",
"pm_score": -1,
"selected": false,
"text": "<p>The using statement is syntactic sugar that converts to:</p>\n\n<pre><code> try\n {\n obj declaration\n ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8701/"
] | In C#, if I want to deterministically clean up non-managed resources, I can use the "using" keyword. But for multiple dependent objects, this ends up nesting further and further:
```
using (FileStream fs = new FileStream("c:\file.txt", FileMode.Open))
{
using (BufferedStream bs = new BufferedStream(fs))
{
... | You don't have to nest with multiple usings:
```
using (FileStream fs = new FileStream("c:\file.txt", FileMode.Open))
using (BufferedStream bs = new BufferedStream(fs))
using (StreamReader sr = new StreamReader(bs))
{
// all three get disposed when you're done
}
``` |
75,746 | <pre><code>EmployeeNumber =
string.IsNullOrEmpty(employeeNumberTextBox.Text)
? null
: Convert.ToInt32(employeeNumberTextBox.Text),
</code></pre>
<p>I often find myself wanting to do things like this (<code>EmployeeNumber</code> is a <code>Nullable<int></code> as it's a property on a LINQ-to-SQL dbml objec... | [
{
"answer_id": 75795,
"author": "Abe Heidebrecht",
"author_id": 9268,
"author_profile": "https://Stackoverflow.com/users/9268",
"pm_score": 2,
"selected": false,
"text": "<p>You can cast the output of Convert:</p>\n\n<pre><code>EmployeeNumber = string.IsNullOrEmpty(employeeNumberTextBox.... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12975/"
] | ```
EmployeeNumber =
string.IsNullOrEmpty(employeeNumberTextBox.Text)
? null
: Convert.ToInt32(employeeNumberTextBox.Text),
```
I often find myself wanting to do things like this (`EmployeeNumber` is a `Nullable<int>` as it's a property on a LINQ-to-SQL dbml object where the column allows NULL values). Unfort... | The problem occurs because the conditional operator doesn't look at how the value is used (assigned in this case) to determine the type of the expression -- just the true/false values. In this case, you have a `null` and an `Int32`, and the type can not be determined (there are real reasons it can't just assume `Nullab... |
75,752 | <p>I'm building a quick csv from a mysql table with a query like:</p>
<pre><code>select DATE(date),count(date) from table group by DATE(date) order by date asc;
</code></pre>
<p>and just dumping them to a file in perl over a:</p>
<pre><code>while(my($date,$sum) = $sth->fetchrow) {
print CSV "$date,$sum\n"
}
<... | [
{
"answer_id": 75807,
"author": "Aeon",
"author_id": 13289,
"author_profile": "https://Stackoverflow.com/users/13289",
"pm_score": 3,
"selected": false,
"text": "<p>When I had to deal with this problem, to fill in missing dates I actually created a reference table that just contained all... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13196/"
] | I'm building a quick csv from a mysql table with a query like:
```
select DATE(date),count(date) from table group by DATE(date) order by date asc;
```
and just dumping them to a file in perl over a:
```
while(my($date,$sum) = $sth->fetchrow) {
print CSV "$date,$sum\n"
}
```
There are date gaps in the data, th... | When you need something like that on server side, you usually create a table which contains all possible dates between two points in time, and then left join this table with query results. Something like this:
```sql
create procedure sp1(d1 date, d2 date)
declare d datetime;
create temporary table foo (d date not... |
75,759 | <p>What's the best way to implement the enum idiom in Ruby? I'm looking for something which I can use (almost) like the Java/C# enums.</p>
| [
{
"answer_id": 75787,
"author": "Jan Krüger",
"author_id": 12471,
"author_profile": "https://Stackoverflow.com/users/12471",
"pm_score": 1,
"selected": false,
"text": "<p>Most people use symbols (that's the <code>:foo_bar</code> syntax). They're sort of unique opaque values. Symbols don'... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4110/"
] | What's the best way to implement the enum idiom in Ruby? I'm looking for something which I can use (almost) like the Java/C# enums. | Two ways. Symbols (`:foo` notation) or constants (`FOO` notation).
Symbols are appropriate when you want to enhance readability without littering code with literal strings.
```
postal_code[:minnesota] = "MN"
postal_code[:new_york] = "NY"
```
Constants are appropriate when you have an underlying value that is import... |
75,785 | <p>Is there any complete guidance on doing AppBar docking (such as locking to the screen edge) in WPF? I understand there are InterOp calls that need to be made, but I'm looking for either a proof of concept based on a simple WPF form, or a componentized version that can be consumed.</p>
<p>Related resources:</p>
<ul... | [
{
"answer_id": 84987,
"author": "Philip Rieck",
"author_id": 12643,
"author_profile": "https://Stackoverflow.com/users/12643",
"pm_score": 8,
"selected": true,
"text": "<p><strong>Please Note:</strong> This question gathered a good amount of feedback, and some people below have made grea... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7301/"
] | Is there any complete guidance on doing AppBar docking (such as locking to the screen edge) in WPF? I understand there are InterOp calls that need to be made, but I'm looking for either a proof of concept based on a simple WPF form, or a componentized version that can be consumed.
Related resources:
* <http://www.cod... | **Please Note:** This question gathered a good amount of feedback, and some people below have made great points or fixes. Therefore, while I'll keep the code here (and possibly update it), I've also **created a [WpfAppBar project on github](https://github.com/PhilipRieck/WpfAppBar)**. Feel free to send pull requests.
... |
75,786 | <p>(Eclipse 3.4, Ganymede)</p>
<p>I have an existing Dynamic Web Application project in Eclipse. When I created the project, I specified 'Default configuration for Apache Tomcat v6' under the 'Configuration' drop down.</p>
<p>It's a month or 2 down the line, and I would now like to change the configuration to Tomcat ... | [
{
"answer_id": 76205,
"author": "William",
"author_id": 9193,
"author_profile": "https://Stackoverflow.com/users/9193",
"pm_score": 7,
"selected": true,
"text": "<p>This is kind of hacking eclipse and you can get into trouble doing this but this should work:</p>\n\n<p>Open the navigator ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13360/"
] | (Eclipse 3.4, Ganymede)
I have an existing Dynamic Web Application project in Eclipse. When I created the project, I specified 'Default configuration for Apache Tomcat v6' under the 'Configuration' drop down.
It's a month or 2 down the line, and I would now like to change the configuration to Tomcat 'v5.5'. (This wil... | This is kind of hacking eclipse and you can get into trouble doing this but this should work:
Open the navigator view and find that there is a .settings folder under your project expand it and then open the file: `org.eclipse.wst.common.project.facet.core.xml` you should see a line that says:
`<installed facet="jst.w... |
75,809 | <p>Given the case I made <strong>two independent changes</strong> in <em>one</em> file: eg. added a new method and changed another method.</p>
<p>I often don't want to commit both changes as <strong>one</strong> commit, but as <strong>two</strong> independent commits.</p>
<p>On a git repository I would use the <stron... | [
{
"answer_id": 75881,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "<p>I used to do this:</p>\n\n<ul>\n<li>In my editor (I use vim), edit the file so that only one of the changes appear</li>... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4308/"
] | Given the case I made **two independent changes** in *one* file: eg. added a new method and changed another method.
I often don't want to commit both changes as **one** commit, but as **two** independent commits.
On a git repository I would use the **Interactive Mode** of [git-add(1)](http://linux.die.net/man/1/git-a... | With git-svn you can make a local GIT repository of the remote SVN repository, work with it using the full GIT feature set (including partial commits) and then push it all back to the SVN repository.
[git-svn (1)](http://schacon.github.com/git/git-svn.html) |
75,819 | <p>I'm having an issue with a query that currently uses </p>
<pre><code>LEFT JOIN weblog_data AS pwd
ON (pwd.field_id_41 != ''
AND pwd.field_id_41 LIKE CONCAT('%', ewd.field_id_32, '%'))
</code></pre>
<p>However I'm discovering that I need it to only use that if there is no exact match first. What's happening i... | [
{
"answer_id": 75861,
"author": "Sam",
"author_id": 9406,
"author_profile": "https://Stackoverflow.com/users/9406",
"pm_score": 1,
"selected": false,
"text": "<p>you're talking about short circuit evaluation.</p>\n\n<p>Take a look at this article it might help you:\n<a href=\"http://bein... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12073/"
] | I'm having an issue with a query that currently uses
```
LEFT JOIN weblog_data AS pwd
ON (pwd.field_id_41 != ''
AND pwd.field_id_41 LIKE CONCAT('%', ewd.field_id_32, '%'))
```
However I'm discovering that I need it to only use that if there is no exact match first. What's happening is that the query is double... | It sounds like you want to join the tables aliased as pwd and ewd in your snippet based first on an exact match, and if that fails, then on the like comparison you have now.
Try this:
```
LEFT JOIN weblog_data AS pwd1 ON (pwd.field_id_41 != '' AND pwd.field_id_41 = ewd.field_id_32)
LEFT JOIN weblog_data AS pwd2 ON (p... |
75,829 | <p>All the docs for SQLAlchemy give <code>INSERT</code> and <code>UPDATE</code> examples using the local table instance (e.g. <code>tablename.update()</code>... )</p>
<p>Doing this seems difficult with the declarative syntax, I need to reference <code>Base.metadata.tables["tablename"]</code> to get the table reference... | [
{
"answer_id": 77962,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>via the <code>__table__</code> attribute on your declarative class</p>\n"
},
{
"answer_id": 156968,
"author": "G... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | All the docs for SQLAlchemy give `INSERT` and `UPDATE` examples using the local table instance (e.g. `tablename.update()`... )
Doing this seems difficult with the declarative syntax, I need to reference `Base.metadata.tables["tablename"]` to get the table reference.
Am I supposed to do this another way? Is there a di... | well it works for me:
```
class Users(Base):
__tablename__ = 'users'
__table_args__ = {'autoload':True}
users = Users()
print users.__table__.select()
```
...SELECT users....... |
75,848 | <p>I'm trying to insert a <a href="http://en.wikipedia.org/wiki/Spry_framework" rel="nofollow noreferrer">Spry</a> <a href="http://en.wikipedia.org/wiki/Accordion_(GUI)" rel="nofollow noreferrer">accordion</a> into an already existing <a href="http://en.wikipedia.org/wiki/JavaServer_Faces" rel="nofollow noreferrer">JSF... | [
{
"answer_id": 81534,
"author": "Dave Smylie",
"author_id": 1505600,
"author_profile": "https://Stackoverflow.com/users/1505600",
"pm_score": 3,
"selected": true,
"text": "<p>I'm not a Dreamweaver expert, but all Spry Accordian requires is the correct HTML structure. E.g.: </p>\n\n<pre><... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1459442/"
] | I'm trying to insert a [Spry](http://en.wikipedia.org/wiki/Spry_framework) [accordion](http://en.wikipedia.org/wiki/Accordion_(GUI)) into an already existing [JSF](http://en.wikipedia.org/wiki/JavaServer_Faces) page using [Dreamweaver](http://en.wikipedia.org/wiki/Adobe_Dreamweaver). Is this possible?
I've already tr... | I'm not a Dreamweaver expert, but all Spry Accordian requires is the correct HTML structure. E.g.:
```
<div id="Accordion1" class="Accordion">
<div class="AccordionPanel">
<div class="AccordionPanelTab">Panel 1</div>
<div class="AccordionPanelContent">
... |
75,943 | <p>I'm working on a web page where I'm making an AJAX call that returns a chunk of HTML like: </p>
<pre><code><div>
<!-- some html -->
<script type="text/javascript">
/** some javascript */
</script>
</div>
</code></pre>
<p>I'm inserting the whole thing into the DOM, but the Ja... | [
{
"answer_id": 76003,
"author": "Scott Nichols",
"author_id": 4299,
"author_profile": "https://Stackoverflow.com/users/4299",
"pm_score": 4,
"selected": false,
"text": "<p>You don't have to use regex if you are using the response to fill a div or something. You can use getElementsByTagNa... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4243/"
] | I'm working on a web page where I'm making an AJAX call that returns a chunk of HTML like:
```
<div>
<!-- some html -->
<script type="text/javascript">
/** some javascript */
</script>
</div>
```
I'm inserting the whole thing into the DOM, but the JavaScript isn't being run. Is there a way to run it?
So... | Script added by setting the innerHTML property of an element doesn't get executed. Try creating a new div, setting its innerHTML, then adding this new div to the DOM. For example:
```
<html>
<head>
<script type='text/javascript'>
function addScript()
{
var str = "<script>alert('i am here');<\/script>";
var ne... |
75,978 | <p>In a .NET Win console application, I would like to access an App.config file in a location different from the console application binary. For example, how can C:\bin\Text.exe get its settings from C:\Test.exe.config?</p>
| [
{
"answer_id": 76067,
"author": "Santiago Palladino",
"author_id": 12791,
"author_profile": "https://Stackoverflow.com/users/12791",
"pm_score": 3,
"selected": false,
"text": "<p>Use the following (remember to include System.Configuration assembly)</p>\n\n<pre><code>ConfigurationManager.... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2748/"
] | In a .NET Win console application, I would like to access an App.config file in a location different from the console application binary. For example, how can C:\bin\Text.exe get its settings from C:\Test.exe.config? | ```
using System.Configuration;
Configuration config =
ConfigurationManager.OpenExeConfiguration("C:\Test.exe");
```
You can then access the app settings, connection strings, etc from the config instance. This assumes of course that the config file is properly formatted and your app has read access to the direct... |
75,980 | <p>When encoding a query string to be sent to a web server - when do you use <code>escape()</code> and when do you use <code>encodeURI()</code> or <code>encodeURIComponent()</code>:</p>
<p>Use escape:</p>
<pre><code>escape("% +&=");
</code></pre>
<p>OR</p>
<p>use encodeURI() / encodeURIComponent()</p>
<pre><co... | [
{
"answer_id": 75989,
"author": "Daniel Papasian",
"author_id": 7548,
"author_profile": "https://Stackoverflow.com/users/7548",
"pm_score": 5,
"selected": false,
"text": "<p>encodeURI() - the escape() function is for javascript escaping, not HTTP.</p>\n"
},
{
"answer_id": 76119,
... | 2008/09/16 | [
"https://Stackoverflow.com/questions/75980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1341/"
] | When encoding a query string to be sent to a web server - when do you use `escape()` and when do you use `encodeURI()` or `encodeURIComponent()`:
Use escape:
```
escape("% +&=");
```
OR
use encodeURI() / encodeURIComponent()
```
encodeURI("http://www.google.com?var1=value1&var2=value2");
encodeURIComponent("var1... | escape()
========
Don't use it!
`escape()` is defined in section [B.2.1.2 escape](https://www.ecma-international.org/ecma-262/9.0/index.html#sec-escape-string) and the [introduction text of Annex B](https://www.ecma-international.org/ecma-262/9.0/index.html#sec-additional-ecmascript-features-for-web-browsers) says:
>... |
76,065 | <p>I know that with mysql you can write SQL statements into a .sql file and run the file from the mysql command line like this:</p>
<pre><code>mysql> source script.sql
</code></pre>
<p>How do I pass a variable to the script? For example, if I want to run a script that retrieves all the employees in a department, I... | [
{
"answer_id": 76124,
"author": "Brad Choate",
"author_id": 553,
"author_profile": "https://Stackoverflow.com/users/553",
"pm_score": 6,
"selected": true,
"text": "<p>Like this:</p>\n\n<pre><code>set @department := 'Engineering';\n</code></pre>\n\n<p>Then, reference <code>@department</co... | 2008/09/16 | [
"https://Stackoverflow.com/questions/76065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13519/"
] | I know that with mysql you can write SQL statements into a .sql file and run the file from the mysql command line like this:
```
mysql> source script.sql
```
How do I pass a variable to the script? For example, if I want to run a script that retrieves all the employees in a department, I want to be able to pass in t... | Like this:
```
set @department := 'Engineering';
```
Then, reference `@department` wherever you need to in script.sql:
```
update employee set salary = salary + 10000 where department = @department;
``` |
76,074 | <p>I have a couple old services that I want to completely uninstall. How can I do this?</p>
| [
{
"answer_id": 76101,
"author": "Mark Schill",
"author_id": 9482,
"author_profile": "https://Stackoverflow.com/users/9482",
"pm_score": 6,
"selected": false,
"text": "<p>Click <em>Start</em> | <strong>Run</strong> and type <code>regedit</code> in the Open: line. Click OK.</p>\n\n<p>Navig... | 2008/09/16 | [
"https://Stackoverflow.com/questions/76074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1204/"
] | I have a couple old services that I want to completely uninstall. How can I do this? | Use the *SC* command, like this (you need to be on a command prompt to execute the commands in this post):
```
SC STOP shortservicename
SC DELETE shortservicename
```
---
**Note:** You need to run the command prompt as an administrator, not just logged in as the administrator, but also with administrative rights. I... |
76,076 | <p>I am trying to solve numerically a set of partial differential equations in three dimensions. In each of the equations the next value of the unknown in a point depends on the current value of each unknown in the closest points.</p>
<p>To write an efficient code I need to keep the points close in the three dimension... | [
{
"answer_id": 76185,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 4,
"selected": true,
"text": "<p>Octtrees are the way to go. You subdivide the array into 8 octants:</p>\n\n<pre>\n1 2\n3 4\n\n---\n\n5 6\n7 8\n</p... | 2008/09/16 | [
"https://Stackoverflow.com/questions/76076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13405/"
] | I am trying to solve numerically a set of partial differential equations in three dimensions. In each of the equations the next value of the unknown in a point depends on the current value of each unknown in the closest points.
To write an efficient code I need to keep the points close in the three dimensions close in... | Octtrees are the way to go. You subdivide the array into 8 octants:
```
1 2
3 4
---
5 6
7 8
```
And then lay them out in memory in the order 1, 2, 3, 4, 5, 6, 7, 8 as above. You repeat this recursively within each octant until you get down to some base size, probably around 128 bytes or so (this is just a guess -... |
76,079 | <p>can anyone please suggest a <strong>good code example</strong> of vb.net/c# code to put the application in system tray when minized.</p>
| [
{
"answer_id": 76120,
"author": "Phillip Wells",
"author_id": 3012,
"author_profile": "https://Stackoverflow.com/users/3012",
"pm_score": 5,
"selected": true,
"text": "<p>Add a NotifyIcon control to your form, then use the following code:</p>\n\n<pre><code> private void frm_main_Resiz... | 2008/09/16 | [
"https://Stackoverflow.com/questions/76079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13337/"
] | can anyone please suggest a **good code example** of vb.net/c# code to put the application in system tray when minized. | Add a NotifyIcon control to your form, then use the following code:
```
private void frm_main_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.ShowInTaskbar = false;
this.Hide();
notifyIcon1.Visible = true;
}... |
76,080 | <p>We need to reliably get the Quick Launch folder for both All and Current users under both Vista and XP. I'm developing in C++, but this is probably more of a general Windows API question.</p>
<p>For reference, here is code to get the Application Data folder under both systems:</p>
<pre><code> HRESULT hres;
... | [
{
"answer_id": 76246,
"author": "StocksR",
"author_id": 6892,
"author_profile": "https://Stackoverflow.com/users/6892",
"pm_score": 3,
"selected": true,
"text": "<p>AppData on vista refers to C:\\Users\\xxxx\\AppData\\Roaming not the C:\\Users\\xxxx\\AppData folder it's self.</p>\n\n<p>A... | 2008/09/16 | [
"https://Stackoverflow.com/questions/76080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10973/"
] | We need to reliably get the Quick Launch folder for both All and Current users under both Vista and XP. I'm developing in C++, but this is probably more of a general Windows API question.
For reference, here is code to get the Application Data folder under both systems:
```
HRESULT hres;
CString basePath;
... | AppData on vista refers to C:\Users\xxxx\AppData\Roaming not the C:\Users\xxxx\AppData folder it's self.
Also this artical <http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept05/hey0901.mspx> on a microsoft site implies that you simply have to use the path relative to the appdata folder |
76,134 | <p>I have 4 2D points in screen-space, and I need to reverse-project them back into 3D space. I know that each of the 4 points is a corner of a 3D-rotated rigid rectangle, and I know the size of the rectangle. How can I get 3D coordinates from this?</p>
<p>I am not using any particular API, and I do not have an existi... | [
{
"answer_id": 76282,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 2,
"selected": false,
"text": "<p>Assuming that the points are indeed part of a rectangle, I'm giving a generic idea :</p>\n\n<p>Find two points with max inter... | 2008/09/16 | [
"https://Stackoverflow.com/questions/76134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8409/"
] | I have 4 2D points in screen-space, and I need to reverse-project them back into 3D space. I know that each of the 4 points is a corner of a 3D-rotated rigid rectangle, and I know the size of the rectangle. How can I get 3D coordinates from this?
I am not using any particular API, and I do not have an existing project... | Alright, I came here looking for an answer and didn't find something simple and straightforward, so I went ahead and did the dumb but effective (and relatively simple) thing: Monte Carlo optimisation.
Very simply put, the algorithm is as follows: Randomly perturb your projection matrix until it projects your known 3D ... |
76,204 | <p>I am receiving a 3rd party feed of which I cannot be certain of the namespace so I am currently having to use the local-name() function in my XSLT to get the element values. However I need to get an attribute from one such element and I don't know how to do this when the namespaces are unknown (hence need for local-... | [
{
"answer_id": 76497,
"author": "Santiago Palladino",
"author_id": 12791,
"author_profile": "https://Stackoverflow.com/users/12791",
"pm_score": 5,
"selected": true,
"text": "<p>I don't have an XSLT editor here, but have you tried using</p>\n\n<pre><code>*[local-name()='category']/@*[loc... | 2008/09/16 | [
"https://Stackoverflow.com/questions/76204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/258/"
] | I am receiving a 3rd party feed of which I cannot be certain of the namespace so I am currently having to use the local-name() function in my XSLT to get the element values. However I need to get an attribute from one such element and I don't know how to do this when the namespaces are unknown (hence need for local-nam... | I don't have an XSLT editor here, but have you tried using
```
*[local-name()='category']/@*[local-name()='term']
``` |
76,223 | <p>I am working on a project where the requirement is to have a date calculated as being the last Friday of a given month. I think I have a solution that only uses standard Java, but I was wondering if anyone knew of anything more concise or efficient. Below is what I tested with for this year:</p>
<pre><code> for... | [
{
"answer_id": 76265,
"author": "scubabbl",
"author_id": 9450,
"author_profile": "https://Stackoverflow.com/users/9450",
"pm_score": 0,
"selected": false,
"text": "<p>That looks like a perfectly acceptable solution. If that works, use it. That is minimal code and there's no reason to opt... | 2008/09/16 | [
"https://Stackoverflow.com/questions/76223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7008/"
] | I am working on a project where the requirement is to have a date calculated as being the last Friday of a given month. I think I have a solution that only uses standard Java, but I was wondering if anyone knew of anything more concise or efficient. Below is what I tested with for this year:
```
for (int month = 0... | Based on [marked23's](https://stackoverflow.com/questions/76223/get-last-friday-of-month-in-java#76437) suggestion:
```
public Date getLastFriday( int month, int year ) {
Calendar cal = Calendar.getInstance();
cal.set( year, month + 1, 1 );
cal.add( Calendar.DAY_OF_MONTH, -( cal.get( Calendar.DAY_OF_WEEK ) % ... |