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 |
|---|---|---|---|---|---|---|
539,668 | <p>I'm trying to understand an <a href="http://www.cis.upenn.edu/%7Ebcpierce/papers/fj-toplas.pdf" rel="nofollow noreferrer">academic paper</a> (pdf) about programming language design. In particular, it describes a lightweight version of Java called Featherweight Java. It has typing rules with notation like this:</p>
<... | [
{
"answer_id": 539701,
"author": "Edwin Jarvis",
"author_id": 18623,
"author_profile": "https://Stackoverflow.com/users/18623",
"pm_score": -1,
"selected": false,
"text": "<p>Looks like <a href=\"http://en.wikipedia.org/wiki/Formal_semantics_of_programming_languages\" rel=\"nofollow nore... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to understand an [academic paper](http://www.cis.upenn.edu/%7Ebcpierce/papers/fj-toplas.pdf) (pdf) about programming language design. In particular, it describes a lightweight version of Java called Featherweight Java. It has typing rules with notation like this:
```
x_ : C_, this : C |- e0 : E0 E0 ... | This is a particularly complicated example, and a few separate things are going on inside it.
The horizontal bar notation is usually used for *inference rules*. Above the line are premises (usually separated by whitespace on a single line), below the line is a conclusion. E.g.,
```
P0 P1 ... Pn
---------------... |
539,676 | <p>Not sure that the example (nor the actual usecase) qualifies as NP-Complete, but I'm wondering about the most Pythonic way to do the below assuming that this was the algorithm available.</p>
<p>Say you have :</p>
<pre><code>class Person:
def __init__(self):
self.status='unknown'
def set(self,value):
if... | [
{
"answer_id": 539695,
"author": "David Z",
"author_id": 56541,
"author_profile": "https://Stackoverflow.com/users/56541",
"pm_score": 2,
"selected": false,
"text": "<p>I think this could do it:</p>\n\n<pre><code>l = list()\nfor i in xrange(2 ** n):\n # create the list of n people\n ... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35335/"
] | Not sure that the example (nor the actual usecase) qualifies as NP-Complete, but I'm wondering about the most Pythonic way to do the below assuming that this was the algorithm available.
Say you have :
```
class Person:
def __init__(self):
self.status='unknown'
def set(self,value):
if value:
self.st... | According to what you've stated in your problem, you're right -- you do need `itertools.product`, but not exactly the way you've stated.
```
import itertools
truth_values = itertools.product((True, False), repeat = 4)
people = (person_a, person_b, person_c, person_d)
all_people_and_states = [[person(truth) for person,... |
539,692 | <p>I have been studying Oracle's mechanism for authenticating against a 10g database. Although it is less documented than its 9i counterpart, I have still managed to find many of its details on various web sites and blogs. One piece remains a mystery, however. Before I mention what is missing, let me explain what is kn... | [
{
"answer_id": 561136,
"author": "Adam Paynter",
"author_id": 41619,
"author_profile": "https://Stackoverflow.com/users/41619",
"pm_score": 3,
"selected": true,
"text": "<p>I have determined that the 16 bytes immediately before the plain text password are randomly generated (for the curi... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41619/"
] | I have been studying Oracle's mechanism for authenticating against a 10g database. Although it is less documented than its 9i counterpart, I have still managed to find many of its details on various web sites and blogs. One piece remains a mystery, however. Before I mention what is missing, let me explain what is known... | I have determined that the 16 bytes immediately before the plain text password are randomly generated (for the curious, take a look at the ztvo5pe function exported by the oran10.dll library - you will see two successive calls to ztcen, the first call fills it in).
I originally posted the question because I was writin... |
539,711 | <p>I'm trying to use this regular expression, but I'm having trouble testing it, because for whatever reason it is crashing the only two regex testers I use.</p>
<p>^([a-zA-Z-]+/?)+$</p>
<p>If I'm not mistaken, that should match any URI that follows this format:</p>
<p>some-uri-string/some-uri-string/some-uri-string... | [
{
"answer_id": 539721,
"author": "LarryF",
"author_id": 18518,
"author_profile": "https://Stackoverflow.com/users/18518",
"pm_score": 2,
"selected": false,
"text": "<p>Look up catastrophic backtracking... You need to define it a little better, or write one that chomps the URI string one... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to use this regular expression, but I'm having trouble testing it, because for whatever reason it is crashing the only two regex testers I use.
^([a-zA-Z-]+/?)+$
If I'm not mistaken, that should match any URI that follows this format:
some-uri-string/some-uri-string/some-uri-string
However, I don't want ... | The problem is that, for a non-matching string, your pattern is a pathological case for a backtracking regular expression engine (which is true of those in most scripting languages, like Perl, Python, and anything based on PCRE).
More information:
* <http://swtch.com/~rsc/regexp/regexp1.html>
* <http://www.regular-ex... |
539,723 | <p>I have seen several examples on how to find children, etc but for some reason I can't get this one right ... any help from the SO community?</p>
<p>The below is my current "attempt" in code --</p>
<p>var trCount = $("#table > tr").size();</p>
| [
{
"answer_id": 539734,
"author": "David Brown",
"author_id": 31516,
"author_profile": "https://Stackoverflow.com/users/31516",
"pm_score": 5,
"selected": true,
"text": "<p>This should work:</p>\n\n<pre><code>var count = $(\"#table tr\").length;\n</code></pre>\n"
},
{
"answer_id":... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2701/"
] | I have seen several examples on how to find children, etc but for some reason I can't get this one right ... any help from the SO community?
The below is my current "attempt" in code --
var trCount = $("#table > tr").size(); | This should work:
```
var count = $("#table tr").length;
``` |
539,732 | <p>I want to use HTTPS in my ASP.NET web application, but only for the Login.aspx page. </p>
<p>How can this be accomplished?</p>
| [
{
"answer_id": 539739,
"author": "tsilb",
"author_id": 11112,
"author_profile": "https://Stackoverflow.com/users/11112",
"pm_score": 2,
"selected": false,
"text": "<p>You can enable HTTPS in your IIS config, but it won't be \"secure\" unless you acquire an SSL Certificate and plug it int... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46979/"
] | I want to use HTTPS in my ASP.NET web application, but only for the Login.aspx page.
How can this be accomplished? | 1. First get or create a certificate
2. Get the SecureWebPageModule module from <http://www.codeproject.com/Articles/7206/Switching-Between-HTTP-and-HTTPS-Automatically-Ver>. Instructions for setup can be found in the article.
3. Add secureWebPages tag to web.config
```
<configuration>
...
<secureWebPages enab... |
539,754 | <p>How does a Silverlight application ask the browser what domain its being served up from?</p>
<p><strong>UPDATE:</strong>
Make sure if your class doesn't already have this <em>using</em> statement add it at the top your class. This will help you on some of the examples you'll see online. It confused me for a bit.</p... | [
{
"answer_id": 539762,
"author": "jcollum",
"author_id": 30946,
"author_profile": "https://Stackoverflow.com/users/30946",
"pm_score": 4,
"selected": true,
"text": "<p>How about <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.browser.htmldocument.documenturi(VS.95).aspx\... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | How does a Silverlight application ask the browser what domain its being served up from?
**UPDATE:**
Make sure if your class doesn't already have this *using* statement add it at the top your class. This will help you on some of the examples you'll see online. It confused me for a bit.
```
using System.Windows.Brow... | How about [HtmlDocument.DocumentUri](http://msdn.microsoft.com/en-us/library/system.windows.browser.htmldocument.documenturi(VS.95).aspx)? That'd get you what you need. Page about browser interop **[here](http://msdn.microsoft.com/en-us/magazine/dd148642.aspx)**. |
539,758 | <p>Given: Class has no fields, every variable is local. littleString was created by refactoring bigString in Eclipse:</p>
<pre><code>public String bigString()
{
StringBuffer bob = new StringBuffer();
this.littleString(bob);
return bob.toString();
}
private void littleString(final Strin... | [
{
"answer_id": 539763,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 4,
"selected": true,
"text": "<p><code>littleString</code> isn't passing the object back -- it's just using the same object. Both the local variab... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13491/"
] | Given: Class has no fields, every variable is local. littleString was created by refactoring bigString in Eclipse:
```
public String bigString()
{
StringBuffer bob = new StringBuffer();
this.littleString(bob);
return bob.toString();
}
private void littleString(final StringBuffer bob)
... | `littleString` isn't passing the object back -- it's just using the same object. Both the local variable `bob` in `bigString()` and the parameter `bob` in `littleString()` refer to the same object, so if you change one of those objects, the changes will appear instantaneously in the other *because they're both referenc... |
539,791 | <p>My default setup is to put the tex source in a subversion repository and insert notes to each other as comments in the source when making changes to other people's content. It all feels pretty sub-optimal, especially when there are subversion conflicts where all it tells you is "these two versions of this huge para... | [
{
"answer_id": 539799,
"author": "dreeves",
"author_id": 4234,
"author_profile": "https://Stackoverflow.com/users/4234",
"pm_score": 3,
"selected": false,
"text": "<p>To mitigate the problem of unhelpful subversion conflicts, you can adopt the convention of newlines at the end of sentenc... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] | My default setup is to put the tex source in a subversion repository and insert notes to each other as comments in the source when making changes to other people's content. It all feels pretty sub-optimal, especially when there are subversion conflicts where all it tells you is "these two versions of this huge paragrap... | *Always* end each sentence with a newline. *Never* reformat paragraphs. These rules not only minimize spurious conflicts but also make your collaboratively edited paper easier to revise.
For author commentary I use marginal comments:
```
\long\def\authornote#1{%
\leavevmode\unskip\raisebox{-3.5pt}{\rlap{$\scr... |
539,797 | <p>What is a good way to <strong>always</strong> do integer division in Perl?</p>
<p>For example, I want:</p>
<pre><code>real / int = int
int / real = int
int / int = int
</code></pre>
| [
{
"answer_id": 539805,
"author": "Bryan Denny",
"author_id": 396,
"author_profile": "https://Stackoverflow.com/users/396",
"pm_score": 7,
"selected": true,
"text": "<p>You can cast ints in Perl:</p>\n\n<pre><code>int(5/1.5) = 3;\n</code></pre>\n"
},
{
"answer_id": 539809,
"au... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396/"
] | What is a good way to **always** do integer division in Perl?
For example, I want:
```
real / int = int
int / real = int
int / int = int
``` | You can cast ints in Perl:
```
int(5/1.5) = 3;
``` |
539,817 | <p>When a list item has an attachment, SharePoint automatically renders a paperclip image for that particular row, which indicates that the item has an attachment. Is there any way to change the image that is rendered?</p>
<p>The site is in a shared hosting environment, so I can't simply replace the image on the file ... | [
{
"answer_id": 539839,
"author": "Jason",
"author_id": 10639,
"author_profile": "https://Stackoverflow.com/users/10639",
"pm_score": 0,
"selected": false,
"text": "<p>i don't know which element off the top, but I would look for it in one of the stylesheets and use SharePoint designer to ... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10792/"
] | When a list item has an attachment, SharePoint automatically renders a paperclip image for that particular row, which indicates that the item has an attachment. Is there any way to change the image that is rendered?
The site is in a shared hosting environment, so I can't simply replace the image on the file system. Al... | The only real way you'll be able to do this is to use jQuery (or some other javascript library). You'll need to locate the elements you want to update on the page and change the URL's
```
$('img[src*=attach.gif]').each(function() {
$(this).attr('src', '/path/to/new/image.png');
}
```
My jQuery may be a touch wron... |
539,824 | <p>I'm trying to write a thread-safe queue using pthreads in c++. My program works 93% of the time. The other 7% of the time it other spits out garbage, OR seems to fall asleep. I'm wondering if there is some flaw in my queue where a context-switch would break it?</p>
<pre><code>// thread-safe queue
// inspired by htt... | [
{
"answer_id": 539829,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 2,
"selected": false,
"text": "<p>If this is your actual code, one problem right off the bat is that you're initializing <code>m_WriteCond</code> tw... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65387/"
] | I'm trying to write a thread-safe queue using pthreads in c++. My program works 93% of the time. The other 7% of the time it other spits out garbage, OR seems to fall asleep. I'm wondering if there is some flaw in my queue where a context-switch would break it?
```
// thread-safe queue
// inspired by http://msmvps.com... | If you want anything with decent performance I would strongly suggest dumping your R/W lock and just use a very simple spinlock. Or if you really think you can get the performance you want with R/W lock, i would roll your own based on [this](http://www.bluebytesoftware.com/blog/2009/01/30/ASinglewordReaderwriterSpinLoc... |
539,836 | <p>I'm trying to find a way to perform an indirect shift-left/right operation without actually using the variable shift op or any branches. </p>
<p>The particular PowerPC processor I'm working on has the quirk that a shift-by-constant-immediate, like </p>
<pre><code>int ShiftByConstant( int x ) { return x << 3 ... | [
{
"answer_id": 539868,
"author": "Joshua",
"author_id": 14768,
"author_profile": "https://Stackoverflow.com/users/14768",
"pm_score": 3,
"selected": false,
"text": "<p>How about this:</p>\n\n<pre><code>if (y & 16) x <<= 16;\nif (y & 8) x <<= 8;\nif (y & 4) x <&... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53543/"
] | I'm trying to find a way to perform an indirect shift-left/right operation without actually using the variable shift op or any branches.
The particular PowerPC processor I'm working on has the quirk that a shift-by-constant-immediate, like
```
int ShiftByConstant( int x ) { return x << 3 ; }
```
is fast, single-... | Here you go...
I decided to try these out as well since Mike Acton claimed it would be faster than using the CELL/PS3 microcoded shift on his CellPerformance site where [he suggests to avoid the indirect shift](http://cellperformance.beyond3d.com/articles/2006/04/avoiding-microcoded-instructions-on-the-ppu.html). Howe... |
539,859 | <p>Even before I learnt programming I've been fascinated with how robots could work. Now I know how the underlying programming instructions would be written, but what I don't understand is how those intructions are followed by the robot.</p>
<p>For example, if I wrote this code:</p>
<pre><code>object=Robot.ScanSurrou... | [
{
"answer_id": 539876,
"author": "Suroot",
"author_id": 64626,
"author_profile": "https://Stackoverflow.com/users/64626",
"pm_score": 1,
"selected": false,
"text": "<p>You would have to have a driver that interfaced with the hardware (most likely a STAMP or FPGA with motors etc...). You... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49153/"
] | Even before I learnt programming I've been fascinated with how robots could work. Now I know how the underlying programming instructions would be written, but what I don't understand is how those intructions are followed by the robot.
For example, if I wrote this code:
```
object=Robot.ScanSurroundings(300,400);
if (... | In most modern robots you would have an Inverse Kinematic model of the mechanism, in this case the arm, that converts the spatial coordinates into positions for the joints of the arm. These joints are usually moved by servo motors. To smoothly move the arm, you need a series of intermediate joint positions defining the... |
539,867 | <p>I have a object built through a factory containing my parameters read from the url.</p>
<p>From this object, I can get the language parameter</p>
<blockquote>
<p>$language =
$my_parameters->getLanguage();</p>
</blockquote>
<p>$language is NULL if it isn't been set.</p>
<p>$language may also be invalid ( $lan... | [
{
"answer_id": 539878,
"author": "Dustin Getz",
"author_id": 20003,
"author_profile": "https://Stackoverflow.com/users/20003",
"pm_score": 1,
"selected": false,
"text": "<p>i know very little about your domain, but in the general case, i like to assert(not null) all over the place, becau... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14673/"
] | I have a object built through a factory containing my parameters read from the url.
From this object, I can get the language parameter
>
> $language =
> $my\_parameters->getLanguage();
>
>
>
$language is NULL if it isn't been set.
$language may also be invalid ( $language->isValid() returns false ).
So, to bu... | [Here is the case for *not* checking for null](http://googletesting.blogspot.com/2009/02/to-assert-or-not-to-assert.html) in a recent blog post from the Google Testing blog.
The argument is that it gets in the way of writing clear, easy unit tests, because you can't actually fake the pieces that don't matter, because ... |
539,877 | <p>I am writing unit tests for some of my code and have run into a case where I have an object with a small exposed interface but complex internal structures as each exposed method runs through a large number of internal functions including dependancies on the object's state. This makes the methods on the external int... | [
{
"answer_id": 539887,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile": "https://Stackoverflow.com/users/2509",
"pm_score": 5,
"selected": true,
"text": "<p>Short answer: yes.</p>\n\n<p>As to how, I caught a passing reference on SO a few days ago: </p>\n\n... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10247/"
] | I am writing unit tests for some of my code and have run into a case where I have an object with a small exposed interface but complex internal structures as each exposed method runs through a large number of internal functions including dependancies on the object's state. This makes the methods on the external interfa... | Short answer: yes.
As to how, I caught a passing reference on SO a few days ago:
```
#define private public
```
in the unit testing code evaluated before the relevant headers are read...
Likewise for protected.
Very cool idea.
---
Slightly longer answer: Test if the code is not *obviously correct*. Which mea... |
539,899 | <p>As an exercise I am trying to create a custom django widget for a 24 hour clock. The widget will is a MultiWidget - a select box for each field.</p>
<p>I am trying to follow docs online (kinda sparse) and looking at the Pro Django book, but I can't seem to figure it out. Am I on the right track? I can save my data ... | [
{
"answer_id": 540678,
"author": "akaihola",
"author_id": 15770,
"author_profile": "https://Stackoverflow.com/users/15770",
"pm_score": 0,
"selected": false,
"text": "<p>I can't reproduce the problem:</p>\n\n<pre><code>>>> class MyForm(forms.Form):\n... t = forms.TimeField(w... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22306/"
] | As an exercise I am trying to create a custom django widget for a 24 hour clock. The widget will is a MultiWidget - a select box for each field.
I am trying to follow docs online (kinda sparse) and looking at the Pro Django book, but I can't seem to figure it out. Am I on the right track? I can save my data from the f... | Note [this line in the docstring for MultiWidget](http://code.djangoproject.com/browser/django/trunk/django/forms/widgets.py#L582):
>
> You'll probably want to use this class with MultiValueField.
>
>
>
That's the root of your problem. You might be able to get the single-widget-only approach working (Marty says i... |
539,900 | <p>I been working on parsing out bookmarks from an export file generated by google bookmarks. This file contains the following date attributes:</p>
<p>ADD_DATE="1231721701079000"</p>
<p>ADD_DATE="1227217588219000"</p>
<p>These are not standard unix style timestamps. Can someone point me in the right direction here? ... | [
{
"answer_id": 539909,
"author": "Rob Haupt",
"author_id": 65388,
"author_profile": "https://Stackoverflow.com/users/65388",
"pm_score": 1,
"selected": false,
"text": "<p>Initially looking at it, it almost looks like if you chopped off the last 6 digits you'd get a reasonable Unix Date u... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1973777/"
] | I been working on parsing out bookmarks from an export file generated by google bookmarks. This file contains the following date attributes:
ADD\_DATE="1231721701079000"
ADD\_DATE="1227217588219000"
These are not standard unix style timestamps. Can someone point me in the right direction here? I'll be parsing them u... | 1231721701079000 looks suspiciously like time since Jan 1st, 1970 in microseconds.
```
perl -wle 'print scalar gmtime(1231721701079000/1_000_000)'
Mon Jan 12 00:55:01 2009
```
I'd make some bookmarks at known times and try it out to confirm. |
539,939 | <p>I'm trying to extract some variables in my C++ code nested in blocks<br>
for example, if I have</p>
<pre><code> DEL_TYPE_NONE,
DEL_TYPE_DONE,
DEL_TYPE_WAIT,
</code></pre>
<p>I'd like to match<br><b>
"DEL_TYPE_NONE"<br>
"DEL_TYPE_DONE"<br>
"DEL_TYPE_WAIT"<br></b></p>
<p>I made my pattern lik... | [
{
"answer_id": 539949,
"author": "Suroot",
"author_id": 64626,
"author_profile": "https://Stackoverflow.com/users/64626",
"pm_score": 0,
"selected": false,
"text": "<p>Just based on POSIX I'd say your regex is \"DEL_TYPE_([ND]ONE|WAIT),\"</p>\n\n<p>That's just based on what you've listed... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59597/"
] | I'm trying to extract some variables in my C++ code nested in blocks
for example, if I have
```
DEL_TYPE_NONE,
DEL_TYPE_DONE,
DEL_TYPE_WAIT,
```
I'd like to match
**"DEL\_TYPE\_NONE"
"DEL\_TYPE\_DONE"
"DEL\_TYPE\_WAIT"**
I made my pattern like this,
**std::string pat("(?<=^[ \\t... | I found the answer. **No** from this [manual](http://www.boost.org/doc/libs/1_38_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html)
>
> Lookbehind
>
>
> (?<=pattern) consumes zero characters,
> only if pattern could be matched
> against the characters preceding the
> current position **(pattern must be o... |
539,942 | <p>I have a table with a row that looks like this:</p>
<p>(<strong>20091231</strong>48498429, '...', '...')</p>
<p>The first part, id, is a timestamp followed by a random number. (needed to work with other parts in the system) The data already exists in the table. </p>
<p>I want to create a column, timestamp, and ex... | [
{
"answer_id": 539951,
"author": "Sampson",
"author_id": 54680,
"author_profile": "https://Stackoverflow.com/users/54680",
"pm_score": 3,
"selected": true,
"text": "<pre><code>SELECT SUBSTRING(colDate,0,8) as 'date' \nFROM someTable\n</code></pre>\n\n<p>Or am I mistaken?</p>\n\n<pre><cod... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12682/"
] | I have a table with a row that looks like this:
(**20091231**48498429, '...', '...')
The first part, id, is a timestamp followed by a random number. (needed to work with other parts in the system) The data already exists in the table.
I want to create a column, timestamp, and extract just the date (20091231) and up... | ```
SELECT SUBSTRING(colDate,0,8) as 'date'
FROM someTable
```
Or am I mistaken?
```
UPDATE someTable
SET newDateField = SUBSTRING(colDate,0,8)
```
Would likely work too. Untested. |
539,944 | <p>I have quite a basic WPF form with a DockPanel, there's a Menu bar, a Status bar, and a UserControl. Like so:</p>
<pre><code><DockPanel>
<Menu DockPanel.Dock="Top">
...
</Menu>
<StatusBar DockPanel.Dock="Bottom">
...
</StatusBar>
<UserControls:MyUserControl />
&... | [
{
"answer_id": 539951,
"author": "Sampson",
"author_id": 54680,
"author_profile": "https://Stackoverflow.com/users/54680",
"pm_score": 3,
"selected": true,
"text": "<pre><code>SELECT SUBSTRING(colDate,0,8) as 'date' \nFROM someTable\n</code></pre>\n\n<p>Or am I mistaken?</p>\n\n<pre><cod... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/233/"
] | I have quite a basic WPF form with a DockPanel, there's a Menu bar, a Status bar, and a UserControl. Like so:
```
<DockPanel>
<Menu DockPanel.Dock="Top">
...
</Menu>
<StatusBar DockPanel.Dock="Bottom">
...
</StatusBar>
<UserControls:MyUserControl />
<DockPanel>
```
**My problem is:** Based on an ev... | ```
SELECT SUBSTRING(colDate,0,8) as 'date'
FROM someTable
```
Or am I mistaken?
```
UPDATE someTable
SET newDateField = SUBSTRING(colDate,0,8)
```
Would likely work too. Untested. |
539,945 | <p>I want to send WM_HOTKEY to be captured by other application using a global desktop HotShortCut.</p>
<p>The expected Keys are CTRL + F10</p>
<p>This is the only way I found to trigger the capture of WM_HOTKEY:</p>
<pre><code>procedure TfmMain.ButtonTalkClick(Sender: TObject);
var
Article: TArticleBase;
Msg: T... | [
{
"answer_id": 539967,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 0,
"selected": false,
"text": "<p>Raymond says You're Doing It Wrong:</p>\n\n<p><a href=\"http://blogs.msdn.com/oldnewthing/archive/2005/05/30/423202.asp... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36875/"
] | I want to send WM\_HOTKEY to be captured by other application using a global desktop HotShortCut.
The expected Keys are CTRL + F10
This is the only way I found to trigger the capture of WM\_HOTKEY:
```
procedure TfmMain.ButtonTalkClick(Sender: TObject);
var
Article: TArticleBase;
Msg: TMessage;
begin
Article:=... | Done using [PostKeyEx32](http://www.delphitricks.com/source-code/windows/simulate_the_pressing_of_keyboard_keys.html).
```
procedure TfmMain.ButtonTalkClick(Sender: TObject);
var
Article: TArticleBase;
begin
Article:= GetSelectedArticle;
if Article <> nil then
begin
Clipboard.AsText:= Article.SelectedText;... |
539,960 | <p>I am a new php and mysql programmer. I am handling quite large amount of data, and in future it will grow slowly, thus I am using hash table. I have couple of questions:</p>
<ol>
<li><p>Does mysql have hash table built in function? If yes, how to use that?</p></li>
<li><p>After couple of days doing research about h... | [
{
"answer_id": 539994,
"author": "Suroot",
"author_id": 64626,
"author_profile": "https://Stackoverflow.com/users/64626",
"pm_score": 1,
"selected": false,
"text": "<p>1) Hashtables do exist in MySQL but are used to keep internal track of keys on tables.\n2) Hashtables work by hashing a ... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65379/"
] | I am a new php and mysql programmer. I am handling quite large amount of data, and in future it will grow slowly, thus I am using hash table. I have couple of questions:
1. Does mysql have hash table built in function? If yes, how to use that?
2. After couple of days doing research about hash table. I briefly know wha... | (sorry about the italics, underscores can trigger them but I can't find a good way to disable that in the middle of a paragraph. Ignore the italics, I didn't mean to put them there)
You don't need to worry about using a hashtable with MySQL. If you intend to have a large number of items in memory while you operate on ... |
539,983 | <p>I have got a collection. The coll has strings:</p>
<pre><code>Location="Theater=2, Name=regal, Area=Area1"
</code></pre>
<p>and so on. I have to extract just the Name bit from the string. For example, here I have to extract the text 'regal'</p>
<p>I am struggling with the query:</p>
<p>Collection.Location.???? (... | [
{
"answer_id": 539989,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 2,
"selected": false,
"text": "<pre><code>Location.Split(\",\").Select(x => x.Split(\"=\")[1])\n</code></pre>\n\n<p>That's the extremely lazy, complet... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have got a collection. The coll has strings:
```
Location="Theater=2, Name=regal, Area=Area1"
```
and so on. I have to extract just the Name bit from the string. For example, here I have to extract the text 'regal'
I am struggling with the query:
Collection.Location.???? (what to add here)
Which is the most sho... | Another LINQ-style answer (without the overhead of a dictionary):
```
var name = (from part in location.Split(',')
let pair = part.Split('=')
where pair[0].Trim() == "Name"
select pair[1].Trim()).FirstOrDefault();
```
---
re group by (edit):
```
var records = new[] {
... |
539,984 | <p>I've <a href="https://stackoverflow.com/questions/539791/tips-for-collaboratively-editing-a-latex-document/539848#539848">seen</a> at least two <a href="https://stackoverflow.com/questions/193298/best-practices-in-latex/196724#196724">recommendations</a> on StackOverflow to insert newlines between sentences when edi... | [
{
"answer_id": 540760,
"author": "Jouni K. Seppänen",
"author_id": 26575,
"author_profile": "https://Stackoverflow.com/users/26575",
"pm_score": 2,
"selected": false,
"text": "<p>If you put a comment marker at the end of each sentence, Emacs knows not to move the next line inside the com... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2509/"
] | I've [seen](https://stackoverflow.com/questions/539791/tips-for-collaboratively-editing-a-latex-document/539848#539848) at least two [recommendations](https://stackoverflow.com/questions/193298/best-practices-in-latex/196724#196724) on StackOverflow to insert newlines between sentences when editing LaTeX documents. The... | Here's [what I use](http://procrastiblog.com/2007/11/25/style-guidelines-for-people/), which was mostly cribbed from [Luca de Alfaro](http://luca.cse.ucsc.edu/Style_guidelines_for_student_co-authors):
```
(defun fill-sentence ()
(interactive)
(save-excursion
(or (eq (point) (point-max)) (forward-char))
(fo... |
540,000 | <p>I want to write a SQL 2005 script to create a new login that uses Windows authentication. The Windows user is a local account (not a domain one). A local account with the same name exists on many SQL Server machines and I want to run the same script on all of them.</p>
<p>It seemed simple enough:</p>
<pre><code>CR... | [
{
"answer_id": 540006,
"author": "beach",
"author_id": 53892,
"author_profile": "https://Stackoverflow.com/users/53892",
"pm_score": 2,
"selected": false,
"text": "<p>This just worked for me:</p>\n\n<pre><code>DECLARE @sql nvarchar(1000)\nSET @SQL = 'CREATE LOGIN [' + @@SERVERNAME + '\\M... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20336/"
] | I want to write a SQL 2005 script to create a new login that uses Windows authentication. The Windows user is a local account (not a domain one). A local account with the same name exists on many SQL Server machines and I want to run the same script on all of them.
It seemed simple enough:
```
CREATE LOGIN [MyUser]
F... | Looks like sp\_executesql is the answer, as beach posted. I'll post mine as well, because @@SERVERNAME doesn't work correctly if you use named SQL instances, as we do.
```
DECLARE @loginName SYSNAME
SET @loginName = CAST(SERVERPROPERTY('MachineName') AS SYSNAME) + '\MyUser'
IF NOT EXISTS (SELECT * FROM sys.server_pri... |
540,007 | <p>Hi I'm using php and sql through odbc to write a program and i hav got abit stuck in a part where i want to display the current date/time in the format date('Y-m-d H:i:s) but it only displays the gmt time. I want to add 8hours to it.Can any of you b able to help me.Thank you so much</p>
| [
{
"answer_id": 540011,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 2,
"selected": false,
"text": "<p>Check out <a href=\"http://us3.php.net/date_default_timezone_set\" rel=\"nofollow noreferrer\"><code>date_defa... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Hi I'm using php and sql through odbc to write a program and i hav got abit stuck in a part where i want to display the current date/time in the format date('Y-m-d H:i:s) but it only displays the gmt time. I want to add 8hours to it.Can any of you b able to help me.Thank you so much | Check out [`date_default_timezone_set`](http://us3.php.net/date_default_timezone_set). You can do something like:
```
date_default_timezone_set('America/Los_Angeles');
print 'Current datetime is: ' . date('Y-m-d H:i:s');
```
You could use that to set the timezone to whatever timezone you need time to be at, and then... |
540,014 | <p>How does one compute the area of intersection between a triangle (specified as three (X,Y) pairs) and a circle (X,Y,R)? I've done some searching to no avail. This is for work, not school. :)</p>
<p>It would look something like this in C#:</p>
<pre><code>struct { PointF vert[3]; } Triangle;
struct { PointF cente... | [
{
"answer_id": 540028,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 1,
"selected": false,
"text": "<p>Assuming you're talking integer pixels, not real, the naive implementation would be to loop through every pixel of the tria... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49737/"
] | How does one compute the area of intersection between a triangle (specified as three (X,Y) pairs) and a circle (X,Y,R)? I've done some searching to no avail. This is for work, not school. :)
It would look something like this in C#:
```
struct { PointF vert[3]; } Triangle;
struct { PointF center; float radius; } Circl... | If you want an exact solution (or at least as exact as you can get using floating-point arithmetic) then this is going to involve a lot of legwork, because there are so many cases to consider.
I count nine different cases (categorized in the figure below by the number of vertices of the triangle inside the circle, and... |
540,066 | <p>I know in php you are able to make a call like:</p>
<pre><code>$function_name = 'hello';
$function_name();
function hello() { echo 'hello'; }
</code></pre>
<p>Is this possible in .Net?</p>
| [
{
"answer_id": 540075,
"author": "ottobar",
"author_id": 5830,
"author_profile": "https://Stackoverflow.com/users/5830",
"pm_score": 9,
"selected": true,
"text": "<p>Yes. You can use reflection. Something like this:</p>\n<pre class=\"lang-cs prettyprint-override\"><code>Type thisType = t... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48943/"
] | I know in php you are able to make a call like:
```
$function_name = 'hello';
$function_name();
function hello() { echo 'hello'; }
```
Is this possible in .Net? | Yes. You can use reflection. Something like this:
```cs
Type thisType = this.GetType();
MethodInfo theMethod = thisType.GetMethod(TheCommandString);
theMethod.Invoke(this, userParameters);
```
With the above code, the method which is invoked must have access modifier `public`. If calling a non-public method, one nee... |
540,073 | <p>I wouldn't mind writing my own function to do this but I was wondering if there existed one in the string.h or if there was a standard way to do this.</p>
<pre><code>char *string = "This is a string";
strcut(string, 4, 7);
printf("%s", string); // 'This a string'
</code></pre>
<p>Thanks!</p>
| [
{
"answer_id": 540090,
"author": "Suroot",
"author_id": 64626,
"author_profile": "https://Stackoverflow.com/users/64626",
"pm_score": -1,
"selected": false,
"text": "<p>If you are doing this in C and know the offset then it's pretty simple.</p>\n\n<pre><code>char string[] = \"my string\"... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58657/"
] | I wouldn't mind writing my own function to do this but I was wondering if there existed one in the string.h or if there was a standard way to do this.
```
char *string = "This is a string";
strcut(string, 4, 7);
printf("%s", string); // 'This a string'
```
Thanks! | Use memmove to move the tail, then put '\0' at the new end position. Be careful not to use memcpy - its behaviour is undefined in this situation since source and destination usually overlap. |
540,078 | <p>I'm sorry for a redundant question. However, I've found many solutions to my problem but none of them are very well explained. I'm hoping that it will be made clear, here.</p>
<p>My C# application's main thread spawns 1..n background workers using the ThreadPool. I wish for the original thread to lock until all ... | [
{
"answer_id": 540124,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": false,
"text": "<p>First, how long do the workers execute? pool threads should generally be used for short-lived tasks - if they are ... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56998/"
] | I'm sorry for a redundant question. However, I've found many solutions to my problem but none of them are very well explained. I'm hoping that it will be made clear, here.
My C# application's main thread spawns 1..n background workers using the ThreadPool. I wish for the original thread to lock until all of the worker... | Try this. The function takes in a list of Action delegates. It will add a ThreadPool worker entry for each item in the list. It will wait for every action to complete before returning.
```
public static void SpawnAndWait(IEnumerable<Action> actions)
{
var list = actions.ToList();
var handles = new ManualResetE... |
540,087 | <p>I have a repository whose layout is like this:</p>
<pre>
trunk/
projectA
projectB
branches/
projectA-1.0
projectB-1.0
tags/
projectA-1.0.1
projectB-1.0.1
</pre>
<p>I want to convert them to separate git repositories with the trunk/projectA as the top-leve... | [
{
"answer_id": 540119,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": false,
"text": "<p>Did you consider <strong><a href=\"https://stackoverflow.com/questions/572893/cloning-a-non-standard-svn-repository-with-git... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9594/"
] | I have a repository whose layout is like this:
```
trunk/
projectA
projectB
branches/
projectA-1.0
projectB-1.0
tags/
projectA-1.0.1
projectB-1.0.1
```
I want to convert them to separate git repositories with the trunk/projectA as the top-level directory a... | What I ended up doing was cloning the root of the repository and copying that new git repo for each project and rearranging things. It wasn't clean or pretty, but it was legacy code that I no longer need to look at very often. |
540,100 | <p>I hope that someone can help me with this problem that I've been having with XmlSerializer. </p>
<p>I've already looked through this thread: <a href="http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/551cee76-fd80-48f8-ac6b-5c22c234fecf/" rel="nofollow noreferrer">http://social.msdn.microsoft.com/Foru... | [
{
"answer_id": 540141,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "<p>You really should consider something like <a href=\"https://trello.com\" rel=\"nofollow noreferrer\">Trello</a>, <a ... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65407/"
] | I hope that someone can help me with this problem that I've been having with XmlSerializer.
I've already looked through this thread: <http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/551cee76-fd80-48f8-ac6b-5c22c234fecf/>
The error I am getting is:
System.InvalidOperationException: Unable to generate... | If you have SharePoint in house already,along with a user base that is comfortable using it I think it would be fairly easy to get started with using it for SCRUM. I would start with the following:
A site collection to hold 1 scrum site per project
A scrum site should contain:
* Document library for the electronic f... |
540,125 | <p>I have the following use case ,
array of integers </p>
<pre><code>vector<int> containing elements 123 345 678 890 555 ...
pos 0 1 2 3 4
</code></pre>
<p>Based on the bits representation I receive for e.g </p>
<pre><code>101 then return 123 678 (Elements of the arr... | [
{
"answer_id": 540183,
"author": "MSN",
"author_id": 6210,
"author_profile": "https://Stackoverflow.com/users/6210",
"pm_score": 2,
"selected": false,
"text": "<p>You ultimately want to map bits set to their bit index. That's pretty easy using well-known bit twiddling hacks: </p>\n\n<pre... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43756/"
] | I have the following use case ,
array of integers
```
vector<int> containing elements 123 345 678 890 555 ...
pos 0 1 2 3 4
```
Based on the bits representation I receive for e.g
```
101 then return 123 678 (Elements of the array with its position bits set)
0011 then re... | You ultimately want to map bits set to their bit index. That's pretty easy using well-known bit twiddling hacks:
```
bit_mask_iterator= bits;
while (bit_mask_iterator)
{
long single_bit_set= bit_mask_iterator & -bit_mask_iterator;
long bit_index= count_bits_set(single_bit_set - 1); // this is the index you w... |
540,128 | <p>I'm using CodeIgniter, and will likely use their template library as I want to keep things extremely simple to use. The content for the template variables will come from the database, but I want the business admins to know what content areas are available. Basically the names of the parameters when they choose a spe... | [
{
"answer_id": 562423,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 1,
"selected": false,
"text": "<p>You could do this directly in the controller:</p>\n\n<pre><code>// in the controller\nprint_r($data);\n$this->l... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm using CodeIgniter, and will likely use their template library as I want to keep things extremely simple to use. The content for the template variables will come from the database, but I want the business admins to know what content areas are available. Basically the names of the parameters when they choose a specif... | I think the nicest way would be to add a small hack to the template parser class. The code looks quite readable and clean in system/libraries/Parser.php. You could insert a hook in that class that can be used to keep track of the variables. I don't know, if it works, but here's a snippet:
```
class CI_Parser {
var... |
540,140 | <p>In C++, what is the convention for including headers for class files in the "main" file. e.g.</p>
<pre><code>myclass.h
class MyClass {
doSomething();
}
myclass.cpp
doSomething() {
cout << "doing something";
}
run.cpp
#include "myclass.h"
#include "myclass.cpp"
etc..
</code></pre>
<p>Is t... | [
{
"answer_id": 540153,
"author": "Steve Rowe",
"author_id": 40744,
"author_profile": "https://Stackoverflow.com/users/40744",
"pm_score": 1,
"selected": false,
"text": "<p>See <a href=\"https://stackoverflow.com/questions/533076/understanding-c-compilers-from-a-java-c-perspective/533138#... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64895/"
] | In C++, what is the convention for including headers for class files in the "main" file. e.g.
```
myclass.h
class MyClass {
doSomething();
}
myclass.cpp
doSomething() {
cout << "doing something";
}
run.cpp
#include "myclass.h"
#include "myclass.cpp"
etc..
```
Is this relatively standard? | You don't include the .cpp file, only the .h file. The function definitions in the .cpp will be compiled to .obj files, which will then be linked into the final binary. If you include the .cpp file in other .cpp files, you will get two different .obj files with the same funciton definition compiled, which will lead to ... |
540,142 | <p>There are similar questions at SO, but none that seem to address this.</p>
<p>Below is a very simplified variant of my situation. Drupal/PHP site -- I have a form w/ submit button that I am using jquery.form plugin to ajax-ly submit. It works fine if I use the submit (#submit) button. </p>
<p>Now, I want to progra... | [
{
"answer_id": 540246,
"author": "ayaz",
"author_id": 23191,
"author_profile": "https://Stackoverflow.com/users/23191",
"pm_score": 0,
"selected": false,
"text": "<p>You may also need to <code>return false</code> immediately after triggering the form submit button from the non-form submi... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11397/"
] | There are similar questions at SO, but none that seem to address this.
Below is a very simplified variant of my situation. Drupal/PHP site -- I have a form w/ submit button that I am using jquery.form plugin to ajax-ly submit. It works fine if I use the submit (#submit) button.
Now, I want to programmatically fire t... | I managed to solve a similar situation to yours. If the only objective of simulating a click on submit1 is to submit the form, you might try:
```
$('#submit2').click(function() {
$('#form').trigger('submit');
});
``` |
540,146 | <p>I have a table in my database in which records conceptually can be children of other rcords. The table has a non-null name field. I need to ensure that each name in a set of children is unique, but not across the entire database. I'd like to enforce this using a constraint inside the Database. What's the best way to... | [
{
"answer_id": 540164,
"author": "James",
"author_id": 56753,
"author_profile": "https://Stackoverflow.com/users/56753",
"pm_score": 1,
"selected": false,
"text": "<p>At first glance I believe this should go into a \"Instead of trigger\". This <a href=\"https://web.archive.org/web/1/http... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65408/"
] | I have a table in my database in which records conceptually can be children of other rcords. The table has a non-null name field. I need to ensure that each name in a set of children is unique, but not across the entire database. I'd like to enforce this using a constraint inside the Database. What's the best way to ac... | I may not be understanding your question correctly, but my suggestion is to create another column that references the parent record of the child. You could then create a A multiple-column index based on those two columns to speed up any queries that reference these columns together in a where clause... Thus your unique... |
540,168 | <p>If I got a table in a text file such like</p>
<ul>
<li>A B 1</li>
<li>A C 2</li>
<li>A D 1</li>
<li>B A 3</li>
<li>C D 2</li>
<li>A E 1</li>
<li>E D 2</li>
<li>C B 2</li>
<li>. . .</li>
<li>. . .</li>
<li>. . .</li>
</ul>
<p>And I got another symbol list in another text file. I want to transform this table into a ... | [
{
"answer_id": 540224,
"author": "Chris Lutz",
"author_id": 60777,
"author_profile": "https://Stackoverflow.com/users/60777",
"pm_score": 3,
"selected": true,
"text": "<p>Use an array for the first one and a 2-dimentional hash for the second one. The first one should look roughly like:</... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65411/"
] | If I got a table in a text file such like
* A B 1
* A C 2
* A D 1
* B A 3
* C D 2
* A E 1
* E D 2
* C B 2
* . . .
* . . .
* . . .
And I got another symbol list in another text file. I want to transform this table into a Perl data structure like:
* \_ A D E . . .
* A 0 1 1 . . .
* D 1 0 2 . . .
* E 1 2 0 . . .
* . . ... | Use an array for the first one and a 2-dimentional hash for the second one. The first one should look roughly like:
```
$list[0] # row 1 - the value is "A B 1"
```
And the hash like:
```
$hash{A}{A} # the intersection of A and A - the value is 0
```
Figuring out how to implement a problem is about 75% of the ment... |
540,201 | <p>I would like to implement a URL rewrriter for DotNetNuke. Have questions as to whether this is a good or possible approach and any suggestions other developers may have.</p>
<p>Can I add a dynamic or static route for URL rewriter from the 'Pages'-> 'Add Page' section?</p>
<p>Let's say I'm creating a page called 'E... | [
{
"answer_id": 540218,
"author": "Brandon",
"author_id": 63775,
"author_profile": "https://Stackoverflow.com/users/63775",
"pm_score": 2,
"selected": false,
"text": "<p>Check this out - details here:</p>\n\n<p><a href=\"http://www.ifinity.com.au/Blog/Technical_Blog/EntryId/19/Rewriting-t... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53885/"
] | I would like to implement a URL rewrriter for DotNetNuke. Have questions as to whether this is a good or possible approach and any suggestions other developers may have.
Can I add a dynamic or static route for URL rewriter from the 'Pages'-> 'Add Page' section?
Let's say I'm creating a page called 'Events' underneath... | If you're using DotNetNuke 4.8 or greater, you just need to enable Human Friendly Urls through the Web.Config.
To enable human friendly urls, replace:
```
<add name="DNNFriendlyUrl" type="DotNetNuke.Services.Url.FriendlyUrl.DNNFriendlyUrlProvider, DotNetNuke.HttpModules" includePageName="true" regexMatch="[^a-zA-Z0-9... |
540,215 | <p>I have a WCF service that is behind an enterprise-class firewall, which is doing both hostname and port translation, e.g.:</p>
<p><a href="https://ws.address.com/Service.svc" rel="nofollow noreferrer">https://ws.address.com/Service.svc</a> --> <a href="https://serv.internal.com:44000/Service.svc" rel="nofollow nore... | [
{
"answer_id": 540243,
"author": "Brandon",
"author_id": 63775,
"author_profile": "https://Stackoverflow.com/users/63775",
"pm_score": 1,
"selected": false,
"text": "<p>You may need to explicitly create your own Binding (i.e., ServiceModel.WSHttpBinding) and add a Service Endpoint (.AddS... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7623/"
] | I have a WCF service that is behind an enterprise-class firewall, which is doing both hostname and port translation, e.g.:
<https://ws.address.com/Service.svc> --> <https://serv.internal.com:44000/Service.svc>
The service is secured with SSL-128 and requires a client certificate.
Because the internal server name is ... | You may need to explicitly create your own Binding (i.e., ServiceModel.WSHttpBinding) and add a Service Endpoint (.AddServiceEndpoint(..) ) with that binding.
<http://msdn.microsoft.com/en-us/library/system.servicemodel.servicehost.addserviceendpoint(VS.85).aspx> |
540,248 | <p>I have got a collection. The coll has strings:</p>
<pre><code>Location="Theater=1, Name=regal, Area=Area1"
Location="Theater=34, Name=Karm, Area=Area4445"
</code></pre>
<p>and so on. I have to extract just the Name bit from the string. For example, here I have to extract the text 'regal' and group the query. Then... | [
{
"answer_id": 540274,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p>Once you've extracted the string, just group by it and count the results:</p>\n\n<pre><code>var query = from location... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have got a collection. The coll has strings:
```
Location="Theater=1, Name=regal, Area=Area1"
Location="Theater=34, Name=Karm, Area=Area4445"
```
and so on. I have to extract just the Name bit from the string. For example, here I have to extract the text 'regal' and group the query. Then display the result as
`... | Yet another Linq + Regex approach:
```
string[] Location = {
"Theater=2, Name=regal, Area=Area1",
"Theater=2, Name=regal, Area=Area1",
"Theater=34, Name=Karm, Area=Area4445"
};
var test = Location.Select(
... |
540,261 | <p>i have a web service which contains a method like the following </p>
<pre><code> [WebMethod]
public string UploadFile(byte[] bytes, string file_name)
{
}
</code></pre>
<p>i want to invoke this web service method using HttpWebRequest so that i can stream the file without buffering in memory. How can do it... ... | [
{
"answer_id": 540276,
"author": "Anton Gogolev",
"author_id": 60188,
"author_profile": "https://Stackoverflow.com/users/60188",
"pm_score": 1,
"selected": false,
"text": "<p>Open up <code>http://localhost/xxx/xxx.asmx/Upload</code> in your browser and ASP.NET will give you an example PO... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | i have a web service which contains a method like the following
```
[WebMethod]
public string UploadFile(byte[] bytes, string file_name)
{
}
```
i want to invoke this web service method using HttpWebRequest so that i can stream the file without buffering in memory. How can do it... i tried to invoke it as fo... | Open up `http://localhost/xxx/xxx.asmx/Upload` in your browser and ASP.NET will give you an example POST requrest you'll need to send in order to invoke the method. Start from there on. |
540,275 | <p>I'm writing a series of related mod_perl handlers for various login-related functions in Apache, so my Apache config file looks like this (for example)</p>
<pre><code>PerlAccessHandler MyApache::MyAccess
PerlAuthenHandler MyApache::MyAuthen
PerlAuthzHandler MyApache::MyAuthz
</code></pre>
<p>Each of the module... | [
{
"answer_id": 540312,
"author": "AndrewR",
"author_id": 2994,
"author_profile": "https://Stackoverflow.com/users/2994",
"pm_score": 1,
"selected": false,
"text": "<p>Looks like one possibility might be using the <code>push_handlers()</code> call and setting up the handlers in code rathe... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2994/"
] | I'm writing a series of related mod\_perl handlers for various login-related functions in Apache, so my Apache config file looks like this (for example)
```
PerlAccessHandler MyApache::MyAccess
PerlAuthenHandler MyApache::MyAuthen
PerlAuthzHandler MyApache::MyAuthz
```
Each of the modules (`MyAccess`, `MyAuthen`... | It appears from the [mod\_perl 2.0 docs](http://perl.apache.org/docs/2.0/user/coding/coding.html#Method_Handlers) that you can use the "method" syntax to do what you're wanting (I've not tested this):
```
PerlAccessHandler MyApache::MyLoginModule->access_handler
PerlAuthenHandler MyApache::MyLoginModule->authen_handl... |
540,282 | <p>I have used log4j for looging error log using FileAppender. The problem is its logging the same error two times in a log file when the below situation </p>
<p><strong>Case1:</strong></p>
<pre><code>Class1 :
public void func(){
try{
new Class2.prop()
}catch(IOException ioe){
logger.log(2,io... | [
{
"answer_id": 540297,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p><em>But its logging the error one time for the below case.</em></p>\n</blockquote>\n\n<p>That's becaus... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51659/"
] | I have used log4j for looging error log using FileAppender. The problem is its logging the same error two times in a log file when the below situation
**Case1:**
```
Class1 :
public void func(){
try{
new Class2.prop()
}catch(IOException ioe){
logger.log(2,ioe);
}
}
Class2 :
public void... | >
> *But its logging the error one time for the below case.*
>
>
>
That's because you're **handling** the exception:
Class1:
```
public void func() {
try{
new Class2.prop()
}catch(IOException ioe){
logger.log(2,ioe);
}
}
```
Class2 :
```
public void prop() throws IOExce... |
540,285 | <p>I want to get an NSData object's contents from a URL. What is the more efficient way of doing this in terms of memory usage dataWithContentsOfURL (or initWithContentsOfURL) or using NSURLConnection?</p>
<p>Should I use</p>
<pre><code>NSData *data = [[NSData alloc] initWithContentsOfURL:myURL]
</code></pre>
<p>or<... | [
{
"answer_id": 540290,
"author": "Alex Wayne",
"author_id": 62076,
"author_profile": "https://Stackoverflow.com/users/62076",
"pm_score": 0,
"selected": false,
"text": "<p>Pretty sure they are quite equivalent.</p>\n"
},
{
"answer_id": 540495,
"author": "Rog",
"author_id"... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46297/"
] | I want to get an NSData object's contents from a URL. What is the more efficient way of doing this in terms of memory usage dataWithContentsOfURL (or initWithContentsOfURL) or using NSURLConnection?
Should I use
```
NSData *data = [[NSData alloc] initWithContentsOfURL:myURL]
```
or
```
NSData *data = [NSURLConnect... | I don't know the internals of Apple's code but I would guess NSData's initWithContents of URL uses NSURLConnection internally. Memory usage differences will be negligible.
Using the asynchronous apis of NSURLConnection would allow you to be more memory efficient by handling data as it came in but (without knowing what... |
540,287 | <p>How should I write error reporting modules in PHP?
Say, I want to write a function in PHP: 'bool isDuplicateEmail($email)'.
In that function, I want to check if the $email is already present in the database.
It will return 'true', if exists. Else 'false'.</p>
<p>Now, the query execution can also fail, In that time ... | [
{
"answer_id": 540341,
"author": "Karsten",
"author_id": 28144,
"author_profile": "https://Stackoverflow.com/users/28144",
"pm_score": 1,
"selected": false,
"text": "<p>Using MVC, i always use some sort of default error/exception handler, where actions with exceptions (and no own error-/... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48625/"
] | How should I write error reporting modules in PHP?
Say, I want to write a function in PHP: 'bool isDuplicateEmail($email)'.
In that function, I want to check if the $email is already present in the database.
It will return 'true', if exists. Else 'false'.
Now, the query execution can also fail, In that time I want to ... | In my PHP projects, I have tried several different tacts. I've come to the following solution which seems to work well for me:
First, any major PHP application I write has some sort of central singleton that manages application-level data and behaviors. The "Application" object. I mention that here because I use this ... |
540,288 | <p>i would like to create a UIButton it will zoom in when mouse over it,can anyone tell me which event can do this</p>
| [
{
"answer_id": 540341,
"author": "Karsten",
"author_id": 28144,
"author_profile": "https://Stackoverflow.com/users/28144",
"pm_score": 1,
"selected": false,
"text": "<p>Using MVC, i always use some sort of default error/exception handler, where actions with exceptions (and no own error-/... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | i would like to create a UIButton it will zoom in when mouse over it,can anyone tell me which event can do this | In my PHP projects, I have tried several different tacts. I've come to the following solution which seems to work well for me:
First, any major PHP application I write has some sort of central singleton that manages application-level data and behaviors. The "Application" object. I mention that here because I use this ... |
540,293 | <p>As by design an enum constant in java is a singleton, and for sake of concurrent usage I normally create stateless enum instances and use method parameters to inject the data as needed.</p>
<p>Example:</p>
<p>Currently I am creating a REST service which has Operations (implemented as an enum using a variant of the... | [
{
"answer_id": 540306,
"author": "mparaz",
"author_id": 48256,
"author_profile": "https://Stackoverflow.com/users/48256",
"pm_score": 5,
"selected": true,
"text": "<p>I think it violates the Principle of Least Astonishment. </p>\n\n<p>People expect the common usage of enums as they were ... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16193/"
] | As by design an enum constant in java is a singleton, and for sake of concurrent usage I normally create stateless enum instances and use method parameters to inject the data as needed.
Example:
Currently I am creating a REST service which has Operations (implemented as an enum using a variant of the strategy pattern... | I think it violates the Principle of Least Astonishment.
People expect the common usage of enums as they were originally designed - as constants or tokens, and not as general purpose classes with state. |
540,294 | <p>If I'm building some XML and using <code><![CDATA[...]]></code>, how do I encode data that may include a <code>]]></code> substring? would it be <code>]]&gt;</code>? I ask because I always thought CDATA content was literal content.</p>
| [
{
"answer_id": 540302,
"author": "Sciolist",
"author_id": 16045,
"author_profile": "https://Stackoverflow.com/users/16045",
"pm_score": 3,
"selected": false,
"text": "<p>It's not terribly efficient, or easy to read, or anything, but <a href=\"http://en.wikipedia.org/wiki/CDATA#Uses_of_CD... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9266/"
] | If I'm building some XML and using `<![CDATA[...]]>`, how do I encode data that may include a `]]>` substring? would it be `]]>`? I ask because I always thought CDATA content was literal content. | It's not terribly efficient, or easy to read, or anything, but [an approach to this](http://en.wikipedia.org/wiki/CDATA#Uses_of_CDATA_sections) appears to be writing..
```
]]]]><![CDATA[>
``` |
540,298 | <p>I want to ask if it is possible to pass arguments to a script function by reference:</p>
<p>i.e. to do something that would look like this in C++:</p>
<pre class="lang-cpp prettyprint-override"><code>void boo(int &myint) { myint = 5; }
int main() {
int t = 4;
printf("%d\n", t); // t->4
boo(t);
... | [
{
"answer_id": 540343,
"author": "RomanM",
"author_id": 14587,
"author_profile": "https://Stackoverflow.com/users/14587",
"pm_score": 4,
"selected": false,
"text": "<p>I have found a way to do this but I am not sure how correct this is:</p>\n\n<pre><code>Newfun()\n{\n local var1=\"$1\... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14587/"
] | I want to ask if it is possible to pass arguments to a script function by reference:
i.e. to do something that would look like this in C++:
```cpp
void boo(int &myint) { myint = 5; }
int main() {
int t = 4;
printf("%d\n", t); // t->4
boo(t);
printf("%d\n", t); // t->5
}
```
So then in BASH I want t... | It's 2018, and this question deserves an update. At least in Bash, as of Bash 4.3-alpha, you can use *namerefs* to pass function arguments by reference:
```
function boo()
{
local -n ref=$1
ref='new'
}
SOME_VAR='old'
echo $SOME_VAR # -> old
boo SOME_VAR
echo $SOME_VAR # -> new
```
The critical pieces here... |
540,300 | <p>I have a function inside of a view function inside of a model class in the model.php file that looks like this</p>
<pre><code>function sqlToUnix($date){
$YMDThenHMS = explode(" ", $date);
$YMD = explode("-", $YMDThenHMS[0]);
$HMS = explode(":", $YMDThenHMS[1]);
$UnixTime = mktime($HMS[0], $HMS[1], $... | [
{
"answer_id": 540307,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I was able to fix the problem by storing the function in the appController.php and called the function when need be using</... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a function inside of a view function inside of a model class in the model.php file that looks like this
```
function sqlToUnix($date){
$YMDThenHMS = explode(" ", $date);
$YMD = explode("-", $YMDThenHMS[0]);
$HMS = explode(":", $YMDThenHMS[1]);
$UnixTime = mktime($HMS[0], $HMS[1], $HMS[2], $YMD[1... | If you want to call this function from anywhere, i.e. in models, controllers, views, behaviors, components and helpers, you can put it in your app/config/bootstrap.php file. That's what it's for. Once the it's available globally simply as sqlToUnix(); |
540,304 | <p>I am using checkbox in gridview .... I am using it in 1st cell.... When I select the checkbox at run time, I need to get those values... but on selecting or on click to checkbox, it's not finding or value is taking as FALSE... how to write in asp.net backend and in c# code?</p>
<pre><code> <asp:TemplateField>... | [
{
"answer_id": 540834,
"author": "Jakob Christensen",
"author_id": 64161,
"author_profile": "https://Stackoverflow.com/users/64161",
"pm_score": 2,
"selected": false,
"text": "<p>How do you populate your GridView? If you do this in Page_Load, make sure you are not doing it on postbacks ... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using checkbox in gridview .... I am using it in 1st cell.... When I select the checkbox at run time, I need to get those values... but on selecting or on click to checkbox, it's not finding or value is taking as FALSE... how to write in asp.net backend and in c# code?
```
<asp:TemplateField>
<ItemTemplate >
... | How do you populate your GridView? If you do this in Page\_Load, make sure you are not doing it on postbacks (check IsPostBack).
Is your chkBx variable null?
The following code works:
```
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
... |
540,311 | <p>Let's say, I have :</p>
<pre>
Key | Indexes | Key-values
----+---------+------------
001 | 100001 | Alex
002 | 100002 | Micheal
003 | 100003 | Daniel
</pre>
<p>Lets say, we want to search 001, how to do the fast searching process using hash table?</p>
<p>Isn't it the same as we use the "SELECT * from .. " in m... | [
{
"answer_id": 540333,
"author": "SteinNorheim",
"author_id": 19220,
"author_profile": "https://Stackoverflow.com/users/19220",
"pm_score": 0,
"selected": false,
"text": "<p>Hash tables are great for locating entries at O(1) cost where the key (that is used for hashing) is already known.... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65379/"
] | Let's say, I have :
```
Key | Indexes | Key-values
----+---------+------------
001 | 100001 | Alex
002 | 100002 | Micheal
003 | 100003 | Daniel
```
Lets say, we want to search 001, how to do the fast searching process using hash table?
Isn't it the same as we use the "SELECT \* from .. " in mysql? I read alot, ... | A simple hash table works by keeping the items on several lists, instead of just one. It uses a very fast and repeatable (i.e. non-random) method to choose which list to keep each item on. So when it is time to find the item again, it repeats that method to discover which list to look in, and then does a normal (slow) ... |
540,314 | <p>I have a SELECT statement that works, and runs fast enough on my tables (<0.01sec on 50k+ products, 3k+ categories). But in my mind it's not very elegant and would like to hear any suggestions on making it better.</p>
<p>There are 3 tables of interest:</p>
<ul>
<li>products - key productID</li>
<li>catego... | [
{
"answer_id": 540330,
"author": "jishi",
"author_id": 33663,
"author_profile": "https://Stackoverflow.com/users/33663",
"pm_score": 0,
"selected": false,
"text": "<p>I believe your query is quite good, but you could compare it with joins:</p>\n\n<pre>\nSELECT DISTINCT pt1.productID \nFR... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17492/"
] | I have a SELECT statement that works, and runs fast enough on my tables (<0.01sec on 50k+ products, 3k+ categories). But in my mind it's not very elegant and would like to hear any suggestions on making it better.
There are 3 tables of interest:
* products - key productID
* categories - key categoryID
* products\_tre... | I can think of a few methods, each of which perform differently depending on indexes and your particular database implementation. Some that may look slow can be optimised in ways you may not have imagined and so it's worth trialling them all and comparing execution plans to see what is happening...
Note1: I use GROUP ... |
540,337 | <p>I am not able to get out of these simple bugs, but would be great full if some one could answer to weed out from these errors. I included windows.h and some other necessary headers but couldn't able get out of it.</p>
<p>Snippet of errors:</p>
<pre><code>error C2146: syntax error : missing ';' before identifier 'M... | [
{
"answer_id": 540357,
"author": "Anton Gogolev",
"author_id": 60188,
"author_profile": "https://Stackoverflow.com/users/60188",
"pm_score": 3,
"selected": true,
"text": "<p>Look in <code>mmsystem.h</code>, lines 112 and 113:</p>\n\n<pre><code>#ifdef _WIN32\ntypedef UINT MMVERSION... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am not able to get out of these simple bugs, but would be great full if some one could answer to weed out from these errors. I included windows.h and some other necessary headers but couldn't able get out of it.
Snippet of errors:
```
error C2146: syntax error : missing ';' before identifier 'MMVERSION'
error C443... | Look in `mmsystem.h`, lines 112 and 113:
```
#ifdef _WIN32
typedef UINT MMVERSION; /* major (high byte), minor (low byte) */
```
So be sure to include `windows.h` befor including `mmsystem.h`, and if it does not help, try `#define`ing `_WIN32` manually. |
540,342 | <pre><code> File "/usr/local/lib/python3.0/cgi.py", line 477, in __init__
self.read_urlencoded()
File "/usr/local/lib/python3.0/cgi.py", line 577, in read_urlencoded
self.strict_parsing):
File "/usr/local/lib/python3.0/urllib/parse.py", line 377, in parse_qsl
pairs = [s2 for s1 in qs.split('&') for... | [
{
"answer_id": 542080,
"author": "bobince",
"author_id": 18936,
"author_profile": "https://Stackoverflow.com/users/18936",
"pm_score": 6,
"selected": true,
"text": "<p>urllib is trying to do:</p>\n\n<pre><code>b'a,b'.split(',')\n</code></pre>\n\n<p>Which doesn't work. byte strings and un... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49701/"
] | ```
File "/usr/local/lib/python3.0/cgi.py", line 477, in __init__
self.read_urlencoded()
File "/usr/local/lib/python3.0/cgi.py", line 577, in read_urlencoded
self.strict_parsing):
File "/usr/local/lib/python3.0/urllib/parse.py", line 377, in parse_qsl
pairs = [s2 for s1 in qs.split('&') for s2 in s1.s... | urllib is trying to do:
```
b'a,b'.split(',')
```
Which doesn't work. byte strings and unicode strings mix even less smoothly in Py3k than they used to — deliberately, to make encoding problems go wrong sooner rather than later.
So the error is rather opaquely telling you ‘you can't pass a byte string to urllib.par... |
540,344 | <p>In Visual Studio 2008's Options > Text Editor > C# > Formatting, I have the following settings ticked.</p>
<ul>
<li><p>Automatically format completed statement on ;</p></li>
<li><p>Automatically format completed block on }</p></li>
</ul>
<p>This is really helpful for when I'm writing a method or a for/foreach/whil... | [
{
"answer_id": 540353,
"author": "Anton Gogolev",
"author_id": 60188,
"author_profile": "https://Stackoverflow.com/users/60188",
"pm_score": 1,
"selected": false,
"text": "<p>ReSharper might have such feature, though I'm not absolutely sure.</p>\n"
},
{
"answer_id": 540369,
"... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39532/"
] | In Visual Studio 2008's Options > Text Editor > C# > Formatting, I have the following settings ticked.
* Automatically format completed statement on ;
* Automatically format completed block on }
This is really helpful for when I'm writing a method or a for/foreach/while/if statement.
ie if I write
```
void MyMetho... | Awesome! I managed to figure it out. Thanks to [Anton](https://stackoverflow.com/questions/540344/is-there-a-way-to-get-visual-studio-2008-to-stop-formatting-my-autoproperties/540353#540353) I had a closer look at the settings available in Resharper and I was able to figure something out.
My solution involves a combin... |
540,345 | <p>The question is simple: How do you load custom <code>UITableViewCell</code> from Xib files? Doing so allows you to use Interface Builder to design your cells. The answer apparently is not simple due to memory managment issues. <a href="https://stackoverflow.com/questions/134575/using-interface-builder-for-uitablevie... | [
{
"answer_id": 540560,
"author": "Stephan Burlot",
"author_id": 53071,
"author_profile": "https://Stackoverflow.com/users/53071",
"pm_score": 0,
"selected": false,
"text": "<p>I dont know if there is a canonical way, but here's my method:</p>\n\n<ul>\n<li>Create a xib for a ViewControlle... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63706/"
] | The question is simple: How do you load custom `UITableViewCell` from Xib files? Doing so allows you to use Interface Builder to design your cells. The answer apparently is not simple due to memory managment issues. [This thread](https://stackoverflow.com/questions/134575/using-interface-builder-for-uitableviews) menti... | Here are two methods which the [original author states was recommended by an IB engineer](http://www.bdunagan.com/2009/06/28/custom-uitableviewcell-from-a-xib-in-interface-builder/).
See the actual post for more details. I prefer method #2 as it seems simpler.
**Method #1:**
```
- (UITableViewCell *)tableView:(UITab... |
540,349 | <p>I have a few images and their rollover images. Using jQuery, I want to show/hide the rollover image when the onmousemove/onmouseout event happen. All my image names follow the same pattern, like this:</p>
<blockquote>
<p>Original Image: <code>Image.gif</code></p>
<p>Rollover Image: <code>Imageover.gif</code></p>
</b... | [
{
"answer_id": 540355,
"author": "Jarrod Dixon",
"author_id": 3,
"author_profile": "https://Stackoverflow.com/users/3",
"pm_score": 10,
"selected": true,
"text": "<p>To set up on ready:</p>\n\n<pre><code>$(function() {\n $(\"img\")\n .mouseover(function() { \n var sr... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2572740/"
] | I have a few images and their rollover images. Using jQuery, I want to show/hide the rollover image when the onmousemove/onmouseout event happen. All my image names follow the same pattern, like this:
>
> Original Image: `Image.gif`
>
>
> Rollover Image: `Imageover.gif`
>
>
>
I want to insert and remove the *"o... | To set up on ready:
```
$(function() {
$("img")
.mouseover(function() {
var src = $(this).attr("src").match(/[^\.]+/) + "over.gif";
$(this).attr("src", src);
})
.mouseout(function() {
var src = $(this).attr("src").replace("over.gif", ".gif");
... |
540,350 | <p>I want generate textboxes dynamically according to user input. If user enter the integer value in the textbox, if he/she enter 5 i want generate 5 textboxes. This code is working in Firefox but not working in IE and Netscape; please help me how to do this or point out any other mistake in this code to me. Also, the ... | [
{
"answer_id": 540366,
"author": "Sesh",
"author_id": 38212,
"author_profile": "https://Stackoverflow.com/users/38212",
"pm_score": 0,
"selected": false,
"text": "<p>Can you try something else than InnerHtml - you can try this:</p>\n\n<ul>\n<li>use GetElementByID to get the element you w... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want generate textboxes dynamically according to user input. If user enter the integer value in the textbox, if he/she enter 5 i want generate 5 textboxes. This code is working in Firefox but not working in IE and Netscape; please help me how to do this or point out any other mistake in this code to me. Also, the tec... | ```
for(var i =1;i<=tot;i++)
{
tbl.innerHTML = 'Mobile No'+i+' <input type="text" size = "20" maxlength= "20" name= hoardingregister.mobileno> <br> \n';
}
```
should be
```
for(var i =1;i<=tot;i++)
{
tbl.innerHTML += 'Mobile No'+i+' <input type="text" size = "20" maxlength= "20" name= hoardingregister.mobile... |
540,364 | <p>actually i'm working with .Net Framework 3.5, so i have all these nice little features like lambdas, linq, etc.</p>
<p>Given is a serial connection (or to be more abstract: a stream) where you receive some data, which will be in a format like this:</p>
<pre><code>struct Packet
{
byte STX
UInt16 DataLength
... | [
{
"answer_id": 540377,
"author": "Peter",
"author_id": 58553,
"author_profile": "https://Stackoverflow.com/users/58553",
"pm_score": 0,
"selected": false,
"text": "<p>I would store them in a byte array and recreate them from there, its a fast and simple way to do it!</p>\n\n<p>I would re... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1838048/"
] | actually i'm working with .Net Framework 3.5, so i have all these nice little features like lambdas, linq, etc.
Given is a serial connection (or to be more abstract: a stream) where you receive some data, which will be in a format like this:
```
struct Packet
{
byte STX
UInt16 DataLength
string Data
b... | How about...
```
struct Packet
{
public byte STX;
public UInt16 DataLength;
public string Data;
public byte CRC;
public byte ETX;
}
//Warning: Need to add error handling
class PacketReader
{
private BinaryReader _reader;
public PacketReader(Stream stream)
{
_reader = new Binar... |
540,391 | <p>I have table with multiple rows, showing items for sale. When the user clicks on a row, a Javascript inserts / shows a new row right beneath it with details about the item. The issue is when the description is long, it forces the column widths to readjust / resize. This shifts the columns positions and is really ann... | [
{
"answer_id": 540400,
"author": "Sachin Gaur",
"author_id": 2572740,
"author_profile": "https://Stackoverflow.com/users/2572740",
"pm_score": 0,
"selected": false,
"text": "<p>You can display the details of the row beneath the clicked one in DIV and set its</p>\n\n<pre><code>style=\"ove... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have table with multiple rows, showing items for sale. When the user clicks on a row, a Javascript inserts / shows a new row right beneath it with details about the item. The issue is when the description is long, it forces the column widths to readjust / resize. This shifts the columns positions and is really annoyi... | For those looking for the code (this is done in jQuery). This also assumes the first row has the proper widths for each cell. Pretty easy changes if needed.
```
$('table.class_of_table_to_fix tr:first td').each(function() {
$(this).css({'width': $(this).width()+"px"});
});
``` |
540,401 | <p>I think it's a good practise to always return empty lists or arrays instead of null
when a method comes up with no results to avoid null checks in the code.</p>
<p>Because Rhino Mocks returns the default value for an object, which is null for lists and arrays, a lot of times I have to either add the null checks ba... | [
{
"answer_id": 540422,
"author": "Richard Szalay",
"author_id": 3603,
"author_profile": "https://Stackoverflow.com/users/3603",
"pm_score": 0,
"selected": false,
"text": "<p>There is nothing in Rhino Mocks to automatically solve your problem. The simplest solution is to simply setup an e... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11547/"
] | I think it's a good practise to always return empty lists or arrays instead of null
when a method comes up with no results to avoid null checks in the code.
Because Rhino Mocks returns the default value for an object, which is null for lists and arrays, a lot of times I have to either add the null checks back in or s... | Turns out that this behaviour is possible with [Moq](http://code.google.com/p/moq/) as long as the returned object is IEnumerable. The following tests pass:
```
[Test]
public void EmptylListTest()
{
var repositoryMock = new Mock<ICustomerRepository>();
IEnumerable<Customer> customers = repositoryMock.Object.G... |
540,427 | <p>I have a C interface that looks like this (simplified):</p>
<pre><code>extern bool Operation(void ** ppData);
extern float GetFieldValue(void* pData);
extern void Cleanup(p);
</code></pre>
<p>which is used as follows:</p>
<pre><code>void * p = NULL;
float theAnswer = 0.0f;
if (Operation(&p))
{
theAnswer = ... | [
{
"answer_id": 540507,
"author": "theller",
"author_id": 65023,
"author_profile": "https://Stackoverflow.com/users/65023",
"pm_score": 2,
"selected": false,
"text": "<p>Would you be willing to use ctypes? Here is sample code that should work (although it is untested):</p>\n\n<pre><code>... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2683/"
] | I have a C interface that looks like this (simplified):
```
extern bool Operation(void ** ppData);
extern float GetFieldValue(void* pData);
extern void Cleanup(p);
```
which is used as follows:
```
void * p = NULL;
float theAnswer = 0.0f;
if (Operation(&p))
{
theAnswer = GetFieldValue(p);
Cleanup(p);
}
```
... | I agree with theller, you should use ctypes instead. It's always easier than thinking about typemaps.
But, if you're dead set on using swig, what you need to do is make a typemap for `void**` that RETURNS the newly allocated `void*`:
```
%typemap (in,numinputs=0) void** (void *temp)
{
$1 = &temp;
}
%typemap (arg... |
540,435 | <p>Why does the following give me a compilation error for line B (Label2, outside UpdatePanel) but not for line A (Label1, inside UpdatePanel)? I would have expected both lines to give an error since both controls are within the same Repeater and should therefore not be directly accessible outside the repeater, since t... | [
{
"answer_id": 540600,
"author": "Spencer Ruport",
"author_id": 52551,
"author_profile": "https://Stackoverflow.com/users/52551",
"pm_score": 1,
"selected": false,
"text": "<p>I'm betting if you comment out line B you'll get a run-time error on execution. Label1 is going to be a null ref... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9449/"
] | Why does the following give me a compilation error for line B (Label2, outside UpdatePanel) but not for line A (Label1, inside UpdatePanel)? I would have expected both lines to give an error since both controls are within the same Repeater and should therefore not be directly accessible outside the repeater, since ther... | I'm betting if you comment out line B you'll get a run-time error on execution. Label1 is going to be a null reference.
When you create controls in the ASPX page Visual Studio tries to help you out by adding the controls to the code behind in the designer file which extends the class for the page. In this case it's ad... |
540,489 | <p>My configuration: </p>
<ul>
<li>windows XP SP3</li>
<li>JDBC 2005</li>
<li>MS SQL Server 2008 Express, exposed via tcp/ip on port 1433</li>
<li>sqljdbc.jar in class path </li>
</ul>
<p>I tried:</p>
<pre><code>try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
con = DriverM... | [
{
"answer_id": 614318,
"author": "raupach",
"author_id": 132162,
"author_profile": "https://Stackoverflow.com/users/132162",
"pm_score": -1,
"selected": false,
"text": "<p>You can try the following. Works fine in my case:</p>\n\n<ol>\n<li>Download the current <a href=\"http://jtds.source... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44533/"
] | My configuration:
* windows XP SP3
* JDBC 2005
* MS SQL Server 2008 Express, exposed via tcp/ip on port 1433
* sqljdbc.jar in class path
I tried:
```
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:143... | You have the wrong URL.
I don't know what you mean by "JDBC 2005". When I looked on the microsoft site, I found something called the [Microsoft SQL Server JDBC Driver 2.0](http://www.microsoft.com/downloads/details.aspx?FamilyID=99b21b65-e98f-4a61-b811-19912601fdc9&displaylang=en). You're going to want that one - it i... |
540,493 | <p>What do I need to do to the following rewrite rule to make it so it works whether or not their is a slash at the end of the URL?</p>
<p>ie.
<a href="http://mydomain.com/content/featured" rel="noreferrer">http://mydomain.com/content/featured</a>
or
<a href="http://mydomain.com/content/featured/" rel="noreferrer">htt... | [
{
"answer_id": 540521,
"author": "Gumbo",
"author_id": 53114,
"author_profile": "https://Stackoverflow.com/users/53114",
"pm_score": 6,
"selected": true,
"text": "<p>Use the <code>$</code> to mark the end of the string and the <code>?</code> to mark the preceding expression to be repeate... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59479/"
] | What do I need to do to the following rewrite rule to make it so it works whether or not their is a slash at the end of the URL?
ie.
<http://mydomain.com/content/featured>
or
<http://mydomain.com/content/featured/>
```
RewriteRule ^content/featured/ /content/today.html
``` | Use the `$` to mark the end of the string and the `?` to mark the preceding expression to be repeated zero or one times:
```
RewriteRule ^content/featured/?$ content/today.html
```
But I recommend you to stick to one notation and correct misspelled:
```
# remove trailing slashes
RewriteRule (.*)/$ $1 [L,R=301]
# a... |
540,505 | <p>I read that "the default namespace is important because otherwise the XAML parser will not recognize the elements".</p>
<p>However, just as a test, I take it out and, although the visual designer cannot recognize the element names anymore, this Silverlight XAML runs just fine:</p>
<pre><code><UserControl x:Clas... | [
{
"answer_id": 569857,
"author": "Chris",
"author_id": 43960,
"author_profile": "https://Stackoverflow.com/users/43960",
"pm_score": 3,
"selected": true,
"text": "<p>Those 4 came to my mind:</p>\n\n<p><strong>MicroC/OS-II</strong>: Its free and simple, but i think there are too few good ... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | I read that "the default namespace is important because otherwise the XAML parser will not recognize the elements".
However, just as a test, I take it out and, although the visual designer cannot recognize the element names anymore, this Silverlight XAML runs just fine:
```
<UserControl x:Class="Second12.Page"
xm... | Those 4 came to my mind:
**MicroC/OS-II**: Its free and simple, but i think there are too few good resources available
**LibeRTOS**: I can recommend that. I used it several times for different projects. It's good it's fast and the dual kernel concept is really well done.
**RTLinux**: Can't tell you much about that ... |
540,515 | <p>I'm working on C++ framework and would like to apply automatic memory management to a number of core classes. So far, I have the standard approach which is</p>
<pre><code>class Foo
{
public:
static
shared_ptr<Foo> init()
{
return shared_ptr<Foo>(new Foo);
}
~Foo()
{
}
protected:... | [
{
"answer_id": 540541,
"author": "Sandeep Datta",
"author_id": 39648,
"author_profile": "https://Stackoverflow.com/users/39648",
"pm_score": 1,
"selected": false,
"text": "<p>How about...</p>\n\n<pre><code>template<typename Derived>\nclass Foo \n{\npublic:\n\n static shared_ptr&... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39167/"
] | I'm working on C++ framework and would like to apply automatic memory management to a number of core classes. So far, I have the standard approach which is
```
class Foo
{
public:
static
shared_ptr<Foo> init()
{
return shared_ptr<Foo>(new Foo);
}
~Foo()
{
}
protected:
Foo()
{
}
};
// ... | I don't understand what this achieves, you don't appear to be getting any extra memory management using this init function than by simply declaring a shared\_ptr.
```
int main( void )
{
shared_ptr<foo> a = foo::init();
shared_ptr<foo> b( new foo );
}
```
What's the difference. shared\_ptr provides the memory... |
540,568 | <p>I have a large number of small files with sequential filenames & I want to create a single file out of it. What is the fastest way to do this?</p>
<p>e.g.</p>
<pre><code>1.tgz.1 1.tgz.2 1.tgz.3 =========> 1.tgz
</code></pre>
| [
{
"answer_id": 540571,
"author": "Zach Scrivena",
"author_id": 20029,
"author_profile": "https://Stackoverflow.com/users/20029",
"pm_score": 3,
"selected": false,
"text": "<p>You could <a href=\"http://en.wikipedia.org/wiki/Concatenation\" rel=\"nofollow noreferrer\">concatenate</a> the ... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65457/"
] | I have a large number of small files with sequential filenames & I want to create a single file out of it. What is the fastest way to do this?
e.g.
```
1.tgz.1 1.tgz.2 1.tgz.3 =========> 1.tgz
``` | You could [concatenate](http://en.wikipedia.org/wiki/Concatenation) the files from the shell.
In Windows (`/b` for binary mode):
```
copy /b 1.tgz.1 + 1.tgz.2 + 1.tgz.3 1.tgz
```
In Unix/Linux:
```
cat 1.tgz.1 1.tgz.2 1.tgz.3 > 1.tgz
``` |
540,593 | <p>Actually, maybe not full-blown Lex/Yacc. I'm implementing a command-interpreter front-end to administer a webapp. I'm looking for something that'll take a grammar definition and turn it into a parser that directly invokes methods on my object. Similar to how ASP.NET MVC can figure out which controller method to invo... | [
{
"answer_id": 540605,
"author": "Anton Gogolev",
"author_id": 60188,
"author_profile": "https://Stackoverflow.com/users/60188",
"pm_score": 5,
"selected": true,
"text": "<p>I'm not sure Lex/Yacc will be of any help. You'll just need a basic tokenizer and an interpreter which are faster ... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8446/"
] | Actually, maybe not full-blown Lex/Yacc. I'm implementing a command-interpreter front-end to administer a webapp. I'm looking for something that'll take a grammar definition and turn it into a parser that directly invokes methods on my object. Similar to how ASP.NET MVC can figure out which controller method to invoke,... | I'm not sure Lex/Yacc will be of any help. You'll just need a basic tokenizer and an interpreter which are faster to write by hand. If you're still into parsing route see [Irony](https://github.com/IronyProject/Irony).
As a sidenote: have you considered PowerShell and its commandlets? |
540,603 | <pre><code>sudo find /etc | xargs grep -i fedora > searchFedora
</code></pre>
<p>gives:</p>
<pre><code>/etc/netplug.d/netplug: # At least on Fedora Core 1
...
</code></pre>
<p>But see the Fedora version in the <code>/etc/netplug.d/netplug</code> file. Is it serious?</p>
| [
{
"answer_id": 540611,
"author": "David Grant",
"author_id": 40581,
"author_profile": "https://Stackoverflow.com/users/40581",
"pm_score": 8,
"selected": true,
"text": "<pre><code>cat /etc/issue\n</code></pre>\n\n<p>Or <code>cat /etc/fedora-release</code> as suggested by @Bruce ONeel</p... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30791/"
] | ```
sudo find /etc | xargs grep -i fedora > searchFedora
```
gives:
```
/etc/netplug.d/netplug: # At least on Fedora Core 1
...
```
But see the Fedora version in the `/etc/netplug.d/netplug` file. Is it serious? | ```
cat /etc/issue
```
Or `cat /etc/fedora-release` as suggested by @Bruce ONeel |
540,607 | <p>What is the difference between these two methods in C# using the speech API or <a href="http://msdn.microsoft.com/en-us/library/ms723627(VS.85).aspx" rel="noreferrer">SAPI</a>?</p>
<pre><code>using SpeechLib;
SpVoice speech = new SpVoice();
speech.Speak(text, SpeechVoiceSpeakFlags.SVSFlagsAsync);
</code></pre>
<p>... | [
{
"answer_id": 540631,
"author": "Richard Szalay",
"author_id": 3603,
"author_profile": "https://Stackoverflow.com/users/3603",
"pm_score": 2,
"selected": false,
"text": "<p>SpeechLib is an interop DLL and so maps to whatever version of SpeechLib it was created for (you can check it's pr... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61821/"
] | What is the difference between these two methods in C# using the speech API or [SAPI](http://msdn.microsoft.com/en-us/library/ms723627(VS.85).aspx)?
```
using SpeechLib;
SpVoice speech = new SpVoice();
speech.Speak(text, SpeechVoiceSpeakFlags.SVSFlagsAsync);
```
returns the [Apacela voices](http://www.acapela-group.... | SpeechLib is an Interop DLL that makes use of classic COM-based SAPI under the covers. System.Speech was developed by Microsoft to interact with Text-to-speech (and voice recognition) directly from within managed code.
In general, it's cleaner to stick with the managed library (System.Speech) when you're writing a man... |
540,634 | <p>I have the following list:</p>
<pre><code> mat.Add(new Material() { ID = 1, ProdName = "Cylinder", Weight=23, Discontinued='N' });
mat.Add(new Material() { ID = 2, ProdName = "Gas", Weight = 25, Discontinued='N' });
mat.Add(new Material() { ID = 3, ProdName = "Match", Weight = 23, Discontinued='N' });
</code></pr... | [
{
"answer_id": 540649,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": true,
"text": "<p>It's not clear exactly what you're actually grouping by - is it both weight <em>and</em> the discontinued status? If s... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55428/"
] | I have the following list:
```
mat.Add(new Material() { ID = 1, ProdName = "Cylinder", Weight=23, Discontinued='N' });
mat.Add(new Material() { ID = 2, ProdName = "Gas", Weight = 25, Discontinued='N' });
mat.Add(new Material() { ID = 3, ProdName = "Match", Weight = 23, Discontinued='N' });
```
I want a result as:... | It's not clear exactly what you're actually grouping by - is it both weight *and* the discontinued status? If so, you can just do:
```
var query = mat.GroupBy(material =>
new { material.Weight, material.Discontinued });
foreach (var result in query)
{
Console.WriteLine("{0} products have ... |
540,640 | <p>I'm using a hosted Linux machine so I don't have permissions to write
into the <code>/usr/lib</code> directory.</p>
<p>When I try to install a CPAN module by doing the usual:</p>
<pre><code>perl Makefile.PL
make test
make install
</code></pre>
<p>That module is extracted to a <code>blib/lib/</code> folder. I have... | [
{
"answer_id": 540716,
"author": "jrockway",
"author_id": 8457,
"author_profile": "https://Stackoverflow.com/users/8457",
"pm_score": 4,
"selected": false,
"text": "<p><a href=\"http://search.cpan.org/perldoc?local::lib\" rel=\"noreferrer\">local::lib</a> will help you. It will convince... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2639206/"
] | I'm using a hosted Linux machine so I don't have permissions to write
into the `/usr/lib` directory.
When I try to install a CPAN module by doing the usual:
```
perl Makefile.PL
make test
make install
```
That module is extracted to a `blib/lib/` folder. I have kept `use
blib/lib/ModuleName` but it still the compil... | I had a similar problem, where I couldn't even install local::lib
I created an installer that installed the module somewhere relative to the .pl files
The install goes like:
```
perl Makefile.PL PREFIX=./modulos
make
make install
```
Then, in the .pl file that requires the module, which is in ./
```
use lib qw(./... |
540,643 | <p>Similar to this <a href="https://stackoverflow.com/questions/124121/how-to-create-excel-2003-udf-with-a-c-excel-add-in-using-vsto-2005-se">question</a> (but in my case not VSTO SE), however, I just want to confirm that it is not possible to create a UDF using pure VSTO in Visual Studio 2005 and Excel 2003 - so, to a... | [
{
"answer_id": 558195,
"author": "Jon Tackabury",
"author_id": 343,
"author_profile": "https://Stackoverflow.com/users/343",
"pm_score": 0,
"selected": false,
"text": "<p>I am not familiar with a method of creating a UDF in Excel 2003 using VS2005 and VSTO without having at least a bit o... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36860/"
] | Similar to this [question](https://stackoverflow.com/questions/124121/how-to-create-excel-2003-udf-with-a-c-excel-add-in-using-vsto-2005-se) (but in my case not VSTO SE), however, I just want to confirm that it is not possible to create a UDF using pure VSTO in Visual Studio 2005 and Excel 2003 - so, to absolutely clea... | Concerning whether there is a way around COM or VBA I don't think that it is possible (at least not without any very dirty tricks). The reason is that the only way Office can execute external code (i.e. you add-in) is via COM. Even VSTO is still using the old IDTExtensibility2 COM interface underneath. IDTExtensibility... |
540,658 | <p>As I understand it when I create an Excel sheet with VBA code the VBA code is saved as binary with the sheet. I therefore can't put the code into source control in a useful way, have multiple devs working on the problems, diffing is difficult, etc.</p>
<p>Is there a way round this without switching to VSTO, COM ad... | [
{
"answer_id": 540675,
"author": "shearichard",
"author_id": 61340,
"author_profile": "https://Stackoverflow.com/users/61340",
"pm_score": 1,
"selected": false,
"text": "<p>Interesting question ... we also have a problem with VBA source control but have never actually got around to addre... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36860/"
] | As I understand it when I create an Excel sheet with VBA code the VBA code is saved as binary with the sheet. I therefore can't put the code into source control in a useful way, have multiple devs working on the problems, diffing is difficult, etc.
Is there a way round this without switching to VSTO, COM addins etc? E... | I wrote a kind of build system for Excel which imports the VBA code from source files (which can then be imported into source control, diffed, etc.). It works by creating a new Excel file which contains the imported code, so it might not work in your case.
The build macro looks like this, I save it in a file called Bu... |
540,697 | <p>If i define a plugin in the <build> tag and want to use this in my site command how do i do that? Do i have to define the plugin within <reporting> tag again? </p>
<p>And how about the configuration which i probably have done within the build tag and want to take place at the reporting tag as well? (i d... | [
{
"answer_id": 540744,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 3,
"selected": true,
"text": "<p>A maven plugin is typically bound to execution in a given lifecycle phase when you define it. The plugin itself speci... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48402/"
] | If i define a plugin in the <build> tag and want to use this in my site command how do i do that? Do i have to define the plugin within <reporting> tag again?
And how about the configuration which i probably have done within the build tag and want to take place at the reporting tag as well? (i dont want to specifie f... | A maven plugin is typically bound to execution in a given lifecycle phase when you define it. The plugin itself specifies which lifecycle phase this is, but you can change this if you have special needs.
If you have a multi-module build you can define a set of plugins with all parameters required in a common parent-p... |
540,701 | <p>I'm a beginner in C#.
I would like to know if there's a way to access different frames inside a GIF animation with C#.
I'm using Visual Studio 2008.</p>
| [
{
"answer_id": 540714,
"author": "RvdK",
"author_id": 47351,
"author_profile": "https://Stackoverflow.com/users/47351",
"pm_score": 3,
"selected": false,
"text": "<p>a bit of googling: <a href=\"http://social.microsoft.com/Forums/en-US/netfxbcl/thread/fcb7d14d-d15b-4336-971c-94a80e34b85e... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65472/"
] | I'm a beginner in C#.
I would like to know if there's a way to access different frames inside a GIF animation with C#.
I'm using Visual Studio 2008. | Try this:
```
using System.Drawing;
using System.Drawing.Imaging;
Image gifImg = Image.FromFile(pathToGifFile);
FrameDimension dimension = new FrameDimension(gifImg.FrameDimensionsList[0]);
// Number of frames
int frameCount = gifImg.GetFrameCount(dimension);
// Return an Image at a certain index
gifImg.SelectAct... |
540,706 | <p>I'm trying to verify a Recaptcha using jQuery, but I keep getting an error telling me: Access to restricted URI denied" code: "1012</p>
<p>This is what I've tried so far:</p>
<pre><code> var challengeVal = $("#recaptcha_challenge_field").attr("value");
var reponseVal = $("#recaptcha_response_field").attr("value")... | [
{
"answer_id": 540805,
"author": "Magnar",
"author_id": 1123,
"author_profile": "https://Stackoverflow.com/users/1123",
"pm_score": 5,
"selected": true,
"text": "<p>JavaScript is prohibited from making cross-domain XMLHttpRequests for security reasons. There are <a href=\"http://ajaxian.... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to verify a Recaptcha using jQuery, but I keep getting an error telling me: Access to restricted URI denied" code: "1012
This is what I've tried so far:
```
var challengeVal = $("#recaptcha_challenge_field").attr("value");
var reponseVal = $("#recaptcha_response_field").attr("value");
var remoteIp = <%=... | JavaScript is prohibited from making cross-domain XMLHttpRequests for security reasons. There are [workarounds](http://ajaxian.com/archives/csshttprequest-cross-domain-ajax-using-css-for-transport), but they only work if you control both domains.
Solution: Make an AJAX-call to your own server, and contact recaptcha th... |
540,709 | <p>I have a javascript method which handles removing from one select box to another.
The code runs as follows :</p>
<pre><code> function moveAllOptions(formName, selectId1, selectId2) {
var sourceSelect = eval("document." + formName + "." + selectId1);
var destSelect = eval("document." + formName + "." + se... | [
{
"answer_id": 540771,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 1,
"selected": false,
"text": "<p>Well, first of all the eval to hunt elements is horrible. There are far better ways of doing this starting with <a hre... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11114/"
] | I have a javascript method which handles removing from one select box to another.
The code runs as follows :
```
function moveAllOptions(formName, selectId1, selectId2) {
var sourceSelect = eval("document." + formName + "." + selectId1);
var destSelect = eval("document." + formName + "." + selectId2);
... | Well, first of all the eval to hunt elements is horrible. There are far better ways of doing this starting with [getElementById](http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-getElBId).
As to your actual problem, again there are simpler native ways to do this: the `add` and `remove` methods of the select object (... |
540,722 | <p>In my DB, I have a table that was created from an Excel sheet, via a Linked Server option. </p>
<p>I am now trying to compare its contents versus one of my main tables. </p>
<p>The tables I am comparing are in the same database.</p>
<p>There is a date column in both tables, both types are datetime and have Colla... | [
{
"answer_id": 540752,
"author": "Nuno G",
"author_id": 20959,
"author_profile": "https://Stackoverflow.com/users/20959",
"pm_score": 4,
"selected": true,
"text": "<p>The error is being reported on the currency comparison <strong>h.currency_cd=hxl.currency_cd</strong>, not on datediff, s... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48310/"
] | In my DB, I have a table that was created from an Excel sheet, via a Linked Server option.
I am now trying to compare its contents versus one of my main tables.
The tables I am comparing are in the same database.
There is a date column in both tables, both types are datetime and have Collation of SQL\_Latin1\_Gene... | The error is being reported on the currency comparison **h.currency\_cd=hxl.currency\_cd**, not on datediff, so try force collation on the currencies.
Collation is only relevant for character (char, varchar, nvarchar) and text types. |
540,725 | <p>The question is how the string matching is done to find matching entries by the firefox 3 <a href="http://mozillalinks.org/wp/2007/11/firefox-3-location-bar-just-became-almighty/" rel="noreferrer">url bar</a>. Substring matching on every entry might be slow. What algorithm can be used to match at any location in a f... | [
{
"answer_id": 540747,
"author": "theomega",
"author_id": 61855,
"author_profile": "https://Stackoverflow.com/users/61855",
"pm_score": 2,
"selected": false,
"text": "<p>I think this is left to the underlying storage: the SQLite Database where Firefox stores the Pages you visited offers ... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62237/"
] | The question is how the string matching is done to find matching entries by the firefox 3 [url bar](http://mozillalinks.org/wp/2007/11/firefox-3-location-bar-just-became-almighty/). Substring matching on every entry might be slow. What algorithm can be used to match at any location in a fast way? | The normal way to do fast substring matching is to create a data structure which contain all the suffixes of all the strings you want search. Depending on the organization, this can be called the "suffix tree" or "suffix array". For example, if you have 1000 strings and every one is 50 characters long, you have 1.000 x... |
540,729 | <p>I have a singleton bean definition like this:</p>
<pre><code><bean id="exampleBean" class="com.examples.ExampleBean">
<property name="exampleBean2">
<bean class="com.examples.ExampleBean2" />
</property>
</bean>
</code></pre>
<p>where <code>ExampleBean</code> could be:</p>
<p... | [
{
"answer_id": 540821,
"author": "eljenso",
"author_id": 30316,
"author_profile": "https://Stackoverflow.com/users/30316",
"pm_score": 1,
"selected": false,
"text": "<p>Is it an option to declare an init-method on your ExampleBean, and in this init-method check if the class ExampleBean2 ... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31136/"
] | I have a singleton bean definition like this:
```
<bean id="exampleBean" class="com.examples.ExampleBean">
<property name="exampleBean2">
<bean class="com.examples.ExampleBean2" />
</property>
</bean>
```
where `ExampleBean` could be:
```
public class ExampleBean {
private ExampleBean2 exampleBean2;
pu... | If you use autowire, what you wish to achieve is possible.
```
<bean class="com.examples.ExampleBean" autowire="byType" />
<bean class="com.examples.ExampleBean2" />
```
Or via annotations
```
@Autowired(required=false)
ExampleBean2 exampleBean2;
``` |
540,737 | <p>I'm wondering how i can make a portable build system (step-by-step), i currently use cmake because it was easy to set up in the first place, with only one arch target, but now that i have to package the library I'm developing I'm wondering how is the best way to make it portable for arch I'm testing.</p>
<p>I know ... | [
{
"answer_id": 540768,
"author": "MichaelM",
"author_id": 64435,
"author_profile": "https://Stackoverflow.com/users/64435",
"pm_score": 2,
"selected": false,
"text": "<p>I have been using the GNU autoconf/automake toolchain which has worked well for me so far. I am only really focussed o... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61838/"
] | I'm wondering how i can make a portable build system (step-by-step), i currently use cmake because it was easy to set up in the first place, with only one arch target, but now that i have to package the library I'm developing I'm wondering how is the best way to make it portable for arch I'm testing.
I know I need a c... | You can just use CMake, it's pretty straightforward.
You need these things:
First, means to find out the configuration specifics. For example, if you know that some function is named differently on some platform, you can use [`TRY_COMPILE`](http://www.cmake.org/cmake/help/cmake2.6docs.html#command:try_compile) to dis... |
540,743 | <p>What more can I do to optimize this query?</p>
<pre><code>SELECT * FROM
(SELECT `item`.itemID, COUNT(`votes`.itemID) AS `votes`,
`item`.title, `item`.itemTypeID, `item`.
submitDate, `item`.deleted, `item`.ItemCat,
`item`.counter, `item`.userID, `users`.name,
TIMESTAM... | [
{
"answer_id": 540756,
"author": "theomega",
"author_id": 61855,
"author_profile": "https://Stackoverflow.com/users/61855",
"pm_score": 3,
"selected": false,
"text": "<p><strong>What does the analyzer say for this query?</strong> Without knowledge about how many rows there are in the tab... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2019426/"
] | What more can I do to optimize this query?
```
SELECT * FROM
(SELECT `item`.itemID, COUNT(`votes`.itemID) AS `votes`,
`item`.title, `item`.itemTypeID, `item`.
submitDate, `item`.deleted, `item`.ItemCat,
`item`.counter, `item`.userID, `users`.name,
TIMESTAMPDIFF(minute,`... | Of course, as @theomega said, look at the execution plan.
But I'd also suggest to try and "clean up" your statement. (I don't know which one is faster - that depends on your table sizes.) Usually, I'd try to start with a clean statement and start optimizing from there. But typically, a clean statement makes it easier ... |
540,746 | <pre><code>public enum aa{ a1=1,a2=2,a3=6,...,a100=203}
</code></pre>
<p>How to get value like this</p>
<pre><code>string att=GetFromDatabase("attribute"); //this return a1 or a2 ...
Enum.GetValue(att);
</code></pre>
| [
{
"answer_id": 540766,
"author": "Bartek Szabat",
"author_id": 23774,
"author_profile": "https://Stackoverflow.com/users/23774",
"pm_score": 6,
"selected": true,
"text": "<p>Solution</p>\n\n<pre><code>string name = GetFromDatabase(\"attribute\");\nEnum.Parse(typeof(aa),name);\n</code></p... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60200/"
] | ```
public enum aa{ a1=1,a2=2,a3=6,...,a100=203}
```
How to get value like this
```
string att=GetFromDatabase("attribute"); //this return a1 or a2 ...
Enum.GetValue(att);
``` | Solution
```
string name = GetFromDatabase("attribute");
Enum.Parse(typeof(aa),name);
``` |
540,748 | <p>I have the following code:</p>
<pre><code>typedef void VOID;
int f(void);
int g(VOID);
</code></pre>
<p>which compiles just fine in C (using gcc 4.3.2 on Fedora 10). The same code compiled as C++ gives me the following error:</p>
<pre><code>void.c:3: error: ‘<anonymous>’ has incomplete type
void.c:3: error:... | [
{
"answer_id": 540791,
"author": "Gal Goldman",
"author_id": 46418,
"author_profile": "https://Stackoverflow.com/users/46418",
"pm_score": 0,
"selected": false,
"text": "<p>I just put your code in a .cpp file, and it compiled with no problems in VS2005, SUSE, Redhat, and Solaris, so I gu... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25406/"
] | I have the following code:
```
typedef void VOID;
int f(void);
int g(VOID);
```
which compiles just fine in C (using gcc 4.3.2 on Fedora 10). The same code compiled as C++ gives me the following error:
```
void.c:3: error: ‘<anonymous>’ has incomplete type
void.c:3: error: invalid use of ‘VOID’
```
Now, this is s... | Yes, as far as i know the second declaration is invalid in C++ and C89, but it is valid in C99.
From The C99 draft, TC2 (`6.7.5.3/10`):
>
> The special case of an unnamed parameter of type void as the only item in the list
> specifies that the function has no parameters.
>
>
>
It's explicitly talking about the ... |
540,749 | <p>This would appear to imply "no". Which is unfortunate.</p>
<pre><code>[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class,
AllowMultiple = true, Inherited = true)]
public class CustomDescriptionAttribute : Attribute
{
public string Description { get; private set; }
public CustomDescription... | [
{
"answer_id": 540785,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 7,
"selected": true,
"text": "<p>No. Whenever implementing an interface or overriding members in a derived class, you need to re-declare the attribu... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8446/"
] | This would appear to imply "no". Which is unfortunate.
```
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class,
AllowMultiple = true, Inherited = true)]
public class CustomDescriptionAttribute : Attribute
{
public string Description { get; private set; }
public CustomDescriptionAttribute(stri... | No. Whenever implementing an interface or overriding members in a derived class, you need to re-declare the attributes.
If you only care about ComponentModel (not direct reflection), there is a way ([`[AttributeProvider]`](http://msdn.microsoft.com/en-us/library/system.componentmodel.attributeproviderattribute.aspx)) ... |
540,800 | <pre><code>std::string sAttr("");
sAttr = sAttr+VAL_TAG_OPEN+sVal->c_str()+VAL_TAG_CLOSE;
</code></pre>
<p>else where in the code I have defined</p>
<pre><code>const char VAL_TAG_OPEN[] = "<value>";
</code></pre>
<p><code>sVal</code> is a variable that is retrieved off of a array of string pointers. This ... | [
{
"answer_id": 540836,
"author": "fbonnet",
"author_id": 54574,
"author_profile": "https://Stackoverflow.com/users/54574",
"pm_score": 3,
"selected": true,
"text": "<p>Why the <code>->c_str()</code>? If <code>sVal</code> is a <code>std::string</code>, try removing this call. Remember ... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1781/"
] | ```
std::string sAttr("");
sAttr = sAttr+VAL_TAG_OPEN+sVal->c_str()+VAL_TAG_CLOSE;
```
else where in the code I have defined
```
const char VAL_TAG_OPEN[] = "<value>";
```
`sVal` is a variable that is retrieved off of a array of string pointers. This works fine in most of the system, windows and linux. However a... | Why the `->c_str()`? If `sVal` is a `std::string`, try removing this call. Remember that the order of evaluation is undefined, so you may end up adding pointers instead of concatenating strings, because `VAL_TAG_OPEN`, `sVal->c_str()` and `VAL_TAG_CLOSE` are all plain C strings. I suggest you use the addition assignmen... |
540,813 | <p>I have a Variable class and and 3 subclasses: VariableBool, VariableLong and VariableDouble. Each subclass defines only a value member of the type of the suffix. </p>
<p>Now, I need to transfert objects based on these classes over WCF. I have multiple clients registering their variale to a server. Whenever a value... | [
{
"answer_id": 540896,
"author": "August",
"author_id": 30966,
"author_profile": "https://Stackoverflow.com/users/30966",
"pm_score": 0,
"selected": false,
"text": "<p>NSFileManager handles all the filesystem operations, including file deletion.</p>\n"
},
{
"answer_id": 540990,
... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65060/"
] | I have a Variable class and and 3 subclasses: VariableBool, VariableLong and VariableDouble. Each subclass defines only a value member of the type of the suffix.
Now, I need to transfert objects based on these classes over WCF. I have multiple clients registering their variale to a server. Whenever a value changes on... | Specifically, you want NSFileManager's `-(BOOL)removeItemAtPath:(NSString *)path error:(NSError **)error` this is documented in the SDK.
There aren't many iPhone programming books but I think Dave Mark and Jeff LaMarche's [Beginning iPhone Development: Exploring the iPhone SDK](https://rads.stackoverflow.com/amzn/clic... |
540,822 | <p>The function <code>somefunction()</code> takes a triple pointer as an argument.</p>
<pre><code>int somefunction(tchar ***returnErrors);
</code></pre>
<p>How to allocate memory for the <code>returnErrors</code> parameter?</p>
| [
{
"answer_id": 540837,
"author": "soulmerge",
"author_id": 44562,
"author_profile": "https://Stackoverflow.com/users/44562",
"pm_score": 0,
"selected": false,
"text": "<p>The triple pointer does not make <strong>any</strong> sense if you don't already have a construct of that type. I wou... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22996/"
] | The function `somefunction()` takes a triple pointer as an argument.
```
int somefunction(tchar ***returnErrors);
```
How to allocate memory for the `returnErrors` parameter? | *At a guess . . .*
You can think of returnErrors as a pointer to an array of strings.
1. The first \* imples pointer to array
of tchar (or a single string of
tchars)
2. The second \* imples a pointer to an
array of strings.
3. The last \* is so you can change
returnErrors and pass back the new
memory.
To delare memo... |
540,830 | <p>I'm using <a href="http://www.castleproject.org/monorail/" rel="nofollow noreferrer">Castle Monorail</a> with <a href="http://docs.jquery.com/UI/Tabs" rel="nofollow noreferrer">jQuery tabbed navigation</a>.</p>
<p>When handling a controller action, I would like to redirect to a view, and control which tab is visibl... | [
{
"answer_id": 540852,
"author": "Robert MacLean",
"author_id": 53236,
"author_profile": "https://Stackoverflow.com/users/53236",
"pm_score": 5,
"selected": true,
"text": "<p>Yes, you can. Just go into the output column list on the Excel source and set the type for each of the columns. <... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30971/"
] | I'm using [Castle Monorail](http://www.castleproject.org/monorail/) with [jQuery tabbed navigation](http://docs.jquery.com/UI/Tabs).
When handling a controller action, I would like to redirect to a view, and control which tab is visible. Therefore, I'd like to have my controller redirecting to a specific anchor in a v... | Yes, you can. Just go into the output column list on the Excel source and set the type for each of the columns.
To get to the input columns list right click on the Excel source, select 'Show Advanced Editor', click the tab labeled 'Input and Output Properties'.
A potentially better solution is to use the derived col... |
540,848 | <p>Here is the <strong>scenario 1.</strong> </p>
<p>I have a table called "items", inside the table has 2 columns, e. g. <code>item_id</code> and <code>item_name</code>.
I store my data in this way:
item_id | item_name</p>
<pre><code>Ss001 | Shirt1
Sb002 | Shirt2
Tb001 | TShirt1
Tm002 | TShirt2
</code></p... | [
{
"answer_id": 540868,
"author": "tehvan",
"author_id": 61848,
"author_profile": "https://Stackoverflow.com/users/61848",
"pm_score": 1,
"selected": false,
"text": "<p>The first optimization would be splitting the id into three different fields:\none for type, one for size, one for the c... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65379/"
] | Here is the **scenario 1.**
I have a table called "items", inside the table has 2 columns, e. g. `item_id` and `item_name`.
I store my data in this way:
item\_id | item\_name
```
Ss001 | Shirt1
Sb002 | Shirt2
Tb001 | TShirt1
Tm002 | TShirt2
```
... etc, i store in this way:
first letter is the code for cl... | The first method will be faster - but IMO it's not the right way of doing it. I'm in agreement with tehvan about that.
I'd recommend keeping the item\_id as is, but add two extra fields one for the code and one for the size, then you can do:
```
select * from items where item_code = 'S' and item_size = 'm'
```
Wit... |
540,851 | <p>I've got an input which it's type is set to hidden, I need to change it's type to text. Can't seem to figure this out or if it's possible with jQuery</p>
| [
{
"answer_id": 540863,
"author": "Aram Verstegen",
"author_id": 64234,
"author_profile": "https://Stackoverflow.com/users/64234",
"pm_score": 4,
"selected": false,
"text": "<p>I'm not sure this is possible, so I would suggest using a hidden div to contain the input element, which can be ... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45350/"
] | I've got an input which it's type is set to hidden, I need to change it's type to text. Can't seem to figure this out or if it's possible with jQuery | With jQuery 1.4 you can change the type of an input while it's detached.
```
marker = $('<span />').insertBefore('#myInput');
$('#myInput').detach().attr('type', 'text').insertAfter(marker);
marker.remove();
``` |
540,856 | <p>I have an ORACLE update statement that I call using the OCIStmtExecute function call. </p>
<p>Using an OCI function call I would like to know how many rows have been updated by the action, e.g. zero, one or more.</p>
<p>How do I do this ?</p>
| [
{
"answer_id": 540983,
"author": "Quassnoi",
"author_id": 55159,
"author_profile": "https://Stackoverflow.com/users/55159",
"pm_score": 2,
"selected": false,
"text": "<p>Invoke <code>OCIAttrGet(OCI_ATTR_ROW_COUNT)</code> on the statement handle.</p>\n"
},
{
"answer_id": 540985,
... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/381/"
] | I have an ORACLE update statement that I call using the OCIStmtExecute function call.
Using an OCI function call I would like to know how many rows have been updated by the action, e.g. zero, one or more.
How do I do this ? | Use the OCIAttrGet function call on your OCIStmt statement handle with the attribute type set to OCI\_ATTR\_ROW\_COUNT
So add the folllowing code to your program :
```
ub4 row_count;
rc = OCIAttrGet ( stmthp, OCI_HTYPE_STMT, &row_count, 0, OCI_ATTR_ROW_COUNT,
errhp );
```
where:
`stmthp` is the O... |
540,860 | <p>I have a ListView whereby I want to display one context menu if an item is right-clicked, and another if the click occurs in the ListView control. The problem I'm getting is the MouseClick event is only firing when an item is right-clicked, not the control. What's causing this and how can I get around it?</p>
| [
{
"answer_id": 540958,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>Use MouseUp instead of MouseClick! Sorry about that. Should have googled harder.</p>\n"
},
{
"answer_id": 540966,
... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a ListView whereby I want to display one context menu if an item is right-clicked, and another if the click occurs in the ListView control. The problem I'm getting is the MouseClick event is only firing when an item is right-clicked, not the control. What's causing this and how can I get around it? | You could subclass the ListView to add a right-click event:
```
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace MyCustomControls
{
public delegate void MyDelegate(Object sender, EventArgs e);
class MyListView : ListView
{
private static readonly object E... |
540,872 | <p>I have a table in the database for various settings in my application. These settings can be added to or changed at any time. I would like to pull them out of the db into an object and reference them in both my server code (C#) and client code (JS).</p>
<pre><code>SettingGroup SettingName type value
Cor... | [
{
"answer_id": 540958,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>Use MouseUp instead of MouseClick! Sorry about that. Should have googled harder.</p>\n"
},
{
"answer_id": 540966,
... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57083/"
] | I have a table in the database for various settings in my application. These settings can be added to or changed at any time. I would like to pull them out of the db into an object and reference them in both my server code (C#) and client code (JS).
```
SettingGroup SettingName type value
Core defa... | You could subclass the ListView to add a right-click event:
```
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace MyCustomControls
{
public delegate void MyDelegate(Object sender, EventArgs e);
class MyListView : ListView
{
private static readonly object E... |
540,875 | <p>I'm working on a Ubuntu 8.04 / 32 bit (as virtual machine). While performing some makes on a project that is not min, I get the error: </p>
<p>g++: /usr/lib/libstdc++.a: No such file or directory</p>
<p>What should I do? the gcc package is installed through synaptic, what do i miss?</p>
<p>Thanks,
Lucian</p>
| [
{
"answer_id": 540886,
"author": "Philip Reynolds",
"author_id": 1087,
"author_profile": "https://Stackoverflow.com/users/1087",
"pm_score": 4,
"selected": true,
"text": "<p>For Ubuntu 8.04 (aka hardy), you need to install the libstdc++6-4.2-dbg package.</p>\n\n<pre><code>$ sudo aptitude... | 2009/02/12 | [
"https://Stackoverflow.com/questions/540875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11464/"
] | I'm working on a Ubuntu 8.04 / 32 bit (as virtual machine). While performing some makes on a project that is not min, I get the error:
g++: /usr/lib/libstdc++.a: No such file or directory
What should I do? the gcc package is installed through synaptic, what do i miss?
Thanks,
Lucian | For Ubuntu 8.04 (aka hardy), you need to install the libstdc++6-4.2-dbg package.
```
$ sudo aptitude install libstdc++6-4.2-dbg
```
If you need to find files like this in future, install apt-file if it isn't already installed and use apt-file search.
```
$ sudo aptitude install apt-file
...
$ sudo apt-file search /... |