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 |
|---|---|---|---|---|---|---|
148,951 | <p>I'm trying to use <code>mysqldump</code> to dump a schema, and it mostly works but I ran into one curiosity: the <code>-p</code> or <code>--password</code> option seems like it is doing something other than setting the password (as the <code>man</code> page and <code>--help</code> output say it should).</p>
<p>Spec... | [
{
"answer_id": 148969,
"author": "itsmatt",
"author_id": 7862,
"author_profile": "https://Stackoverflow.com/users/7862",
"pm_score": 2,
"selected": false,
"text": "<p>Did you try --password=whatever-password-is ?</p>\n\n<p>Perhaps I'm missing the question, but that is what I do to run th... | 2008/09/29 | [
"https://Stackoverflow.com/questions/148951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4323/"
] | I'm trying to use `mysqldump` to dump a schema, and it mostly works but I ran into one curiosity: the `-p` or `--password` option seems like it is doing something other than setting the password (as the `man` page and `--help` output say it should).
Specifically, it looks like it's doing what is indicated here: <http:... | From man mysqldump:
>
> --password[=password], -p[password]
>
>
> The password to use when connecting to the server. If you use
> the short option form (-p), you cannot have a space between the option
> and the password. If you omit the password value following the
> --password or -p option on the command line, ... |
148,955 | <p>I want the 2 columns to touch ie. remove the margins, how can I do this?</p>
<p>My code:</p>
<pre><code> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>testing</TITLE>
<!-- css -->
<link rel="stylesheet" type="text/css" href="http... | [
{
"answer_id": 148973,
"author": "Matthias Winkelmann",
"author_id": 4494,
"author_profile": "https://Stackoverflow.com/users/4494",
"pm_score": 1,
"selected": false,
"text": "<p>Add a class to the right column and set margin-left to 0. </p>\n\n<p>If that doesn't work you might have to i... | 2008/09/29 | [
"https://Stackoverflow.com/questions/148955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want the 2 columns to touch ie. remove the margins, how can I do this?
My code:
```
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>testing</TITLE>
<!-- css -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/reset-fonts-grids/reset-fon... | Add a class to the right column and set margin-left to 0.
If that doesn't work you might have to increase the width by 1 or 2%. You can use firebug to check the applied styles and change them on the fly. |
148,982 | <p>I have a function that passes an array to another function as an argument, there will be multiple data types in this array but I want to know how to pass a function or a reference to a function so the other function can call it at any time.</p>
<p>ex.</p>
<p>function A:</p>
<pre><code>add(new Array("hello", some ... | [
{
"answer_id": 148990,
"author": "davr",
"author_id": 14569,
"author_profile": "https://Stackoverflow.com/users/14569",
"pm_score": 3,
"selected": false,
"text": "<p>This is very easy in ActionScript:</p>\n\n<pre><code>function someFunction(foo, bar) {\n ...\n}\n\nfunction a() {\n b... | 2008/09/29 | [
"https://Stackoverflow.com/questions/148982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a function that passes an array to another function as an argument, there will be multiple data types in this array but I want to know how to pass a function or a reference to a function so the other function can call it at any time.
ex.
function A:
```
add(new Array("hello", some function));
```
function B... | Simply pass the function name as an argument, no, just like in AS2 or JavaScript?
```
function functionToPass()
{
}
function otherFunction( f:Function )
{
// passed-in function available here
f();
}
otherFunction( functionToPass );
``` |
148,988 | <p>I need to create an XML schema that validates a tree structure of an XML document. I don't know exactly the occurrences or depth level of the tree.</p>
<p>XML example:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<node>
<attribute/>
<node>
<attribute/>
<node/&g... | [
{
"answer_id": 149003,
"author": "Michael Brown",
"author_id": 14359,
"author_profile": "https://Stackoverflow.com/users/14359",
"pm_score": 5,
"selected": false,
"text": "<p>XSD does indeed allow for recursion of elements. Here <a href=\"https://web.archive.org/web/20140421153734/http:/... | 2008/09/29 | [
"https://Stackoverflow.com/questions/148988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19012/"
] | I need to create an XML schema that validates a tree structure of an XML document. I don't know exactly the occurrences or depth level of the tree.
XML example:
```
<?xml version="1.0" encoding="utf-8"?>
<node>
<attribute/>
<node>
<attribute/>
<node/>
</node>
</node>
```
Which is the best way t... | if you need a recursive type declaration, here is an example that might help:
```
<xs:schema id="XMLSchema1"
targetNamespace="http://tempuri.org/XMLSchema1.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema1.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema1.xsd"
xmlns:xs="http://... |
149,008 | <p>I have an object that I'm testing that raises an event. What is the best way of using Rhino Mocks to check that it was raised? </p>
<p>Best I could come up with (I am certain it gets better than this):</p>
<pre><code>public void MyCallback(object sender, EventArgs e) { _flag = true;}
[Test]
public void DoSometh... | [
{
"answer_id": 149077,
"author": "casademora",
"author_id": 5619,
"author_profile": "https://Stackoverflow.com/users/5619",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure how your test actually calls the DoSomething() Method. Maybe you're missing something to fire the event. ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149008",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | I have an object that I'm testing that raises an event. What is the best way of using Rhino Mocks to check that it was raised?
Best I could come up with (I am certain it gets better than this):
```
public void MyCallback(object sender, EventArgs e) { _flag = true;}
[Test]
public void DoSomethingRaisesEvent() {
_f... | I found [this article by Phil Haack on how to test events using anonymous delegates](http://haacked.com/archive/2006/12/13/tip_jar_unit_test_events_with_anonymous_delegates.aspx)
Here is the code, ripped directly from his blog for those too lazy to click through:
```
[Test]
public void SettingValueRaisesEvent()
{
... |
149,037 | <p><P>How can I instantiate a JMS queue listener in java (JRE /JDK / J2EE 1.4) that only receives messages that match a given JMSCorrelationID? The messages that I'm looking to pick up have been published to a queue and not a topic, although that can change if needed.</P>
Here's the code that I'm currently using to pu... | [
{
"answer_id": 149167,
"author": "Robin",
"author_id": 21925,
"author_profile": "https://Stackoverflow.com/users/21925",
"pm_score": 5,
"selected": true,
"text": "<p>The queue connection setup is the same, but once you have the QueueSession, you set the selector when creating a receiver.... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/231627/"
] | How can I instantiate a JMS queue listener in java (JRE /JDK / J2EE 1.4) that only receives messages that match a given JMSCorrelationID? The messages that I'm looking to pick up have been published to a queue and not a topic, although that can change if needed.
Here's the code that I'm currently using to put the mess... | The queue connection setup is the same, but once you have the QueueSession, you set the selector when creating a receiver.
```
QueueReceiver receiver = session.createReceiver(myQueue, "JMSCorrelationID='theid'");
```
then
```
receiver.receive()
```
or
```
receiver.setListener(myListener);
``` |
149,040 | <p>Assume the following:</p>
<p><em>models.py</em></p>
<pre><code>class Entry(models.Model):
title = models.CharField(max_length=50)
slug = models.CharField(max_length=50, unique=True)
body = models.CharField(max_length=200)
</code></pre>
<p><em>admin.py</em></p>
<pre><code>class EntryAdmin(admin.ModelA... | [
{
"answer_id": 149067,
"author": "Douglas Mayle",
"author_id": 8458,
"author_profile": "https://Stackoverflow.com/users/8458",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure what you're asking for IS possible. Your best bet is probably to hide the slug from the admin interfa... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149040",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22306/"
] | Assume the following:
*models.py*
```
class Entry(models.Model):
title = models.CharField(max_length=50)
slug = models.CharField(max_length=50, unique=True)
body = models.CharField(max_length=200)
```
*admin.py*
```
class EntryAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug':('title',)}
```
... | For this particular case you can override your save method to slugify (it's built-in method, look at django source) the title and store it in slug field. Also from there you can easily check if this slug is indeed unique and change it somehow if it's not.
Consider this example:
```
def save(self):
from django.tem... |
149,055 | <p>I would like to format a price in JavaScript. I'd like a function which takes a <code>float</code> as an argument and returns a <code>string</code> formatted like this:</p>
<pre><code>"$ 2,500.00"
</code></pre>
<p>How can I do this?</p>
| [
{
"answer_id": 149080,
"author": "roenving",
"author_id": 23142,
"author_profile": "https://Stackoverflow.com/users/23142",
"pm_score": 5,
"selected": false,
"text": "<p>The main part is inserting the thousand-separators, and that could be done like this:</p>\n<pre><code><script type=... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | I would like to format a price in JavaScript. I'd like a function which takes a `float` as an argument and returns a `string` formatted like this:
```
"$ 2,500.00"
```
How can I do this? | Ok, based on what you said, I'm using this:
```
var DecimalSeparator = Number("1.2").toLocaleString().substr(1,1);
var AmountWithCommas = Amount.toLocaleString();
var arParts = String(AmountWithCommas).split(DecimalSeparator);
var intPart = arParts[0];
var decPart = (arParts.length > 1 ? arParts[1] : '');
decPart = (... |
149,057 | <p>How can you remove all of the trailing whitespace of an entire project? Starting at a root directory, and removing the trailing whitespace from all files in all folders.</p>
<p>Also, I want to to be able to modify the file directly, and not just print everything to stdout.</p>
| [
{
"answer_id": 149070,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 5,
"selected": false,
"text": "<p>In Bash:</p>\n\n<p><code>find dir -type f -exec sed -i 's/ *$//' '{}' ';'</code></p>\n\n<p>Note: If you're using ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19718/"
] | How can you remove all of the trailing whitespace of an entire project? Starting at a root directory, and removing the trailing whitespace from all files in all folders.
Also, I want to to be able to modify the file directly, and not just print everything to stdout. | Here is an OS X >= 10.6 Snow Leopard solution.
**It Ignores .git and .svn folders** and their contents. Also it won't leave a backup file.
```
(export LANG=C LC_CTYPE=C
find . -not \( -name .svn -prune -o -name .git -prune \) -type f -print0 | perl -0ne 'print if -T' | xargs -0 sed -Ei 's/[[:blank:]]+$//'
)
```
The... |
149,073 | <p>I want to see the stack trace in any function of my code, so i made somthing like this to call it and print the stack trace:</p>
<pre><code>public function PrintStackTrace() {
try {
throw new Error('StackTrace');
} catch (e:Error) {
trace(e.getStackTrace());
}
}
</code></pre>
<p>I like ... | [
{
"answer_id": 149188,
"author": "hasseg",
"author_id": 4111,
"author_profile": "https://Stackoverflow.com/users/4111",
"pm_score": 7,
"selected": true,
"text": "<p>As far as I know, the only way to make the stack trace available to your own code is via the <a href=\"http://livedocs.adob... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20601/"
] | I want to see the stack trace in any function of my code, so i made somthing like this to call it and print the stack trace:
```
public function PrintStackTrace() {
try {
throw new Error('StackTrace');
} catch (e:Error) {
trace(e.getStackTrace());
}
}
```
I like to know if there are other... | As far as I know, the only way to make the stack trace available to your own code is via the [getStackTrace()](http://livedocs.adobe.com/flex/3/langref/Error.html#getStackTrace()) method in the Error class, just like you're already doing. In response to the example in your question, though, I would mention that you don... |
149,078 | <p>Suppose I have a database table with two fields, "foo" and "bar". Neither of them are unique, but each of them are indexed. However, rather than being indexed together, they each have a separate index.</p>
<p>Now suppose I perform a query such as <code>SELECT * FROM sometable WHERE foo='hello' AND bar='world';</c... | [
{
"answer_id": 149104,
"author": "Georgi",
"author_id": 13209,
"author_profile": "https://Stackoverflow.com/users/13209",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, you can give \"hints\" with the query to Oracle. These hints are disguised as comments (\"/* HINT */\") to the data... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1694/"
] | Suppose I have a database table with two fields, "foo" and "bar". Neither of them are unique, but each of them are indexed. However, rather than being indexed together, they each have a separate index.
Now suppose I perform a query such as `SELECT * FROM sometable WHERE foo='hello' AND bar='world';` My table a huge nu... | Oracle will almost certainly use the most selective index to drive the query, and you can check that with the explain plan.
Furthermore, Oracle can combine the use of both indexes in a couple of ways -- it can convert btree indexes to bitmaps and perform a bitmap ANd operation on them, or it can perform a hash join on... |
149,092 | <p>I have backups of files archived in optical media (CDs and DVDs). These all have par2 recovery files, stored on separate media. Even in cases where there are no par2 files, minor errors when reading on one optical drive can be read fine on another drive.</p>
<p>The thing is, when reading faulty media, the read time... | [
{
"answer_id": 149840,
"author": "Daniel Papasian",
"author_id": 7548,
"author_profile": "https://Stackoverflow.com/users/7548",
"pm_score": -1,
"selected": false,
"text": "<p>dd(1) is your friend.</p>\n\n<p>dd if=/dev/cdrom of=image bs=2352 conv=noerror,notrunc</p>\n\n<p>The drive may s... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6899/"
] | I have backups of files archived in optical media (CDs and DVDs). These all have par2 recovery files, stored on separate media. Even in cases where there are no par2 files, minor errors when reading on one optical drive can be read fine on another drive.
The thing is, when reading faulty media, the read time is very, ... | `man readom`, a program that comes with cdrecord:
```
-noerror
Do not abort if the high level error checking in readom found an
uncorrectable error in the data stream.
-nocorr
Switch the drive into a mode where it ignores read errors in
data sectors that are a result ... |
149,102 | <p>How can I capture the event in Excel when a user clicks on a cell. I want to be able to use this event to trigger some code to count how many times the user clicks on several different cells in a column.</p>
| [
{
"answer_id": 149109,
"author": "Ben Hoffstein",
"author_id": 4482,
"author_profile": "https://Stackoverflow.com/users/4482",
"pm_score": 1,
"selected": false,
"text": "<p>Use the <a href=\"http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet.selectionchange(VS... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22376/"
] | How can I capture the event in Excel when a user clicks on a cell. I want to be able to use this event to trigger some code to count how many times the user clicks on several different cells in a column. | Check out the Worksheet\_SelectionChange event. In that event you could use Intersect() with named ranges to figure out if a specific range were clicked.
Here's some code that might help you get started.
```
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("SomeNam... |
149,132 | <p>I'm not sure if this is something I should do in T-SQL or not, and I'm pretty sure using the word 'iterate' was wrong in this context, since you should never iterate anything in sql. It should be a set based operation, correct? Anyway, here's the scenario:</p>
<p>I have a stored proc that returns many uniqueidentif... | [
{
"answer_id": 149152,
"author": "Ben Hoffstein",
"author_id": 4482,
"author_profile": "https://Stackoverflow.com/users/4482",
"pm_score": 5,
"selected": true,
"text": "<p>This may not be the most efficient, but I would create a temp table to hold the results of the stored proc and then ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5469/"
] | I'm not sure if this is something I should do in T-SQL or not, and I'm pretty sure using the word 'iterate' was wrong in this context, since you should never iterate anything in sql. It should be a set based operation, correct? Anyway, here's the scenario:
I have a stored proc that returns many uniqueidentifiers (sing... | This may not be the most efficient, but I would create a temp table to hold the results of the stored proc and then use that in a join against the target table. For example:
```
CREATE TABLE #t (uniqueid int)
INSERT INTO #t EXEC p_YourStoredProc
UPDATE TargetTable
SET a.FlagColumn = 1
FROM TargetTable a JOIN #t b
... |
149,153 | <p>I'm trying to create a ImageIcon from a animated gif stored in a jar file.</p>
<pre><code>ImageIcon imageIcon = new ImageIcon(ImageIO.read(MyClass.class.getClassLoader().getResourceAsStream("animated.gif")));
</code></pre>
<p>The image loads, but only the first frame of the animated gif. The animation does not pl... | [
{
"answer_id": 149182,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 3,
"selected": false,
"text": "<p>You have to use getClass().getResource(imgName); to get a URL to the image file. Check out <a href=\"http://www.... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/739/"
] | I'm trying to create a ImageIcon from a animated gif stored in a jar file.
```
ImageIcon imageIcon = new ImageIcon(ImageIO.read(MyClass.class.getClassLoader().getResourceAsStream("animated.gif")));
```
The image loads, but only the first frame of the animated gif. The animation does not play.
If I load the animate... | This reads gif animation from inputStream
```
InputStream in = ...;
Image image = Toolkit.getDefaultToolkit().createImage(org.apache.commons.io.IOUtils.toByteArray(in));
``` |
149,191 | <p>I am seeing some rather weird behavior with PowerShell, it looks like custom functions might need a "parenthesis wrapper" to evaluate as you might expect them. Given a simple PowerShell function:</p>
<pre><code>function Return-True { return $true }
</code></pre>
<p>and then some sample code to invoke it:</p>
<pre... | [
{
"answer_id": 149373,
"author": "hurcane",
"author_id": 21363,
"author_profile": "https://Stackoverflow.com/users/21363",
"pm_score": 3,
"selected": false,
"text": "<p>The second line is not doing a boolean evaluation. Look at what happens if you do the same thing with strings.</p>\n\n<... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/243/"
] | I am seeing some rather weird behavior with PowerShell, it looks like custom functions might need a "parenthesis wrapper" to evaluate as you might expect them. Given a simple PowerShell function:
```
function Return-True { return $true }
```
and then some sample code to invoke it:
```
PS C:\> Return-True
True
PS C:... | When PowerShell sees the token `Return-True` it identifies it as a command and until evaluation or end of the statement, everything else is an argument which is passed to the function `Return-True`.
You can see this in action if you do:
```
PS > function Return-True { "The arguments are: $args"; return $true }
PS > R... |
149,198 | <p>I use Tortoise SVN usuallly, but I have been looking into Mercurial since it is a distributed revision control system. </p>
<p>What I am looking for, in both systems, is a tool that let me pick only parts of a file and commit them. If I want to do this now, I have to copy to a temp version of the file and keep only... | [
{
"answer_id": 149270,
"author": "Nicholas Riley",
"author_id": 6372,
"author_profile": "https://Stackoverflow.com/users/6372",
"pm_score": 6,
"selected": true,
"text": "<p>Mercurial can do this with the <a href=\"https://www.mercurial-scm.org/wiki/RecordExtension\" rel=\"nofollow norefe... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6752/"
] | I use Tortoise SVN usuallly, but I have been looking into Mercurial since it is a distributed revision control system.
What I am looking for, in both systems, is a tool that let me pick only parts of a file and commit them. If I want to do this now, I have to copy to a temp version of the file and keep only the chang... | Mercurial can do this with the [record](https://www.mercurial-scm.org/wiki/RecordExtension) extension.
It'll prompt you for each file and each diff hunk. For example:
```
% hg record
diff --git a/prelim.tex b/prelim.tex
2 hunks, 4 lines changed
examine changes to 'prelim.tex'? [Ynsfdaq?]
@@ -12,7 +12,7 @@
\setmono... |
149,206 | <p>I have a XML response from an HTTPService call with the e4x result format.</p>
<pre>
<code>
<?xml version="1.0" encoding="utf-8"?>
<Validation Error="Invalid Username/Password Combination" />
</code>
</pre>
<p>I have tried:</p>
<pre>
<code>
private function callback(event:ResultEvent):void {
if(event.re... | [
{
"answer_id": 149291,
"author": "mmattax",
"author_id": 1638,
"author_profile": "https://Stackoverflow.com/users/1638",
"pm_score": 1,
"selected": false,
"text": "<p>I have figured out a solution, I'm still interested if there is a better way to do this...</p>\n\n<p>This will work:</p>\... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | I have a XML response from an HTTPService call with the e4x result format.
```
<?xml version="1.0" encoding="utf-8"?>
<Validation Error="Invalid Username/Password Combination" />
```
I have tried:
```
private function callback(event:ResultEvent):void {
if(event.result..@Error) {
// error attr present
... | You have found the best way to do it:
```
event.result.attribute("Error").length() > 0
```
The `attribute` method is the preferred way to retrieve attributes if you don't know if they are there or not. |
149,268 | <p>Since I have started using this site, I keep hearing about the Boost library. I am wondering what are some of the major benefits of the Boost library (hence why should I use it) and how portable is the Boost library?</p>
| [
{
"answer_id": 149277,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 4,
"selected": false,
"text": "<p>Boost is a collection of C++ libraries. 10 of which are being included in tr1 of C++0x.</p>\n\n<p>You can <a href... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20229/"
] | Since I have started using this site, I keep hearing about the Boost library. I am wondering what are some of the major benefits of the Boost library (hence why should I use it) and how portable is the Boost library? | Boost is organized by several members of the standard committee.
So it is a breeding ground for libraries that will be in the next standard.
1. It is an extension to the STL (it fills in the bits left out)
2. It is well documented.
3. It is well peer-reviewed.
4. It has high activity so bugs are found and fixed qui... |
149,311 | <p>When adding an EditItemTemplate of some complexity (mulitple fields in one template), and then parsing the controls from the RowUpdating event, the controls that were manually entered by the user have no values. My guess is there is something going on with when the data is bound, but I've had instances where simply ... | [
{
"answer_id": 149392,
"author": "Elijah Manor",
"author_id": 4481,
"author_profile": "https://Stackoverflow.com/users/4481",
"pm_score": 0,
"selected": false,
"text": "<p>You should be able to use the GridViewUpdateEventArgs to retrieve the inputted value, for example: </p>\n\n<pre><cod... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017/"
] | When adding an EditItemTemplate of some complexity (mulitple fields in one template), and then parsing the controls from the RowUpdating event, the controls that were manually entered by the user have no values. My guess is there is something going on with when the data is bound, but I've had instances where simply add... | Did you turn off ViewState?
Did you add control programmatically in the template? If so, did you create them at the correct stage? |
149,324 | <p>Is there a way set flags on a per-file basis with automake?<br>
In particular, if I have a c++ project and want to compile with -WAll all the files except one for which I want to disable a particular warning, what could I do?</p>
<p>I tried something like:</p>
<pre><code>CXXFLAGS = -WAll ...
bin_PROGRAMS = test
te... | [
{
"answer_id": 149642,
"author": "Douglas Leeder",
"author_id": 3978,
"author_profile": "https://Stackoverflow.com/users/3978",
"pm_score": 2,
"selected": false,
"text": "<p>You've got confused - that section is referring to options to automake itself.</p>\n\n<p>It's a way of setting the... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15622/"
] | Is there a way set flags on a per-file basis with automake?
In particular, if I have a c++ project and want to compile with -WAll all the files except one for which I want to disable a particular warning, what could I do?
I tried something like:
```
CXXFLAGS = -WAll ...
bin_PROGRAMS = test
test_SOURCES = main.cpp ... | Automake only supports per-target flags, while you want per-object flags. One way around is to create a small library that contains your object:
```
CXXFLAGS = -Wall ...
bin_PROGRAMS = test
test_SOURCES = main.cpp
test_LDADD = libutility.a
noinst_LIBRARIES = libutility.a
libutility_a_SOURCES = utility.cpp
libutility_... |
149,337 | <p>Is it possible to create a .NET equivalent to the following code?</p>
<pre><code><?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button';
exit;
} else {
echo "<p&g... | [
{
"answer_id": 149353,
"author": "mattlant",
"author_id": 14642,
"author_profile": "https://Stackoverflow.com/users/14642",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, you can add to web.config and use forms authentication. I dont know php, so i cant help witjh the rest of your qu... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/795/"
] | Is it possible to create a .NET equivalent to the following code?
```
<?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button';
exit;
} else {
echo "<p>Hello {$_SERVER['PHP_... | The easiest way to achieve the same as with the PHP code would be to directly send the same headers via [Reponse.AppendHeader()](http://msdn.microsoft.com/en-us/library/system.web.httpresponse.appendheader(VS.80).aspx).
Still I would suggest you to read an [ASP.NET Forms Authentication Tutorial](http://www.asp.net/Lea... |
149,379 | <p>I want to create Code39 encoded barcodes from my application. </p>
<p>I know I can use a font for this, but I'd prefer not to as I'd have to register the font on the server and I've had some pretty bad experiences with that.</p>
<p><em>An example of what I've produced after asking this question is in the answers</... | [
{
"answer_id": 149412,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 3,
"selected": false,
"text": "<p>If you choose Code39, you could probably code up from this code I wrote</p>\n\n<p><a href=\"http://www.atalasoft.com/c... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5018/"
] | I want to create Code39 encoded barcodes from my application.
I know I can use a font for this, but I'd prefer not to as I'd have to register the font on the server and I've had some pretty bad experiences with that.
*An example of what I've produced after asking this question is in the answers* | This is my current codebehind, with lots of comments:
```
Option Explicit On
Option Strict On
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Drawing.Bitmap
Imports System.Drawing.Graphics
Imports System.IO
Partial Public Class Barcode
Inherits System.Web.UI.Page
'Sebastiaan Janssen - 20... |
149,380 | <p>This is an issue that I've spent hours researching in the past. It seems to me to be something that should have been addressed by modern <a href="http://en.wikipedia.org/wiki/Relational_database_management_system" rel="noreferrer">RDBMS</a> solutions but as yet I have not found anything that really addresses what I... | [
{
"answer_id": 149391,
"author": "Kevin Fairchild",
"author_id": 3743,
"author_profile": "https://Stackoverflow.com/users/3743",
"pm_score": 1,
"selected": false,
"text": "<p>How about handling sorting on the stuff displaying the results -- grids, reports, etc. rather than on SQL?</p>\n\... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7290/"
] | This is an issue that I've spent hours researching in the past. It seems to me to be something that should have been addressed by modern [RDBMS](http://en.wikipedia.org/wiki/Relational_database_management_system) solutions but as yet I have not found anything that really addresses what I see to be an incredibly common ... | Yeah, it's a pain, and the way you're doing it looks similar to what I do:
```
order by
case when @SortExpr = 'CustomerName' and @SortDir = 'ASC'
then CustomerName end asc,
case when @SortExpr = 'CustomerName' and @SortDir = 'DESC'
then CustomerName end desc,
...
```
This, to me, is still much better than... |
149,388 | <p>Was wondering if anyone knows, or has pointers to good documentation that discusses, the low-level implementation details of Cocoa's 'performSelectorOnMainThread:' method.</p>
<p>My best guess, and one I think is probably pretty close, is that it uses mach ports or an abstraction on top of them to provide intra-thr... | [
{
"answer_id": 149448,
"author": "Evan DiBiase",
"author_id": 2399475,
"author_profile": "https://Stackoverflow.com/users/2399475",
"pm_score": 2,
"selected": false,
"text": "<p>The <a href=\"http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Refer... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23498/"
] | Was wondering if anyone knows, or has pointers to good documentation that discusses, the low-level implementation details of Cocoa's 'performSelectorOnMainThread:' method.
My best guess, and one I think is probably pretty close, is that it uses mach ports or an abstraction on top of them to provide intra-thread commun... | Yes, it does use Mach ports. What happens is this:
1. A block of data encapsulating the perform info (the target object, the selector, the optional object argument to the selector, etc.) is enqueued in the thread's run loop info. This is done using `@synchronized`, which ultimately uses `pthread_mutex_lock`.
2. CFRunL... |
149,394 | <p>I have a winforms application, the issue has to do with threading.
Since I am calling 'MyCustomCode() which creates a new thread, and calls the method
'SomeMethod()' which then accesses MessageBox.Show(...).</p>
<p>The problem has to do with threading, since the newly created thread is trying to access
a control t... | [
{
"answer_id": 149404,
"author": "albertein",
"author_id": 23020,
"author_profile": "https://Stackoverflow.com/users/23020",
"pm_score": 3,
"selected": false,
"text": "<p>You cannot acces UI elements from multiple threads.</p>\n\n<p>One way to solve this is to call the Invoke method of a... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a winforms application, the issue has to do with threading.
Since I am calling 'MyCustomCode() which creates a new thread, and calls the method
'SomeMethod()' which then accesses MessageBox.Show(...).
The problem has to do with threading, since the newly created thread is trying to access
a control that was cr... | You cannot acces UI elements from multiple threads.
One way to solve this is to call the Invoke method of a control with a delegate to the function wich use the UI elements (like the message box). Somethin like:
```
public delegate void InvokeDelegate();
public void SomeMethod()
{
button1.Invoke((InvokeDelegate... |
149,395 | <p>We have a Windows machine running SQL Server 2005, and we need to be able to run some database queries on it from a Linux box. What are some of the recommended ways of doing this? Ideally, we would want a command-line utility similar to sqlcmd on Windows.</p>
| [
{
"answer_id": 149418,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 6,
"selected": true,
"text": "<p><a href=\"http://www.freetds.org\" rel=\"noreferrer\">FreeTDS</a> + <a href=\"http://www.unixodbc.org\" rel=\"nore... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4828/"
] | We have a Windows machine running SQL Server 2005, and we need to be able to run some database queries on it from a Linux box. What are some of the recommended ways of doing this? Ideally, we would want a command-line utility similar to sqlcmd on Windows. | [FreeTDS](http://www.freetds.org) + [unixODBC](http://www.unixodbc.org) or [iODBC](http://www.iodbc.org)
Install first FreeTDS, then configure one of the two ODBC engines to use FreeTDS as its ODBC driver. Then use the commandline interface of the ODBC engine.
unixODBC has isql, iODBC has iodbctest
You can also use ... |
149,416 | <p>I have a curious question about efficiency. Say I have a field on a database that is just a numeric digit that represents something else. Like, a value of 1 means the term is 30 days.</p>
<p>Would it be better (more efficient) to code a SELECT statement like this...</p>
<pre><code>SELECT
CASE TermId
... | [
{
"answer_id": 149469,
"author": "hurcane",
"author_id": 21363,
"author_profile": "https://Stackoverflow.com/users/21363",
"pm_score": 0,
"selected": false,
"text": "<p>For a number of reasons, I would process the translation in the grid view.</p>\n\n<p>Reason #1: SQL resource is shared.... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54420/"
] | I have a curious question about efficiency. Say I have a field on a database that is just a numeric digit that represents something else. Like, a value of 1 means the term is 30 days.
Would it be better (more efficient) to code a SELECT statement like this...
```
SELECT
CASE TermId
WHEN 1 THEN '30 days'
... | Efficiency probably wouldn't matter here - code maintainability does though.
Ask yourself - will these values change? What if they do? What would I need to do after 2 years of use if these values change?
If it becomes evident that scripting them in SQL would mean better maintainability (easier to change), then do it in... |
149,439 | <p>How can you avoid circular dependencies when you're designing two classes with a producer/consumer relationship? Here ListenerImpl needs a reference to Broadcaster in order to register/unregister itself, and Broadcaster needs a reference back to the Listeners in order to send messages. This example is in Java but it... | [
{
"answer_id": 149457,
"author": "Herms",
"author_id": 1409,
"author_profile": "https://Stackoverflow.com/users/1409",
"pm_score": 4,
"selected": true,
"text": "<p>I don't see that being a circular dependency.</p>\n\n<p>Listener depends on nothing.</p>\n\n<p>ListenerImpl depends on Liste... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16399/"
] | How can you avoid circular dependencies when you're designing two classes with a producer/consumer relationship? Here ListenerImpl needs a reference to Broadcaster in order to register/unregister itself, and Broadcaster needs a reference back to the Listeners in order to send messages. This example is in Java but it ca... | I don't see that being a circular dependency.
Listener depends on nothing.
ListenerImpl depends on Listener and Broadcaster
Broadcaster depends on Listener.
```
Listener
^ ^
/ \
/ \
Broadcaster <-- ListenerImpl
```
All arrows end at Listener. There's no cycle.... |
149,463 | <p>I have this code inside a class:</p>
<pre><code>void SendStones()
{
int currenthole = hole;
int lastplace = 0;
for(int i=0;i<stns.size();i++)
{
while(1)
{//Calculate new currenthole
if(currenthole == 13) { currenthole = 7; break;}
if(currenthole == 14) { cu... | [
{
"answer_id": 149482,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like hole is a simple int, and you're trying to subscript it. Is that what you mean to do? Where is ho... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have this code inside a class:
```
void SendStones()
{
int currenthole = hole;
int lastplace = 0;
for(int i=0;i<stns.size();i++)
{
while(1)
{//Calculate new currenthole
if(currenthole == 13) { currenthole = 7; break;}
if(currenthole == 14) { currenthole = 6; br... | It looks like hole is a simple int, and you're trying to subscript it. Is that what you mean to do? Where is hole declared? |
149,474 | <p>This XML file contained archived news stories for all of last year. I was asked to sort these stories by story categor[y|ies] into new XML files.</p>
<pre><code>big_story_export.xml
</code></pre>
<p>turns into</p>
<pre><code>lifestyles.xml
food.xml
nascar.xml
</code></pre>
<p>...and so on.</p>
<p>I got the job ... | [
{
"answer_id": 149495,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 2,
"selected": false,
"text": "<p>What language/parser were you using?<br>\nFor large files I try to use Unix command line tools.<br>\nThey are usually muc... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22491/"
] | This XML file contained archived news stories for all of last year. I was asked to sort these stories by story categor[y|ies] into new XML files.
```
big_story_export.xml
```
turns into
```
lifestyles.xml
food.xml
nascar.xml
```
...and so on.
I got the job done using a one-off python script, *however*, **I origi... | This sounds like a bug in the large XML file or the XSLT processor. There are two things you should check on your file.
1. Is the file well-formed XML? That is, are all tags and attributes properly terminated and matched? An XML processor, like [xmlstarlet](http://xmlstar.sourceforge.net/), can tell you that.
2. Does ... |
149,479 | <p>Well, it seems simple enough, but I can't find a way to add a caption to an equation.
The caption is needed to explain the variables used in the equation, so some kind of table-like structure to keep it all aligned and pretty would be great.</p>
| [
{
"answer_id": 149494,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile": "https://Stackoverflow.com/users/2509",
"pm_score": 4,
"selected": false,
"text": "<p>You may want to look at <a href=\"http://tug.ctan.org/tex-archive/macros/latex/contrib/float/\" re... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2841/"
] | Well, it seems simple enough, but I can't find a way to add a caption to an equation.
The caption is needed to explain the variables used in the equation, so some kind of table-like structure to keep it all aligned and pretty would be great. | The `\caption` command is restricted to floats: you will need to place the equation in a figure or table environment (or a new kind of floating environment). For example:
```
\begin{figure}
\[ E = m c^2 \]
\caption{A famous equation}
\end{figure}
```
The point of floats is that you let LaTeX determine their placemen... |
149,484 | <p>I want to create a VB.NET generic factory method that creates instances of classes (as a home-grown inversion of control container). If I pass the interface IDoSomething as the generic parameter, I want to return an instance of DoSomething (that implements IDoSomething). I cannot figure out the syntax of the if st... | [
{
"answer_id": 149536,
"author": "codeConcussion",
"author_id": 1321,
"author_profile": "https://Stackoverflow.com/users/1321",
"pm_score": 2,
"selected": false,
"text": "<pre><code>Public Function Build(Of T) As T\n Dim foo As Type = GetType(T)\n\n If foo Is GetType(IDoSomething) Then... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to create a VB.NET generic factory method that creates instances of classes (as a home-grown inversion of control container). If I pass the interface IDoSomething as the generic parameter, I want to return an instance of DoSomething (that implements IDoSomething). I cannot figure out the syntax of the if stateme... | ```
Public Function Build(Of T) As T
Dim foo As Type = GetType(T)
If foo Is GetType(IDoSomething) Then
Return New DoSomething()
...
End If
End Function
``` |
149,485 | <p>Like many projects, we deploy to many environments, QA, UA, Developer trunks, etc..</p>
<p>What is the best way to store sensitive configuration parameters in SVN? Or, should you not and just maintain a smaller unversioned file with credentials in it on the server?</p>
<p>Mainly, we do not want to expose productio... | [
{
"answer_id": 149497,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 0,
"selected": false,
"text": "<p>I would not store configuration information in the repository at all. That way you don't have to worry about SVN... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Like many projects, we deploy to many environments, QA, UA, Developer trunks, etc..
What is the best way to store sensitive configuration parameters in SVN? Or, should you not and just maintain a smaller unversioned file with credentials in it on the server?
Mainly, we do not want to expose production credentials to ... | I'd rather provide configuration examples than real config files. In my project there is `setup.default.php` file in root directory that every user need to copy as `setup.php` and amend to match local environment. Additionally, to prevent checking in back customised setup files there is a rule for it in `.svnignore`.
... |
149,491 | <p>I've been arguing with my coworkers about Pascal casing (upper camel case) vs. lower <a href="http://en.wikipedia.org/wiki/CamelCase" rel="noreferrer">CamelCasing</a>. They are used to lower camel casing for everything from table names in SQL databases to property naming in C# code but I like Pascal casing better, l... | [
{
"answer_id": 149507,
"author": "Dennis S.",
"author_id": 22250,
"author_profile": "https://Stackoverflow.com/users/22250",
"pm_score": 2,
"selected": false,
"text": "<p>I (and my team) prefer to reserve initial capitals for class names. </p>\n\n<p>Why? Java standards propagating, I th... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14533/"
] | I've been arguing with my coworkers about Pascal casing (upper camel case) vs. lower [CamelCasing](http://en.wikipedia.org/wiki/CamelCase). They are used to lower camel casing for everything from table names in SQL databases to property naming in C# code but I like Pascal casing better, lower camel casing for variables... | I use what the Framework uses, as it's the de-facto best practice. However, so long as the code in your company is **consistently** using their style, then you're much better off getting used to it. If every developer has their own standard, then there's no standard at all. |
149,500 | <p>What does the following code do in C/C++?</p>
<pre><code>if (blah(), 5) {
//do something
}
</code></pre>
| [
{
"answer_id": 149514,
"author": "itsmatt",
"author_id": 7862,
"author_profile": "https://Stackoverflow.com/users/7862",
"pm_score": 7,
"selected": true,
"text": "<p>Comma operator is applied and the value 5 is used to determine the conditional's true/false.</p>\n\n<p>It will execute bla... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20630/"
] | What does the following code do in C/C++?
```
if (blah(), 5) {
//do something
}
``` | Comma operator is applied and the value 5 is used to determine the conditional's true/false.
It will execute blah() and get something back (presumably), then the comma operator is employed and 5 will be the only thing that is used to determine the true/false value for the expression.
---
Note that the , operator cou... |
149,506 | <p>I'm investigating an annotation-based approach to validating Spring beans using <a href="https://springmodules.dev.java.net/" rel="nofollow noreferrer">spring modules</a>. In <a href="http://wheelersoftware.com/articles/spring-bean-validation-framework.html" rel="nofollow noreferrer">this tutorial</a>, the following... | [
{
"answer_id": 176039,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 4,
"selected": true,
"text": "<p>I took a quick look at the <a href=\"https://springmodules.dev.java.net/source/browse/%2Acheckout%2A/springmodules/www/doc... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I'm investigating an annotation-based approach to validating Spring beans using [spring modules](https://springmodules.dev.java.net/). In [this tutorial](http://wheelersoftware.com/articles/spring-bean-validation-framework.html), the following bean (getters and setters omitted) is used as an example:
```
public final ... | I took a quick look at the [BeanValidator API](https://springmodules.dev.java.net/source/browse/%2Acheckout%2A/springmodules/www/docs/javadocs/0.8/org/springmodules/validation/bean/BeanValidator.html), and it looks like you might want to try the *errorCodeConverter* property.
You would need to implement your own [Erro... |
149,573 | <p>Using jQuery, how do you check if there is an option selected in a select menu, and if not, assign one of the options as selected.</p>
<p>(The select is generated with a maze of PHP functions in an app I just inherited, so this is a quick fix while I get my head around those :)</p>
| [
{
"answer_id": 149592,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://Stackoverflow.com/users/4203",
"pm_score": 2,
"selected": false,
"text": "<p>Look at the <a href=\"http://www.w3schools.com/htmldom/prop_select_selectedindex.asp\" rel=\"nofollow noreferrer\">selec... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4196/"
] | Using jQuery, how do you check if there is an option selected in a select menu, and if not, assign one of the options as selected.
(The select is generated with a maze of PHP functions in an app I just inherited, so this is a quick fix while I get my head around those :) | While I'm not sure about exactly what you want to accomplish, this bit of code worked for me.
```
<select id="mySelect" multiple="multiple">
<option value="1">First</option>
<option value="2">Second</option>
<option value="3">Third</option>
<option value="4">Fourth</option>
</select>
<script type="text/javasc... |
149,600 | <p>Do you know any good tools for nicely formatting messy php code? Preferably a script for Aptana/Eclipse, but a standalone tool will do too.</p>
| [
{
"answer_id": 149612,
"author": "Ian P",
"author_id": 10853,
"author_profile": "https://Stackoverflow.com/users/10853",
"pm_score": 3,
"selected": false,
"text": "<p>If you use Zend Development Environment, you can use the Indent Code feature (Ctrl+Shift+F).</p>\n"
},
{
"answer_... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/556/"
] | Do you know any good tools for nicely formatting messy php code? Preferably a script for Aptana/Eclipse, but a standalone tool will do too. | [PHP Code Beautifier](http://www.waterproof.fr/products/phpCodeBeautifier/) is a useful free tool that should do what you're after, although their [download page](http://www.waterproof.fr/products/phpCodeBeautifier/download.php) does require an account to be created.
>
> The tool has been declined into 3 versions:
> ... |
149,609 | <p>Does the using catch the exception or throw it? i.e. </p>
<pre><code>using (StreamReader rdr = File.OpenText("file.txt"))
{
//do stuff
}
</code></pre>
<p>If the streamreader throws an exception is it caught by using or thrown so the calling function can handle it?</p>
| [
{
"answer_id": 149623,
"author": "hometoast",
"author_id": 2009,
"author_profile": "https://Stackoverflow.com/users/2009",
"pm_score": 2,
"selected": false,
"text": "<p>If you don't specifically catch an exception it's thrown up the stack until something does</p>\n"
},
{
"answer_... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21299/"
] | Does the using catch the exception or throw it? i.e.
```
using (StreamReader rdr = File.OpenText("file.txt"))
{
//do stuff
}
```
If the streamreader throws an exception is it caught by using or thrown so the calling function can handle it? | using statements do not eat exceptions.
All "Using" does is scope your object to the using block, and automatically calls Dispose() on the object when it leaves the block.
There is a gotcha though, if a thread is forcefully aborted by an outside source, it is possible that Dispose will never be called. |
149,617 | <p>Let's assume that I have some packets with a 16-bit checksum at the end. I would like to guess which checksum algorithm is used.</p>
<p>For a start, from dump data I can see that one byte change in the packet's payload totally changes the checksum, so I can assume that it isn't some kind of simple XOR or sum.</p>
... | [
{
"answer_id": 149663,
"author": "Martin Cote",
"author_id": 9936,
"author_profile": "https://Stackoverflow.com/users/9936",
"pm_score": 0,
"selected": false,
"text": "<p>You would have to try every possible checksum algorithm and see which one generates the same result. However, there ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1081/"
] | Let's assume that I have some packets with a 16-bit checksum at the end. I would like to guess which checksum algorithm is used.
For a start, from dump data I can see that one byte change in the packet's payload totally changes the checksum, so I can assume that it isn't some kind of simple XOR or sum.
Then I tried [... | There are a number of variables to consider for a CRC:
```
Polynomial
No of bits (16 or 32)
Normal (LSB first) or Reverse (MSB first)
Initial value
How the final value is manipulated (e.g. subtracted from 0xffff), or is a constant value
```
Typical CRCs:
```
LRC: Polynomial=0x81; 8 bits; Normal; Initial=0; Final... |
149,627 | <p>Is there a clean way of cloning a record in SQL that has an index(auto increment). I want to clone all the fields except the index. I currently have to enumerate every field, and use that in an insert select, and I would rather not explicitly list all of the fields, as they may change over time.</p>
| [
{
"answer_id": 149650,
"author": "Ben Hoffstein",
"author_id": 4482,
"author_profile": "https://Stackoverflow.com/users/4482",
"pm_score": 2,
"selected": true,
"text": "<p>Not unless you want to get into dynamic SQL. Since you wrote \"clean\", I'll assume not.</p>\n\n<p><strong>Edit:</s... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17712/"
] | Is there a clean way of cloning a record in SQL that has an index(auto increment). I want to clone all the fields except the index. I currently have to enumerate every field, and use that in an insert select, and I would rather not explicitly list all of the fields, as they may change over time. | Not unless you want to get into dynamic SQL. Since you wrote "clean", I'll assume not.
**Edit:** Since he asked for a dynamic SQL example, I'll take a stab at it. I'm not connected to any databases at the moment, so this is off the top of my head and will almost certainly need revision. But hopefully it captures the s... |
149,639 | <p>I've got a 'task list' database that uses the adjacency list model (see below) so each 'task' can have unlimited sub-tasks. The table has an 'TaskOrder' column so everything renders in the correct order on a treeview.</p>
<p>Is there an SQL statement (MS-SQL 2005) that will select all the child nodes for a specifie... | [
{
"answer_id": 149695,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 2,
"selected": false,
"text": "<p>If you're only using TaskOrder for sorting, it would certainly be simpler to simply leave the holes in TaskOrder,... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14072/"
] | I've got a 'task list' database that uses the adjacency list model (see below) so each 'task' can have unlimited sub-tasks. The table has an 'TaskOrder' column so everything renders in the correct order on a treeview.
Is there an SQL statement (MS-SQL 2005) that will select all the child nodes for a specified parent a... | Couple of different ways... Since the TaskOrder is scoped by parent id, it's not terribly difficult to gather it. In SQL Server, I'd put a trigger on delete that decrements all the ones 'higher' than the one you deleted, thereby closing the gap (pseudocode follows):
```
CREATE TRIGGER ON yourtable FOR DELETE
AS
UPDA... |
149,646 | <p>In the Apple documentation for <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSRunLoop_Class/Reference/Reference.html#//apple_ref/occ/instm/NSRunLoop/run" rel="noreferrer">NSRunLoop</a> there is sample code demonstrating suspending execution while waiting for a flag to be set b... | [
{
"answer_id": 150302,
"author": "schwa",
"author_id": 23113,
"author_profile": "https://Stackoverflow.com/users/23113",
"pm_score": 6,
"selected": true,
"text": "<p>Runloops can be a bit of a magic box where stuff just happens.</p>\n\n<p>Basically you're telling the runloop to go proces... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4496/"
] | In the Apple documentation for [NSRunLoop](http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSRunLoop_Class/Reference/Reference.html#//apple_ref/occ/instm/NSRunLoop/run) there is sample code demonstrating suspending execution while waiting for a flag to be set by something else.
```
BOOL sho... | Runloops can be a bit of a magic box where stuff just happens.
Basically you're telling the runloop to go process some events and then return. OR return if it doesn't process any events before the timeout is hit.
With 0.1 second timeout, you're htting the timeout more often than not. The runloop fires, doesn't proces... |
149,690 | <p>I am trying to extract a certain part of a column that is between delimiters.</p>
<p>e.g. find foo in the following</p>
<p>test 'esf :foo: bar</p>
<p>So in the above I'd want to return foo, but all the regexp functions only return true|false,
is there a way to do this in MySQL</p>
| [
{
"answer_id": 149703,
"author": "Mark Biek",
"author_id": 305,
"author_profile": "https://Stackoverflow.com/users/305",
"pm_score": 2,
"selected": false,
"text": "<p>A combination of <a href=\"http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_locate\" rel=\"nofollow ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to extract a certain part of a column that is between delimiters.
e.g. find foo in the following
test 'esf :foo: bar
So in the above I'd want to return foo, but all the regexp functions only return true|false,
is there a way to do this in MySQL | Here ya go, bud:
```
SELECT
SUBSTR(column,
LOCATE(':',column)+1,
(CHAR_LENGTH(column) - LOCATE(':',REVERSE(column)) - LOCATE(':',column)))
FROM table
```
Yea, no clue why you're doing this, but this will do the trick.
By performing a LOCATE, we can find the first ':'. To find the last ':', there's n... |
149,772 | <p>Basically the question is how to get from this:</p>
<pre>
foo_id foo_name
1 A
1 B
2 C
</pre>
<p>to this:</p>
<pre>
foo_id foo_name
1 A B
2 C
</pre>
| [
{
"answer_id": 149799,
"author": "Scott Noyes",
"author_id": 23539,
"author_profile": "https://Stackoverflow.com/users/23539",
"pm_score": 10,
"selected": true,
"text": "<pre><code>SELECT id, GROUP_CONCAT(name SEPARATOR ' ') FROM table GROUP BY id;\n</code></pre>\n<p><a href=\"https://de... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9403/"
] | Basically the question is how to get from this:
```
foo_id foo_name
1 A
1 B
2 C
```
to this:
```
foo_id foo_name
1 A B
2 C
``` | ```
SELECT id, GROUP_CONCAT(name SEPARATOR ' ') FROM table GROUP BY id;
```
<https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat>
From the link above, `GROUP_CONCAT`: This function returns a string result with the concatenated non-NULL values from a group. It returns NULL if there ... |
149,784 | <p><a href="https://stackoverflow.com/questions/57168/how-to-copy-a-row-from-one-sql-server-table-to-another">This question</a> comes close to what I need, but my scenario is slightly different. The source table and destination table are the same and the primary key is a uniqueidentifier (guid). When I try this:</p>
<... | [
{
"answer_id": 149792,
"author": "AaronSieb",
"author_id": 16911,
"author_profile": "https://Stackoverflow.com/users/16911",
"pm_score": 9,
"selected": true,
"text": "<p>Try this:\n<pre><code>\ninsert into MyTable(field1, field2, id_backup)\n select field1, field2, uniqueId from MyTab... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5469/"
] | [This question](https://stackoverflow.com/questions/57168/how-to-copy-a-row-from-one-sql-server-table-to-another) comes close to what I need, but my scenario is slightly different. The source table and destination table are the same and the primary key is a uniqueidentifier (guid). When I try this:
```
insert into MyT... | Try this:
```
insert into MyTable(field1, field2, id_backup)
select field1, field2, uniqueId from MyTable where uniqueId = @Id;
```
Any fields not specified should receive their default value (which is usually NULL when not defined). |
149,796 | <p>Often I want to add a value to a table or update the value if its key already exists. This can be accomplished in several ways, assuming a primary or unique key is set on the 'user_id' and 'pref_key' columns in the example:</p>
<p><strong>1. Blind insert, update if receiving a duplicate key error:</strong></p>
<pr... | [
{
"answer_id": 149812,
"author": "J.J.",
"author_id": 21204,
"author_profile": "https://Stackoverflow.com/users/21204",
"pm_score": 0,
"selected": false,
"text": "<p>The first way is the preferred way as far as I know.</p>\n"
},
{
"answer_id": 149819,
"author": "Dave Verwer",... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15872/"
] | Often I want to add a value to a table or update the value if its key already exists. This can be accomplished in several ways, assuming a primary or unique key is set on the 'user\_id' and 'pref\_key' columns in the example:
**1. Blind insert, update if receiving a duplicate key error:**
```
// Try to insert as a ne... | Will there be concurrent INSERTs to these rows? DELETEs?
"ON DUPLICATE" sounds great (the behavior is just what you want) provided that you're not concerned about portability to non-MySQL databases.
The "blind insert" seems reasonable and robust provided that rows are never deleted. (If the INSERT case fails because ... |
149,800 | <p>I'm making a small quiz-application in Flash (and ActionScript 3). Decided to use the RadioButton-component for radiobuttons, but I'm having some problems getting the word-wrapping to work.</p>
<p>The code for creating the button can be found below.</p>
<pre><code>_button = new RadioButton();
_button.setStyle("tex... | [
{
"answer_id": 149926,
"author": "davr",
"author_id": 14569,
"author_profile": "https://Stackoverflow.com/users/14569",
"pm_score": 3,
"selected": true,
"text": "<p>Two possibilities: width should be in pixels, not in characters. In addition, don't forget that the button itself uses up s... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm making a small quiz-application in Flash (and ActionScript 3). Decided to use the RadioButton-component for radiobuttons, but I'm having some problems getting the word-wrapping to work.
The code for creating the button can be found below.
```
_button = new RadioButton();
_button.setStyle("textFormat", _format);
_... | Two possibilities: width should be in pixels, not in characters. In addition, don't forget that the button itself uses up some of the width.
If you can't get it to work, instead of banging your head on it, might want to just create the label separately, either a simple TextField, or using a Label component. Slightly m... |
149,808 | <p>I have several stored procedures in my database that are used to load data from a datamart that is housed in a separate database. These procedures are, generally, in the form:</p>
<pre><code>
CREATE PROCEDURE load_stuff
WITH EXECUTE AS OWNER AS
INSERT INTO my_db.dbo.report_table
(
column_a
)
SELECT
column_b
FR... | [
{
"answer_id": 149984,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 2,
"selected": false,
"text": "<p>Why not remove EXECUTE AS OWNER?</p>\n\n<p>Usually, my user executing the SP would have appropriate rights in both da... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11780/"
] | I have several stored procedures in my database that are used to load data from a datamart that is housed in a separate database. These procedures are, generally, in the form:
```
CREATE PROCEDURE load_stuff
WITH EXECUTE AS OWNER AS
INSERT INTO my_db.dbo.report_table
(
column_a
)
SELECT
column_b
FROM data_mart.db... | Why not remove EXECUTE AS OWNER?
Usually, my user executing the SP would have appropriate rights in both databases, and I don't have to do that at all. |
149,821 | <p>I have the following function that is pulling data from a database. The ajax call is working correctly. How can I send the tab delimited data in my success function to the user? Setting the contect type to "application/vnd.ms-excel" didn't work. The alert on success shows the correctly formatted data.</p>
<pre>... | [
{
"answer_id": 149859,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 5,
"selected": true,
"text": "<p>AJAX is... the wrong choice. Redirect the user to a server resource that will send the data down with the proper MIME type, an... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/681/"
] | I have the following function that is pulling data from a database. The ajax call is working correctly. How can I send the tab delimited data in my success function to the user? Setting the contect type to "application/vnd.ms-excel" didn't work. The alert on success shows the correctly formatted data.
```
functio... | AJAX is... the wrong choice. Redirect the user to a server resource that will send the data down with the proper MIME type, and let the browser figure out what to do with it. |
149,823 | <p>When I dynamically create a Datagrid and add in a new buttoncolumn how do I access the buttoncolumn_click event? </p>
<p>Thanks.</p>
| [
{
"answer_id": 150068,
"author": "Brendan Enrick",
"author_id": 22381,
"author_profile": "https://Stackoverflow.com/users/22381",
"pm_score": 0,
"selected": false,
"text": "<p>This article on the MSDN site clearly explains how to go about <a href=\"http://msdn.microsoft.com/en-us/library... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20748/"
] | When I dynamically create a Datagrid and add in a new buttoncolumn how do I access the buttoncolumn\_click event?
Thanks. | ```
protected void Page_Load(object sender, EventArgs e)
{
DataGrid dg = new DataGrid();
dg.GridLines = GridLines.Both;
dg.Columns.Add(new ButtonColumn {
CommandName = "add",
HeaderText = "Event Details",
Text = "Details",
ButtonType = ButtonColumnType.PushButton
});
dg.DataSource = getData... |
149,825 | <p>I ran across the following code in <a href="http://www.quietlyscheming.com/blog/" rel="nofollow noreferrer">Ely Greenfield's</a> SuperImage from his Book component - I understand loader.load() but what does the rest of do?</p>
<pre><code>loader.load((newSource is URLRequest)? newSource:new URLRequest(newSource));
<... | [
{
"answer_id": 149847,
"author": "Matt",
"author_id": 20630,
"author_profile": "https://Stackoverflow.com/users/20630",
"pm_score": 0,
"selected": false,
"text": "<p>this is using the <a href=\"http://en.wikipedia.org/wiki/%3F:\" rel=\"nofollow noreferrer\">ternary ?: operator</a>. the ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3435/"
] | I ran across the following code in [Ely Greenfield's](http://www.quietlyscheming.com/blog/) SuperImage from his Book component - I understand loader.load() but what does the rest of do?
```
loader.load((newSource is URLRequest)? newSource:new URLRequest(newSource));
```
It looks like some kind of crazy inline if sta... | ? is called the 'ternary operator' and it's basic use is:
```
(expression) ? (evaluate to this if expression is true) : (evaluate to this otherwise);
```
In this case, if newSource is a URLRequest, loader.load will be passed newSource directly, otherwise it will be passed a new URLRequest built from newSource.
The ... |
149,827 | <p>I want to be able to run a text editor from my app, as given by the user in the TEXT_EDITOR environment variable. Now, assuming there is nothing in that variable, I want to default to the TextEdit program that ships with OSX. Is it kosher to hardcode /Applications/TextEdit.app/Contents/MacOS/TextEdit into my app, ... | [
{
"answer_id": 149846,
"author": "JeeBee",
"author_id": 17832,
"author_profile": "https://Stackoverflow.com/users/17832",
"pm_score": 0,
"selected": false,
"text": "<p>I believe that Mac OS X provides a default application mechanism, so that .txt will open in TextEdit.app or Emacs or GVi... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3830/"
] | I want to be able to run a text editor from my app, as given by the user in the TEXT\_EDITOR environment variable. Now, assuming there is nothing in that variable, I want to default to the TextEdit program that ships with OSX. Is it kosher to hardcode /Applications/TextEdit.app/Contents/MacOS/TextEdit into my app, or i... | In your second edit it makes it sound like you just want to get the path to TextEdit, this can be done easily by using NSWorkspace method absolutePathForAppBundleWithIdentifier:
```
NSString *path = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.apple.TextEdit"];
``` |
149,844 | <p>I'm running my site through the W3C's validator trying to get it to validate as XHTML 1.0 Strict and I've gotten down to a particularly sticky (at least in my experience) validation error. I'm including certain badges from various services in the site that provide their own API and code for inclusion on an external... | [
{
"answer_id": 150071,
"author": "Rudi",
"author_id": 22830,
"author_profile": "https://Stackoverflow.com/users/22830",
"pm_score": 2,
"selected": false,
"text": "<p>Perhaps you could use javascript to write the initial badge HTML? You'd probably only want the badge code to be inserted i... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16562/"
] | I'm running my site through the W3C's validator trying to get it to validate as XHTML 1.0 Strict and I've gotten down to a particularly sticky (at least in my experience) validation error. I'm including certain badges from various services in the site that provide their own API and code for inclusion on an external sit... | The following fragment is valid XHTML and does the job:
```
<div id="twitter_div">
<h2 class="twitter-title"><a href="http://twitter.com/stopsineman" title="Tim's Twitter Page.">Twitter Updates</a></h2>
<div id="myDiv" />
</div>
<script type="text/javascript">
var placeHolderNode = document.getElementByI... |
149,848 | <p>What is a strong way to protect against sql injection for a classic asp app?</p>
<p>FYI I am using it with an access DB. (I didnt write the app)</p>
| [
{
"answer_id": 149854,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 6,
"selected": true,
"text": "<p>Stored Procedures and/or prepared statements:</p>\n\n<p><a href=\"https://stackoverflow.com/questions/1973/what-is-the... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23528/"
] | What is a strong way to protect against sql injection for a classic asp app?
FYI I am using it with an access DB. (I didnt write the app) | Stored Procedures and/or prepared statements:
<https://stackoverflow.com/questions/1973/what-is-the-best-way-to-avoid-sql-injection-attacks>
[Can I protect against SQL Injection by escaping single-quote and surrounding user input with single-quotes?](https://stackoverflow.com/questions/139199/can-i-protect-against-sq... |
149,860 | <p>I have a <code>popen()</code> function which executes <code>tail -f sometextfile</code>. Aslong as there is data in the filestream obviously I can get the data through <code>fgets()</code>. Now, if no new data comes from tail, <code>fgets()</code> hangs. I tried <code>ferror()</code> and <code>feof()</code> to no av... | [
{
"answer_id": 149875,
"author": "Kasprzol",
"author_id": 5957,
"author_profile": "https://Stackoverflow.com/users/5957",
"pm_score": 0,
"selected": false,
"text": "<p>I you would use POSIX functions for IO instead of those of C library, you could use <a href=\"http://linux.die.net/man/2... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10010/"
] | I have a `popen()` function which executes `tail -f sometextfile`. Aslong as there is data in the filestream obviously I can get the data through `fgets()`. Now, if no new data comes from tail, `fgets()` hangs. I tried `ferror()` and `feof()` to no avail. How can I make sure `fgets()` doesn't try to read data when noth... | In Linux (or any Unix-y OS), you can mark the underlying file descriptor used by popen() to be non-blocking.
```
#include <fcntl.h>
FILE *proc = popen("tail -f /tmp/test.txt", "r");
int fd = fileno(proc);
int flags;
flags = fcntl(fd, F_GETFL, 0);
flags |= O_NONBLOCK;
fcntl(fd, F_SETFL, flags);
```
If there is no ... |
149,871 | <p>I'm building a data warehouse that includes delivery information for restaurants. The data is stored in SQL Server 2005 and is then put into a SQL Server Analysis Services 2005 cube.</p>
<p>The Deliveries information consists of the following tables:</p>
<p><strong>FactDeliveres</strong></p>
<ul>
<li>BranchKey</l... | [
{
"answer_id": 149951,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 2,
"selected": false,
"text": "<p>I would have Quantity, UnitCode, InvoiceNumber, DeliveryID all in the fact table. Both InvoiceNumber and DeliveryID ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16279/"
] | I'm building a data warehouse that includes delivery information for restaurants. The data is stored in SQL Server 2005 and is then put into a SQL Server Analysis Services 2005 cube.
The Deliveries information consists of the following tables:
**FactDeliveres**
* BranchKey
* DeliveryDateKey
* ProductKey
* InvoiceNum... | I would have Quantity, UnitCode, InvoiceNumber, DeliveryID all in the fact table. Both InvoiceNumber and DeliveryID are degenerate dimensions, because they will change with every fact (or very few facts). It is possible that you could put them in their own dimension if you have a large number of items on each order. Th... |
149,909 | <p>I would like to specify a constraint which is another type with a generic argument.</p>
<pre><code>class KeyFrame<T>
{
public float Time;
public T Value;
}
// I want any kind of Keyframe to be accepted
class Timeline<T> where T : Keyframe<*>
{
}
</code></pre>
<p>But this cannot be done i... | [
{
"answer_id": 149954,
"author": "workmad3",
"author_id": 16035,
"author_profile": "https://Stackoverflow.com/users/16035",
"pm_score": 2,
"selected": false,
"text": "<p>As TimeLine is most likely an aggregation of KeyFrames, wouldn't something like:</p>\n\n<pre><code>class TimeLine<T... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839/"
] | I would like to specify a constraint which is another type with a generic argument.
```
class KeyFrame<T>
{
public float Time;
public T Value;
}
// I want any kind of Keyframe to be accepted
class Timeline<T> where T : Keyframe<*>
{
}
```
But this cannot be done in c# as of yet, (and I really doubt it will ... | Read about this from [Eric Lippert's blog](http://blogs.msdn.com/ericlippert/archive/2008/05/19/a-generic-constraint-question.aspx)
Basically, you have to find a way to refer to the type you want without specifying the secondary type parameter.
In his post, he shows this example as a possible solution:
```
public ab... |
149,939 | <p>I would like to do something like
<code><test:di id="someService"</code>/`><br>
<%
someService.methodCall();
%></p>
<p>where <code><test:di</code><br>
gets and instantiates a service bean and creates a scripting variable for use. similar to how jsp:usebean works for example
<code>... | [
{
"answer_id": 149989,
"author": "zmf",
"author_id": 13285,
"author_profile": "https://Stackoverflow.com/users/13285",
"pm_score": 1,
"selected": false,
"text": "<p>I think you're trying to write your own tag library.</p>\n\n<p>Check out the tutorial at:\n<a href=\"http://www.ironflare.c... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20641/"
] | I would like to do something like
`<test:di id="someService"`/`>
<%
someService.methodCall();
%>
where `<test:di`
gets and instantiates a service bean and creates a scripting variable for use. similar to how jsp:usebean works for example
`<jsp:useBean id="someDate" class="java.util.Date"`/>
<%
som... | The way this is done in a Tag Library is by using a Tag Extra Info (TEI) class.
You can find an [example here](http://www.stardeveloper.com/articles/display.html?article=2001081601&page=2). |
149,956 | <p>Does anyone know of a method to determine when a file copy completes in VBScript? I'm using the following to copy:</p>
<pre><code>set sa = CreateObject("Shell.Application")
set zip = sa.NameSpace(saveFile)
set Fol = sa.NameSpace(folderToZip)
zip.copyHere (Fol.items)
</code></pre>
| [
{
"answer_id": 149979,
"author": "Matt Dillard",
"author_id": 863,
"author_profile": "https://Stackoverflow.com/users/863",
"pm_score": 2,
"selected": false,
"text": "<p>You may have better luck using the Copy method on a <a href=\"http://msdn.microsoft.com/en-us/library/6973t06a(VS.85).... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14092/"
] | Does anyone know of a method to determine when a file copy completes in VBScript? I'm using the following to copy:
```
set sa = CreateObject("Shell.Application")
set zip = sa.NameSpace(saveFile)
set Fol = sa.NameSpace(folderToZip)
zip.copyHere (Fol.items)
``` | ```
Do Until zip.Items.Count = Fol.Items.Count
WScript.Sleep 300
Loop
```
When the loop finishes your copy is finished.
But if you only want to copy and not zip, FSO or WMI is better.
If you are zipping and want them in a file you have to create the zip-file yourself, with the right header first. Else you only ... |
149,995 | <p>I have a C++ program representing a TCP header as a struct:</p>
<pre><code>#include "stdafx.h"
/* TCP HEADER
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+... | [
{
"answer_id": 150001,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 3,
"selected": false,
"text": "<p>Because the compiler is packing your bitfield into a 32-bit int, not a 16-bit entity.</p>\n\n<p>In general you sho... | 2008/09/29 | [
"https://Stackoverflow.com/questions/149995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a C++ program representing a TCP header as a struct:
```
#include "stdafx.h"
/* TCP HEADER
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... | See this question: [Why isn't sizeof for a struct equal to the sum of sizeof of each member?](https://stackoverflow.com/questions/119123/why-does-the-sizeof-operator-return-a-size-larger-for-a-structure-than-the-tota) .
I believe that compiler takes a hint to disable padding when you use the "unsigned int wWindow:16" ... |
150,010 | <p>I am creating a "department picker" form that is going to serve as a modal popup form with many of my "primary" forms of a Winforms application. Ideally the user is going to click on an icon next to a text box that will pop up the form, they will select the department they need, and when they click OK, the dialog wi... | [
{
"answer_id": 150021,
"author": "OregonGhost",
"author_id": 20363,
"author_profile": "https://Stackoverflow.com/users/20363",
"pm_score": 3,
"selected": true,
"text": "<p>In such cases, I usually either</p>\n\n<ul>\n<li>Write a ShowDialog function that does what I want (e.g. return the ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71/"
] | I am creating a "department picker" form that is going to serve as a modal popup form with many of my "primary" forms of a Winforms application. Ideally the user is going to click on an icon next to a text box that will pop up the form, they will select the department they need, and when they click OK, the dialog will ... | In such cases, I usually either
* Write a ShowDialog function that does what I want (e.g. return the value) or
* Just let the result be a property in the dialog. This is how the common file dialogs do it in the BCL. The caller must then read the property to get the result. That's fine in my opinion.
You can also comb... |
150,011 | <p>My clients application exports and imports quite a few variables of type real through a text file using writeln and readln. I've tried to increase the width of the fields written so the code looks like: </p>
<pre><code>writeln(file, exportRealvalue:30); //using excess width of field
....
readln(file, importRealval... | [
{
"answer_id": 150180,
"author": "Jon Trauntvein",
"author_id": 19674,
"author_profile": "https://Stackoverflow.com/users/19674",
"pm_score": 0,
"selected": false,
"text": "<p>When using floating point types, you should be aware of the precision limitations on the specified types. A 4 b... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9077/"
] | My clients application exports and imports quite a few variables of type real through a text file using writeln and readln. I've tried to increase the width of the fields written so the code looks like:
```
writeln(file, exportRealvalue:30); //using excess width of field
....
readln(file, importRealvalue);
```
When... | If you want to specify the precision of a real with a WriteLn, use the following:
```
WriteLn(RealVar:12:3);
```
It outputs the value Realvar with at least 12 positions and a precision of 3. |
150,017 | <p>I have a query that I'm executing from a .NET application to a SQL Server database and it seems to take quite a while to complete (5+ Minutes). I created a test app in c# to try to see what was talking so long (the query should return quickly). </p>
<p>As I was reconstructing the query by adding in elements to se... | [
{
"answer_id": 150029,
"author": "Russ Cam",
"author_id": 1831,
"author_profile": "https://Stackoverflow.com/users/1831",
"pm_score": 1,
"selected": false,
"text": "<p>Since you are using SQL Server 2005, have you tried with a SqlCommand object instead of the OleDbCommand object?</p>\n"
... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23553/"
] | I have a query that I'm executing from a .NET application to a SQL Server database and it seems to take quite a while to complete (5+ Minutes). I created a test app in c# to try to see what was talking so long (the query should return quickly).
As I was reconstructing the query by adding in elements to see which port... | I suspect that this is a procedure cache issue. One benefit of stored procedures is that the plan is stored for you, which speeds things up. Unfortunately, it's possible to get a bad plan in the cache (even when using dynamic queries).
Just for fun, I checked my procedure cache, ran an adhoc query, checked again, then... |
150,032 | <p>We have a Cash flow report which is basically in this structure:</p>
<pre><code>Date |Credit|Debit|balance|
09/29| 20 | 10 | 10 |
09/30| 0 | 10 | 0 |
</code></pre>
<p>The main problem is the balance, and as we are using a DataSet for the Data, it's kinda hard to calculate the balance on the DataSet, ... | [
{
"answer_id": 150064,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": 0,
"selected": false,
"text": "<p>On the code side of things, you've got two relatively easy options, but they both involve iterating through the ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/727/"
] | We have a Cash flow report which is basically in this structure:
```
Date |Credit|Debit|balance|
09/29| 20 | 10 | 10 |
09/30| 0 | 10 | 0 |
```
The main problem is the balance, and as we are using a DataSet for the Data, it's kinda hard to calculate the balance on the DataSet, because we always need the... | This may be too big a change or off the mark for you, but a cash flow report indicates to me that you are probably maintaining, either formally or informally, a general ledger arrangement of some sort. If you are, then maybe I am naive about this but I think you should maintain your general ledger detail as a single ta... |
150,033 | <p>What is the easiest way to match non-ASCII characters in a regex? I would like to match all words individually in an input string, but the language may not be English, so I will need to match things like ü, ö, ß, and ñ. Also, this is in Javascript/jQuery, so any solution will need to apply to that. </p>
| [
{
"answer_id": 150062,
"author": "OregonGhost",
"author_id": 20363,
"author_profile": "https://Stackoverflow.com/users/20363",
"pm_score": 2,
"selected": false,
"text": "<p>All Unicode-enabled Regex flavours should have a special character class like \\w that match any Unicode letter. Ta... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85/"
] | What is the easiest way to match non-ASCII characters in a regex? I would like to match all words individually in an input string, but the language may not be English, so I will need to match things like ü, ö, ß, and ñ. Also, this is in Javascript/jQuery, so any solution will need to apply to that. | This should do it:
```
[^\x00-\x7F]+
```
It matches any character which is not contained in the [ASCII character set](http://en.wikipedia.org/wiki/American_Standard_Code_for_Information_Interchange) (0-127, i.e. 0x0 to 0x7F).
You can do the same thing with Unicode:
```
[^\u0000-\u007F]+
```
For unicode you can ... |
150,038 | <p>I have a middle tier containing several related objects and a data tier that is using a DataSet with several DataTables and relationships.</p>
<p>I want to call a Save method on one of my objects (a parent object) and have its private variable data transformed into a DataRow and added to a DataTable. Some of the p... | [
{
"answer_id": 151255,
"author": "Keith Sirmons",
"author_id": 1048,
"author_profile": "https://Stackoverflow.com/users/1048",
"pm_score": 0,
"selected": false,
"text": "<p>So, What I am doing right now is passing a reference to the DataSet and a reference to the DataRow of the parent in... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1048/"
] | I have a middle tier containing several related objects and a data tier that is using a DataSet with several DataTables and relationships.
I want to call a Save method on one of my objects (a parent object) and have its private variable data transformed into a DataRow and added to a DataTable. Some of the private vari... | I will not start another debate whether datasets are good or evil. If you continue to use them, here are something to consider:
* You need to keep the original dataset and update that, in order to get correct inserts and updates.
* You want your parents to know their children, but not the other way. Banish the ParentT... |
150,042 | <p>I have tried this...</p>
<pre><code>Dim myMatches As String() =
System.Text.RegularExpressions.Regex.Split(postRow.Item("Post"), "\b\#\b")
</code></pre>
<p>But it is splitting all words, I want an array of words that start with#</p>
<p>Thanks!</p>
| [
{
"answer_id": 150086,
"author": "rslite",
"author_id": 15682,
"author_profile": "https://Stackoverflow.com/users/15682",
"pm_score": 1,
"selected": false,
"text": "<p>Since you want to include the words in the split you should use something like</p>\n\n<pre><code>\"\\b#\\w+\\b\"\n</code... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6514/"
] | I have tried this...
```
Dim myMatches As String() =
System.Text.RegularExpressions.Regex.Split(postRow.Item("Post"), "\b\#\b")
```
But it is splitting all words, I want an array of words that start with#
Thanks! | This seems to work...
c#
```
Regex MyRegex = new Regex("\\#\\w+");
MatchCollection ms = MyRegex.Matches(InputText);
```
or vb.net
```
Dim MyRegex as Regex = new Regex("\#\w+")
Dim ms as MatchCollection = MyRegex.Matches(InputText)
```
Given input text of...
"asdfas asdf #asdf asd fas df asd fas #df asd f asdf"
... |
150,044 | <p>I'm new to ASP.NET and want to have an asp:content control for the page title, but I want that value to be used for the tag and for a page header. When I tried to do this with two tags with the same id, it complained that I couldn't have two tags with the same id. Is there a way to achieve this with contentplaceho... | [
{
"answer_id": 150072,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 2,
"selected": true,
"text": "<p>Title is actually an attribute on content pages, so you do something like:</p>\n\n<pre><code><%@ Page Language=\"... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6222/"
] | I'm new to ASP.NET and want to have an asp:content control for the page title, but I want that value to be used for the tag and for a page header. When I tried to do this with two tags with the same id, it complained that I couldn't have two tags with the same id. Is there a way to achieve this with contentplaceholders... | Title is actually an attribute on content pages, so you do something like:
```
<%@ Page Language="C#" MasterPageFile="~/default.master" Title="My Content Title" %>
```
on the content page. To get that into a header, on the master page just render the page title:
```
<h1><%= this.Page.Title %></h3>
``` |
150,047 | <p>Does anyone know how to get the name of the TARGET (/t) called from the MSBuild command line? There are a few types of targets that can be called and I want to use that property in a notification to users.</p>
<p>Example:</p>
<pre><code>msbuild Project.proj /t:ApplicationDeployment /p:Environment=DEV
</code></pre>... | [
{
"answer_id": 150271,
"author": "Tim Booker",
"author_id": 10046,
"author_profile": "https://Stackoverflow.com/users/10046",
"pm_score": 4,
"selected": false,
"text": "<p>I'm not sure how to do exactly what you ask, but could you pass that string using the /p option?</p>\n\n<pre><code>m... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18475/"
] | Does anyone know how to get the name of the TARGET (/t) called from the MSBuild command line? There are a few types of targets that can be called and I want to use that property in a notification to users.
Example:
```
msbuild Project.proj /t:ApplicationDeployment /p:Environment=DEV
```
I want access to the target ... | I found the answer!
```
<Target Name="ApplicationDeployment" >
<CreateProperty Value="$(MSBuildProjectName) - $(Environment) - Application Deployment Complete">
<Output TaskParameter="Value" PropertyName="DeploymentCompleteNotifySubject" />
</CreateProperty>
```
I would like to give partial credit to a... |
150,053 | <p>How can I limit my post-build events to running only for one type of build?</p>
<p>I'm using the events to copy DLL files to a local IIS virtual directory, but I don't want this happening on the build server in release mode.</p>
| [
{
"answer_id": 150070,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 3,
"selected": false,
"text": "<p>You can pass the configuration name to the post-build script and check it in there to see if it should run.</p>\n\n<p>... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3615/"
] | How can I limit my post-build events to running only for one type of build?
I'm using the events to copy DLL files to a local IIS virtual directory, but I don't want this happening on the build server in release mode. | Pre- and Post-Build Events run as a batch script. You can do a conditional statement on `$(ConfigurationName)`.
For instance
```
if $(ConfigurationName) == Debug xcopy something somewhere
``` |
150,076 | <p>I created a Rails application normally. Then created the scaffold for an event class. Then tried the following code. When run it complains about a InvalidAuthenticityToken when the destroy method is executed. How do I authenticate to avoid this response?</p>
<pre><code>require 'rubygems'
require 'activeresource'
c... | [
{
"answer_id": 150109,
"author": "skaffman",
"author_id": 21234,
"author_profile": "https://Stackoverflow.com/users/21234",
"pm_score": 3,
"selected": false,
"text": "<p>By default, all innodb databases in a given mysql server installation use the same physical pool of data files, so con... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/219658/"
] | I created a Rails application normally. Then created the scaffold for an event class. Then tried the following code. When run it complains about a InvalidAuthenticityToken when the destroy method is executed. How do I authenticate to avoid this response?
```
require 'rubygems'
require 'activeresource'
class Event < A... | So I'm not sure [Matt Rogish's answer](https://stackoverflow.com/a/150763) is going to help 100%.
The problem is that MySQL\* has a mutex (mutually exclusive lock) around opening and closing tables, so that basically means that if a table is in the process of being closed/deleted, *no* other tables can be opened.
Thi... |
150,084 | <p>I have a collection of data stored in XDocuments and DataTables, and I'd like to address both as a single unified data space with XPath queries. So, for example, "/Root/Tables/Orders/FirstName" would fetch the value of the Firstname column in every row of the DataTable named "Orders". </p>
<p>Is there a way to do t... | [
{
"answer_id": 150117,
"author": "dacracot",
"author_id": 13930,
"author_profile": "https://Stackoverflow.com/users/13930",
"pm_score": 0,
"selected": false,
"text": "<p>Are you looking for something similar to what I asked regarding <a href=\"https://stackoverflow.com/questions/142010/c... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5548/"
] | I have a collection of data stored in XDocuments and DataTables, and I'd like to address both as a single unified data space with XPath queries. So, for example, "/Root/Tables/Orders/FirstName" would fetch the value of the Firstname column in every row of the DataTable named "Orders".
Is there a way to do this withou... | I eventually figured out the answer to this myself. I discovered a class in System.Xml.LINQ called XStreamingElement that can create an XML structure on-the-fly from a LINQ expression. Here's an example of casting a DataTable into an XML-space.
```
Dictionary<string,DataTable> Tables = new Dictionary<string,DataTable>... |
150,095 | <p>I need to substitute the value of a string into my regular expression in Ruby. Is there an easy way to do this? For example:</p>
<pre><code>foo = "0.0.0.0"
goo = "here is some other stuff 0.0.0.0"
if goo =~ /value of foo here dynamically/
puts "success!"
end
</code></pre>
| [
{
"answer_id": 150108,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 2,
"selected": false,
"text": "<p>Use Regexp.new:</p>\n\n<pre><code>if goo =~ Regexp.new(foo) # Evaluates to /0.0.0.0/\n</code></pre>\n"
},
{
"an... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/422/"
] | I need to substitute the value of a string into my regular expression in Ruby. Is there an easy way to do this? For example:
```
foo = "0.0.0.0"
goo = "here is some other stuff 0.0.0.0"
if goo =~ /value of foo here dynamically/
puts "success!"
end
``` | Same as string insertion.
```
if goo =~ /#{Regexp.quote(foo)}/
#...
``` |
150,113 | <p>An older application using System.Web.Mail is throwing an exception on emails coming from <em>hr@domain.com</em>. Other addresses appear to be working correctly. We changed our mail server to Exchange 2007 when the errors started, so I assume that is where the problem is. Does anyone know what is happening?</p>
<p>... | [
{
"answer_id": 150108,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 2,
"selected": false,
"text": "<p>Use Regexp.new:</p>\n\n<pre><code>if goo =~ Regexp.new(foo) # Evaluates to /0.0.0.0/\n</code></pre>\n"
},
{
"an... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17287/"
] | An older application using System.Web.Mail is throwing an exception on emails coming from *hr@domain.com*. Other addresses appear to be working correctly. We changed our mail server to Exchange 2007 when the errors started, so I assume that is where the problem is. Does anyone know what is happening?
Here is the excep... | Same as string insertion.
```
if goo =~ /#{Regexp.quote(foo)}/
#...
``` |
150,114 | <p>I know plenty about the different ways of handling parsing text for information. For parsing integers for example, what kind of performance can be expected. I am wondering if anyone knows of any good stats on this. I am looking for some real numbers from someone who has tested this.</p>
<p>Which of these offers the... | [
{
"answer_id": 150123,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 7,
"selected": true,
"text": "<p>Always use <strong>T.TryParse(string str, out T value)</strong>. Throwing exceptions is expensive and should be avoided i... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22381/"
] | I know plenty about the different ways of handling parsing text for information. For parsing integers for example, what kind of performance can be expected. I am wondering if anyone knows of any good stats on this. I am looking for some real numbers from someone who has tested this.
Which of these offers the best perf... | Always use **T.TryParse(string str, out T value)**. Throwing exceptions is expensive and should be avoided if you can handle the situation *a priori*. Using a try-catch block to "save" on performance (because your invalid data rate is low) is an abuse of exception handling at the expense of maintainability and good cod... |
150,146 | <p>In my just-completed project, I was working getting distributed transactions working.</p>
<p>We implemented this using JBoss's Arjuna Transaction Manager, and Spring's declarative transaction boundaries.</p>
<p>Our request sequence looked like:</p>
<pre><code>browser -> secured servlet -> 'wafer-thin' SLSB ... | [
{
"answer_id": 150526,
"author": "Michael Brown",
"author_id": 14359,
"author_profile": "https://Stackoverflow.com/users/14359",
"pm_score": 1,
"selected": false,
"text": "<p>Jeremiah Morrill has recently released a <a href=\"http://www.codeplex.com/WPFMediaKit\" rel=\"nofollow noreferre... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3295/"
] | In my just-completed project, I was working getting distributed transactions working.
We implemented this using JBoss's Arjuna Transaction Manager, and Spring's declarative transaction boundaries.
Our request sequence looked like:
```
browser -> secured servlet -> 'wafer-thin' SLSB -> spring TX-aware proxy -> reques... | Jeremiah Morrill has recently released a [specialized WPF library](http://www.codeplex.com/WPFMediaKit) that supports displaying HD Media (among other features) |
150,150 | <p>I have a defined MenuItem that I would like to share between two different menus on one page. The menu contains functionallity that is the same between both menus and I do not want two copies of it. Is there anyway to define a MenuItem in the Page.Resources and reference it in the ContextMenu XAML below?</p>
<pre><... | [
{
"answer_id": 150203,
"author": "Phobis",
"author_id": 19854,
"author_profile": "https://Stackoverflow.com/users/19854",
"pm_score": 1,
"selected": false,
"text": "<p>Because you want to mix-and-match... I would make a custom control that inherits from ContextMenu that has a \"SharedMen... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1514/"
] | I have a defined MenuItem that I would like to share between two different menus on one page. The menu contains functionallity that is the same between both menus and I do not want two copies of it. Is there anyway to define a MenuItem in the Page.Resources and reference it in the ContextMenu XAML below?
```
<Page.Res... | I've done this by setting x:Shared="False" on the menu item itself. Resources are shared between each place that uses them by default (meaning one instance across all uses), so turning that off means that a new "copy" of the resource is made each time.
So:
```
<MenuItem x:Key="myMenuItem" x:Shared="False" />
```
Yo... |
150,161 | <p>I have searched but apparently my google foo is weak. What I need is a way to prompt for user input in the console and have the request time out after a period of time and continue executing the script if no input comes in. As near as I can tell, Read-Host does not provide this functionality. Neither does $host.UI.P... | [
{
"answer_id": 150326,
"author": "Lars Truijens",
"author_id": 1242,
"author_profile": "https://Stackoverflow.com/users/1242",
"pm_score": 5,
"selected": true,
"text": "<p>Found something <a href=\"http://huddledmasses.org/powershell-xmpp-jabber-snapin/\" rel=\"noreferrer\">here</a>:</p>... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1358/"
] | I have searched but apparently my google foo is weak. What I need is a way to prompt for user input in the console and have the request time out after a period of time and continue executing the script if no input comes in. As near as I can tell, Read-Host does not provide this functionality. Neither does $host.UI.Prom... | Found something [here](http://huddledmasses.org/powershell-xmpp-jabber-snapin/):
```
$counter = 0
while(!$Host.UI.RawUI.KeyAvailable -and ($counter++ -lt 600))
{
[Threading.Thread]::Sleep( 1000 )
}
``` |
150,167 | <p>How do I list and export a private key from a keystore?</p>
| [
{
"answer_id": 150181,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 6,
"selected": true,
"text": "<p>A portion of code originally from Example Depot for listing all of the aliases in a key store:</p>\n\n<pre><code> // Lo... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1310/"
] | How do I list and export a private key from a keystore? | A portion of code originally from Example Depot for listing all of the aliases in a key store:
```
// Load input stream into keystore
keystore.load(is, password.toCharArray());
// List the aliases
Enumeration aliases = keystore.aliases();
for (; aliases.hasMoreElements(); ) {
String alias ... |
150,177 | <p>I was helping out some colleagues of mine with an SQL problem. Mainly they wanted to move all the rows from table A to table B (both tables having the same columns (names and types)). Although this was done in Oracle 11g I don't think it really matters.</p>
<p>Their initial naive implementation was something like <... | [
{
"answer_id": 150187,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 1,
"selected": false,
"text": "<p>i don't know if this is relevant, but in SQL Server the syntax is</p>\n\n<pre><code>begin tran\n....\ncommit\n</co... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1796/"
] | I was helping out some colleagues of mine with an SQL problem. Mainly they wanted to move all the rows from table A to table B (both tables having the same columns (names and types)). Although this was done in Oracle 11g I don't think it really matters.
Their initial naive implementation was something like
```
BEGIN... | Depending on your isolation level, selecting all the rows from a table does not prevent new inserts, it will just lock the rows you read. In SQL Server, if you use the Serializable isolation level then it will prevent new rows if they would have been including in your select query.
<http://msdn.microsoft.com/en-us/lib... |
150,186 | <p>I'm trying to build a new .NET C++ project from scratch. I am planning to mix managed and unmanaged code in this project.</p>
<p>this forum thread
<a href="http://www.daniweb.com/forums/thread29742.html" rel="nofollow noreferrer">IDataObject : ambiguous symbol error</a> answers a problem I've seen multiple times.</... | [
{
"answer_id": 150236,
"author": "Evan Teran",
"author_id": 13430,
"author_profile": "https://Stackoverflow.com/users/13430",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know much about .NET, so my answer only applies to the unmanaged c++ part of your question. Personally, this... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6367/"
] | I'm trying to build a new .NET C++ project from scratch. I am planning to mix managed and unmanaged code in this project.
this forum thread
[IDataObject : ambiguous symbol error](http://www.daniweb.com/forums/thread29742.html) answers a problem I've seen multiple times.
Post #4 states
"Move all 'using namespace XXXX'... | It's a good idea to always use fully qualified names in header files. Because the `using` statement affects all following code regardless of `#include`, putting a `using` statement in a header file affects everybody that might include that header.
So you would change your function declaration in your header file to:
... |
150,208 | <p>Is there a free third-party or .NET class that will convert HTML to RTF (for use in a rich-text enabled Windows Forms control)?</p>
<p>The "free" requirement comes from the fact that I'm only working on a prototype and can just load the BrowserControl and just render HTML if need be (even if it is slow) and that De... | [
{
"answer_id": 152182,
"author": "GvS",
"author_id": 11492,
"author_profile": "https://Stackoverflow.com/users/11492",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe what you need is <a href=\"http://www.codeplex.com/WinformHtmlTextbox\" rel=\"nofollow noreferrer\">a control to edit... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/549/"
] | Is there a free third-party or .NET class that will convert HTML to RTF (for use in a rich-text enabled Windows Forms control)?
The "free" requirement comes from the fact that I'm only working on a prototype and can just load the BrowserControl and just render HTML if need be (even if it is slow) and that Developer Ex... | Actually there is a simple and **free** solution: use your browser, ok this is the trick I used:
```
var webBrowser = new WebBrowser();
webBrowser.CreateControl(); // only if needed
webBrowser.DocumentText = *yourhtmlstring*;
while (_webBrowser.DocumentText != *yourhtmlstring*)
Application.DoEvents();
webBrowser.D... |
150,213 | <p>I'm trying to chart the number of registrations per day in our registration system. I have an Attendee table in sql server that has a smalldatetime field A_DT, which is the date and time the person registered.</p>
<p>I started with this:</p>
<pre><code>var dailyCountList =
(from a in showDC.Attendee
let ju... | [
{
"answer_id": 150334,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 2,
"selected": true,
"text": "<p>O(n) with 2 enumerations. It's very good to pull the items into memory before trying this. Database has enough to do witho... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13700/"
] | I'm trying to chart the number of registrations per day in our registration system. I have an Attendee table in sql server that has a smalldatetime field A\_DT, which is the date and time the person registered.
I started with this:
```
var dailyCountList =
(from a in showDC.Attendee
let justDate = new DateTim... | O(n) with 2 enumerations. It's very good to pull the items into memory before trying this. Database has enough to do without thinking about this stuff.
```
if (!dailyCountList.Any())
return;
//make a dictionary to provide O(1) lookups for later
Dictionary<DateTime, RegistrationCount> lookup = dailyCountL... |
150,223 | <p>Looking for a way to programatically, or otherwise, add a new instance of SQL 2005 Express Edition to a system that already has an instance installed. Traditionally, you run Micrsoft's installer like I am in the command line below and it does the trick. Executing the command in my installer is not the issue, it's ... | [
{
"answer_id": 150247,
"author": "Scott Isaacs",
"author_id": 1664,
"author_profile": "https://Stackoverflow.com/users/1664",
"pm_score": 0,
"selected": false,
"text": "<p>I do not know how to do it with an API, but if no one gives a better solution, you can always use Process.Start() to... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5678/"
] | Looking for a way to programatically, or otherwise, add a new instance of SQL 2005 Express Edition to a system that already has an instance installed. Traditionally, you run Micrsoft's installer like I am in the command line below and it does the trick. Executing the command in my installer is not the issue, it's more ... | After months/years of looking into this it appears it can't be done. Oh well, I guess I just reinstall each time I want a new instance. I guess it's because each instance is it's own service. |
150,250 | <p>I was recently tasked with debugging a strange problem within an e-commerce application. After an application upgrade the site started to hang from time to time and I was sent in to debug. After checking the event log I found that the SQL-server wrote ~200 000 events in a couple of minutes with the message saying th... | [
{
"answer_id": 150267,
"author": "Alex Fort",
"author_id": 12624,
"author_profile": "https://Stackoverflow.com/users/12624",
"pm_score": 0,
"selected": false,
"text": "<p>Obviously, something is not being deleted or modified where it should. If the condition is still the same on the next... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2114/"
] | I was recently tasked with debugging a strange problem within an e-commerce application. After an application upgrade the site started to hang from time to time and I was sent in to debug. After checking the event log I found that the SQL-server wrote ~200 000 events in a couple of minutes with the message saying that ... | Are you operating in explicit or implicit [transaction mode](http://doc.ddart.net/mssql/sql70/ta-tz_8.htm)?
Since you're in explicit mode, I think you need to surround the DELETE operation with BEGIN TRANSACTION and COMMIT TRANSACTION statements.
```
WHILE EXISTS (SELECT * FROM ShoppingCartItem WHERE ShoppingCartItem... |
150,329 | <p>I recently migrated a website to a new CMS (Umbraco). A lot of the links have changed, but they can be easily corrected by searching for patters in the url, so I would like to write something that will redirect to the correct page if the old one is not found. That part isn't a problem. </p>
<p>How can I obtain the ... | [
{
"answer_id": 150336,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 0,
"selected": false,
"text": "<p>Update, you actually want to pick up:</p>\n\n<p>VB.NET:</p>\n\n<pre><code>Request.QueryString(\"aspxerrorpath\")\n</code></pre>... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20483/"
] | I recently migrated a website to a new CMS (Umbraco). A lot of the links have changed, but they can be easily corrected by searching for patters in the url, so I would like to write something that will redirect to the correct page if the old one is not found. That part isn't a problem.
How can I obtain the requested ... | I do basically the same thing you ask in a custom 404 error handling page. On IIS 6 the original URL is in the query string. The code below shows how to grab the original URL and then forward the user. In my case I switched from old ASP to new ASP.NET, so all the .asp pages had to be forwarded to .aspx pages. Also, som... |
150,332 | <p>If I have variable of type <code>IEnumerable<List<string>></code> is there a LINQ statement or lambda expression I can apply to it which will combine the lists returning an <code>IEnumerable<string></code>? </p>
| [
{
"answer_id": 150343,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": true,
"text": "<p>SelectMany - i.e.</p>\n\n<pre><code> IEnumerable<List<string>> someList = ...;\n IEnumera... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If I have variable of type `IEnumerable<List<string>>` is there a LINQ statement or lambda expression I can apply to it which will combine the lists returning an `IEnumerable<string>`? | SelectMany - i.e.
```
IEnumerable<List<string>> someList = ...;
IEnumerable<string> all = someList.SelectMany(x => x);
```
For each item in someList, this then uses the lambda "x => x" to get an IEnumerable<T> for the inner items. In this case, each "x" is a List<T>, which is already IEnumerable<T>.
... |
150,333 | <p>We need to remotely create an Exchange 2007 distribution list from Asp.Net.</p>
<p>Near as I can tell, the only way to create a distribution list in the GAL is via the exchange management tools. Without installing this on our web server, is there any way to create a distribution list remotely? There are some thir... | [
{
"answer_id": 150343,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": true,
"text": "<p>SelectMany - i.e.</p>\n\n<pre><code> IEnumerable<List<string>> someList = ...;\n IEnumera... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23583/"
] | We need to remotely create an Exchange 2007 distribution list from Asp.Net.
Near as I can tell, the only way to create a distribution list in the GAL is via the exchange management tools. Without installing this on our web server, is there any way to create a distribution list remotely? There are some third party comp... | SelectMany - i.e.
```
IEnumerable<List<string>> someList = ...;
IEnumerable<string> all = someList.SelectMany(x => x);
```
For each item in someList, this then uses the lambda "x => x" to get an IEnumerable<T> for the inner items. In this case, each "x" is a List<T>, which is already IEnumerable<T>.
... |
150,341 | <p>How do people approach mocking out TcpClient (or things like TcpClient)?</p>
<p>I have a service that takes in a TcpClient. Should I wrap that in something else more mockable? How should I approach this?</p>
| [
{
"answer_id": 150480,
"author": "Doron Yaacoby",
"author_id": 3389,
"author_profile": "https://Stackoverflow.com/users/3389",
"pm_score": 6,
"selected": true,
"text": "<p>When coming to mock classes that are not test friendly (i.e. sealed/not implementing any interface/methods are not v... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3285/"
] | How do people approach mocking out TcpClient (or things like TcpClient)?
I have a service that takes in a TcpClient. Should I wrap that in something else more mockable? How should I approach this? | When coming to mock classes that are not test friendly (i.e. sealed/not implementing any interface/methods are not virtual), you would probably want to use the [Adapter](http://en.wikipedia.org/wiki/Adapter_pattern) design pattern.
In this pattern you add a wrapping class that implements an interface. You should then ... |
150,355 | <p>Is there a way to determine how many cores a machine has from C/C++ in a platform-independent way? If no such thing exists, what about determining it per-platform (Windows/*nix/Mac)?</p>
| [
{
"answer_id": 150369,
"author": "Chris Ballance",
"author_id": 1551,
"author_profile": "https://Stackoverflow.com/users/1551",
"pm_score": 2,
"selected": false,
"text": "<p>Windows Server 2003 and later lets you leverage the GetLogicalProcessorInformation function</p>\n\n<p><a href=\"ht... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5066/"
] | Is there a way to determine how many cores a machine has from C/C++ in a platform-independent way? If no such thing exists, what about determining it per-platform (Windows/\*nix/Mac)? | C++11
=====
```
#include <thread>
//may return 0 when not able to detect
const auto processor_count = std::thread::hardware_concurrency();
```
Reference: [std::thread::hardware\_concurrency](http://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency)
---
In C++ prior to C++11, there's no portable way. In... |
150,375 | <p>What do you insert into Python source code to have it break into pdb (when execution gets to that spot)? </p>
| [
{
"answer_id": 150376,
"author": "Daryl Spitzer",
"author_id": 4766,
"author_profile": "https://Stackoverflow.com/users/4766",
"pm_score": 6,
"selected": true,
"text": "<pre><code>import pdb; pdb.set_trace()\n</code></pre>\n\n<p>See <a href=\"http://jjinux.blogspot.com/2007/08/python-cod... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4766/"
] | What do you insert into Python source code to have it break into pdb (when execution gets to that spot)? | ```
import pdb; pdb.set_trace()
```
See [Python: Coding in the Debugger for Beginners](http://jjinux.blogspot.com/2007/08/python-coding-in-debugger-for-beginners.html) for this and more helpful hints. |
150,446 | <p>I want to react when somebody shakes the iPhone. I don't particularly care how they shake it, just that it was waved vigorously about for a split second. Does anyone know how to detect this?</p>
| [
{
"answer_id": 150449,
"author": "camflan",
"author_id": 22445,
"author_profile": "https://Stackoverflow.com/users/22445",
"pm_score": 3,
"selected": false,
"text": "<p>Check out the GLPaint example.</p>\n\n<p><a href=\"http://developer.apple.com/library/ios/#samplecode/GLPaint/Introduct... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7944/"
] | I want to react when somebody shakes the iPhone. I don't particularly care how they shake it, just that it was waved vigorously about for a split second. Does anyone know how to detect this? | In 3.0, there's now an easier way - hook into the new motion events.
The main trick is that you need to have some UIView (not UIViewController) that you want as firstResponder to receive the shake event messages. Here's the code that you can use in any UIView to get shake events:
```
@implementation ShakingView
- (v... |
150,454 | <p>In light of Michael Carman's comment, I have decided to rewrite the question. Note that 11 comments appear before this edit, and give credence to Michael's observation that I did not write the question in a way that made it clear what I was asking.
<hr/>
<em>Question:</em> What is the standard--or <em>cleanest</em>... | [
{
"answer_id": 150483,
"author": "moritz",
"author_id": 14132,
"author_profile": "https://Stackoverflow.com/users/14132",
"pm_score": 1,
"selected": false,
"text": "<p><code>$a</code> and <code>$b</code> are just global variables. You can achieve similar effects by simply declaring <code... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11289/"
] | In light of Michael Carman's comment, I have decided to rewrite the question. Note that 11 comments appear before this edit, and give credence to Michael's observation that I did not write the question in a way that made it clear what I was asking.
---
*Question:* What is the standard--or *cleanest* way--to fake the... | If I'm understanding your question you want to write a module that declares variables in the user's namespace (so they don't have to) and which get localized automatically in callbacks. Is that right?
You can do this by declaring globals and exporting them. (Though do note that it's generally considered bad form to ex... |
150,471 | <p>I have a DataGridView whose DataSource is a DataTable.
This DataTable has a boolean column, which is interpreted as a checkbox in the DataGridView.</p>
<pre><code>employeeSelectionTable.Columns.Add("IsSelected", typeof(bool));
...
employeeSelectionTable.RowChanged += selectionTableRowChanged;
dataGridViewSelectedEm... | [
{
"answer_id": 150482,
"author": "Ian Jacobs",
"author_id": 22818,
"author_profile": "https://Stackoverflow.com/users/22818",
"pm_score": 1,
"selected": false,
"text": "<p>Is there some reason it needs to be done that low level? Can the DoubleClick Method just be an empty method that ea... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a DataGridView whose DataSource is a DataTable.
This DataTable has a boolean column, which is interpreted as a checkbox in the DataGridView.
```
employeeSelectionTable.Columns.Add("IsSelected", typeof(bool));
...
employeeSelectionTable.RowChanged += selectionTableRowChanged;
dataGridViewSelectedEmployees.DataSo... | The reason that making an empty DoubleClick event method would not help would be that is executed in addition to the other operations that happen when a double click occurs.
If you look at the windows generated code or examples of programatically adding event handlers, you use += to assign the event handler. This mean... |
150,505 | <p>I am currently defining regular expressions in order to capture parameters in a URL, as described in the tutorial. How do I access parameters from the URL as part the <code>HttpRequest</code> object?</p>
<p>My <code>HttpRequest.GET</code> currently returns an empty <code>QueryDict</code> object.</p>
<p>I'd like to l... | [
{
"answer_id": 150518,
"author": "camflan",
"author_id": 22445,
"author_profile": "https://Stackoverflow.com/users/22445",
"pm_score": 11,
"selected": true,
"text": "<p>When a URL is like <code>domain/search/?q=haha</code>, you would use <code>request.GET.get('q', '')</code>.</p>\n<p><co... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1227001/"
] | I am currently defining regular expressions in order to capture parameters in a URL, as described in the tutorial. How do I access parameters from the URL as part the `HttpRequest` object?
My `HttpRequest.GET` currently returns an empty `QueryDict` object.
I'd like to learn how to do this without a library, so I can ... | When a URL is like `domain/search/?q=haha`, you would use `request.GET.get('q', '')`.
`q` is the parameter you want, and `''` is the default value if `q` isn't found.
However, if you are instead just configuring your `URLconf`\*\*, then your captures from the `regex` are passed to the function as arguments (or named ... |
150,513 | <p>I have a form in HTML where our users fill in the data and then print it. The data isn't saved anywhere. These forms come from outside our company and are built as html pages to resemble the original as closely as possible and then stuffed away and forgotten in a folder on the intranet. Normally another developer... | [
{
"answer_id": 150521,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 2,
"selected": false,
"text": "<pre><code><input type=\"text\" style=\"border: 0; background-color: #fff;\" />\n</code></pre>\n\n<p>Where #fff is your ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3043/"
] | I have a form in HTML where our users fill in the data and then print it. The data isn't saved anywhere. These forms come from outside our company and are built as html pages to resemble the original as closely as possible and then stuffed away and forgotten in a folder on the intranet. Normally another developer does ... | Add a separate CSS file for printing by doing something like this:
```
<link rel="stylsheet" type="text/css" media="print" href="print.css">
```
add it to the `<head>` section of the page.
In this(print.css) file include styling relevant to what you want to see when the page is printed, for example:
`input{border:... |
150,514 | <p>In the database I have a field named 'body' that has an XML in it. The
method I created in the model looks like this:</p>
<pre><code>def self.get_personal_data_module(person_id)
person_module = find_by_person_id(person_id)
item_module = Hpricot(person_module.body)
personal_info = Array.new
pers... | [
{
"answer_id": 150587,
"author": "Atiaxi",
"author_id": 2555346,
"author_profile": "https://Stackoverflow.com/users/2555346",
"pm_score": 3,
"selected": true,
"text": "<p>This is relatively simple; you're getting an Array because the code is building one. If you wanted to return an objec... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3718/"
] | In the database I have a field named 'body' that has an XML in it. The
method I created in the model looks like this:
```
def self.get_personal_data_module(person_id)
person_module = find_by_person_id(person_id)
item_module = Hpricot(person_module.body)
personal_info = Array.new
personal_info = {:... | This is relatively simple; you're getting an Array because the code is building one. If you wanted to return an object, you'd do something like this:
```
class PersonalData
attr_accessor :studies
attr_accessor :birth_place
attr_accessor :marital_status
def initialize(studies,birth_place,marital_status)
@s... |
150,517 | <p>This is an almost-duplicate of <a href="https://stackoverflow.com/questions/68477/send-file-using-post-from-a-python-script">Send file using POST from a Python script</a>, but I'd like to add a caveat: I need something that properly handles the encoding of fields and attached files. The solutions I've been able to f... | [
{
"answer_id": 151642,
"author": "Dan Lenski",
"author_id": 20789,
"author_profile": "https://Stackoverflow.com/users/20789",
"pm_score": 3,
"selected": false,
"text": "<p>Best thing I can think of is to encode it yourself. How about this subroutine?</p>\n\n<pre><code>from urllib2 impor... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150517",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23582/"
] | This is an almost-duplicate of [Send file using POST from a Python script](https://stackoverflow.com/questions/68477/send-file-using-post-from-a-python-script), but I'd like to add a caveat: I need something that properly handles the encoding of fields and attached files. The solutions I've been able to find blow up wh... | Best thing I can think of is to encode it yourself. How about this subroutine?
```
from urllib2 import Request, urlopen
from binascii import b2a_base64
def b64open(url, postdata):
req = Request(url, b2a_base64(postdata), headers={'Content-Transfer-Encoding': 'base64'})
return urlopen(req)
conn = b64open("http://... |