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 |
|---|---|---|---|---|---|---|
171,529 | <p>I have this Task model:</p>
<pre><code>class Task < ActiveRecord::Base
acts_as_tree :order => 'sort_order'
end
</code></pre>
<p>And I have this test</p>
<pre><code>class TaskTest < Test::Unit::TestCase
def setup
@root = create_root
end
def test_destroying_a_task_should_destroy_all_of_its_des... | [
{
"answer_id": 172553,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 1,
"selected": false,
"text": "<p><code>children</code> <a href=\"http://github.com/rails/acts_as_tree/tree/master/lib/active_record/acts/tree.rb#L47\"... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11082/"
] | I have this Task model:
```
class Task < ActiveRecord::Base
acts_as_tree :order => 'sort_order'
end
```
And I have this test
```
class TaskTest < Test::Unit::TestCase
def setup
@root = create_root
end
def test_destroying_a_task_should_destroy_all_of_its_descendants
d1 = create_task(:parent_id => @r... | I found the bug. The line
```
d1 = create_task(:parent_id => @root.id, :sort_order => 2)
```
creates d1. This calls the `before_save` callback, which in turn calls `self.children`. As Orion pointed out, this caches the children of d1.
However, at this point, d1 doesn't have any children yet. So d1's cache of childr... |
171,541 | <p>I have a service app that creates AppDomain's during the course of its use for long running tasks. I've been tracking these by storing them in a Hashtable with a unique ID.</p>
<p>After a task is completed the service app then unloads the AppDomain allocated to that task and then it's removed it from the appdomain ... | [
{
"answer_id": 172553,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 1,
"selected": false,
"text": "<p><code>children</code> <a href=\"http://github.com/rails/acts_as_tree/tree/master/lib/active_record/acts/tree.rb#L47\"... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/419/"
] | I have a service app that creates AppDomain's during the course of its use for long running tasks. I've been tracking these by storing them in a Hashtable with a unique ID.
After a task is completed the service app then unloads the AppDomain allocated to that task and then it's removed it from the appdomain Hashtable.... | I found the bug. The line
```
d1 = create_task(:parent_id => @root.id, :sort_order => 2)
```
creates d1. This calls the `before_save` callback, which in turn calls `self.children`. As Orion pointed out, this caches the children of d1.
However, at this point, d1 doesn't have any children yet. So d1's cache of childr... |
171,542 | <p>I'm trying to set the width and height of an element with javascript to cover the entire browser viewport, and I'm successful using <pre>document.body.clientHeight</pre> but in IE6 it seems that I always get horizontal and vertical scrollbars because the element must be slightly too big. </p>
<p>Now, I really don't... | [
{
"answer_id": 171544,
"author": "micahwittman",
"author_id": 11181,
"author_profile": "https://Stackoverflow.com/users/11181",
"pm_score": 2,
"selected": false,
"text": "<p>This <em>may</em> help the cause ...</p>\n\n<blockquote>\n <p>From <a href=\"http://andylangton.co.uk/articles/ja... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25066/"
] | I'm trying to set the width and height of an element with javascript to cover the entire browser viewport, and I'm successful using
```
document.body.clientHeight
```
but in IE6 it seems that I always get horizontal and vertical scrollbars because the element must be slightly too big.
Now, I really don't want to us... | have you considered using [jQuery](http://jquery.com)? it abstracts most of the browser specific functionality away into a common interface.
```
var width = $(document).width();
var height = $(document.height();
$('#mySpecialElement').width(width).height(height);
``` |
171,550 | <blockquote>
<p><strong>See also:</strong> <br/>
<em><a href="https://stackoverflow.com/questions/4950725">How can I see which Git branches are tracking which remote / upstream branch?</a></em></p>
</blockquote>
<p>How can I find out which remote branch a local branch is tracking?</p>
<p>Do I need to parse <cod... | [
{
"answer_id": 172075,
"author": "Pat Notz",
"author_id": 825,
"author_profile": "https://Stackoverflow.com/users/825",
"pm_score": -1,
"selected": false,
"text": "<p>I use <a href=\"https://people.gnome.org/~newren/eg/\" rel=\"nofollow noreferrer\">EasyGit (a.k.a. \"eg\")</a> as a super... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | >
> **See also:**
>
> *[How can I see which Git branches are tracking which remote / upstream branch?](https://stackoverflow.com/questions/4950725)*
>
>
>
How can I find out which remote branch a local branch is tracking?
Do I need to parse `git config` output, or is there a command that would do this for me? | [Here](https://git-scm.com/docs/git-branch#Documentation/git-branch.txt--vv) is a command that gives you all tracking branches (configured for 'pull'), see:
```
$ git branch -vv
main aaf02f0 [main/master: ahead 25] Some other commit
* master add0a03 [jdsumsion/master] Some commit
```
You have to wade through the... |
171,566 | <p>Im using delphi's ttreeview as an 'options' menu. how would i go upon selecting the next node at runtime like a previous and next button? i tried the getprev and getnext methods but no luck.</p>
| [
{
"answer_id": 171722,
"author": "John Thomas",
"author_id": 22599,
"author_profile": "https://Stackoverflow.com/users/22599",
"pm_score": 3,
"selected": false,
"text": "<p>Here you have the 'Next' behavior. For 'Previous' I leave as exercise for you: :-)</p>\n\n<pre><code>procedure TFor... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Im using delphi's ttreeview as an 'options' menu. how would i go upon selecting the next node at runtime like a previous and next button? i tried the getprev and getnext methods but no luck. | Here you have the 'Next' behavior. For 'Previous' I leave as exercise for you: :-)
```
procedure TForm8.btn1Click(Sender: TObject);
var
crt: TTreeNode;
begin
with tv1 do //this is our tree
begin
if Selected=nil then
crt:=Items[0] //the first one
else
crt:=Selected.GetNext; //for previous... |
171,569 | <p>Actually I will want to use that JeOS for our webserver. Is it a good choice?</p>
| [
{
"answer_id": 171722,
"author": "John Thomas",
"author_id": 22599,
"author_profile": "https://Stackoverflow.com/users/22599",
"pm_score": 3,
"selected": false,
"text": "<p>Here you have the 'Next' behavior. For 'Previous' I leave as exercise for you: :-)</p>\n\n<pre><code>procedure TFor... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Actually I will want to use that JeOS for our webserver. Is it a good choice? | Here you have the 'Next' behavior. For 'Previous' I leave as exercise for you: :-)
```
procedure TForm8.btn1Click(Sender: TObject);
var
crt: TTreeNode;
begin
with tv1 do //this is our tree
begin
if Selected=nil then
crt:=Items[0] //the first one
else
crt:=Selected.GetNext; //for previous... |
171,588 | <p>If I modify or add an environment variable I have to restart the command prompt. Is there a command I could execute that would do this without restarting CMD?</p>
| [
{
"answer_id": 171593,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 6,
"selected": false,
"text": "<p>By design there isn't a <strong>built in</strong> mechanism for Windows to propagate an environment variable add/change/remove ... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] | If I modify or add an environment variable I have to restart the command prompt. Is there a command I could execute that would do this without restarting CMD? | You can capture the system environment variables with a vbs script, but you need a bat script to actually change the current environment variables, so this is a combined solution.
Create a file named `resetvars.vbs` containing this code, and save it on the path:
```vb
Set oShell = WScript.CreateObject("WScript.Shell"... |
171,596 | <p>After having implemented the strategy pattern, I wanted to make an array of the interface-type, to which I can then add any concrete type. </p>
<p>For those who don't know the strategy pattern:
<a href="http://en.wikipedia.org/wiki/Strategy_pattern" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Strategy_pa... | [
{
"answer_id": 171599,
"author": "Keith Nicholas",
"author_id": 10431,
"author_profile": "https://Stackoverflow.com/users/10431",
"pm_score": 2,
"selected": false,
"text": "<p>store pointers not objects..... use boost::shared_ptr if you are wanting to store objects.</p>\n"
},
{
... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23163/"
] | After having implemented the strategy pattern, I wanted to make an array of the interface-type, to which I can then add any concrete type.
For those who don't know the strategy pattern:
<http://en.wikipedia.org/wiki/Strategy_pattern>
In this particular example I would want to make a StrategyInterface array, which I c... | Make the array store pointers to the interface type:
```
typedef std::vector<Interface *> Array;
Array myArray;
myArray.push_back(new A());
```
Additionally, you can use ptr\_vector which manages memory for you:
```
typedef boost::ptr_vector<Interface> Array;
// the rest is the same
``` |
171,640 | <p>In multi-threaded code, when an instance may be read or written by multiple threads, they need to be locked on to perform these operations safely.</p>
<p>To avoid the repetition of creating an object to lock on and writing a bunch of lock statements through code, I've created a generic class to handle the locking. ... | [
{
"answer_id": 171659,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>That only locks for the duration of the get/set; of course, in many common cases this will be atomic anyway, simpl... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11574/"
] | In multi-threaded code, when an instance may be read or written by multiple threads, they need to be locked on to perform these operations safely.
To avoid the repetition of creating an object to lock on and writing a bunch of lock statements through code, I've created a generic class to handle the locking.
Am I mis... | That only locks for the duration of the get/set; of course, in many common cases this will be atomic anyway, simply due to to data size.
However, in reality most locks need to span more than this, in the same way that collections locking over just the Add etc don't help much - a caller typically needs a single lock to... |
171,641 | <p>When maintaining a <code>COM</code> interface should an empty <code>BSTR</code> be treated the same way as <code>NULL</code>?
In other words should these two function calls produce the same result?</p>
<pre><code> // Empty BSTR
CComBSTR empty(L""); // Or SysAllocString(L"")
someObj->Foo(empty);
// NULL BSTR
... | [
{
"answer_id": 171644,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 5,
"selected": true,
"text": "<p>Yes - a NULL BSTR is the same as an empty one. I remember we had all sorts of bugs that were uncovered when we sw... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3848/"
] | When maintaining a `COM` interface should an empty `BSTR` be treated the same way as `NULL`?
In other words should these two function calls produce the same result?
```
// Empty BSTR
CComBSTR empty(L""); // Or SysAllocString(L"")
someObj->Foo(empty);
// NULL BSTR
someObj->Foo(NULL);
``` | Yes - a NULL BSTR is the same as an empty one. I remember we had all sorts of bugs that were uncovered when we switched from VS6 to 2003 - the CComBSTR class had a change to the default constructor that allocated it using NULL rather than an empty string. This happens when you for example treat a BSTR as a regular C st... |
171,662 | <p>I'm trying to output a list of string values into a 2 column format. The standard way of making a list of strings into "normal text" is by using the <strong>string.join</strong> method. However, it only takes 2 arguments so I can only make a single column using "\n". I thought trying to make a loop that would simply... | [
{
"answer_id": 171686,
"author": "Douglas Leeder",
"author_id": 3978,
"author_profile": "https://Stackoverflow.com/users/3978",
"pm_score": 0,
"selected": false,
"text": "<pre><code>data = [ (\"1\",\"2\"),(\"3\",\"4\") ]\nprint \"\\n\".join(map(\"\\t\".join,data))\n</code></pre>\n\n<p>No... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18676/"
] | I'm trying to output a list of string values into a 2 column format. The standard way of making a list of strings into "normal text" is by using the **string.join** method. However, it only takes 2 arguments so I can only make a single column using "\n". I thought trying to make a loop that would simply add a tab betwe... | Two columns, separated by tabs, joined into lines. Look in *itertools* for iterator equivalents, to achieve a space-efficient solution.
```
import string
def fmtpairs(mylist):
pairs = zip(mylist[::2],mylist[1::2])
return '\n'.join('\t'.join(i) for i in pairs)
print fmtpairs(list(string.ascii_uppercase))
A ... |
171,664 | <p>I have not used generics much and so cannot figure out if it is possible to turn the following three methods into one using generics to reduce duplication. Actually my code currently has six methods but if you can solve it for the three then the rest should just work anyway with the same solution.</p>
<pre><code> ... | [
{
"answer_id": 171668,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "<p>Generics doesn't natively support arithmetic. However, it can be done with .NET 3.5, <a href=\"http://www.pobox.com... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6276/"
] | I have not used generics much and so cannot figure out if it is possible to turn the following three methods into one using generics to reduce duplication. Actually my code currently has six methods but if you can solve it for the three then the rest should just work anyway with the same solution.
```
private obje... | Generics doesn't natively support arithmetic. However, it can be done with .NET 3.5, [like so](http://www.pobox.com/~skeet/csharp/miscutil/usage/genericoperators.html). The Operator class is part of [MiscUtil](http://www.yoda.arachsys.com/csharp/miscutil/). This then becomes:
```
public T Evaluate<T>(T x, T y) {
... |
171,673 | <p>I've been trying to create a Windows Media Player plugin in Visual Studio 2008, and am having great difficulty finding the correct template. MSDN provides advice <a href="http://msdn.microsoft.com/en-us/library/bb262076(VS.85).aspx" rel="nofollow noreferrer">here</a>, but it does not appear to be relevant to VS2008.... | [
{
"answer_id": 171668,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "<p>Generics doesn't natively support arithmetic. However, it can be done with .NET 3.5, <a href=\"http://www.pobox.com... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11484/"
] | I've been trying to create a Windows Media Player plugin in Visual Studio 2008, and am having great difficulty finding the correct template. MSDN provides advice [here](http://msdn.microsoft.com/en-us/library/bb262076(VS.85).aspx), but it does not appear to be relevant to VS2008.
Can anyone suggest how to start a WMP ... | Generics doesn't natively support arithmetic. However, it can be done with .NET 3.5, [like so](http://www.pobox.com/~skeet/csharp/miscutil/usage/genericoperators.html). The Operator class is part of [MiscUtil](http://www.yoda.arachsys.com/csharp/miscutil/). This then becomes:
```
public T Evaluate<T>(T x, T y) {
... |
171,730 | <p>I have a small problem with interfaces. Here it is in Pseudo code :</p>
<pre><code>type
Interface1 = interface
end;
Interface2 = interface
end;
TParentClass = class(TInterfacedObject, Interface1)
private
fChild : Interface2;
public
procedure AddChild(aChild : Interface2);
end;
TChildCla... | [
{
"answer_id": 171738,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 1,
"selected": false,
"text": "<p>You must make a method that explicitly unlinks the right references. There is no way to get the automatic referenc... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22712/"
] | I have a small problem with interfaces. Here it is in Pseudo code :
```
type
Interface1 = interface
end;
Interface2 = interface
end;
TParentClass = class(TInterfacedObject, Interface1)
private
fChild : Interface2;
public
procedure AddChild(aChild : Interface2);
end;
TChildClass = class(TIn... | A reference-counted reference has two semantics: it acts as a share of ownership as well as a means of navigating the object graph.
Typically, you don't need **both** of these semantics on all links in a cycle in the graph of references. Perhaps only parents own children, and not the other way around? If that is the c... |
171,755 | <p>Is it possible to implement the <a href="http://en.wikipedia.org/wiki/Visitor_pattern" rel="noreferrer">Visitor Pattern</a> respecting the <a href="http://en.wikipedia.org/wiki/Open/closed_principle" rel="noreferrer">Open/Closed Principle</a>, but still be able to add new visitable classes?</p>
<p>The Open/Closed P... | [
{
"answer_id": 171768,
"author": "Brian",
"author_id": 19299,
"author_profile": "https://Stackoverflow.com/users/19299",
"pm_score": 2,
"selected": false,
"text": "<p>You might want to check out research on \"the expression problem\", see e.g.</p>\n\n<p><a href=\"http://lambda-the-ultima... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19100/"
] | Is it possible to implement the [Visitor Pattern](http://en.wikipedia.org/wiki/Visitor_pattern) respecting the [Open/Closed Principle](http://en.wikipedia.org/wiki/Open/closed_principle), but still be able to add new visitable classes?
The Open/Closed Principle states that "software entities (classes, modules, functio... | In C++, [Acyclic Visitor](https://condor.depaul.edu/dmumaugh/OOT/Design-Principles/acv.pdf) (pdf) gets you what you want. |
171,765 | <p>Here's the very dumb way:</p>
<pre><code>def divisorGenerator(n):
for i in xrange(1,n/2+1):
if n%i == 0: yield i
yield n
</code></pre>
<p>The result I'd like to get is similar to this one, but I'd like a smarter algorithm (this one it's too much slow and dumb :-)</p>
<p>I can find prime factors an... | [
{
"answer_id": 171779,
"author": "Matthew Scharley",
"author_id": 15537,
"author_profile": "https://Stackoverflow.com/users/15537",
"pm_score": 5,
"selected": false,
"text": "<p>To expand on what Shimi has said, you should only be running your loop from 1 to the square root of n. Then to... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21384/"
] | Here's the very dumb way:
```
def divisorGenerator(n):
for i in xrange(1,n/2+1):
if n%i == 0: yield i
yield n
```
The result I'd like to get is similar to this one, but I'd like a smarter algorithm (this one it's too much slow and dumb :-)
I can find prime factors and their multiplicity fast enough.... | Given your `factorGenerator` function, here is a `divisorGen` that should work:
```
def divisorGen(n):
factors = list(factorGenerator(n))
nfactors = len(factors)
f = [0] * nfactors
while True:
yield reduce(lambda x, y: x*y, [factors[x][0]**f[x] for x in range(nfactors)], 1)
i = 0
... |
171,771 | <p>Okay, so I'm doing my first foray into using the ADO.NET Entity Framework. </p>
<p>My test case right now includes a SQL Server 2008 database with 2 tables, Member and Profile, with a 1:1 relationship.</p>
<p>I then used the Entity Data Model wizard to auto-generate the EDM from the database. It generated a model ... | [
{
"answer_id": 173273,
"author": "Gerald",
"author_id": 19404,
"author_profile": "https://Stackoverflow.com/users/19404",
"pm_score": 4,
"selected": true,
"text": "<p>Okay I managed to find the answer I needed here <a href=\"http://msdn.microsoft.com/en-us/magazine/cc507640.aspx\" rel=\"... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19404/"
] | Okay, so I'm doing my first foray into using the ADO.NET Entity Framework.
My test case right now includes a SQL Server 2008 database with 2 tables, Member and Profile, with a 1:1 relationship.
I then used the Entity Data Model wizard to auto-generate the EDM from the database. It generated a model with the correct ... | Okay I managed to find the answer I needed here <http://msdn.microsoft.com/en-us/magazine/cc507640.aspx>. The following query will make sure that the Profile entity is loaded:
```
IQueryable<Member> membersQuery = from m in members.Include("Profile") select m;
``` |
171,776 | <p>I've looked at <a href="http://en.wikipedia.org/wiki/Strategy_pattern" rel="noreferrer">this explanation on Wikipedia</a>, specifically the C++ sample, and fail to recognize the difference between just defining 3 classes, creating instances and calling them, and that example. What I saw was just placing two other cl... | [
{
"answer_id": 171781,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 1,
"selected": false,
"text": "<p>In the Wikipedia example, those instances can be passed into a function that doesn't have to care which class those insta... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15161/"
] | I've looked at [this explanation on Wikipedia](http://en.wikipedia.org/wiki/Strategy_pattern), specifically the C++ sample, and fail to recognize the difference between just defining 3 classes, creating instances and calling them, and that example. What I saw was just placing two other classes into the process and cann... | The point is to separate algorithms into classes that can be plugged in at runtime. For instance, let's say you have an application that includes a clock. There are many different ways that you can draw a clock, but for the most part the underlying functionality is the same. So you can create a clock display interface:... |
171,778 | <p>Using NHibernate from C# and only HQL (not SQL) in a way that is compatible with MS SQL Server 2005/2008 (and preferably Oracle).</p>
<p>Is there a way to write the order by clause so that nulls will sort at the end of the query results while the non-null results will be sorted in ascending order?</p>
<p>Based on ... | [
{
"answer_id": 171781,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 1,
"selected": false,
"text": "<p>In the Wikipedia example, those instances can be passed into a function that doesn't have to care which class those insta... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3509/"
] | Using NHibernate from C# and only HQL (not SQL) in a way that is compatible with MS SQL Server 2005/2008 (and preferably Oracle).
Is there a way to write the order by clause so that nulls will sort at the end of the query results while the non-null results will be sorted in ascending order?
Based on the answer to the... | The point is to separate algorithms into classes that can be plugged in at runtime. For instance, let's say you have an application that includes a clock. There are many different ways that you can draw a clock, but for the most part the underlying functionality is the same. So you can create a clock display interface:... |
171,824 | <p>I have a plug-in to an Eclipse RCP application that has a view. After an event occurs in the RCP application, the plug-in is instantiated, its methods are called to populate the plug-in's model, but I cannot find how to make the view appear without going to the "Show View..." menu.</p>
<p>I would think that there ... | [
{
"answer_id": 172082,
"author": "ILikeCoffee",
"author_id": 25270,
"author_profile": "https://Stackoverflow.com/users/25270",
"pm_score": 7,
"selected": true,
"text": "<p>You are probably looking for this:</p>\n\n<pre><code>PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActiveP... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/725/"
] | I have a plug-in to an Eclipse RCP application that has a view. After an event occurs in the RCP application, the plug-in is instantiated, its methods are called to populate the plug-in's model, but I cannot find how to make the view appear without going to the "Show View..." menu.
I would think that there would be so... | You are probably looking for this:
```
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("viewId");
``` |
171,828 | <p>When receiving a bug report or an it-doesnt-work message one of my initials questions is always what version? With a different builds being at many stages of testing, planning and deploying this is often a non-trivial question.</p>
<p>I the case of releasing Java JAR (ear, jar, rar, war) files I would like to be ab... | [
{
"answer_id": 171851,
"author": "svrist",
"author_id": 86,
"author_profile": "https://Stackoverflow.com/users/86",
"pm_score": 1,
"selected": false,
"text": "<p>From the top of my mind. A tag for each jar build?</p>\n"
},
{
"answer_id": 171858,
"author": "Martin",
"autho... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16352/"
] | When receiving a bug report or an it-doesnt-work message one of my initials questions is always what version? With a different builds being at many stages of testing, planning and deploying this is often a non-trivial question.
I the case of releasing Java JAR (ear, jar, rar, war) files I would like to be able to look... | Use the *svnversion* command in your Ant script to get the revision number:
```
<exec executable="svnversion" outputproperty="svnversion" failonerror="true">
<env key="path" value="/usr/bin"/>
<arg value="--no-newline" />
</exec>
```
Then use the *${svnversion}* property somewhere in your EAR. We put it in the E... |
171,849 | <p>I have a program that spits out an Excel workbook in Excel 2003 XML format. It works fine with one problem, I cannot get the column widths to set automatically.</p>
<p>A snippet of what I produce:</p>
<pre><code> <Table >
<Column ss:AutoFitWidth="1" ss:Width="2"/>
<Row ss:AutoFitHeight="0" s... | [
{
"answer_id": 172057,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": true,
"text": "<p>Only date and number values are autofitted :-(\nquote: \"... We do not autofit textual values\"</p>\n\n<p><a href=\"http://m... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5189/"
] | I have a program that spits out an Excel workbook in Excel 2003 XML format. It works fine with one problem, I cannot get the column widths to set automatically.
A snippet of what I produce:
```
<Table >
<Column ss:AutoFitWidth="1" ss:Width="2"/>
<Row ss:AutoFitHeight="0" ss:Height="14.55">
<Cell ss:StyleI... | Only date and number values are autofitted :-(
quote: "... We do not autofit textual values"
<http://msdn.microsoft.com/en-us/library/aa140066.aspx#odc_xmlss_ss:column> |
171,862 | <p>When authoring a library in a particular namespace, it's often convenient to provide overloaded operators for the classes in that namespace. It seems (at least with g++) that the overloaded operators can be implemented either in the library's namespace:</p>
<pre><code>namespace Lib {
class A {
};
A operator+(cons... | [
{
"answer_id": 171869,
"author": "David Pierre",
"author_id": 18296,
"author_profile": "https://Stackoverflow.com/users/18296",
"pm_score": 6,
"selected": true,
"text": "<p>You should define them in the library namespace.\nThe compiler will find them anyway through argument dependant loo... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/78437/"
] | When authoring a library in a particular namespace, it's often convenient to provide overloaded operators for the classes in that namespace. It seems (at least with g++) that the overloaded operators can be implemented either in the library's namespace:
```
namespace Lib {
class A {
};
A operator+(const A&, const A&)... | You should define them in the library namespace.
The compiler will find them anyway through argument dependant lookup.
No need to pollute the global namespace. |
171,873 | <p>I try to write KSH script for processing a file consisting of name-value pairs, several of them on each line.</p>
<p>Format is:</p>
<pre><code>NAME1 VALUE1,NAME2 VALUE2,NAME3 VALUE3, etc
</code></pre>
<p>Suppose I write:</p>
<pre><code>read l
IFS=","
set -A nvls $l
echo "$nvls[2]"
</code></pre>
<p>This will giv... | [
{
"answer_id": 171945,
"author": "ADEpt",
"author_id": 10105,
"author_profile": "https://Stackoverflow.com/users/10105",
"pm_score": 1,
"selected": false,
"text": "<p>As it often happens, I deviced an answer minutes after asking the question in public forum :(</p>\n\n<p>I worked around t... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10105/"
] | I try to write KSH script for processing a file consisting of name-value pairs, several of them on each line.
Format is:
```
NAME1 VALUE1,NAME2 VALUE2,NAME3 VALUE3, etc
```
Suppose I write:
```
read l
IFS=","
set -A nvls $l
echo "$nvls[2]"
```
This will give me second name-value pair, nice and easy. Now, suppose... | You can also change the `\,` pattern to something else that is known not to appear in any of your strings, and then change it back after you've split the input into an array. You can use the ksh builtin pattern-substitution syntax to do this, you don't need to use sed or awk or anything.
```
read l
l=${l//\\,/!!}
IFS=... |
171,924 | <p>Is it possible to check a bash script syntax without executing it?</p>
<p>Using Perl, I can run <code>perl -c 'script name'</code>. Is there any equivalent command for bash scripts?</p>
| [
{
"answer_id": 171932,
"author": "andy",
"author_id": 6152,
"author_profile": "https://Stackoverflow.com/users/6152",
"pm_score": 10,
"selected": true,
"text": "<pre><code>bash -n scriptname\n</code></pre>\n\n<p>Perhaps an obvious caveat: this validates syntax but won't check if your bas... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13523/"
] | Is it possible to check a bash script syntax without executing it?
Using Perl, I can run `perl -c 'script name'`. Is there any equivalent command for bash scripts? | ```
bash -n scriptname
```
Perhaps an obvious caveat: this validates syntax but won't check if your bash script tries to execute a command that isn't in your path, like `ech hello` instead of `echo hello`. |
171,928 | <p>I am using the <a href="https://jqueryui.com/dialog/" rel="noreferrer"><code>jquery-ui-dialog</code></a> plugin</p>
<p>I am looking for way to refresh the page when in some circumstances when the dialog is closed.</p>
<p>Is there a way to capture a close event from the dialog?</p>
<p>I know I can run code when th... | [
{
"answer_id": 171953,
"author": "andy",
"author_id": 6152,
"author_profile": "https://Stackoverflow.com/users/6152",
"pm_score": 2,
"selected": false,
"text": "<p>If I'm understanding the type of window you're talking about, wouldn't <b>$(window).unload()</b> (for the dialog window) giv... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6600/"
] | I am using the [`jquery-ui-dialog`](https://jqueryui.com/dialog/) plugin
I am looking for way to refresh the page when in some circumstances when the dialog is closed.
Is there a way to capture a close event from the dialog?
I know I can run code when the close button is clicked but that doesn't cover the user closi... | I have found it!
You can catch the close event using the following code:
```
$('div#popup_content').on('dialogclose', function(event) {
alert('closed');
});
```
Obviously I can replace the alert with whatever I need to do.
**Edit:** As of Jquery 1.7, the bind() has become on() |
171,962 | <p>I'm storing all localizable strings in a <code>ResourceDictionary</code> (in <code>App.xaml</code>) and assign those via the <code>StaticResource</code> markup extension to <code>TextBlock.Text</code>, <code>Button.Content</code> etc.</p>
<p>In Beta 2 and RC0, <em>sometimes</em> parsing the XAML in <code>Initialize... | [
{
"answer_id": 179607,
"author": "Brian Leahy",
"author_id": 580,
"author_profile": "https://Stackoverflow.com/users/580",
"pm_score": 2,
"selected": false,
"text": "<p>Parser, at least in beta 2, didnt like whitespace...</p>\n\n<p>For instance: </p>\n\n<pre><code>Text=\"{StaticResource... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23222/"
] | I'm storing all localizable strings in a `ResourceDictionary` (in `App.xaml`) and assign those via the `StaticResource` markup extension to `TextBlock.Text`, `Button.Content` etc.
In Beta 2 and RC0, *sometimes* parsing the XAML in `InitializeComponent()` will fail with an `AG_E_PARSER_BAD_PROPERTY_VALUE` on the line a... | Parser, at least in beta 2, didnt like whitespace...
For instance:
```
Text="{StaticResource bleh}"
```
worked
however this:
```
Text = "{StaticResource bleh}"
```
bombed |
171,970 | <p>When logging in C#, how can I learn the name of the method that called the current method? I know all about <code>System.Reflection.MethodBase.GetCurrentMethod()</code>, but I want to go one step beneath this in the stack trace. I've considered parsing the stack trace, but I am hoping to find a cleaner more explicit... | [
{
"answer_id": 171974,
"author": "Firas Assaad",
"author_id": 23153,
"author_profile": "https://Stackoverflow.com/users/23153",
"pm_score": 10,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code>using System.Diagnostics;\n// Get call stack\nStackTrace stackTrace = new StackTrace()... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/470/"
] | When logging in C#, how can I learn the name of the method that called the current method? I know all about `System.Reflection.MethodBase.GetCurrentMethod()`, but I want to go one step beneath this in the stack trace. I've considered parsing the stack trace, but I am hoping to find a cleaner more explicit way, somethin... | Try this:
```
using System.Diagnostics;
// Get call stack
StackTrace stackTrace = new StackTrace();
// Get calling method name
Console.WriteLine(stackTrace.GetFrame(1).GetMethod().Name);
```
one-liner:
```
(new System.Diagnostics.StackTrace()).GetFrame(1).GetMethod().Name
```
It is from *[Get Calling Method usin... |
171,999 | <p>How can I extract the whole line in a row, for example, row 3.
These data are saved in my text editor in linux.
Here's my data:</p>
<pre><code>1,julz,kath,shiela,angel
2,may,ann,janice,aika
3,christal,justine,kim
4,kris,allan,jc,mine
</code></pre>
<p>I want output like:</p>
<pre><code>3,christal,justine,kim
</cod... | [
{
"answer_id": 172005,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 2,
"selected": false,
"text": "<p>You can assign the diamond operator on your filehandle to a list, each element will be a line or row.</p>\n\n<pre... | 2008/10/05 | [
"https://Stackoverflow.com/questions/171999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I extract the whole line in a row, for example, row 3.
These data are saved in my text editor in linux.
Here's my data:
```
1,julz,kath,shiela,angel
2,may,ann,janice,aika
3,christal,justine,kim
4,kris,allan,jc,mine
```
I want output like:
```
3,christal,justine,kim
``` | The following snippet reads in the first three lines, prints only the third then exits to ensure that no unnecessary processing takes place.
Without the exit, the script would continue to process the input file despite you knowing that you have no use for it.
```
perl -ne 'if ($. == 3) {print;exit}' infile.txt
```
... |
172,018 | <p>Is there a way to exclude all svn externals when doing a recursive update?</p>
<p>Is there a way to exclude only 1 of all of the svn externals when doing a recursive update?</p>
<p>Basically I'd like to cut down the svn update time, and a couple of the SVN externals that I have will just about never get updated.</... | [
{
"answer_id": 172043,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 6,
"selected": true,
"text": "<p>Yes, there is an option for this (to ignore all):</p>\n\n<pre><code>> svn update --ignore-externals\n</code></p... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] | Is there a way to exclude all svn externals when doing a recursive update?
Is there a way to exclude only 1 of all of the svn externals when doing a recursive update?
Basically I'd like to cut down the svn update time, and a couple of the SVN externals that I have will just about never get updated. | Yes, there is an option for this (to ignore all):
```
> svn update --ignore-externals
```
I don't know of any option to specifically ignore one or some externals while updating the rest. |
172,095 | <p>I'm doing some experiments with Microsoft Dynamics CRM. You interact with it through web services and I have added a Web Reference to my project. The web service interface is very rich, and the generated "Reference.cs" is some 90k loc. </p>
<p>I'm using the web reference in a console application. I often change som... | [
{
"answer_id": 172106,
"author": "Alex Lyman",
"author_id": 5897,
"author_profile": "https://Stackoverflow.com/users/5897",
"pm_score": 1,
"selected": false,
"text": "<p>You might wish to look into the <a href=\"http://msdn.microsoft.com/en-us/library/bk3w6240(VS.80).aspx\" rel=\"nofollo... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2942/"
] | I'm doing some experiments with Microsoft Dynamics CRM. You interact with it through web services and I have added a Web Reference to my project. The web service interface is very rich, and the generated "Reference.cs" is some 90k loc.
I'm using the web reference in a console application. I often change something, re... | The following is ripped from [this](http://communities.vmware.com/thread/47063) thread on the VMWare forums:
Hi folks,
We've found that sgen.exe does work. It'just that there is a couple of additional steps beyond pre-generating the serializer dll's that we missed in this thread. Here is the detailed instruction
PRO... |
172,110 | <p>How can I elegantly print the date in RFC822 format in Perl?</p>
| [
{
"answer_id": 172119,
"author": "njsf",
"author_id": 4995,
"author_profile": "https://Stackoverflow.com/users/4995",
"pm_score": 6,
"selected": true,
"text": "<pre><code>use POSIX qw(strftime);\nprint strftime(\"%a, %d %b %Y %H:%M:%S %z\", localtime(time())) . \"\\n\";\n</code></pre>\n"... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13523/"
] | How can I elegantly print the date in RFC822 format in Perl? | ```
use POSIX qw(strftime);
print strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time())) . "\n";
``` |
172,111 | <p>Is it possible to get notified (without polling, but via an event) when a drive letter becomes accessible. For example if you have an external hard drive that always appears as drive F - is it possible to have an event raised when that is connected and F becomes accessible?</p>
| [
{
"answer_id": 172119,
"author": "njsf",
"author_id": 4995,
"author_profile": "https://Stackoverflow.com/users/4995",
"pm_score": 6,
"selected": true,
"text": "<pre><code>use POSIX qw(strftime);\nprint strftime(\"%a, %d %b %Y %H:%M:%S %z\", localtime(time())) . \"\\n\";\n</code></pre>\n"... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1912/"
] | Is it possible to get notified (without polling, but via an event) when a drive letter becomes accessible. For example if you have an external hard drive that always appears as drive F - is it possible to have an event raised when that is connected and F becomes accessible? | ```
use POSIX qw(strftime);
print strftime("%a, %d %b %Y %H:%M:%S %z", localtime(time())) . "\n";
``` |
172,151 | <p>I want to write a program in which plays an audio file that reads a text.
I want to highlite the current syllable that the audiofile plays in green and the rest of the current word in red.
What kind of datastructure should I use to store the audio file and the information that tells the program when to switch to th... | [
{
"answer_id": 172165,
"author": "anjanb",
"author_id": 11142,
"author_profile": "https://Stackoverflow.com/users/11142",
"pm_score": 0,
"selected": false,
"text": "<p>you might want to get familiar with FreeTTS -- this open source tool : <a href=\"http://freetts.sourceforge.net/docs/ind... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25282/"
] | I want to write a program in which plays an audio file that reads a text.
I want to highlite the current syllable that the audiofile plays in green and the rest of the current word in red.
What kind of datastructure should I use to store the audio file and the information that tells the program when to switch to the n... | This is a slightly left-field suggestion, but have you looked at Karaoke software? It may not be seen as "serious" enough, but it sounds very similar to what you're doing. For example, [Aegisub](http://www.aegisub.net/) is a subtitling program that lets you create subtitles in the SSA/ASS format. It has karaoke tools f... |
172,156 | <p>I get the Total length of columns in constraint is too long. erro from the following</p>
<pre><code>sql] Failed to execute: CREATE TABLE GTW_WORKFLOW_MON ( WORKFLOW_NAME VARCHAR(255) NOT
NULL, WORKFLOW_LOADED NUMERIC(20) NOT NULL, ACTIVITY_NAME VARCHAR(255) NOT NULL, FLAGS
INTEGER NOT NULL, MONITOR_NAME VARCH... | [
{
"answer_id": 172382,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 3,
"selected": true,
"text": "<p>Your primary key constraint is 785 bytes (255+20+255+255). If you increase your database page size to 4K it should ... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15352/"
] | I get the Total length of columns in constraint is too long. erro from the following
```
sql] Failed to execute: CREATE TABLE GTW_WORKFLOW_MON ( WORKFLOW_NAME VARCHAR(255) NOT
NULL, WORKFLOW_LOADED NUMERIC(20) NOT NULL, ACTIVITY_NAME VARCHAR(255) NOT NULL, FLAGS
INTEGER NOT NULL, MONITOR_NAME VARCHAR(255) NOT NU... | Your primary key constraint is 785 bytes (255+20+255+255). If you increase your database page size to 4K it should work, barely. You should also reconsider if you need your columns to be as wide as you are defining them.
I found a discussion group where an engineer, Radhika Gadde, [describes](http://www.iiug.org/forum... |
172,175 | <p>Here's my code in a gridview that is bound at runtime:</p>
<pre><code>...
<asp:templatefield>
<edititemtemplate>
<asp:dropdownlist runat="server" id="ddgvOpp" />
</edititemtemplate>
<itemtemplate>
<%# Eval("opponent.name") %>
</itemtemplate>
... | [
{
"answer_id": 172220,
"author": "Jason",
"author_id": 7173,
"author_profile": "https://Stackoverflow.com/users/7173",
"pm_score": 4,
"selected": true,
"text": "<p>Ok, I guess I'm just dumb. I figured it out.</p>\n\n<p>In the RowDataBound event, simply add the following conditional:</p>... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7173/"
] | Here's my code in a gridview that is bound at runtime:
```
...
<asp:templatefield>
<edititemtemplate>
<asp:dropdownlist runat="server" id="ddgvOpp" />
</edititemtemplate>
<itemtemplate>
<%# Eval("opponent.name") %>
</itemtemplate>
</asp:templatefield>
...
```
I want to bind the dropdo... | Ok, I guess I'm just dumb. I figured it out.
In the RowDataBound event, simply add the following conditional:
```
if (myGridView.EditIndex == e.Row.RowIndex)
{
//do work
}
``` |
172,176 | <p>What is the best way to deal with storing and indexing URL's in SQL Server 2005? </p>
<p>I have a WebPage table that stores metadata and content about Web Pages. I also have many other tables related to the WebPage table. They all use URL as a key. </p>
<p>The problem is URL's can be very large, and using them as ... | [
{
"answer_id": 172180,
"author": "David Robbins",
"author_id": 19799,
"author_profile": "https://Stackoverflow.com/users/19799",
"pm_score": 1,
"selected": false,
"text": "<p>I would stick with the hash solution. This generates a unique key with a fairly low chance of collision. </p>\n... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1982/"
] | What is the best way to deal with storing and indexing URL's in SQL Server 2005?
I have a WebPage table that stores metadata and content about Web Pages. I also have many other tables related to the WebPage table. They all use URL as a key.
The problem is URL's can be very large, and using them as a key makes the i... | I'd use a normal identity column as the primary key. You say:
>
> This keeps all the associated indexes smaller and more efficient
> but it makes importing data a bit of a pain. Each import for the
> associated tables has to first lookup what the id of a url is
> before inserting data in the tables.
>
>
>
Yes... |
172,199 | <p>Where can I find a list of all types of bsd style socket errors?</p>
| [
{
"answer_id": 172216,
"author": "Head Geek",
"author_id": 12193,
"author_profile": "https://Stackoverflow.com/users/12193",
"pm_score": 2,
"selected": false,
"text": "<p>You can also find a list of error codes (and a general description of their meaning) on the Open Group's pages for ea... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4946/"
] | Where can I find a list of all types of bsd style socket errors? | In the documentation? For instance, for connect(), see:
```
% man connect
...
ECONNREFUSED
No-one listening on the remote address.
EISCONN
The socket is already connected.
ENETUNREACH
Network is unreachable.
``` |
172,203 | <p>I can get both System.Net.Mail and System.Web.Mail to work with GMail, but I can't get them both to work with smtp.att.yahoo.com.</p>
<p>I get the SMTP settings from my own Web.config keys. These settings work when I send using System.Web.Mail, but fail with System.Net.Mail.</p>
<pre><code> <add key="SmtpS... | [
{
"answer_id": 172922,
"author": "Corey Trager",
"author_id": 9328,
"author_profile": "https://Stackoverflow.com/users/9328",
"pm_score": 4,
"selected": true,
"text": "<p>I've learned the answer. The answer is:</p>\n\n<p>Because System.Net.Mail does not support \"implicit\" SSL, only \"... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9328/"
] | I can get both System.Net.Mail and System.Web.Mail to work with GMail, but I can't get them both to work with smtp.att.yahoo.com.
I get the SMTP settings from my own Web.config keys. These settings work when I send using System.Web.Mail, but fail with System.Net.Mail.
```
<add key="SmtpServer" value="smtp.att.yah... | I've learned the answer. The answer is:
Because System.Net.Mail does not support "implicit" SSL, only "explicit" SSL. |
172,223 | <p>From the Apple <a href="http://developer.apple.com/internet/safari/faq.html" rel="noreferrer">developer faq</a></p>
<blockquote>
<p>Safari ships with a conservative
cookie policy which limits cookie
writes to only the pages chosen
("navigated to") by the user.</p>
</blockquote>
<p>By default Safari only al... | [
{
"answer_id": 1032746,
"author": "M.W. Felker",
"author_id": 127012,
"author_profile": "https://Stackoverflow.com/users/127012",
"pm_score": 3,
"selected": false,
"text": "<p>This is an issue known as Same Origin Policy. Essentially it is a security measure against creating security loo... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25286/"
] | From the Apple [developer faq](http://developer.apple.com/internet/safari/faq.html)
>
> Safari ships with a conservative
> cookie policy which limits cookie
> writes to only the pages chosen
> ("navigated to") by the user.
>
>
>
By default Safari only allows cookies from sites you navigate to directly. (i.e. i... | This is an issue known as Same Origin Policy. Essentially it is a security measure against creating security loopholes.
When you have an iframe that points to a page on your own domain, JavaScript can access both the page you're on and the page within the Iframe. This is an acceptable parent to child and child to par... |
172,258 | <p>I've written up a weekly-review GTD checklist for myself in TiddlyWiki, using <a href="http://www.tiddlytools.com/#CheckboxPlugin" rel="nofollow noreferrer">CheckboxPlugin</a>. After I'm finished with it each week, I'd like to click one link to uncheck (reset) all of the items on it, so it's ready for the next use.<... | [
{
"answer_id": 178066,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Try this (adapted from ChecklistScript's \"resetall\" code):</p>\n\n<pre><code><html><form style=\"display:inline\... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12193/"
] | I've written up a weekly-review GTD checklist for myself in TiddlyWiki, using [CheckboxPlugin](http://www.tiddlytools.com/#CheckboxPlugin). After I'm finished with it each week, I'd like to click one link to uncheck (reset) all of the items on it, so it's ready for the next use.
I'm storing the check information as ta... | It took a while, but I figured it out (thanks to ELS's answer for the inspiration):
```
<script label="(Reset All)" title="Reset all items" key="X">
var tid='WeeklyReviewStepsChecklistItems';
store.getTiddler(tid).tags=[];
story.refreshTiddler(tid,null,true);
story.refreshTiddler('Week... |
172,265 | <p>I've got a WCF Web Service method whose prototype is:</p>
<pre><code>[OperationContract]
Response<List<Customer>> GetCustomers();
</code></pre>
<p>When I add the service reference to a client, Visual Studio (2005) creates a type called "ResponseOfArrayOfCustomerrleXg3IC" that is a wrapper for "Response... | [
{
"answer_id": 172349,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": -1,
"selected": false,
"text": "<p>Yes. The OperationContractAttribute takes a parameter called Name. You could specify it like this:</p>\n\n<pre><code>[Op... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9825/"
] | I've got a WCF Web Service method whose prototype is:
```
[OperationContract]
Response<List<Customer>> GetCustomers();
```
When I add the service reference to a client, Visual Studio (2005) creates a type called "ResponseOfArrayOfCustomerrleXg3IC" that is a wrapper for "Response<List<Customer>>". Is there any way I ... | You can define your own name in the `DataContract` attribute like this:
```
[DataContract(Name = "ResponseOf{0}")]
public class Response<T>
```
Note that in your example the `{0}` will be replaced and your proxy reference type will be `ResponseOfArrayOfCustomer`.
More info here: [WCF: Serialization and Generics](h... |
172,278 | <p>I have a stored procedure with the following header:</p>
<pre><code>FUNCTION SaveShipment (p_user_id IN INTEGER, p_transaction_id IN INTEGER, p_vehicle_code IN VARCHAR2 DEFAULT NULL, p_seals IN VARCHAR2 DEFAULT NULL) RETURN INTEGER;
</code></pre>
<p>And I am having trouble running it from TOAD's Editor. I cannot ... | [
{
"answer_id": 172309,
"author": "friol",
"author_id": 23034,
"author_profile": "https://Stackoverflow.com/users/23034",
"pm_score": 3,
"selected": true,
"text": "<p>Are you calling the stored procedure from another SP?</p>\n\n<p>I think the syntax is (if I recall correctly):</p>\n\n<pre... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | I have a stored procedure with the following header:
```
FUNCTION SaveShipment (p_user_id IN INTEGER, p_transaction_id IN INTEGER, p_vehicle_code IN VARCHAR2 DEFAULT NULL, p_seals IN VARCHAR2 DEFAULT NULL) RETURN INTEGER;
```
And I am having trouble running it from TOAD's Editor. I cannot run it as part of a select ... | Are you calling the stored procedure from another SP?
I think the syntax is (if I recall correctly):
```
declare
c integer;
begin
c:=storedProc(...parameters...);
```
Hope this helps. |
172,302 | <p>This is for a small scheduling app. I need an algorithm to efficiently compare two "schedules", find differences, and update only the data rows which have been changed, as well as entries in another table having this table as a foreign key. This is a big question, so I'll say right away I'm looking for either <str... | [
{
"answer_id": 172485,
"author": "ADEpt",
"author_id": 10105,
"author_profile": "https://Stackoverflow.com/users/10105",
"pm_score": 1,
"selected": false,
"text": "<p>You post is almost in the \"too long; didnt read\" category - shortening it will probably give you more feedback.</p>\n\n... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21632/"
] | This is for a small scheduling app. I need an algorithm to efficiently compare two "schedules", find differences, and update only the data rows which have been changed, as well as entries in another table having this table as a foreign key. This is a big question, so I'll say right away I'm looking for either **general... | I have worked extensively with periods, but I'm afraid I don't understand entirely how table A and B work together, perhaps it's the word *subsume* that I don't understand.
Can you give some concrete examples of what you want done?
Do you mean that timespans recorded in table A contains entirely timespans in table B,... |
172,303 | <p>Is it possible to detect a valid regular expression with another regular expression? If so please give example code below.</p>
| [
{
"answer_id": 172312,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 8,
"selected": false,
"text": "<p>Unlikely.</p>\n\n<p>Evaluate it in a <code>try..catch</code> or whatever your language provides.</p>\n"
},
{
"answe... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10950/"
] | Is it possible to detect a valid regular expression with another regular expression? If so please give example code below. | ```
/
^ # start of string
( # first group start
(?:
(?:[^?+*{}()[\]\\|]+ # literals and ^, $
| \\. # escaped characters
| \[ (?: \^?\\. | \^[^\\] | [^\\^] ) ... |
172,320 | <p>I'm working with a webservice that offers almost duplicated code across two namesspaces. Lets say for example PigFeet and HorseFeet, both namespaces contain a Feet class and other code that works with the Feet class requires it to be part of that same namespace.</p>
<p>Right now In my code I'm forced to do somethi... | [
{
"answer_id": 172324,
"author": "Eric Schoonover",
"author_id": 3957,
"author_profile": "https://Stackoverflow.com/users/3957",
"pm_score": 2,
"selected": false,
"text": "<p>In your namespace imports you can assign an <a href=\"http://msdn.microsoft.com/en-us/library/aa664765(VS.71).asp... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25300/"
] | I'm working with a webservice that offers almost duplicated code across two namesspaces. Lets say for example PigFeet and HorseFeet, both namespaces contain a Feet class and other code that works with the Feet class requires it to be part of that same namespace.
Right now In my code I'm forced to do something like thi... | The namespace isn't the problem - it's simply that the 2 classes aren't related, so there's no inheritance chain that you can use for polymorphism.
You'll need to look at something like [duck typing](http://www.deftflux.net/blog/page/Duck-Typing-Project.aspx), or an [adapter pattern](http://en.wikipedia.org/wiki/Adap... |
172,365 | <p>I've created a web page that lets you input some information and then draws an image in a canvas element based on that info. I have it pretty much working the way I want except for the printing.</p>
<p>Is there a way to print out the canvas element or is creating a new window to draw in, the only way to do it?</p>... | [
{
"answer_id": 172376,
"author": "Darryl Hein",
"author_id": 5441,
"author_profile": "https://Stackoverflow.com/users/5441",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not 100% sure of the support, but you can use CSS and put an attribute in the <code><link></code> tag for <... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/791/"
] | I've created a web page that lets you input some information and then draws an image in a canvas element based on that info. I have it pretty much working the way I want except for the printing.
Is there a way to print out the canvas element or is creating a new window to draw in, the only way to do it?
Update:
The ... | You could try something like this:
```
@media print {
* {
display:none;
}
#SOME-CANVAS-ID {
display:block;
}
}
```
I'm not sure if a canvas is block by default, but you could try something along the lines of that and see if it works. The idea is that it will hide everything (\*) for print media, exc... |
172,372 | <p>I am wondering about what the difference between logging and tracing is.</p>
<p>Is the difference basically that tracing is more detailed log giving developers a tool to debug applications at runtime?</p>
<p>I have been experimenting with log4net and doing logging. Now I am wondering if I should be doing tracing a... | [
{
"answer_id": 172375,
"author": "Karl",
"author_id": 17613,
"author_profile": "https://Stackoverflow.com/users/17613",
"pm_score": 0,
"selected": false,
"text": "<p>logging != debugging</p>\n\n<p>Sometimes keeping log files is necessary to solve issues with the client, they prove what h... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15771/"
] | I am wondering about what the difference between logging and tracing is.
Is the difference basically that tracing is more detailed log giving developers a tool to debug applications at runtime?
I have been experimenting with log4net and doing logging. Now I am wondering if I should be doing tracing as well and if I c... | Logging is the generic term for recording information - tracing is the specific form of logging used to debug.
In .NET the System.Diagnostics.Trace and System.Diagnostics.Debug objects allow simple logging to a number of "event listeners" that you can configure in app.config. You can also use TraceSwitches to configur... |
172,393 | <p>I have a method that takes an IQueryable. Is there a LINQ query that will give me back the size of each column in the IQueryable?</p>
<p>To be more clear: this is Linq-to-objects. I want to get the length of the ToString() of each "column".</p>
| [
{
"answer_id": 172413,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 2,
"selected": true,
"text": "<p>It depends. If you mean is there a completely generic way to make this determination the answer is no. All IQueryable... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5189/"
] | I have a method that takes an IQueryable. Is there a LINQ query that will give me back the size of each column in the IQueryable?
To be more clear: this is Linq-to-objects. I want to get the length of the ToString() of each "column". | It depends. If you mean is there a completely generic way to make this determination the answer is no. All IQueryable will give access to is the Type of each expression. There is no way to arbitrarily map a Type to a column size.
If on the other hand you have the ability to map a Type to members and member type to a ... |
172,397 | <p>I am trying to use the <a href="http://www.javac.info/" rel="nofollow noreferrer">BGGA closures prototype</a> with an existing JDK 6 (standard on Mac OS X Leopard). The sample code I'm compiling is from a BGGA tutorial:</p>
<pre><code>public static void main(String[] args) {
// function with no arguments; return... | [
{
"answer_id": 172418,
"author": "skaffman",
"author_id": 21234,
"author_profile": "https://Stackoverflow.com/users/21234",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried javac with -J-Xbootclasspath instead? That's used for passing -X arguments to the VM itself, which may ... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8217/"
] | I am trying to use the [BGGA closures prototype](http://www.javac.info/) with an existing JDK 6 (standard on Mac OS X Leopard). The sample code I'm compiling is from a BGGA tutorial:
```
public static void main(String[] args) {
// function with no arguments; return value is always 42
int answer = { => 42 }.invoke(... | The TAR file distribution includes a modified javac.bat with a complete command line, including "-source 7", which is probably what you are missing here. |
172,439 | <p>I have a multi-line string that I want to do an operation on each line, like so:</p>
<pre><code>inputString = """Line 1
Line 2
Line 3"""
</code></pre>
<p>I want to iterate on each line:</p>
<pre><code>for line in inputString:
doStuff()
</code></pre>
| [
{
"answer_id": 172454,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 10,
"selected": true,
"text": "<pre class=\"lang-py prettyprint-override\"><code>inputString.splitlines()\n</code></pre>\n\n<p>Will give you a list with ea... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1546/"
] | I have a multi-line string that I want to do an operation on each line, like so:
```
inputString = """Line 1
Line 2
Line 3"""
```
I want to iterate on each line:
```
for line in inputString:
doStuff()
``` | ```py
inputString.splitlines()
```
Will give you a list with each item, the [`splitlines()`](https://docs.python.org/3/library/stdtypes.html#str.splitlines) method is designed to split each line into a list element. |
172,465 | <pre><code>y: &pause
cd ptls5.0 &pause
sdp describe Integration.dpk &pause
z: &pause
cd ptls5.0 &pause
dir &pause
</code></pre>
<p>I have those commands in the 1.cmd file. First three are executed fine. The result of it is that after "sdp describe Integration.dpk &pause" is executed I'm giv... | [
{
"answer_id": 172471,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 1,
"selected": false,
"text": "<p>Is \"sdp\" another batch file itself? If so, you will need to use <code>call</code>:</p>\n\n<pre><code>call sdp descri... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
y: &pause
cd ptls5.0 &pause
sdp describe Integration.dpk &pause
z: &pause
cd ptls5.0 &pause
dir &pause
```
I have those commands in the 1.cmd file. First three are executed fine. The result of it is that after "sdp describe Integration.dpk &pause" is executed I'm given "press any key to continue..." after I hit a... | If sdp is a .cmd or .bat file, change it to "call sdp....." |
172,484 | <p>I recently added <a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-pedantic-1" rel="nofollow noreferrer">-pedantic</a> and <a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-pedantic-errors-1" rel="nofollow noreferrer">-pedantic-errors</a> to my make GCC compile options to he... | [
{
"answer_id": 172515,
"author": "friol",
"author_id": 23034,
"author_profile": "https://Stackoverflow.com/users/23034",
"pm_score": 0,
"selected": false,
"text": "<p>One idea that comes to my mind (I don't know if there's an 'out of the box' parameter for this):</p>\n<p>Prepare a script... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13676/"
] | I recently added [-pedantic](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-pedantic-1) and [-pedantic-errors](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-pedantic-errors-1) to my make GCC compile options to help clean up my cross-platform code. All was fine until it found errors in ext... | You could fix the headers and submit a patch to [FFmpeg](https://en.wikipedia.org/wiki/FFmpeg); compatibility with [`-pedantic`](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-pedantic-1) is a worthy goal, so I'm sure they'd consider it, especially if it just involved removing trailing commas and suchlik... |
172,524 | <p>Last time <a href="https://stackoverflow.com/questions/169506/get-form-input-fields-with-jquery">I asked about the reverse process</a>, and got some very efficient answers. I'm aiming for least lines of code here. I have a form of fields and an associative array in the {fieldname:data} format, I want to populate a c... | [
{
"answer_id": 172532,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 4,
"selected": false,
"text": "<p>If your form elements have their ID set to the fieldname:</p>\n\n<pre><code>$.each(myAssocArry, function(i,val) {... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7883/"
] | Last time [I asked about the reverse process](https://stackoverflow.com/questions/169506/get-form-input-fields-with-jquery), and got some very efficient answers. I'm aiming for least lines of code here. I have a form of fields and an associative array in the {fieldname:data} format, I want to populate a corresponding f... | When I did this for a project, I found that setting the value of select fields, radio buttons and checkboxes necessitated more complex code, something along the lines of:
```
jQuery.each(data, function (name,value) {
jQuery("input[name='"+name+"'],select[name='"+name+"']").each(function() {
switch (this.nodeNam... |
172,544 | <p>I am trying to display a list of all files found in the selected directory (and optionally any subdirectories). The problem I am having is that when the GetFiles() method comes across a folder that it cannot access, it throws an exception and the process stops.</p>
<p>How do I ignore this exception (and ignore the ... | [
{
"answer_id": 172575,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 7,
"selected": true,
"text": "<p>You will have to do the recursion manually; don't use AllDirectories - look one folder at a time, then try getting ... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2493/"
] | I am trying to display a list of all files found in the selected directory (and optionally any subdirectories). The problem I am having is that when the GetFiles() method comes across a folder that it cannot access, it throws an exception and the process stops.
How do I ignore this exception (and ignore the protected ... | You will have to do the recursion manually; don't use AllDirectories - look one folder at a time, then try getting the files from sub-dirs. Untested, but something like below (note uses a delegate rather than building an array):
```
using System;
using System.IO;
static class Program
{
static void Main()
{
... |
172,552 | <p>I wrote a short bash script to complete a task that involves creating a temporary directory and storing various files in it and performing various operations on it.</p>
<p>In my first pass I just created the temp dir at /tmp/$$.$script", but then I tested the script on a computer where I didn't have write access to... | [
{
"answer_id": 172555,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 1,
"selected": false,
"text": "<p>You could try <code>/var/tmp</code>, although it's likely that <code>/tmp</code> is a symlink to that (or vice-ve... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] | I wrote a short bash script to complete a task that involves creating a temporary directory and storing various files in it and performing various operations on it.
In my first pass I just created the temp dir at /tmp/$$.$script", but then I tested the script on a computer where I didn't have write access to /tmp/, an... | Many systems also have a `/var/tmp`. If the sysadmin doesn't want you writing in to `/tmp`, presumably they have provided some alternative… is the `$TMPDIR` environment variable set? For example, on my Mac:
```
$ echo $TMPDIR
/var/folders/jf/jfu4pjGtGGGkUuuq8HL7UE+++TI/-Tmp-/
``` |
172,559 | <pre><code>function returnsAnArray ()
{
return array ('test');
}
echo returnsAnArray ()[0];
</code></pre>
<p>generates a syntax error in PHP. What's the most efficient way to directly obtain an element from a returned array without assigning the result to a temp variable?</p>
| [
{
"answer_id": 172570,
"author": "Eran Galperin",
"author_id": 10585,
"author_profile": "https://Stackoverflow.com/users/10585",
"pm_score": 1,
"selected": false,
"text": "<p>This will work if there is only one member in the array:</p>\n\n<pre><code> <?php\n echo current(returnsAnArra... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24288/"
] | ```
function returnsAnArray ()
{
return array ('test');
}
echo returnsAnArray ()[0];
```
generates a syntax error in PHP. What's the most efficient way to directly obtain an element from a returned array without assigning the result to a temp variable? | Here's one way, using the [list](http://www.php.net/list) language construct
```
function returnsAnArray ()
{
return array ('test');
}
list($foo)=returnsAnArray();
```
You could grab a sequence of elements from an offset by combining this with [array\_slice](http://www.php.net/array_slice)
```
list($third,$fourt... |
172,573 | <p>I've been using <a href="http://www.jcraft.com/jsch/" rel="nofollow noreferrer">JSch</a> for a couple of weeks now. It seems to <em>work</em> okay, but its API is a little bit cumbersome. I'm also a little off put by its total lack of documentation (not even javadoc style comments). Has anyone used a good Java SS... | [
{
"answer_id": 172570,
"author": "Eran Galperin",
"author_id": 10585,
"author_profile": "https://Stackoverflow.com/users/10585",
"pm_score": 1,
"selected": false,
"text": "<p>This will work if there is only one member in the array:</p>\n\n<pre><code> <?php\n echo current(returnsAnArra... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288/"
] | I've been using [JSch](http://www.jcraft.com/jsch/) for a couple of weeks now. It seems to *work* okay, but its API is a little bit cumbersome. I'm also a little off put by its total lack of documentation (not even javadoc style comments). Has anyone used a good Java SSH2 library that they'd recommend. I'm particularly... | Here's one way, using the [list](http://www.php.net/list) language construct
```
function returnsAnArray ()
{
return array ('test');
}
list($foo)=returnsAnArray();
```
You could grab a sequence of elements from an offset by combining this with [array\_slice](http://www.php.net/array_slice)
```
list($third,$fourt... |
172,598 | <p>I just started programming Objective-C and, having a background in Java, wonder how people writing Objective-C programs deal with private methods.</p>
<p>I understand there may be several conventions and habits and think about this question as an aggregator of the best techniques people use dealing with private met... | [
{
"answer_id": 172738,
"author": "Andy",
"author_id": 3857,
"author_profile": "https://Stackoverflow.com/users/3857",
"pm_score": 5,
"selected": false,
"text": "<p>While I am no Objective-C expert, I personally just define the method in the implementation of my class. Granted, it must be... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20294/"
] | I just started programming Objective-C and, having a background in Java, wonder how people writing Objective-C programs deal with private methods.
I understand there may be several conventions and habits and think about this question as an aggregator of the best techniques people use dealing with private methods in Ob... | There isn't, as others have already said, such a thing as a private method in Objective-C. However, starting in Objective-C 2.0 (meaning Mac OS X Leopard, iPhone OS 2.0, and later) you can create a category with an empty name (i.e. `@interface MyClass ()`) called *Class Extension*. What's unique about a class extension... |
172,600 | <p>When I try this with a generic class where this.value is T:</p>
<pre><code>if (this.value.GetType() == typeof(int))
{
((int)this.value)++;
}
else
{
throw new InvalidOperationException
("T must be an int to perform this operation");
}
</code></pre>
<p>I get a compile-time error: "Cannot convert ... | [
{
"answer_id": 172639,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": true,
"text": "<p>Unfortunately, it is very hard to convince the compiler about specific T implementations. One (nasty) approach is t... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11574/"
] | When I try this with a generic class where this.value is T:
```
if (this.value.GetType() == typeof(int))
{
((int)this.value)++;
}
else
{
throw new InvalidOperationException
("T must be an int to perform this operation");
}
```
I get a compile-time error: "Cannot convert type 'T' to 'int'"
What s... | Unfortunately, it is very hard to convince the compiler about specific T implementations. One (nasty) approach is to cast to object in the middle (note this will box and unbox value-types):
```
int i = (int)(object)this.value;
i++;
this.value = (T)(object)i;
```
Ugly but it works. In .NET 3.5 I have some better wrap... |
172,658 | <p>I'm attempting to use extension methods to add an operater overload to the C# <code>StringBuilder</code> class. Specifically, given <code>StringBuilder</code> <code>sb</code>, I'd like <code>sb += "text"</code> to become equivalent to <code>sb.Append("text")</code>.</p>
<p>Here's the syntax for creating an extensi... | [
{
"answer_id": 172666,
"author": "Jacob Krall",
"author_id": 3140,
"author_profile": "https://Stackoverflow.com/users/3140",
"pm_score": 8,
"selected": true,
"text": "<p>This is not currently possible, because extension methods must be in static classes, and static classes can't have ope... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1388/"
] | I'm attempting to use extension methods to add an operater overload to the C# `StringBuilder` class. Specifically, given `StringBuilder` `sb`, I'd like `sb += "text"` to become equivalent to `sb.Append("text")`.
Here's the syntax for creating an extension method for `StringBuilder`:
```
public static class sbExtensio... | This is not currently possible, because extension methods must be in static classes, and static classes can't have operator overloads. But the [feature is being discussed for *some* future release of C#](https://github.com/dotnet/csharplang/issues/192). Mads talked a bit more about implementing it [in this video from 2... |
172,691 | <p>I'm trying to determine if the user is using 24 hour or 12 hour time, and there doesn't seem to be a good way to figure this out other than creating an NSDateFormatter and searching the format string for the period field ('a' character)</p>
<p>Here's what I'm doing now:</p>
<pre><code>NSDateFormatter *formatter = ... | [
{
"answer_id": 172755,
"author": "schwa",
"author_id": 23113,
"author_profile": "https://Stackoverflow.com/users/23113",
"pm_score": 3,
"selected": true,
"text": "<p>This information is provided in NSUserDefaults. Maybe under the NSShortTimeDateFormatString key? (Still requires parsing o... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17188/"
] | I'm trying to determine if the user is using 24 hour or 12 hour time, and there doesn't seem to be a good way to figure this out other than creating an NSDateFormatter and searching the format string for the period field ('a' character)
Here's what I'm doing now:
```
NSDateFormatter *formatter = [[NSDateFormatter all... | This information is provided in NSUserDefaults. Maybe under the NSShortTimeDateFormatString key? (Still requires parsing of course).
(Use
```
NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
```
to dump all the pre-defined user defaults).
Not quite sure why you want to do this - I be... |
172,720 | <p>This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:</p>
<ul>
<li><p><strong>Firstly</strong>: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?</p></li>
<li><p><strong>Secondly</stron... | [
{
"answer_id": 172726,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 4,
"selected": false,
"text": "<p>First thing that comes to mind: <a href=\"http://psyco.sourceforge.net/\" rel=\"nofollow noreferrer\">psyco</a>. It runs onl... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/145/"
] | This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:
* **Firstly**: Given an established python project, what are some decent ways to speed it up beyond just plain in-code optimization?
* **Secondly**: When writing a program from scratch in python, what a... | The usual suspects -- profile it, find the most expensive line, figure out what it's doing, fix it. If you haven't done much profiling before, there could be some big fat quadratic loops or string duplication hiding behind otherwise innocuous-looking expressions.
In Python, two of the most common causes I've found for... |
172,748 | <p>Is there a way to make a popup window maximised as soon as it is opened? If not that, at least make it screen-sized? This:</p>
<pre><code>window.open(src, 'newWin', 'fullscreen="yes"')
</code></pre>
<p>apparently only worked for old version of IE.</p>
| [
{
"answer_id": 172756,
"author": "Geoff",
"author_id": 10427,
"author_profile": "https://Stackoverflow.com/users/10427",
"pm_score": 7,
"selected": true,
"text": "<p>Use <code>screen.availWidth</code> and <code>screen.availHeight</code> to calculate a suitable size for the height and wid... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3037/"
] | Is there a way to make a popup window maximised as soon as it is opened? If not that, at least make it screen-sized? This:
```
window.open(src, 'newWin', 'fullscreen="yes"')
```
apparently only worked for old version of IE. | Use `screen.availWidth` and `screen.availHeight` to calculate a suitable size for the height and width parameters in `window.open()`
Although this is likely to be close, it will not be maximised, nor accurate for everyone, especially if all the toolbars are shown. |
172,753 | <p>just wondering if anyone has ever tried embedding and actually integrating any js engine into the .net environment. I could find and actually use (after a <strong>LOT</strong> of pain and effort, since it's pretty outdated and not quite finished) spidermonkey-dotnet project. Anyone with experience in this area? Engi... | [
{
"answer_id": 172804,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 3,
"selected": false,
"text": "<p>I guess I am still unclear about what it is you are trying to do, but JScript.NET might be worth looking into, thou... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25339/"
] | just wondering if anyone has ever tried embedding and actually integrating any js engine into the .net environment. I could find and actually use (after a **LOT** of pain and effort, since it's pretty outdated and not quite finished) spidermonkey-dotnet project. Anyone with experience in this area? Engines like Squirre... | The open source JavaScript interpreter Jint (<http://jint.codeplex.com>) does exactly what you are looking for.
**Edit:**
The project has been entirely rewritten and is now hosted on Github at <https://github.com/sebastienros/jint> |
172,777 | <p>We're all familiar with the pre- and post-increment operators, e.g.</p>
<pre><code>c++; // c = c + 1
++c; // ditto
</code></pre>
<p>and the "combined operators" which extend this principle:</p>
<pre><code>c += 5; // c = c + 5
s .= ", world"; // s = s . ", world"; e.g. PHP
</code></pre>
<p>I've often ... | [
{
"answer_id": 172792,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>A basic objection to the example as-given is that it'd create ambiguity:</p>\n\n<pre><code>a=-5; //'a = -5' or 'a =- 5'?\... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5058/"
] | We're all familiar with the pre- and post-increment operators, e.g.
```
c++; // c = c + 1
++c; // ditto
```
and the "combined operators" which extend this principle:
```
c += 5; // c = c + 5
s .= ", world"; // s = s . ", world"; e.g. PHP
```
I've often had a need for a 'post-combined operator', which ... | A basic objection to the example as-given is that it'd create ambiguity:
```
a=-5; //'a = -5' or 'a =- 5'?
b=*p; //'b = *p' or 'b =* p'?
c=.5; //'c = .5' or 'c =. 5'?
```
**Edit:** But no, I'm not aware of any languages that use them. Presumably this is because they were omitted from C from whence most othe... |
172,812 | <p>I have the following style in an external CSS file called first.css</p>
<pre><code>table { width: 100%; }
</code></pre>
<p>This makes the tables fill their container. If there are only two small columns they appear too far from each other.</p>
<p>To force the columns to appear nearer I have added this style</p>
... | [
{
"answer_id": 172816,
"author": "Bobby Jack",
"author_id": 5058,
"author_profile": "https://Stackoverflow.com/users/5058",
"pm_score": 6,
"selected": true,
"text": "<p>You can use:</p>\n\n<pre><code>table { width: auto; }\n</code></pre>\n\n<p>in second.css, to strictly make \"the html b... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14755/"
] | I have the following style in an external CSS file called first.css
```
table { width: 100%; }
```
This makes the tables fill their container. If there are only two small columns they appear too far from each other.
To force the columns to appear nearer I have added this style
```
table { width: 50%; }
```
to a ... | You can use:
```
table { width: auto; }
```
in second.css, to strictly make "the html behave as if there was never been a width property". But I'm not 100% sure this is exactly what you want - if not, please clarify! |
172,821 | <p>I've got a div that contains some content that's being added and removed dynamically, so its height is changing often. I also have a div that is absolutely positioned directly underneath with javascript, so unless I can detect when the height of the div changes, I can't reposition the div below it.</p>
<p>So, how c... | [
{
"answer_id": 173349,
"author": "eyelidlessness",
"author_id": 17964,
"author_profile": "https://Stackoverflow.com/users/17964",
"pm_score": 5,
"selected": false,
"text": "<p>You can use the DOMSubtreeModified event </p>\n\n<pre><code>$(something).bind('DOMSubtreeModified' ...\n</code><... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384/"
] | I've got a div that contains some content that's being added and removed dynamically, so its height is changing often. I also have a div that is absolutely positioned directly underneath with javascript, so unless I can detect when the height of the div changes, I can't reposition the div below it.
So, how can I detec... | I wrote a plugin sometime back for **[attrchange](http://meetselva.github.io/attrchange/)** listener which basically adds a listener function on attribute change. Even though I say it as a plugin, actually it is a simple function written as a jQuery plugin.. so if you want.. strip off the plugin specfic code and use th... |
172,831 | <p>If you have the following:</p>
<pre><code>$var = 3; // we'll say it's set to 3 for this example
if ($var == 4) {
// do something
} else if ($var == 5) {
// do something
} else if ($var == 2) {
// do something
} else if ($var == 3) {
// do something
} else {
// do something
}
</code></pre>
<p>If... | [
{
"answer_id": 172836,
"author": "Dark Shikari",
"author_id": 11206,
"author_profile": "https://Stackoverflow.com/users/11206",
"pm_score": 3,
"selected": false,
"text": "<p>A classic case of this occurring (with literally 5 options as in your post) was in ffmpeg, in the decode_cabac_res... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | If you have the following:
```
$var = 3; // we'll say it's set to 3 for this example
if ($var == 4) {
// do something
} else if ($var == 5) {
// do something
} else if ($var == 2) {
// do something
} else if ($var == 3) {
// do something
} else {
// do something
}
```
If say 80% of the time `$var... | Here's how we did it when I used to write software for radar systems. (Speed matters in radar. It's one of the few places where "real time" actually means "real" instead of "fast".)
[I'll switch to Python syntax, it's easier for me and I'm sure you can interpret it.]
```
if var <= 3:
if var == 2:
# do som... |
172,841 | <p>I have applied a <code>Formatter</code> to a <code>JFormattedTextField</code> using a <code>FormatterFactory</code>, when a user clicks into the text field I want to select the contents. </p>
<p>A focus listener does not work as expected because the formatter gets called, which eventually causes the value to be res... | [
{
"answer_id": 186156,
"author": "Chris Kimpton",
"author_id": 48310,
"author_profile": "https://Stackoverflow.com/users/48310",
"pm_score": 1,
"selected": false,
"text": "<p>which jdk are you using - any chance this is a bug in it?</p>\n"
},
{
"answer_id": 190302,
"author": ... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18445/"
] | I have applied a `Formatter` to a `JFormattedTextField` using a `FormatterFactory`, when a user clicks into the text field I want to select the contents.
A focus listener does not work as expected because the formatter gets called, which eventually causes the value to be reset which ultimately de-selects the fields c... | Quick and dirty workaround is to use
EventQueue.invokeLater from your focusListener.
```
EventQueue.invokeLater(new Runnable(){
public void run() { yourTextField.selectAll();}
});
``` |
172,854 | <p>I have a Boost unit test case which causes the object under test to throw an exception (that's the test, to cause an exception). How do I specify in the test to expect that particular exception.</p>
<p>I can specify that the test should have a certain number of failures by using BOOST_AUTO_TEST_CASE_EXPECTED_FAILUR... | [
{
"answer_id": 172995,
"author": "jonner",
"author_id": 78437,
"author_profile": "https://Stackoverflow.com/users/78437",
"pm_score": 7,
"selected": true,
"text": "<p>Doesn't this work?</p>\n\n<pre><code>BOOST_CHECK_THROW (expression, an_exception_type);\n</code></pre>\n\n<p>That should ... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4086/"
] | I have a Boost unit test case which causes the object under test to throw an exception (that's the test, to cause an exception). How do I specify in the test to expect that particular exception.
I can specify that the test should have a certain number of failures by using BOOST\_AUTO\_TEST\_CASE\_EXPECTED\_FAILURES bu... | Doesn't this work?
```
BOOST_CHECK_THROW (expression, an_exception_type);
```
That should cause the test to pass if the expression throws the given exception type or fail otherwise. If you need a different severity than 'CHECK', you could also use `BOOST_WARN_THROW()` or `BOOST_REQUIRE_THROW()` instead. See [the doc... |
172,875 | <p>Basically I'm running some performance tests and don't want the external network to be the drag factor. I'm looking into ways of disabling network LAN. What is an effective way of doing it programmatically? I'm interested in c#. If anyone has a code snippet that can drive the point home that would be cool.</p>
| [
{
"answer_id": 6170507,
"author": "Melvyn",
"author_id": 755986,
"author_profile": "https://Stackoverflow.com/users/755986",
"pm_score": 5,
"selected": false,
"text": "<p>Found this thread while searching for the same thing, so, here is the answer :)</p>\n\n<p>The best method I tested in... | 2008/10/05 | [
"https://Stackoverflow.com/questions/172875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Basically I'm running some performance tests and don't want the external network to be the drag factor. I'm looking into ways of disabling network LAN. What is an effective way of doing it programmatically? I'm interested in c#. If anyone has a code snippet that can drive the point home that would be cool. | Found this thread while searching for the same thing, so, here is the answer :)
The best method I tested in C# uses WMI.
<http://www.codeproject.com/KB/cs/EverythingInWmi02.aspx>
[Win32\_NetworkAdapter on msdn](http://msdn.microsoft.com/en-us/library/aa394216)
C# Snippet : (System.Management must be referenced in t... |
172,888 | <p>This will hopefully be an easy one. I have an F# project (latest F# CTP) with two files (Program.fs, Stack.fs). In Stack.fs I have a simple namespace and type definition</p>
<p>Stack.fs</p>
<pre><code>namespace Col
type Stack=
...
</code></pre>
<p>Now I try to include the namespace in Program.fs by declaring... | [
{
"answer_id": 172896,
"author": "Brian",
"author_id": 19299,
"author_profile": "https://Stackoverflow.com/users/19299",
"pm_score": 8,
"selected": true,
"text": "<p>What order are the files in the <code>.fsproj</code> file? Stack.fs needs to come before Program.fs for Program.fs to be ... | 2008/10/06 | [
"https://Stackoverflow.com/questions/172888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23283/"
] | This will hopefully be an easy one. I have an F# project (latest F# CTP) with two files (Program.fs, Stack.fs). In Stack.fs I have a simple namespace and type definition
Stack.fs
```
namespace Col
type Stack=
...
```
Now I try to include the namespace in Program.fs by declaring
```
open Col
```
This doesn't w... | What order are the files in the `.fsproj` file? Stack.fs needs to come before Program.fs for Program.fs to be able to 'see' it.
See also the start of
<http://lorgonblog.spaces.live.com/blog/cns!701679AD17B6D310!444.entry>
and the end of
<http://lorgonblog.spaces.live.com/blog/cns!701679AD17B6D310!347.entry> |
172,895 | <p>Is there any easy way to retrieve table creation DDL from Microsoft Access (2007) or do I have to code it myself using VBA to read the table structure? </p>
<p>I have about 30 tables that we are porting to Oracle and it would make life easier if we could create the tables from the Access definitions.</p>
| [
{
"answer_id": 172907,
"author": "Corey Trager",
"author_id": 9328,
"author_profile": "https://Stackoverflow.com/users/9328",
"pm_score": 3,
"selected": false,
"text": "<p>I've done this:</p>\n\n<p>There's a tool for \"upsizing\" from Access to SQL Server. Do that, then use the excellen... | 2008/10/06 | [
"https://Stackoverflow.com/questions/172895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24355/"
] | Is there any easy way to retrieve table creation DDL from Microsoft Access (2007) or do I have to code it myself using VBA to read the table structure?
I have about 30 tables that we are porting to Oracle and it would make life easier if we could create the tables from the Access definitions. | Thanks for the other suggestions. While I was waiting I wrote some VBA code to do it. It's not perfect, but did the job for me.
```
Option Compare Database
Public Function TableCreateDDL(TableDef As TableDef) As String
Dim fldDef As Field
Dim FieldIndex As Integer
Dim fldName As String, fld... |
172,906 | <p>I'd like to take XML in the format below and load each code record into a domain object in my <code>BootStrap.groovy</code>. I want to preserve the formatting of each snippet of code. </p>
<h2>XML</h2>
<pre><code><records>
<code>
<language>Groovy</language>
<snippet&... | [
{
"answer_id": 172972,
"author": "mbrevoort",
"author_id": 18228,
"author_profile": "https://Stackoverflow.com/users/18228",
"pm_score": 2,
"selected": true,
"text": "<p>roughly something like this:</p>\n\n<pre><code>def CODE_XML = '''\n<records>\n <code>\n <lang... | 2008/10/06 | [
"https://Stackoverflow.com/questions/172906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd like to take XML in the format below and load each code record into a domain object in my `BootStrap.groovy`. I want to preserve the formatting of each snippet of code.
XML
---
```
<records>
<code>
<language>Groovy</language>
<snippet>
println "This is Groovy"
println ... | roughly something like this:
```
def CODE_XML = '''
<records>
<code>
<language>Groovy</language>
<snippet>
println "This is Groovy"
println "A very powerful language"
</snippet>
</code>
<code>
<language>Groovy</language>
<snippet>
... |
172,916 | <p>I have develop an XNA game on computer 1. When I send it to computer two (and I have everything to be able to run XNA Code). When the program execute game.run, I get an InvalidOperationException. </p>
<p>I didn't tried to run code from computer two on computer one. But I know that both machine can run the code I've... | [
{
"answer_id": 172927,
"author": "Gerald",
"author_id": 19404,
"author_profile": "https://Stackoverflow.com/users/19404",
"pm_score": 0,
"selected": false,
"text": "<p>The docs say Game.Run will throw that exception if Game.Run is called more than once. What does the rest of the exceptio... | 2008/10/06 | [
"https://Stackoverflow.com/questions/172916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23141/"
] | I have develop an XNA game on computer 1. When I send it to computer two (and I have everything to be able to run XNA Code). When the program execute game.run, I get an InvalidOperationException.
I didn't tried to run code from computer two on computer one. But I know that both machine can run the code I've wrote on ... | I finally found the problem. For a reason, the hardware acceleration setting was set to None. So the project wouldn't start.
Thanks for all your reply. |
172,918 | <p>I have a container div that holds two internal divs; both should take 100% width and 100% height within the container.</p>
<p>I set both internal divs to 100% height. That works fine in Firefox, however in IE the divs do not stretch to 100% height but only the height of the text inside them.</p>
<p>The following i... | [
{
"answer_id": 172923,
"author": "Jarett Millard",
"author_id": 15882,
"author_profile": "https://Stackoverflow.com/users/15882",
"pm_score": 1,
"selected": false,
"text": "<p>You might have to put one or both of:</p>\n\n<pre><code>html { height:100%; }\n</code></pre>\n\n<p>or</p>\n\n<pr... | 2008/10/06 | [
"https://Stackoverflow.com/questions/172918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/131/"
] | I have a container div that holds two internal divs; both should take 100% width and 100% height within the container.
I set both internal divs to 100% height. That works fine in Firefox, however in IE the divs do not stretch to 100% height but only the height of the text inside them.
The following is a simplified ve... | I think "works fine in Firefox" is in the **Quirks mode** rendering only.
In the **Standard mode** rendering, that might not work fine in Firefox too.
percentage depends on "containing block", instead of viewport.
[CSS Specification says](http://www.w3.org/TR/CSS21/visudet.html#the-height-property)
>
> The percenta... |
172,921 | <p>In order to create an arbitrary precision floating point / drop in replacement for Double, I'm trying to wrap <a href="http://www.mpfr.org/" rel="nofollow noreferrer">MPFR</a> using the FFI but despite all my efforts the simplest bit of code doesn't work. It compiles, it runs, but it crashes mockingly after pretendi... | [
{
"answer_id": 173181,
"author": "Jared Updike",
"author_id": 2543,
"author_profile": "https://Stackoverflow.com/users/2543",
"pm_score": 2,
"selected": false,
"text": "<p>Judah Jacobsen answered this on the Haskell-cafe mailing list:</p>\n\n<p>This is <a href=\"http://hackage.haskell.or... | 2008/10/06 | [
"https://Stackoverflow.com/questions/172921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2543/"
] | In order to create an arbitrary precision floating point / drop in replacement for Double, I'm trying to wrap [MPFR](http://www.mpfr.org/) using the FFI but despite all my efforts the simplest bit of code doesn't work. It compiles, it runs, but it crashes mockingly after pretending to work for a while. A simple C versi... | I see the problem too, on a
```
$ uname -a
Linux burnup 2.6.26-gentoo-r1 #1 SMP PREEMPT Tue Sep 9 00:05:54 EDT 2008 i686 Intel(R) Pentium(R) 4 CPU 2.80GHz GenuineIntel GNU/Linux
$ gcc --version
gcc (GCC) 4.2.4 (Gentoo 4.2.4 p1.0)
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.8.3
```
I al... |
172,934 | <p>I need to retrieve a set of Widgets from my data access layer, grouped by widget.Manufacturer, to display in a set of nested ASP.NET ListViews.</p>
<p>The problem is that (as far as I can tell) the nested ListView approach requires me to shape the data before using it, and I can't figure out the best approach to ta... | [
{
"answer_id": 173177,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 2,
"selected": false,
"text": "<p>When you're using Linq to group, you can get a strongly typed object without that shaping:</p>\n\n<pre><code>List<int>... | 2008/10/06 | [
"https://Stackoverflow.com/questions/172934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4160/"
] | I need to retrieve a set of Widgets from my data access layer, grouped by widget.Manufacturer, to display in a set of nested ASP.NET ListViews.
The problem is that (as far as I can tell) the nested ListView approach requires me to shape the data before using it, and I can't figure out the best approach to take. The be... | Ok, I'm going to contradict my prior statement. Since eval wants some kind of property name in the nested control, we should probably shape that data.
```
public class CustomGroup<TKey, TValue>
{
public TKey Key {get;set;}
public IEnumerable<TValue> Values {get;set;}
}
```
// and use it thusly...
```
IEnumerabl... |
172,935 | <p>After understanding (quote), I'm curious as to how one might cause the statement to execute. My first thought was</p>
<pre><code>(defvar x '(+ 2 21))
`(,@x)
</code></pre>
<p>but that just evaluates to <code>(+ 2 21)</code>, or the contents of <code>x</code>. How would one run code that was placed in a list?</p>
| [
{
"answer_id": 172939,
"author": "Rich",
"author_id": 22003,
"author_profile": "https://Stackoverflow.com/users/22003",
"pm_score": 5,
"selected": true,
"text": "<p><code>(eval '(+ 2 21))</code></p>\n"
},
{
"answer_id": 175970,
"author": "Rich",
"author_id": 22003,
"a... | 2008/10/06 | [
"https://Stackoverflow.com/questions/172935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1256/"
] | After understanding (quote), I'm curious as to how one might cause the statement to execute. My first thought was
```
(defvar x '(+ 2 21))
`(,@x)
```
but that just evaluates to `(+ 2 21)`, or the contents of `x`. How would one run code that was placed in a list? | `(eval '(+ 2 21))` |
172,948 | <p>Anyone have any idea how to do the following?</p>
<p>declare cursor
open cursor
fetch cursor
<< Start reading the cursor in a LOOP >>
Lets say the cursor have 10 records.
Read until 5th record then go to the 6th record and do some checking.</p>
<p>Now, is it possible to go back to 5th record from 6th record... | [
{
"answer_id": 172953,
"author": "Thilo",
"author_id": 14955,
"author_profile": "https://Stackoverflow.com/users/14955",
"pm_score": 0,
"selected": false,
"text": "<p>How far do you need to go back? If you only need a look-ahead of one row, you could buffer just the previous row in your ... | 2008/10/06 | [
"https://Stackoverflow.com/questions/172948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25368/"
] | Anyone have any idea how to do the following?
declare cursor
open cursor
fetch cursor
<< Start reading the cursor in a LOOP >>
Lets say the cursor have 10 records.
Read until 5th record then go to the 6th record and do some checking.
Now, is it possible to go back to 5th record from 6th record ? | Depends on the requirements.
You can use the LAG() and LEAD() analytic functions to get information for the next and prior rows, i.e.
```
SQL> ed
Wrote file afiedt.buf
1 select ename,
2 sal,
3 lead(sal) over (order by ename) next_sal,
4 lag(sal) over (order by ename) prior_sal
5 ... |
172,957 | <p>I just set up my new homepage at <a href="http://ritter.vg" rel="noreferrer">http://ritter.vg</a>. I'm using jQuery, but very minimally.<br>
It loads all the pages using AJAX - I have it set up to allow bookmarking by detecting the hash in the URL. </p>
<pre><code> //general functions
function getUrl(u) {
... | [
{
"answer_id": 173075,
"author": "Komang",
"author_id": 19463,
"author_profile": "https://Stackoverflow.com/users/19463",
"pm_score": 6,
"selected": true,
"text": "<p>Use the <a href=\"https://github.com/cowboy/jquery-hashchange\" rel=\"noreferrer\">jQuery hashchange event</a> plugin ins... | 2008/10/06 | [
"https://Stackoverflow.com/questions/172957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8435/"
] | I just set up my new homepage at <http://ritter.vg>. I'm using jQuery, but very minimally.
It loads all the pages using AJAX - I have it set up to allow bookmarking by detecting the hash in the URL.
```
//general functions
function getUrl(u) {
return u + '.html';
}
function loadURL(u) {
$.get(ge... | Use the [jQuery hashchange event](https://github.com/cowboy/jquery-hashchange) plugin instead. Regarding your full ajax navigation, try to have [SEO friendly ajax](http://www.chazzuka.com/blog/?p=90). Otherwise your pages shown nothing in browsers with JavaScript limitations. |
173,017 | <p>I'm running some java processes on Windows 2003 server R2
I'm using Apache log4j-1.2.8. All my processes called via
one jar file with different parameter example</p>
<pre><code> java -jar process.jar one
java -jar process.jar two
java -jar process.jar three
</code></pre>
<p>And I config log4j.propert... | [
{
"answer_id": 173053,
"author": "David Crow",
"author_id": 2783,
"author_profile": "https://Stackoverflow.com/users/2783",
"pm_score": 2,
"selected": false,
"text": "<p>Is your log4j.properties file in the classpath when executed by the scheduler? I had a similar problem in the past, an... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24550/"
] | I'm running some java processes on Windows 2003 server R2
I'm using Apache log4j-1.2.8. All my processes called via
one jar file with different parameter example
```
java -jar process.jar one
java -jar process.jar two
java -jar process.jar three
```
And I config log4j.properties follow
```
#===========... | Is your log4j.properties file in the classpath when executed by the scheduler? I had a similar problem in the past, and it was due to the configuration file not being in the classpath.
You can include it in your process.jar file, or specify its location like this:
>
> java
> -Dlog4j.configuration=file:///path/to/lo... |
173,041 | <p>Which of these queries is the faster?</p>
<p>NOT EXISTS:</p>
<pre><code>SELECT ProductID, ProductName
FROM Northwind..Products p
WHERE NOT EXISTS (
SELECT 1
FROM Northwind..[Order Details] od
WHERE p.ProductId = od.ProductId)
</code></pre>
<p>Or NOT IN:</p>
<pre><code>SELECT ProductID, ProductName... | [
{
"answer_id": 173045,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 5,
"selected": false,
"text": "<p>If the execution planner says they're the same, they're the same. Use whichever one will make your intention more o... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9825/"
] | Which of these queries is the faster?
NOT EXISTS:
```
SELECT ProductID, ProductName
FROM Northwind..Products p
WHERE NOT EXISTS (
SELECT 1
FROM Northwind..[Order Details] od
WHERE p.ProductId = od.ProductId)
```
Or NOT IN:
```
SELECT ProductID, ProductName
FROM Northwind..Products p
WHERE p.Product... | I always default to `NOT EXISTS`.
The execution plans may be the same at the moment but if either column is altered in the future to allow `NULL`s the `NOT IN` version will need to do more work (even if no `NULL`s are actually present in the data) and the semantics of `NOT IN` if `NULL`s *are* present are unlikely to ... |
173,056 | <p>I've been trying to solve this, and have been getting stuck, so I thought I'd ask.</p>
<p>Imagine two ActionBeans, A and B.</p>
<p><code>A.jsp</code> has this section in it:</p>
<pre><code>...
<jsp:include page="/B.action">
<jsp:param name="ponies" value="on"/>
</jsp:include>
<jsp:include p... | [
{
"answer_id": 173049,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 6,
"selected": true,
"text": "<p><a href=\"http://jqueryui.com/demos/slider/\" rel=\"noreferrer\">jQuery UI Slider</a> (<a href=\"http://docs.jquery.... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22419/"
] | I've been trying to solve this, and have been getting stuck, so I thought I'd ask.
Imagine two ActionBeans, A and B.
`A.jsp` has this section in it:
```
...
<jsp:include page="/B.action">
<jsp:param name="ponies" value="on"/>
</jsp:include>
<jsp:include page="/B.action">
<jsp:param name="ponies" value="off"/>
</... | [jQuery UI Slider](http://jqueryui.com/demos/slider/) ([API docs](http://docs.jquery.com/UI/Slider)) |
173,070 | <p>I heard that you could right-shift a number by .5 instead of using Math.floor(). I decided to check its limits to make sure that it was a suitable replacement, so I checked the following values and got the following results in Google Chrome:</p>
<pre><code>
2.5 >> .5 == 2;
2.9999 >> .5 == 2;
2.999999999999999 >> .5... | [
{
"answer_id": 173090,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 5,
"selected": false,
"text": "<p>This is possibly the single worst idea I have ever seen. Its only possible purpose for existing is for winning an o... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25357/"
] | I heard that you could right-shift a number by .5 instead of using Math.floor(). I decided to check its limits to make sure that it was a suitable replacement, so I checked the following values and got the following results in Google Chrome:
```
2.5 >> .5 == 2;
2.9999 >> .5 == 2;
2.999999999999999 >> .5 == 2; // 15 ... | Actually, you're simply ending up doing a floor() on the first operand, without any floating point operations going on. Since the left shift and right shift bitwise operations only make sense with integer operands, the JavaScript engine is converting the two operands to integers first:
```
2.999999 >> 0.5
```
Become... |
173,115 | <p>I'm currently working on the <code>Tips.js</code> from <code>mootools</code> library and my code breaks on the line that has those <code>el.$tmp</code>, and console says it's undefined</p>
<p>Can anybody help me?</p>
| [
{
"answer_id": 173155,
"author": "keif",
"author_id": 19289,
"author_profile": "https://Stackoverflow.com/users/19289",
"pm_score": 1,
"selected": false,
"text": "<p>I'd suggest taking your question and posting it, along with a link to the page to either/or/and:</p>\n\n<p><a href=\"http:... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24744/"
] | I'm currently working on the `Tips.js` from `mootools` library and my code breaks on the line that has those `el.$tmp`, and console says it's undefined
Can anybody help me? | in 1.11 (haven't checked in 1.2+) $tmp is a reference to the element itself, created and used internally by the garbage collector:
```
var Garbage = {
elements: [],
collect: function(el){
if (!el.$tmp){
Garbage.elements.push(el);
el.$tmp = {'opacity': 1};
}
ret... |
173,133 | <p>1.
How can I reinterpret cast a float to an int (or a double to a long)?</p>
<pre><code>float f = 2.0f;
int i = (int)f; // causes conversion
</code></pre>
<p>I only want to copy the bit-pattern from <code>f</code> to <code>i</code>. How can this be done?</p>
<p>2.
The implicit and explicit operators in C# uses on... | [
{
"answer_id": 173139,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 3,
"selected": false,
"text": "<ol>\n<li><p>The <a href=\"http://msdn.microsoft.com/en-us/library/system.bitconverter.aspx\" rel=\"noreferrer\">BitConvert... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | 1.
How can I reinterpret cast a float to an int (or a double to a long)?
```
float f = 2.0f;
int i = (int)f; // causes conversion
```
I only want to copy the bit-pattern from `f` to `i`. How can this be done?
2.
The implicit and explicit operators in C# uses one intermediate object because the operator function is ... | 1: BitConverter (as sixlettervariables) is an option; as is unsafe code (which doesn't need an intermediate buffer):
```
float f = 2.0f;
int i;
// perform unsafe cast (preserving raw binary)
unsafe
{
float* fRef = &f;
i = *((int*)fRef);
}
Console.WriteLine(i);
// prove ... |
173,144 | <p>I want to make sure people can't type the name of a PHP script in the URL and run it. What's the best way of doing this?</p>
<p>I could set a variable in the file that will be including this file, and then check that variable in the file being included, but is there an easier way?</p>
| [
{
"answer_id": 173152,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 4,
"selected": true,
"text": "<p>You could check the URI and see if that file is being called with `</p>\n\n<pre><code>$_SERVER['SCRIPT_FILENAME']\n</code>... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/813/"
] | I want to make sure people can't type the name of a PHP script in the URL and run it. What's the best way of doing this?
I could set a variable in the file that will be including this file, and then check that variable in the file being included, but is there an easier way? | You could check the URI and see if that file is being called with `
```
$_SERVER['SCRIPT_FILENAME']
```
or you could move the file outside the public folder, this is a better solution. |
173,145 | <p>Given:</p>
<pre><code>interface I
{
}
class B: I
{
}
class C: I
{
}
class A
{
public void Method(B arg)
{
}
public void Method(C arg)
{
}
public void Method(I arg)
{
// THIS is the method I want to simplify.
if (I is B)
{
this.Method(arg as B);
... | [
{
"answer_id": 173165,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "<p>It doesn't exist in a convenient form withing C# - <a href=\"https://stackoverflow.com/questions/156467/switch-pat... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25388/"
] | Given:
```
interface I
{
}
class B: I
{
}
class C: I
{
}
class A
{
public void Method(B arg)
{
}
public void Method(C arg)
{
}
public void Method(I arg)
{
// THIS is the method I want to simplify.
if (I is B)
{
this.Method(arg as B);
}
... | What you want is [double dispatch](http://en.wikipedia.org/wiki/Double_dispatch), and [visitor pattern](http://en.wikipedia.org/wiki/Visitor_pattern) in particular. |
173,149 | <p>Can someone please explain how to remove the background/borders off an embedded CrystalReportViewer control in Visual Studio 2008.</p>
<p>I'm trying to remove the light gray (below the "Crystal Report" heading) and then the darker gray underneath that. I want to be left with only the white box and the report inside... | [
{
"answer_id": 173165,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "<p>It doesn't exist in a convenient form withing C# - <a href=\"https://stackoverflow.com/questions/156467/switch-pat... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Can someone please explain how to remove the background/borders off an embedded CrystalReportViewer control in Visual Studio 2008.
I'm trying to remove the light gray (below the "Crystal Report" heading) and then the darker gray underneath that. I want to be left with only the white box and the report inside this.
Th... | What you want is [double dispatch](http://en.wikipedia.org/wiki/Double_dispatch), and [visitor pattern](http://en.wikipedia.org/wiki/Visitor_pattern) in particular. |
173,209 | <p>Specifically, in VS 2008, I want to connect to a data source that you can have by right-clicking on the automatically-generated App_Data folder (an .mdf "database"). Seems easy, and it is once you know how.</p>
| [
{
"answer_id": 173221,
"author": "MrBoJangles",
"author_id": 13578,
"author_profile": "https://Stackoverflow.com/users/13578",
"pm_score": 4,
"selected": true,
"text": "<p>So here's the answer from MSDN:</p>\n\n<blockquote>\n <p>Choos[e] \"Add New Data Source\" from the\n Data menu.[An... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13578/"
] | Specifically, in VS 2008, I want to connect to a data source that you can have by right-clicking on the automatically-generated App\_Data folder (an .mdf "database"). Seems easy, and it is once you know how. | So here's the answer from MSDN:
>
> Choos[e] "Add New Data Source" from the
> Data menu.[And follow the connection wizard]
>
>
>
Very easy, except that I have no Data menu. If you don't have a Data menu, do the following:
* Click on Tools >> Connect to Database...
* Select "Microsoft SQL Server Database File", ... |
173,212 | <p>I just moved to a new hosting company and now whenever a string gets escaped using:</p>
<pre><code>mysql_real_escape_string($str);
</code></pre>
<p>the slashes remain in the database. This is the first time I've ever seen this happen so none of my scripts use</p>
<pre><code>stripslashes()
</code></pre>
<p>anymore.</... | [
{
"answer_id": 173234,
"author": "Steve Obbayi",
"author_id": 11190,
"author_profile": "https://Stackoverflow.com/users/11190",
"pm_score": -1,
"selected": false,
"text": "<p><code>mysql_real_escape_string($str);</code> is supposed to do exactly that. it is meant to add backslashes to sp... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/538/"
] | I just moved to a new hosting company and now whenever a string gets escaped using:
```
mysql_real_escape_string($str);
```
the slashes remain in the database. This is the first time I've ever seen this happen so none of my scripts use
```
stripslashes()
```
anymore.
This is on a CentOS 4.5 64bit running php 5.2... | The host that you've moved probably has `magic_quotes_runtime` turned on. You can turn it off with `set_magic_quotes_runtime(0)`.
Please turn off `magic_quotes_runtime`, and then change your code to use bind variables, rather than using the string escaping. |
173,219 | <p>I run php 5.2.6 as a cgi under lighttpd 1.4 and for some reason it's always running as root. All php-cgi processes in are owned by root and all files written to the file system are owned by root. </p>
<p>I've tried setting the user in lighttpd as non privileged, and confirmed, it's running right it's just php that ... | [
{
"answer_id": 173229,
"author": "Devon",
"author_id": 13850,
"author_profile": "https://Stackoverflow.com/users/13850",
"pm_score": 0,
"selected": false,
"text": "<p>It is possible that you have a fastcgi process that was started on the server as root. If this is the case, then the fas... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/538/"
] | I run php 5.2.6 as a cgi under lighttpd 1.4 and for some reason it's always running as root. All php-cgi processes in are owned by root and all files written to the file system are owned by root.
I've tried setting the user in lighttpd as non privileged, and confirmed, it's running right it's just php that runs as ro... | 1. Ensure :
```
server.username = "nonprivuser"
server.groupname = "nonprivgroup"
```
2. stop lighttpd.
3. check for existing php processes and kill them.
4. start lighttpd
5. check php processes are running as non priv
if php is still running as root, then you possibly have a SETUID script some... |
173,241 | <p>What library should be included to use TransparentBlt?</p>
<p>This is VC98 (Visual Studio 6) linking to the Gdi32.lib. (Other GDI functions such as BitBlt link as expected), and the compilers compiles with out error or warning.</p>
<p>Even though the Gdi32.lib is included, yet the linker returns this error:</p>
<... | [
{
"answer_id": 173251,
"author": "Peter Parker",
"author_id": 23264,
"author_profile": "https://Stackoverflow.com/users/23264",
"pm_score": 3,
"selected": true,
"text": "<p>AFAIK, you will need the Msimg32.lib</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/ms532303(VS.85).as... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3137/"
] | What library should be included to use TransparentBlt?
This is VC98 (Visual Studio 6) linking to the Gdi32.lib. (Other GDI functions such as BitBlt link as expected), and the compilers compiles with out error or warning.
Even though the Gdi32.lib is included, yet the linker returns this error:
```
mtcombo.obj : err... | AFAIK, you will need the Msimg32.lib
<http://msdn.microsoft.com/en-us/library/ms532303(VS.85).aspx> |
173,278 | <p>The docs say that calling sys.exit() raises a SystemExit exception which can be caught in outer levels. I have a situation in which I want to definitively and unquestionably exit from inside a test case, however the unittest module catches SystemExit and prevents the exit. This is normally great, but the specific ... | [
{
"answer_id": 173323,
"author": "Jerub",
"author_id": 14648,
"author_profile": "https://Stackoverflow.com/users/14648",
"pm_score": 8,
"selected": true,
"text": "<p>You can call <a href=\"https://docs.python.org/library/os.html#os._exit\" rel=\"noreferrer\"><code>os._exit()</code></a> t... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] | The docs say that calling sys.exit() raises a SystemExit exception which can be caught in outer levels. I have a situation in which I want to definitively and unquestionably exit from inside a test case, however the unittest module catches SystemExit and prevents the exit. This is normally great, but the specific situa... | You can call [`os._exit()`](https://docs.python.org/library/os.html#os._exit) to directly exit, without throwing an exception:
```
import os
os._exit(1)
```
This bypasses all of the python shutdown logic, such as the `atexit` module, and will not run through the exception handling logic that you're trying to avoid i... |
173,290 | <p>I have a list string tag.</p>
<p>I am trying to initialize a dictionary with the key as the tag string and values as the array index.</p>
<pre><code>for i, ithTag in enumerate(tag):
tagDict.update(ithTag=i)
</code></pre>
<p>The above returns me {'ithTag': 608} <em>608 is the 608th index</em></p>
<p>My probl... | [
{
"answer_id": 173299,
"author": "Jerub",
"author_id": 14648,
"author_profile": "https://Stackoverflow.com/users/14648",
"pm_score": 7,
"selected": true,
"text": "<p>You actually want to do this:</p>\n\n<pre><code>for i, tag in enumerate(tag):\n tagDict[tag] = i\n</code></pre>\n\n<p>T... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17085/"
] | I have a list string tag.
I am trying to initialize a dictionary with the key as the tag string and values as the array index.
```
for i, ithTag in enumerate(tag):
tagDict.update(ithTag=i)
```
The above returns me {'ithTag': 608} *608 is the 608th index*
My problem is that while the i is being interpreted as a... | You actually want to do this:
```
for i, tag in enumerate(tag):
tagDict[tag] = i
```
The .update() method is used for updating a dictionary using another dictionary, not for changing a single key/value pair. |
173,295 | <p>How do you select a datagridview row on a right-click?</p>
| [
{
"answer_id": 173315,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "<pre><code> // Clear all the previously selected rows\n foreach (DataGridViewRow row in yourDataGridView.Rows)\n {\n ... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173295",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25078/"
] | How do you select a datagridview row on a right-click? | Make it behave similarly to the left mouse button? e.g.
```
private void dataGridView_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
dataGridView.CurrentCell = dataGridView[e.ColumnIndex, e.RowIndex];
}
}
``` |
173,305 | <p>I have a <code>QTreeView</code> class with a context menu installed as follows:</p>
<pre><code>m_ui.tree->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_ui.tree, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(ShowTreeContextMenu(const QPoint&)));
...
void ShowTreeContextMen... | [
{
"answer_id": 173488,
"author": "shoosh",
"author_id": 9611,
"author_profile": "https://Stackoverflow.com/users/9611",
"pm_score": 2,
"selected": false,
"text": "<p>A possible solution which I haven't verified would be to capture the click event of the right click, manually make the sel... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6049/"
] | I have a `QTreeView` class with a context menu installed as follows:
```
m_ui.tree->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_ui.tree, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(ShowTreeContextMenu(const QPoint&)));
...
void ShowTreeContextMenu(const QPoint& point)
{
m_treeCo... | You don't say which version of Qt you are using, but we found the same problem in Qt4.4.0, it worked in 4.3. We reported this to Trolltech as a bug [225615](http://trolltech.com/developer/task-tracker/index_html?method=entry&id=225615)
This is still marked as pending, so in the meantime I would follow Shy's suggestion... |
173,329 | <p>I have this query in sql server 2000:</p>
<pre><code>select pwdencrypt('AAAA')
</code></pre>
<p>which outputs an encrypted string of 'AAAA':</p>
<pre>
0x0100CF465B7B12625EF019E157120D58DD46569AC7BF4118455D12625EF019E157120D58DD46569AC7BF4118455D
</pre>
<p><strong>How can I convert (decrypt) the output from its o... | [
{
"answer_id": 173344,
"author": "Svet",
"author_id": 8934,
"author_profile": "https://Stackoverflow.com/users/8934",
"pm_score": 5,
"selected": true,
"text": "<p>I believe pwdencrypt is using a hash so you cannot really reverse the hashed string - the algorithm is designed so it's impos... | 2008/10/06 | [
"https://Stackoverflow.com/questions/173329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21963/"
] | I have this query in sql server 2000:
```
select pwdencrypt('AAAA')
```
which outputs an encrypted string of 'AAAA':
```
0x0100CF465B7B12625EF019E157120D58DD46569AC7BF4118455D12625EF019E157120D58DD46569AC7BF4118455D
```
**How can I convert (decrypt) the output from its origin (which is 'AAAA')?** | I believe pwdencrypt is using a hash so you cannot really reverse the hashed string - the algorithm is designed so it's impossible.
If you are verifying the password that a user entered the usual technique is to hash it and then compare it to the hashed version in the database.
This is how you could verify a usered ... |