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 |
|---|---|---|---|---|---|---|
211,118 | <p>I'm using the following view function to iterate over all items in the database (in order to find a tag), but I think the performance is very poor if the dataset is large.
Any other approach?</p>
<pre><code>def by_tag(tag):
return '''
function(doc) {
if (doc.tags.length > 0) {
... | [
{
"answer_id": 211144,
"author": "Paul J. Davis",
"author_id": 129506,
"author_profile": "https://Stackoverflow.com/users/129506",
"pm_score": 1,
"selected": false,
"text": "<p>You are very much on the right track with the view. A list of thoughts though:</p>\n\n<p>View generation is inc... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28809/"
] | I'm using the following view function to iterate over all items in the database (in order to find a tag), but I think the performance is very poor if the dataset is large.
Any other approach?
```
def by_tag(tag):
return '''
function(doc) {
if (doc.tags.length > 0) {
for (var tag in... | *Disclaimer: I didn't test this and don't know if it can perform better.*
Create a single perm view:
```
function(doc) {
for (var tag in doc.tags) {
emit([tag, doc.published], doc)
}
};
```
And query with
\_view/your\_view/all?startkey=['your\_tag\_here']&endkey=['your\_tag\_here', {}]
Resulting JSON str... |
211,122 | <p>In an application that is hosting several WCF services, what would be the best way to add custom configuration information for each service? For example you may want to pass or set a company name or specify the connectionString a service or some other parameter. </p>
<p>I'm guessing this might be possible by imple... | [
{
"answer_id": 211993,
"author": "tomasr",
"author_id": 10292,
"author_profile": "https://Stackoverflow.com/users/10292",
"pm_score": 0,
"selected": false,
"text": "<p>It depends a lot of where and how you expect to use said information. If it's not something that's going to do a lot wit... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In an application that is hosting several WCF services, what would be the best way to add custom configuration information for each service? For example you may want to pass or set a company name or specify the connectionString a service or some other parameter.
I'm guessing this might be possible by implementing ISe... | I know this is old, but it was never marked answered, so I thought I'd take a shot. If I understand what you're after, you can do it with a custom ServiceHostFactory.
Good post on this [here](http://blogs.msdn.com/dotnetinterop/archive/2008/09/22/custom-service-config-file-for-a-wcf-service-hosted-in-iis.aspx).
Yo... |
211,133 | <p>Oracle has this concept of allowing database users to be identified by the operating system user who is running the program that is connecting to Oracle. See <a href="http://www.oracle-base.com/articles/misc/OsAuthentication.php" rel="noreferrer">here</a>.</p>
<p>This allows you to do, as that user on a unix machin... | [
{
"answer_id": 211178,
"author": "anjanb",
"author_id": 11142,
"author_profile": "https://Stackoverflow.com/users/11142",
"pm_score": 1,
"selected": false,
"text": "<p>The jdbc driver that oracle ships does NOT have the capability of gathering the OS username and password from the URL th... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27308/"
] | Oracle has this concept of allowing database users to be identified by the operating system user who is running the program that is connecting to Oracle. See [here](http://www.oracle-base.com/articles/misc/OsAuthentication.php).
This allows you to do, as that user on a unix machine for example, a command such as:
```... | The JDBC Thin driver is a 100% pure Java implementation that cannot collect the needed information from the operating system.
The JDBC OCI driver can do this! Use `jdbc:oracle:oci8:/@MYDBSID`, it will require that the Oracle driver be installed on that machine, not a problem if this is a server (and is faster to boot... |
211,137 | <p>I have ASP.Net code similar to the following (this is inside a FIELDSET):</p>
<pre><code><ol>
<li>
<label>Some label</label>
<one or more form controls, ASP.Net controls, labels, etc.>
</li>
<li>
<label>Another label</label>
... | [
{
"answer_id": 211150,
"author": "Matt",
"author_id": 2338,
"author_profile": "https://Stackoverflow.com/users/2338",
"pm_score": 2,
"selected": false,
"text": "<p>One approach would be to just wrap everything inside the <li> and then move the label out, e.g.</p>\n\n<pre><code>var ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14894/"
] | I have ASP.Net code similar to the following (this is inside a FIELDSET):
```
<ol>
<li>
<label>Some label</label>
<one or more form controls, ASP.Net controls, labels, etc.>
</li>
<li>
<label>Another label</label>
<... more of the same...>
</li>
...
</ol>
```
I'm t... | **edit**: corrected code (see old code in revision history and comments for more info)
ok this should work:
```
$('li label:first-child').each(function() {
$(this).siblings().wrapAll('<div class="li-non-label-child-wrapper">');
});
```
from:
```
<li>
<label>Some label</label>
<div>stuff</div>
<div>... |
211,143 | <p>I thought I understood Java generics pretty well, but then I came across the following in java.lang.Enum:</p>
<pre><code>class Enum<E extends Enum<E>>
</code></pre>
<p>Could someone explain how to interpret this type parameter? Bonus points for providing other examples of where a similar type parameter... | [
{
"answer_id": 211161,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 8,
"selected": true,
"text": "<p>It means that the type argument for enum has to derive from an enum which itself has the same type argument. How can t... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I thought I understood Java generics pretty well, but then I came across the following in java.lang.Enum:
```
class Enum<E extends Enum<E>>
```
Could someone explain how to interpret this type parameter? Bonus points for providing other examples of where a similar type parameter could be used. | It means that the type argument for enum has to derive from an enum which itself has the same type argument. How can this happen? By making the type argument the new type itself. So if I've got an enum called StatusCode, it would be equivalent to:
```
public class StatusCode extends Enum<StatusCode>
```
Now if you c... |
211,160 | <p>How do I get the inverse of a matrix in python? I've implemented it myself, but it's pure python, and I suspect there are faster modules out there to do it.</p>
| [
{
"answer_id": 211174,
"author": "Mapad",
"author_id": 28165,
"author_profile": "https://Stackoverflow.com/users/28165",
"pm_score": 8,
"selected": true,
"text": "<p>You should have a look at <a href=\"http://www.scipy.org/Tentative_NumPy_Tutorial\" rel=\"noreferrer\">numpy</a> if you do... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | How do I get the inverse of a matrix in python? I've implemented it myself, but it's pure python, and I suspect there are faster modules out there to do it. | You should have a look at [numpy](http://www.scipy.org/Tentative_NumPy_Tutorial) if you do matrix manipulation. This is a module mainly written in C, which will be much faster than programming in pure python. Here is an example of how to invert a matrix, and do other matrix manipulation.
```
from numpy import matrix
f... |
211,176 | <p>I am seeing following exception when I try to use dynamic proxy </p>
<pre><code> com.intellij.rt.execution.application.AppMain DynamicProxy.DynamicProxy
Exception in thread "main" java.lang.IllegalArgumentException: interface Interfaces.IPerson is not visible from class loader
at java.lang.reflect.Proxy.getProx... | [
{
"answer_id": 211226,
"author": "ddimitrov",
"author_id": 18187,
"author_profile": "https://Stackoverflow.com/users/18187",
"pm_score": 3,
"selected": false,
"text": "<p>When your <code>DynamicProxy</code> tries to do <code>Class.forName(youInterfaceClass.getName())</code> the resulting... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am seeing following exception when I try to use dynamic proxy
```
com.intellij.rt.execution.application.AppMain DynamicProxy.DynamicProxy
Exception in thread "main" java.lang.IllegalArgumentException: interface Interfaces.IPerson is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass(Proxy.j... | If this is web application, then you should use the web application classloader when creating dynamic proxy. So, for example instead of:
```
Proxy.newProxyInstance(
ClassLoader.getSystemClassLoader(),
new Class < ? >[] {MyInterface.class},
new InvocationHandler() {
// (...)
});
```
try:
```
Proxy.newProxy... |
211,184 | <p>What's the best way to implement user controls that require AJAX callbacks? </p>
<p>I want to accomplish a few things:</p>
<ul>
<li>Have events done in the browser (eg, drag and drop) trigger an AJAX notification that can raise a control event, which causes code on the page using the control to do whatever it need... | [
{
"answer_id": 211939,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 3,
"selected": true,
"text": "<p>Look into implementing ICallbackEventHandler in your Page -- it's a simple way to make a call back to a page function f... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7913/"
] | What's the best way to implement user controls that require AJAX callbacks?
I want to accomplish a few things:
* Have events done in the browser (eg, drag and drop) trigger an AJAX notification that can raise a control event, which causes code on the page using the control to do whatever it needs to do (eg, change a... | Look into implementing ICallbackEventHandler in your Page -- it's a simple way to make a call back to a page function from JavaScript.
Here's a good tutorial:
<http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=119> |
211,216 | <p>What are the lesser-known but useful features of the Haskell programming language. (I understand the language itself is lesser-known, but work with me. Even explanations of the simple things in Haskell, like defining the Fibonacci sequence with one line of code, will get upvoted by me.) </p>
<ul>
<li>Try to limit a... | [
{
"answer_id": 212014,
"author": "Jonathan Tran",
"author_id": 12887,
"author_profile": "https://Stackoverflow.com/users/12887",
"pm_score": 4,
"selected": false,
"text": "<p><strong>Optional Layout</strong></p>\n\n<p>You can use explicit braces and semicolons instead of whitespace (aka ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | What are the lesser-known but useful features of the Haskell programming language. (I understand the language itself is lesser-known, but work with me. Even explanations of the simple things in Haskell, like defining the Fibonacci sequence with one line of code, will get upvoted by me.)
* Try to limit answers to the ... | **My brain just exploded**
If you try to compile this code:
```
{-# LANGUAGE ExistentialQuantification #-}
data Foo = forall a. Foo a
ignorefoo f = 1 where Foo a = f
```
You will get this error message:
```
$ ghc Foo.hs
Foo.hs:3:22:
My brain just exploded.
I can't handle pattern bindings for existentially... |
211,236 | <p>Since we cannot setup Eclipse's RSE to use at the tool for remote editing, I have installed <a href="http://www.cis.upenn.edu/~bcpierce/unison/docs.html" rel="nofollow noreferrer">Unison</a>. But how can I get Eclipse to automatically run unison on every file save? Is there an eclipse plugin available for this?</p>
... | [
{
"answer_id": 271641,
"author": "javamonkey79",
"author_id": 27657,
"author_profile": "https://Stackoverflow.com/users/27657",
"pm_score": 3,
"selected": false,
"text": "<p>Depending on the importance, I would write a simple plugin to handle this. </p>\n\n<p>EDIT:\nAll you <em>really</e... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14351/"
] | Since we cannot setup Eclipse's RSE to use at the tool for remote editing, I have installed [Unison](http://www.cis.upenn.edu/~bcpierce/unison/docs.html). But how can I get Eclipse to automatically run unison on every file save? Is there an eclipse plugin available for this?
TIA | Depending on the importance, I would write a simple plugin to handle this.
EDIT:
All you *really* need to do is this:
1) Create the plugin from the templates with the RCP\PDE Eclipse install
2) Add the following code to your activator...
```
@Override
public void start( final BundleContext context ) throws Exc... |
211,243 | <p>I have code looking something like this:</p>
<pre><code>$data = file_get_contents($tempFile); // perhaps 30MB of file data, now in PHP's memory
$hash = md5($data);
$query = "INSERT INTO some_table
SET BlobData = '" . mysql_real_escape_string($data) . "',
BlobHash = '$hash'
";
mysql_que... | [
{
"answer_id": 211265,
"author": "Don Neufeld",
"author_id": 13097,
"author_profile": "https://Stackoverflow.com/users/13097",
"pm_score": 0,
"selected": false,
"text": "<p>Have you benchmarked the output buffering trick?</p>\n\n<pre><code>ob_start();\necho 'INSERT INTO some_table SET Bl... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28835/"
] | I have code looking something like this:
```
$data = file_get_contents($tempFile); // perhaps 30MB of file data, now in PHP's memory
$hash = md5($data);
$query = "INSERT INTO some_table
SET BlobData = '" . mysql_real_escape_string($data) . "',
BlobHash = '$hash'
";
mysql_query($query);
`... | You have two issues here:
#1, there are several different ways you can compute the MD5 hash:
* Do as you do and load into PHP as a string and use PHP's `md5()`
* Use PHP's `md5_file()`
* As of PHP 5.1+ you can use PHP's streams API with either of `md5` or `md5_file` to avoid loading entirely into memory
* Use `exec()... |
211,260 | <p>No extracted data output to data2.txt? What goes wrong to the code?</p>
<p><strong>MyFile.txt</strong></p>
<pre><code>ex1,fx2,xx1
mm1,nn2,gg3
EX1,hh2,ff7
</code></pre>
<p>This is my desired output in data2.txt:</p>
<pre><code>ex1,fx2,xx1
EX1,hh2,ff7
</code></pre>
<p><br></p>
<pre><code>#! /DATA/PLUG/pvelasco/S... | [
{
"answer_id": 211269,
"author": "moritz",
"author_id": 14132,
"author_profile": "https://Stackoverflow.com/users/14132",
"pm_score": 1,
"selected": false,
"text": "<p>When I run your code, but name the input file <code>My1.txt</code> instead of <code>MyFile.txt</code> I get the desired ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28607/"
] | No extracted data output to data2.txt? What goes wrong to the code?
**MyFile.txt**
```
ex1,fx2,xx1
mm1,nn2,gg3
EX1,hh2,ff7
```
This is my desired output in data2.txt:
```
ex1,fx2,xx1
EX1,hh2,ff7
```
```
#! /DATA/PLUG/pvelasco/Softwares/PERLINUX/bin/perl -w
my $infile ='My1.txt';
my $outfile ='data2.txt';
open... | This regex makes no sense:
```
m/EX$HF|ex$HF/
```
Is $HF supposed to be a variable? What are you trying to match?
Also, the second line in *every* Perl script you write should be:
```
use strict;
```
It will make Perl catch such mistakes and tell you about them, rather than silently ignoring them. |
211,319 | <p>i wonder if it is possible to cascade converters when using wpf databinding.
e.g. something like </p>
<pre><code><SomeControl Visibility="{Binding Path=SomeProperty, Converter={StaticResource firstConverter}, Converter={StaticResource secondConverter}}"/>
</code></pre>
<p>is it possible at all or do i have t... | [
{
"answer_id": 211812,
"author": "Brad Leach",
"author_id": 708,
"author_profile": "https://Stackoverflow.com/users/708",
"pm_score": 4,
"selected": false,
"text": "<p>You may be looking for a solution similar to Josh Smith's \"<a href=\"http://www.codeproject.com/KB/WPF/PipingValueConve... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20227/"
] | i wonder if it is possible to cascade converters when using wpf databinding.
e.g. something like
```
<SomeControl Visibility="{Binding Path=SomeProperty, Converter={StaticResource firstConverter}, Converter={StaticResource secondConverter}}"/>
```
is it possible at all or do i have to create a custom converter that... | You could try to use a **MultiBinding**, and bind twice to the same source, but with different converts on the single bindings. Something like:
```
<SomeControl>
<SomeControl.Visibility>
<MultiBinding Converter="{StaticResource combiningConverter}">
<Binding Path="SomeProperty" Converter="{Stat... |
211,335 | <p>I have a swf file that is not controlled by me. The swf expects a javascript call to set some variables after initialization. </p>
<p>The swf is embedded using the swfobject and I'm trying to call the as function right after the embed. This appears to be too soon because I get an error. Everything else should be fi... | [
{
"answer_id": 211489,
"author": "jcoder",
"author_id": 417292,
"author_profile": "https://Stackoverflow.com/users/417292",
"pm_score": 1,
"selected": false,
"text": "<p>Are you doing this while the page is still loading? Or from am onload handler?\nIf it's inline javascript I would sugg... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22673/"
] | I have a swf file that is not controlled by me. The swf expects a javascript call to set some variables after initialization.
The swf is embedded using the swfobject and I'm trying to call the as function right after the embed. This appears to be too soon because I get an error. Everything else should be fine since c... | Are you doing this while the page is still loading? Or from am onload handler?
If it's inline javascript I would suggest doing it in the onload handler from javascript which you can do like this -
```
window.onload = function() {
// your code here
}
```
it will run your code once the page is fully loaded.
This d... |
211,345 | <p>To use <a href="http://en.wikipedia.org/wiki/Modular_exponentiation" rel="noreferrer">modular exponentiation</a> as you would require when using the <a href="http://en.wikipedia.org/wiki/Fermat_primality_test" rel="noreferrer">Fermat Primality Test</a> with large numbers (100,000+), it calls for some very large calc... | [
{
"answer_id": 211365,
"author": "Yuval F",
"author_id": 1702,
"author_profile": "https://Stackoverflow.com/users/1702",
"pm_score": 2,
"selected": false,
"text": "<p>I suggest you try <a href=\"http://pear.php.net/package/Math_BigInteger\" rel=\"nofollow noreferrer\">BigInteger</a>. If ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | To use [modular exponentiation](http://en.wikipedia.org/wiki/Modular_exponentiation) as you would require when using the [Fermat Primality Test](http://en.wikipedia.org/wiki/Fermat_primality_test) with large numbers (100,000+), it calls for some very large calculations.
When I multiply two large numbers (eg: 62574 and... | For some reason, there are two standard libraries in PHP handling the arbitrary length/precision numbers: [BC Math](http://www.php.net/manual/en/book.bc.php) and [GMP](http://www.php.net/manual/en/book.gmp.php). I personally prefer GMP, as it's fresher and has richer API.
Based on GMP I've implemented [Decimal2 class]... |
211,348 | <p>I created an ASMX file with a code behind file. It's working fine, but it is outputting XML.</p>
<p>However, I need it to output JSON. The ResponseFormat configuration doesn't seem to work. My code-behind is:</p>
<pre><code>[System.Web.Script.Services.ScriptService]
public class _default : System.Web.Services.WebS... | [
{
"answer_id": 211671,
"author": "Pavel Chuchuva",
"author_id": 14131,
"author_profile": "https://Stackoverflow.com/users/14131",
"pm_score": 6,
"selected": true,
"text": "<p>From <a href=\"http://forums.asp.net/p/1327142/2652827.aspx\" rel=\"noreferrer\">WebService returns XML even whe... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56/"
] | I created an ASMX file with a code behind file. It's working fine, but it is outputting XML.
However, I need it to output JSON. The ResponseFormat configuration doesn't seem to work. My code-behind is:
```
[System.Web.Script.Services.ScriptService]
public class _default : System.Web.Services.WebService {
[WebMeth... | From [WebService returns XML even when ResponseFormat set to JSON](http://forums.asp.net/p/1327142/2652827.aspx):
>
> Make sure that the request is a POST request, not a GET. Scott Guthrie has a [post explaining why](http://weblogs.asp.net/scottgu/archive/2007/04/04/json-hijacking-and-how-asp-net-ajax-1-0-mitigates-t... |
211,353 | <p>I'm porting an application from Crystal Reports 8 to Crystal Reports XI in Delphi 5, using the RDC/ActiveX interface.</p>
<p>In Crystal Reports 8, I was able to bring up the crystal reports default report viewer window for a report like so:</p>
<pre><code>RptInvoicing.Destination := 0; // To: window
RptInvoicing.A... | [
{
"answer_id": 255130,
"author": "Arvo",
"author_id": 35777,
"author_profile": "https://Stackoverflow.com/users/35777",
"pm_score": 0,
"selected": false,
"text": "<p>I can't say anything about Delphi, but in VB we are using CRViewer ActiveX Control. Using it is straightforward - you put ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15477/"
] | I'm porting an application from Crystal Reports 8 to Crystal Reports XI in Delphi 5, using the RDC/ActiveX interface.
In Crystal Reports 8, I was able to bring up the crystal reports default report viewer window for a report like so:
```
RptInvoicing.Destination := 0; // To: window
RptInvoicing.Action := 1; // Execut... | I recently had the same problem, and [described the solution here](https://stackoverflow.com/questions/378089/how-can-i-display-crystal-xi-reports-inside-a-delphi-2007-application#378099). I am using Delphi 2007, but since the code involves calls to an external ActiveX DLL, it should work for you too. |
211,355 | <p>A while ago I had a query that I ran quite a lot for one of my users. It was still being evolved and tweaked but eventually it stablised and ran quite quickly, so we created a stored procedure from it. </p>
<p>So far, so normal. </p>
<p>The stored procedure, though, was dog slow. No material difference between the... | [
{
"answer_id": 211847,
"author": "nkav",
"author_id": 6828,
"author_profile": "https://Stackoverflow.com/users/6828",
"pm_score": 5,
"selected": false,
"text": "<p>Yes, I think you mean parameter sniffing, which is a technique the SQL Server optimizer uses to try to figure out parameter... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2902/"
] | A while ago I had a query that I ran quite a lot for one of my users. It was still being evolved and tweaked but eventually it stablised and ran quite quickly, so we created a stored procedure from it.
So far, so normal.
The stored procedure, though, was dog slow. No material difference between the query and the pr... | FYI - you need to be aware of something else when you're working with SQL 2005 and stored procs with parameters.
SQL Server will compile the stored proc's execution plan with the first parameter that's used. So if you run this:
```
usp_QueryMyDataByState 'Rhode Island'
```
The execution plan will work best with a s... |
211,369 | <p>I'm writing a MFC app that uses the MS Mappoint OCX. I need to display the locations of people and vehicles on the map and the best of doing this appears to be with Pushpin objects. I have no problem displaying a stock pushpin icon with some text but want to change the icon to a custom designed one. From the limited... | [
{
"answer_id": 221651,
"author": "IanW",
"author_id": 3875,
"author_profile": "https://Stackoverflow.com/users/3875",
"pm_score": 2,
"selected": false,
"text": "<p>I found the solution to this one myself. The following code works ..</p>\n\n<pre><code>CSymbols symbols;\nCSymbol symbol;\n\... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3875/"
] | I'm writing a MFC app that uses the MS Mappoint OCX. I need to display the locations of people and vehicles on the map and the best of doing this appears to be with Pushpin objects. I have no problem displaying a stock pushpin icon with some text but want to change the icon to a custom designed one. From the limited am... | I found the solution to this one myself. The following code works ..
```
CSymbols symbols;
CSymbol symbol;
symbols=map.get_Symbols();
symbol=symbols.Add("c:/temp/myicon.ico");
pushpin.put_Symbol(symbol.get_ID());
```
Where map is the Mappoint control. |
211,376 | <p>I've got a big big code base that includes two main namespaces: the engine and the application. </p>
<p>The engine defines a vector3 class as a typedef of another vector3 class, with equality operators that sit in the engine namespace, not in the vector3 class. I added a class to the application that also had equ... | [
{
"answer_id": 211386,
"author": "QBziZ",
"author_id": 11572,
"author_profile": "https://Stackoverflow.com/users/11572",
"pm_score": -1,
"selected": false,
"text": "<pre><code>bool operator==(Vector3 const &lhs, Vector3 const &rhs) { ... }\n</code></pre>\n\n<p>The canonical defin... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11801/"
] | I've got a big big code base that includes two main namespaces: the engine and the application.
The engine defines a vector3 class as a typedef of another vector3 class, with equality operators that sit in the engine namespace, not in the vector3 class. I added a class to the application that also had equality operat... | C++ Standard, 3.4.4.2 declares:
>
> For each argument type T in the function call, there is a set of zero or more associated namespaces and a set of zero
> or more associated classes to be considered. The sets of namespaces and classes is determined entirely by the types of
> the function arguments (and the namespa... |
211,383 | <p>I have the age-old problem of a <code>div</code> wrapping a two-column layout. My sidebar is floated, so my container <code>div</code> fails to wrap the content and sidebar.</p>
<pre class="lang-html prettyprint-override"><code><div id="container">
<div id="content"></div>
<div id="sidebar"... | [
{
"answer_id": 211415,
"author": "Torkel",
"author_id": 24425,
"author_profile": "https://Stackoverflow.com/users/24425",
"pm_score": -1,
"selected": false,
"text": "<p>Have you tried this:</p>\n\n<pre><code><div style=\"clear:both;\"/>\n</code></pre>\n\n<p>I haven't had any proble... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26107/"
] | I have the age-old problem of a `div` wrapping a two-column layout. My sidebar is floated, so my container `div` fails to wrap the content and sidebar.
```html
<div id="container">
<div id="content"></div>
<div id="sidebar"></div>
</div>
```
There seem to be numerous methods of fixing the clear bug in Firefox:
... | Depending upon the design being produced, each of the below clearfix CSS solutions has its own benefits.
The clearfix does have useful applications but it has also been used as a hack. Before you use a clearfix perhaps these modern css solutions can be useful:
* [css flexbox](https://css-tricks.com/snippets/css/a-gui... |
211,399 | <p>I need to execute a select and then update some of the rows in the <code>ResultSet</code> in an atomic way.</p>
<p>The code I am using looks like (simplified):</p>
<pre><code>stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery("SELECT ...");
while (rs.ne... | [
{
"answer_id": 211401,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 0,
"selected": false,
"text": "<p>Use transactions.</p>\n"
},
{
"answer_id": 211502,
"author": "Ian",
"author_id": 4396,
"author... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12388/"
] | I need to execute a select and then update some of the rows in the `ResultSet` in an atomic way.
The code I am using looks like (simplified):
```
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery("SELECT ...");
while (rs.next()) {
if (conditions_to_up... | There's probably a whole heap of technologies and concepts that come into play here, and things start to get fairly sticky when you start considering multi-threaded / multi request applications.
As Iassevk stated, you should look into using [Transactions](http://java.sun.com/docs/books/tutorial/jdbc/basics/transaction... |
211,436 | <p>In my database, in one of the table I have a GUID column with allow nulls. I have a method with a Guid? parameter that inserts a new data row in the table. However when I say myNewRow.myGuidColumn = myGuid I get the following error: "Cannot implicitly convert type 'System.Guid?' to 'System.Guid'." </p>
| [
{
"answer_id": 211462,
"author": "Greg Beech",
"author_id": 13552,
"author_profile": "https://Stackoverflow.com/users/13552",
"pm_score": 6,
"selected": true,
"text": "<p>The ADO.NET API has some problems when it comes to handling nullable value types (i.e. it simply doesn't work correct... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1360/"
] | In my database, in one of the table I have a GUID column with allow nulls. I have a method with a Guid? parameter that inserts a new data row in the table. However when I say myNewRow.myGuidColumn = myGuid I get the following error: "Cannot implicitly convert type 'System.Guid?' to 'System.Guid'." | The ADO.NET API has some problems when it comes to handling nullable value types (i.e. it simply doesn't work correctly). We've had no end of issues with it, and so have arrived at the conclusion that it's best to manually set the value to null, e.g.
```
myNewRow.myGuidColumn = myGuid == null ? (object)DBNull.Value : ... |
211,448 | <p>I have a custom class that implements <code>ICollection</code>, and this class is readonly, ie. <code>IsReadOnly</code> returns true (as opposed to using the <code>readonly</code> keyword), and all functions that would normally modify the data in the collection throw <code>InvalidOperationException</code>'s.</p>
<p... | [
{
"answer_id": 211469,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p>I guess the issue would be if clients used your sync root to achieve locking of not only your collection, but somethi... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15537/"
] | I have a custom class that implements `ICollection`, and this class is readonly, ie. `IsReadOnly` returns true (as opposed to using the `readonly` keyword), and all functions that would normally modify the data in the collection throw `InvalidOperationException`'s.
Now, given such a construct, and a quick skim over th... | Yes this is an issue in some cases. Even though the collection is read only and cannot be changed, the objects the collection references are not read only. Thus if the clients use the SyncRoot to perform locking they will not be thread safe when modifying the objects referenced by the collection.
I would recommend add... |
211,477 | <p>I'd like to know how to - if even possible - reflect what method calls are executed inside the method during execution. I'm especially interested in either external method calls (that is, methods in other classes) or calling some specific method like getDatabaseConnection().</p>
<p>My intention would be to monitor ... | [
{
"answer_id": 211482,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>I'd expect <a href=\"http://jakarta.apache.org/bcel/index.html\" rel=\"nofollow noreferrer\">BCEL</a> to be able to d... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd like to know how to - if even possible - reflect what method calls are executed inside the method during execution. I'm especially interested in either external method calls (that is, methods in other classes) or calling some specific method like getDatabaseConnection().
My intention would be to monitor predefined... | [Aspect J](http://www.eclipse.org/aspectj/) will solve your problem.
Try to define a pointcut like this:
```
pointcut profilling(): execution(public * *(..)) && (
within(com.myPackage..*) ||
```
In this way you will catch all the call to any public method within the package com.myPackage. Add as many w... |
211,483 | <p>I'm a bit confused that the argument to crypto functions is a string. Should I simply wrap non-string arguments with str() e.g.</p>
<pre><code>hashlib.sha256(str(user_id)+str(expiry_time))
hmac.new(str(random.randbits(256)))
</code></pre>
<p>(ignore for the moment that random.randbits() might not be cryptographica... | [
{
"answer_id": 211503,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 1,
"selected": false,
"text": "<p>You can.</p>\n\n<p>However, for the HMAC, you actually want to store the key somewhere. Without the key, there is no way ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23402/"
] | I'm a bit confused that the argument to crypto functions is a string. Should I simply wrap non-string arguments with str() e.g.
```
hashlib.sha256(str(user_id)+str(expiry_time))
hmac.new(str(random.randbits(256)))
```
(ignore for the moment that random.randbits() might not be cryptographically good).
edit: I realise... | Well, usually hash-functions (and cryptographic functions generally) work on bytes. The Python strings are basically byte-strings. If you want to compute the hash of some object you have to convert it to a string representation. Just make sure to apply the same operation later if you want to check if the hash is correc... |
211,487 | <p>In JUnit 3 I simply called</p>
<pre><code>suite.addTestSuite( MyTest.class )
</code></pre>
<p>However if MyTest is a JUnit 4 test which does not extend TestCase this doesn't work. What should I do instead to create a suite of tests?</p>
| [
{
"answer_id": 211603,
"author": "Treb",
"author_id": 22114,
"author_profile": "https://Stackoverflow.com/users/22114",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the Waveform Audio Interface, there is an <a href=\"http://msdn.microsoft.com/en-us/library/aa446573.aspx\" re... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6583/"
] | In JUnit 3 I simply called
```
suite.addTestSuite( MyTest.class )
```
However if MyTest is a JUnit 4 test which does not extend TestCase this doesn't work. What should I do instead to create a suite of tests? | Assuming that you are talking about Windows, there are essentially three ways to do this.
The first is to open the audio device's main output as a recording source. This is only possible when the driver supports it, although most do these days. Common names for the virtual device are "What You Hear" or "Wave Out". Yo... |
211,493 | <p>I'm just in the process of upgrading my Preview 5 application to Beta 1, and I'm nearly there save for this one error when trying to render a control:</p>
<blockquote>
<p>'System.Web.Mvc.HtmlHelper' does not
contain a definition for
'RenderPartial' and no extension
method 'RenderPartial' accepting a
first... | [
{
"answer_id": 211524,
"author": "tags2k",
"author_id": 192,
"author_profile": "https://Stackoverflow.com/users/192",
"pm_score": 3,
"selected": false,
"text": "<p>Now fixed - the conflict was a difference in Web.config requirements between Preview 5 and Beta 1. The following needs to b... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] | I'm just in the process of upgrading my Preview 5 application to Beta 1, and I'm nearly there save for this one error when trying to render a control:
>
> 'System.Web.Mvc.HtmlHelper' does not
> contain a definition for
> 'RenderPartial' and no extension
> method 'RenderPartial' accepting a
> first argument of typ... | And also don't forget to add namespaces like below to the web config, I think preview 5 default web.config does not have System.Web.Mvc.Html in it:
```
<namespaces>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
... |
211,496 | <p>Is using a handrolled POCO queue class using pseudo code</p>
<pre><code>T Dequeue() {
lock(syncRoot) {
if(queue.Empty) Thread.Wait();
}
}
void Enqueue(T item) {
queue.Enqueue(item);
Thread.Notify();
}
</code></pre>
<p>For WCF is request queueing a scalable approach?</p>
| [
{
"answer_id": 211524,
"author": "tags2k",
"author_id": 192,
"author_profile": "https://Stackoverflow.com/users/192",
"pm_score": 3,
"selected": false,
"text": "<p>Now fixed - the conflict was a difference in Web.config requirements between Preview 5 and Beta 1. The following needs to b... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28413/"
] | Is using a handrolled POCO queue class using pseudo code
```
T Dequeue() {
lock(syncRoot) {
if(queue.Empty) Thread.Wait();
}
}
void Enqueue(T item) {
queue.Enqueue(item);
Thread.Notify();
}
```
For WCF is request queueing a scalable approach? | And also don't forget to add namespaces like below to the web config, I think preview 5 default web.config does not have System.Web.Mvc.Html in it:
```
<namespaces>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
... |
211,498 | <p>We use GUIDs for primary key, which you know is clustered by default.</p>
<p>When inserting a new row into a table it is inserted at a random page in the table (because GUIDs are random). This has a measurable performance impact because the DB will split data pages all the time (fragmentation). But the main reason I... | [
{
"answer_id": 211514,
"author": "BlackWasp",
"author_id": 21862,
"author_profile": "https://Stackoverflow.com/users/21862",
"pm_score": -1,
"selected": false,
"text": "<p>The key problem is knowing what the last value was in a .NET application. SQL Server keeps track of this for you. Yo... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8547/"
] | We use GUIDs for primary key, which you know is clustered by default.
When inserting a new row into a table it is inserted at a random page in the table (because GUIDs are random). This has a measurable performance impact because the DB will split data pages all the time (fragmentation). But the main reason I what a s... | It should be possible to create a sequential GUID in c# or vb.net using an API call to UuidCreateSequential. The API declaration (C#) below has been taken from [Pinvoke.net](http://www.pinvoke.net/default.aspx/rpcrt4/UuidCreateSequential.html) where you can also find a full example of how to call the function.
```
[D... |
211,535 | <h2>Note</h2>
<p>The question below was asked in 2008 about some code from 2003. As the OP's <strong>update</strong> shows, this entire post has been obsoleted by vintage 2008 algorithms and persists here only as a historical curiosity.</p>
<hr>
<p>I need to do a fast case-insensitive substring search in C/C++. My r... | [
{
"answer_id": 211561,
"author": "Chris Young",
"author_id": 9417,
"author_profile": "https://Stackoverflow.com/users/9417",
"pm_score": 2,
"selected": false,
"text": "<p>Why do you use _strlwr(string); in init_stristr()? It's not a standard function. Presumably it's for locale s... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1709/"
] | Note
----
The question below was asked in 2008 about some code from 2003. As the OP's **update** shows, this entire post has been obsoleted by vintage 2008 algorithms and persists here only as a historical curiosity.
---
I need to do a fast case-insensitive substring search in C/C++. My requirements are as follows:
... | The code you posted is about half as fast as `strcasestr`.
```none
$ gcc -Wall -o my_stristr my_stristr.c
steve@solaris:~/code/tmp
$ gcc -Wall -o strcasestr strcasestr.c
steve@solaris:~/code/tmp
$ ./bench ./my_stristr > my_stristr.result ; ./bench ./strcasestr > strcasestr.result;
steve@solaris:~/code/tmp
$ cat my_st... |
211,549 | <p>How can I change the system-default regional settings in windows XP for use by services (run by the system user)?</p>
<p>Regional and Language Options in the control panel modify the settings for the logged-in user. However, services don't use the user's settings - they use the system settings. I know that they can... | [
{
"answer_id": 211589,
"author": "Paul M",
"author_id": 28241,
"author_profile": "https://Stackoverflow.com/users/28241",
"pm_score": 0,
"selected": false,
"text": "<p>IM not sure if this will help</p>\n\n<p>First type in gpedit.msc from the run command and a dialog box should now open. ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15698/"
] | How can I change the system-default regional settings in windows XP for use by services (run by the system user)?
Regional and Language Options in the control panel modify the settings for the logged-in user. However, services don't use the user's settings - they use the system settings. I know that they can be found ... | There is no documented way to do that.
A quick look in the Regional Settings Applet dll shows that it calls a totally undocumented API: NlsUpdateSystemLocale().
Why do you want to do that? Do you want to control the locale of a service of yours? Then let your service run under a user account you control. |
211,550 | <p>Having a strange rendering issue with Safari: </p>
<p>I have a table inside a div. Inside the table <td> I have lots of div's floated left. So the normal display is all of the divs within the td stacked up to the left until they fill the width, then flow to the next line, and so forth. So something like this:... | [
{
"answer_id": 548640,
"author": "Parand",
"author_id": 13055,
"author_profile": "https://Stackoverflow.com/users/13055",
"pm_score": 3,
"selected": true,
"text": "<p>Answering my own question: </p>\n\n<p>Finally figured out the issue: my inner divs (the \"XXX\"s) had white-space: nowrap... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13055/"
] | Having a strange rendering issue with Safari:
I have a table inside a div. Inside the table <td> I have lots of div's floated left. So the normal display is all of the divs within the td stacked up to the left until they fill the width, then flow to the next line, and so forth. So something like this:
```
|=========... | Answering my own question:
Finally figured out the issue: my inner divs (the "XXX"s) had white-space: nowrap. Apparently webkit was no-wrap'ing the entire list of divs instead of applying the nowrap within the div.
That was a nasty one.
(This had nothing to do with display:none) |
211,567 | <p>When using a class that has an enum property, one usually gets a naming conflict between the property name and the enum type. Example:</p>
<pre><code>enum Day{ Monday, Tuesday, ... }
class MyDateClass
{
private Day day;
public Day Day{ get{ return day; } }
}
</code></pre>
<p>Since only flags enums should h... | [
{
"answer_id": 211571,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>So long as the enumeration isn't nested within MyDateClass, I don't see that that's a problem. It's far from uncommon... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28858/"
] | When using a class that has an enum property, one usually gets a naming conflict between the property name and the enum type. Example:
```
enum Day{ Monday, Tuesday, ... }
class MyDateClass
{
private Day day;
public Day Day{ get{ return day; } }
}
```
Since only flags enums should have plural names, naming t... | There is no conflict. In fact, the [.NET Framework style guide encourages you to do this](http://msdn.microsoft.com/en-us/library/ms229012.aspx), e.g. if you have a class that has a single property of a type (no matter if enum or class), then you should name it the same. Typical example is a Color property of type Colo... |
211,583 | <p>I am using a microcontroller with a C51 core. I have a fairly timeconsuming and large subroutine that needs to be called every 500ms. An RTOS is not being used. </p>
<p>The way I am doing it right now is that I have an existing Timer interrupt of 10 ms. I set a flag after every 50 interrupts that is checked for bei... | [
{
"answer_id": 211632,
"author": "Will Dean",
"author_id": 987,
"author_profile": "https://Stackoverflow.com/users/987",
"pm_score": 1,
"selected": false,
"text": "<p>I think you have some conflicting/not-thought-through requirements here. You say that you can't call this code from the ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27795/"
] | I am using a microcontroller with a C51 core. I have a fairly timeconsuming and large subroutine that needs to be called every 500ms. An RTOS is not being used.
The way I am doing it right now is that I have an existing Timer interrupt of 10 ms. I set a flag after every 50 interrupts that is checked for being true in... | Would this do what you need?
```
#define FUDGE_MARGIN 2 //In 10ms increments
volatile unsigned int ticks = 0;
void timer_10ms_interrupt( void ) { ticks++; }
void mainloop( void )
{
unsigned int next_time = ticks+50;
while( 1 )
{
do_mainloopy_stuff();
if( ticks >= next_time-FUDGE_MA... |
211,611 | <p>I have a <a href="http://en.wikipedia.org/wiki/Windows_Forms" rel="noreferrer">Windows Forms</a> <a href="http://www.google.com/search?hl=en&q=TreeView%20msdn&btnG=Search" rel="noreferrer">TreeView</a> (node, subnodes). Each node contains some additional information in its Tag. Also, each nodes maps a file o... | [
{
"answer_id": 211619,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 6,
"selected": false,
"text": "<p>Consider using the <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.clipboard_members.aspx\"... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a [Windows Forms](http://en.wikipedia.org/wiki/Windows_Forms) [TreeView](http://www.google.com/search?hl=en&q=TreeView%20msdn&btnG=Search) (node, subnodes). Each node contains some additional information in its Tag. Also, each nodes maps a file on the disk. What's the easiest way copy/cut/paste nodes/files in C#... | Consider using the [Clipboard class](http://msdn.microsoft.com/en-us/library/system.windows.forms.clipboard_members.aspx). It features all the methods necessary for putting data on the Windows clipboard and to retrieve data from the Windows clipboard.
```
StringCollection paths = new StringCollection();
paths.Add("f:\... |
211,612 | <p>There are a dozen Rails plugins whose goal is to replace fixtures in testing. Here are a few I can think of:</p>
<ul>
<li>fixture replacement</li>
<li>factory girl</li>
<li>factories and workers</li>
<li>rails scenarios</li>
<li>fixture-scenarios</li>
<li>object daddy</li>
</ul>
<p>There are probably others. Which... | [
{
"answer_id": 211649,
"author": "Codebeef",
"author_id": 12037,
"author_profile": "https://Stackoverflow.com/users/12037",
"pm_score": 3,
"selected": false,
"text": "<p>I personally use <a href=\"http://faker.rubyforge.org/\" rel=\"nofollow noreferrer\">Faker</a> with a custom Factory c... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11082/"
] | There are a dozen Rails plugins whose goal is to replace fixtures in testing. Here are a few I can think of:
* fixture replacement
* factory girl
* factories and workers
* rails scenarios
* fixture-scenarios
* object daddy
There are probably others. Which of these plugins do you prefer and why? | I personally use [Faker](http://faker.rubyforge.org/) with a custom Factory class. This allows me to create my factories, and populate the generated instances with non-static data.
```
# spec/factory.rb
module Factory
def self.create_offer(options={})
Offer.create({
:code => Faker::Lorem.words(1),
:e... |
211,616 | <p>Objective-C is getting wider use due to its use by Apple for Mac OS X and iPhone development. What are some of your favourite "hidden" features of the Objective-C language?</p>
<ul>
<li>One feature per answer.</li>
<li>Give an example and short description of the feature, not just a link to documentation.</li>
<li>... | [
{
"answer_id": 211672,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 4,
"selected": false,
"text": "<h2>Posing</h2>\n\n<p>Objective-C permits a class to <strong>entirely replace another class</strong> within an application.... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2438/"
] | Objective-C is getting wider use due to its use by Apple for Mac OS X and iPhone development. What are some of your favourite "hidden" features of the Objective-C language?
* One feature per answer.
* Give an example and short description of the feature, not just a link to documentation.
* Label the feature using a ti... | Posing
------
Objective-C permits a class to **entirely replace another class** within an application. The replacing class is said to "pose as" the target class. All messages sent to the target class are then instead received by the posing class. There are some restrictions on which classes can pose:
* A class may on... |
211,622 | <p>I would like to have some kind of catch-all exceptions mechanism in the root of my code, so when an app terminates unexpectedly I can still provide some useful logging.</p>
<p>Something along the lines of</p>
<pre><code>static void Main () {
if (Debugger.IsAttached)
RunApp();
else {
try {
... | [
{
"answer_id": 211641,
"author": "massimogentilini",
"author_id": 11673,
"author_profile": "https://Stackoverflow.com/users/11673",
"pm_score": 0,
"selected": false,
"text": "<p>Shouldn't simply do a</p>\n\n<pre><code>Exception e1 = e;\nLogException(e);\nthrow(e1);\n</code></pre>\n\n<p>i... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28859/"
] | I would like to have some kind of catch-all exceptions mechanism in the root of my code, so when an app terminates unexpectedly I can still provide some useful logging.
Something along the lines of
```
static void Main () {
if (Debugger.IsAttached)
RunApp();
else {
try {
RunApp();
... | As Paul Betts already mentioned, you might be better off using the [AppDomain.UnhandledException](http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception.aspx) event instead of a try/catch block.
In your UnhandledException event handler you can log/display the exception and then offer the option to... |
211,629 | <p>How to remove the program icon from the Programs folder?</p>
| [
{
"answer_id": 211631,
"author": "Guvante",
"author_id": 16800,
"author_profile": "https://Stackoverflow.com/users/16800",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the standard file operations on shortcuts.</p>\n\n<p>I believe the file extension is lnk.</p>\n"
},
{
... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How to remove the program icon from the Programs folder? | A shortcut file is a normal file that happens to redirect (on click) the call to another file, program or directory. To remove a shortcut you can use the [File.Delete](http://msdn.microsoft.com/en-us/library/system.io.file.delete.aspx) method.
```
File.Delete(path_to_lnk_file);
``` |
211,648 | <p>I have a form, when I click on submit button, I want to communicate with the server and get something from the server to be displayed on the same page. Everything must be done in AJAX manner. How to do it in Google App Engine? If possible, I want to do it in JQuery.</p>
<p>Edit: The example in <a href="http://group... | [
{
"answer_id": 216929,
"author": "JJ.",
"author_id": 9106,
"author_profile": "https://Stackoverflow.com/users/9106",
"pm_score": 1,
"selected": false,
"text": "<p>I'd add that in Firebug, you should see your ajax call pop up in the console. If you're getting the exception when you open t... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | I have a form, when I click on submit button, I want to communicate with the server and get something from the server to be displayed on the same page. Everything must be done in AJAX manner. How to do it in Google App Engine? If possible, I want to do it in JQuery.
Edit: The example in [code.google.com/appengine/arti... | You can use [jquery Form plugin](http://www.malsup.com/jquery/form/) to submit forms using ajax. Works very well.
```
$('#myFormId').submit(function() {
// submit the form
$(this).ajaxSubmit();
return false;
});
``` |
211,689 | <p>I'm using xsd.exe to make the C# classes for our settings. I have a setting that is per-server and per-database, so I want the class to behave like Dictionary<string, string[][]>. So I want to be able to say</p>
<pre><code>string serverName = "myServer";
int databaseId = 1;
FieldSettings fieldSettings = get... | [
{
"answer_id": 211700,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 1,
"selected": false,
"text": "<p>This not what <code>xsd</code> is used for. You can always just add your own indexer to a partial class, and mark it wit... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] | I'm using xsd.exe to make the C# classes for our settings. I have a setting that is per-server and per-database, so I want the class to behave like Dictionary<string, string[][]>. So I want to be able to say
```
string serverName = "myServer";
int databaseId = 1;
FieldSettings fieldSettings = getFieldSettings();
stri... | xsd defines the data structure, not really the access approach. I don't think you can express "this is a lookup" in xsd : everything is either values or set of values/entities.
If you want specific handling, you might consider custom serialization - or alternatively consider your DTOs and your *working* classes as sep... |
211,693 | <p>What steps do I need to take to get HTML documentation automatically building via the build step in Visual Studio? I have all the comments in place and the comments.xml file being generated, and Sandcastle installed. I just need to know what to add to the post-build step in order to generate the docs.</p>
| [
{
"answer_id": 211710,
"author": "Joe",
"author_id": 13087,
"author_profile": "https://Stackoverflow.com/users/13087",
"pm_score": 3,
"selected": false,
"text": "<p>I recommend you install Sandcastle Help File Builder from <a href=\"http://www.codeplex.com/SHFB\" rel=\"noreferrer\">Codep... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/986/"
] | What steps do I need to take to get HTML documentation automatically building via the build step in Visual Studio? I have all the comments in place and the comments.xml file being generated, and Sandcastle installed. I just need to know what to add to the post-build step in order to generate the docs. | Some changes have been made since this question was asked. Sandcastle no longer includes `SandcastleBuilderConsole.exe`. Instead it uses plain old `MSBuild.exe`.
To integrate this with visual studio here is what I did:
Place this in your Post-build event:
```
IF "$(ConfigurationName)"=="Release" Goto Exit
"$(System... |
211,694 | <p>I am writing controls that work nice with JavaScript, but they have to work even without it. Now testing with selenium works fine for me. But all test with disabled JavaScript (in my browser) won't run with selenium. Is there a way to do automated test for this purpose?</p>
| [
{
"answer_id": 211726,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>I don't know Selenium, but with the NoScript Firefox extension, you can disable scripts on a per-domain basis. So could you... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am writing controls that work nice with JavaScript, but they have to work even without it. Now testing with selenium works fine for me. But all test with disabled JavaScript (in my browser) won't run with selenium. Is there a way to do automated test for this purpose? | [WWW::Mechanize](http://search.cpan.org/perldoc?WWW::Mechanize) and [Test::WWW::Mechanize](http://search.cpan.org/perldoc?Test::WWW::Mechanize) are two Perl modules to do exactly that.
```
use Test::More tests => 5;
use Test::WWW::Mechanize;
my $mech = Test::WWW::Mechanize->new;
# Test you can get http://petdance.co... |
211,695 | <p>I would like to create a trivial one-off Python object to hold some command-line options. I would like to do something like this:</p>
<pre><code>options = ??????
options.VERBOSE = True
options.IGNORE_WARNINGS = False
# Then, elsewhere in the code...
if options.VERBOSE:
...
</code></pre>
<p>Of course I could ... | [
{
"answer_id": 211774,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 4,
"selected": false,
"text": "<p>The <a href=\"http://docs.python.org/library/collections.html\" rel=\"noreferrer\">collections module</a> has grown a <em>n... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24478/"
] | I would like to create a trivial one-off Python object to hold some command-line options. I would like to do something like this:
```
options = ??????
options.VERBOSE = True
options.IGNORE_WARNINGS = False
# Then, elsewhere in the code...
if options.VERBOSE:
...
```
Of course I could use a dictionary, but `opti... | Given your requirements, I'd say the custom class is your best bet:
```
class options(object):
VERBOSE = True
IGNORE_WARNINGS = True
if options.VERBOSE:
# ...
```
To be complete, another approach would be using a separate module, i.e. `options.py` to encapsulate your option defaults.
`options.py`:
```... |
211,703 | <p>Is this doable in either IE7 or Firefox?</p>
| [
{
"answer_id": 211732,
"author": "Pistos",
"author_id": 28558,
"author_profile": "https://Stackoverflow.com/users/28558",
"pm_score": 2,
"selected": false,
"text": "<p>Try <a href=\"http://plugins.jquery.com/project/dimensions\" rel=\"nofollow noreferrer\">the dimensions jQuery plugin</a... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9328/"
] | Is this doable in either IE7 or Firefox? | You can do it in both - get the position relative to the document, then subtract the scroll position.
```
var e = document.getElementById('xxx');
var offset = {x:0,y:0};
while (e)
{
offset.x += e.offsetLeft;
offset.y += e.offsetTop;
e = e.offsetParent;
}
if (document.documentElement && (document.documentE... |
211,714 | <p>Morning all,</p>
<p>Bit of a language theory question here... I've found some references online suggesting that exception handling and delegates in C# have some different behaviour in some cases but I cannot find any concrete documentation on the matter.</p>
<p>We recently had some big problems with exceptions ins... | [
{
"answer_id": 213569,
"author": "Sunny Milenov",
"author_id": 8220,
"author_profile": "https://Stackoverflow.com/users/8220",
"pm_score": 0,
"selected": false,
"text": "<p>Side note:\nThe whole idea of exception catching is not to \"swallow\" them and display the error message, but to r... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25519/"
] | Morning all,
Bit of a language theory question here... I've found some references online suggesting that exception handling and delegates in C# have some different behaviour in some cases but I cannot find any concrete documentation on the matter.
We recently had some big problems with exceptions inside delegates for... | I think what you might find here is that you are not releasing the MS Excel COM objects you are implicitly creating when an exception is thrown. In my experience MS Office apps are very sensitive to their resources not being released (though most of my experience is with Outlook).
I would tend NOT to try to handle CO... |
211,715 | <p>How does one execute some VBA code periodically, completely automated?</p>
| [
{
"answer_id": 211742,
"author": "Adam Davis",
"author_id": 2915,
"author_profile": "https://Stackoverflow.com/users/2915",
"pm_score": 1,
"selected": false,
"text": "<p>There is an application method that can be used for timing events. If you want this to occur periodically you'll have... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9095/"
] | How does one execute some VBA code periodically, completely automated? | You can use Application.OnTime to schedule a macro to be executed periodically. For example create a module with the code below. Call "Enable" to start the timer running.
It is important to stop the timer running when you close your workbook: to do so handle Workbook\_BeforeClose and call "Disable"
```
Option Explic... |
211,717 | <p>Is there a function in Common Lisp that takes a string as an argument and returns a keyword?</p>
<p>Example: <code>(keyword "foo")</code> -> <code>:foo</code></p>
| [
{
"answer_id": 211786,
"author": "Jonathan Wright",
"author_id": 28840,
"author_profile": "https://Stackoverflow.com/users/28840",
"pm_score": -1,
"selected": false,
"text": "<pre><code>(intern \"foo\" \"KEYWORD\") -> :foo\n</code></pre>\n\n<p>See the <a href=\"https://lispcookbook.gi... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18480/"
] | Is there a function in Common Lisp that takes a string as an argument and returns a keyword?
Example: `(keyword "foo")` -> `:foo` | Here's a `make-keyword` function which packages up keyword creation process (`intern`ing of a name into the `KEYWORD` package). :-)
```
(defun make-keyword (name) (values (intern name "KEYWORD")))
``` |
211,718 | <p>Why doesn't the code below work? The idea is that the page checks to see if the dropdown variable has changes since you last refreshed the page.</p>
<pre><code> <logic:equal name="Result" value = "-1">
<bean:define id="JOININGDATE" name="smlMoverDetailForm" property="empFDJoiningDate"
type="jav... | [
{
"answer_id": 211797,
"author": "Sietse",
"author_id": 6400,
"author_profile": "https://Stackoverflow.com/users/6400",
"pm_score": 0,
"selected": false,
"text": "<pre><code><logic:equal name= DropDownValue value = NewDropDownValue>\n</code></pre>\n\n<p>I'm not sure if this is yo... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Why doesn't the code below work? The idea is that the page checks to see if the dropdown variable has changes since you last refreshed the page.
```
<logic:equal name="Result" value = "-1">
<bean:define id="JOININGDATE" name="smlMoverDetailForm" property="empFDJoiningDate"
type="java.lang.String" toScope ... | You have realized, that your bean:define - at least in your question stated here - is flawed?
```
toScope="sess
```
is most likely not what you want - it doesn't even terminate the tag. But this may be formatting in StackOverflow... Also, the missing quotes have been mentioned in other answers.
The error may be th... |
211,758 | <p>I have a sproc that returns a single line and column with a text, I need to set this text to a variable, something like:</p>
<pre><code>declare @bla varchar(100)
select @bla = sp_Name 9999, 99989999, 'A', 'S', null
</code></pre>
<p>but of course, this code doesn't work...</p>
<p>thanks!</p>
| [
{
"answer_id": 211778,
"author": "Tim C",
"author_id": 7585,
"author_profile": "https://Stackoverflow.com/users/7585",
"pm_score": 4,
"selected": false,
"text": "<p>If the stored procedure is returning a single value you could define one of the parameters on the stored procedure to be an... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17648/"
] | I have a sproc that returns a single line and column with a text, I need to set this text to a variable, something like:
```
declare @bla varchar(100)
select @bla = sp_Name 9999, 99989999, 'A', 'S', null
```
but of course, this code doesn't work...
thanks! | If you are unable to change the stored procedure, another solution would be to define a temporary table, and insert the results into that
```
DECLARE @Output VARCHAR(100)
CREATE TABLE #tmpTable
(
OutputValue VARCHAR(100)
)
INSERT INTO #tmpTable (OutputValue)
EXEC dbo.sp_name 9999, 99989999, 'A', 'S', null
SELECT... |
211,800 | <p>I have no idea. This causes seemingly random time-outs. These in turn break the flash that i am loading it into. Has anyone seen anything like this before?</p>
<pre><code><?php
require_once("../includes/class.database.php");
require_once("../includes/dbConnectInfo.inc");
require_once("../includes/functions.php")... | [
{
"answer_id": 211807,
"author": "Thomas Owens",
"author_id": 572,
"author_profile": "https://Stackoverflow.com/users/572",
"pm_score": 3,
"selected": true,
"text": "<p>What happens if you add <code>set_time_limit(0);</code> to the code? I usually add that line to long-executing code bel... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have no idea. This causes seemingly random time-outs. These in turn break the flash that i am loading it into. Has anyone seen anything like this before?
```
<?php
require_once("../includes/class.database.php");
require_once("../includes/dbConnectInfo.inc");
require_once("../includes/functions.php");
include("../in... | What happens if you add `set_time_limit(0);` to the code? I usually add that line to long-executing code below the include statements.
Since this works, let me elaborate.
By default, PHP scripts are set up to only execute for so long. I believe the limit is 30 seconds when PHP is installed, but this can be changed in... |
211,819 | <p>When doing a <code>cvs update</code>, you get a nice summary of the state of the repository, for example:</p>
<pre><code>M src/file1.txt
M src/file2.txt
C src/file3.txt
A src/file4.txt
? src/file5.txt
</code></pre>
<p>Is there a way to get this without actually updating? I know there is <code>cvs status</code>, bu... | [
{
"answer_id": 211821,
"author": "jmcnamara",
"author_id": 10238,
"author_profile": "https://Stackoverflow.com/users/10238",
"pm_score": 6,
"selected": true,
"text": "<p>You can use the -n flag to get the update output without actually updating the files. You can also add -q (quiet) to s... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3102/"
] | When doing a `cvs update`, you get a nice summary of the state of the repository, for example:
```
M src/file1.txt
M src/file2.txt
C src/file3.txt
A src/file4.txt
? src/file5.txt
```
Is there a way to get this without actually updating? I know there is `cvs status`, but this is way to verbose:
```
=================... | You can use the -n flag to get the update output without actually updating the files. You can also add -q (quiet) to suppress any server messages.
```
cvs -q -n update
``` |
211,834 | <p>OK... I'm a VB.NET WinForms guy trying to understand WPF and all of its awesomeness. I'm writing a basic app as a learning experience, and have been reading lots of information and watching tutorial videos, but I just can't get off the ground with simple DataBinding, and I know I'm missing some basic concept. As muc... | [
{
"answer_id": 211990,
"author": "Samuel Jack",
"author_id": 1727,
"author_profile": "https://Stackoverflow.com/users/1727",
"pm_score": 4,
"selected": true,
"text": "<p>Here's how you need to change your XAML (the code is fine). </p>\n\n<pre><code><Window x:Class=\"Window1\" \n ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/641985/"
] | OK... I'm a VB.NET WinForms guy trying to understand WPF and all of its awesomeness. I'm writing a basic app as a learning experience, and have been reading lots of information and watching tutorial videos, but I just can't get off the ground with simple DataBinding, and I know I'm missing some basic concept. As much a... | Here's how you need to change your XAML (the code is fine).
```
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300"
DataContext="{Binding... |
211,875 | <p>I have a string column in a database table which maps to an Enum in code. In my dbml file when I set the "Type" to <code>MyTypes.EnumType</code> I get the following error:</p>
<blockquote>
<p>Error 1 DBML1005: Mapping between DbType 'VarChar(50) NOT NULL' and
Type 'MyTypes.EnumType' in Column 'EnumCol' of Ty... | [
{
"answer_id": 211894,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": true,
"text": "<p>Curious - it should work IIRC; I'll see if I can do a quick example - however, you might want to check that you hav... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28889/"
] | I have a string column in a database table which maps to an Enum in code. In my dbml file when I set the "Type" to `MyTypes.EnumType` I get the following error:
>
> Error 1 DBML1005: Mapping between DbType 'VarChar(50) NOT NULL' and
> Type 'MyTypes.EnumType' in Column 'EnumCol' of Type 'Table1' is not
> supported.
... | Curious - it should work IIRC; I'll see if I can do a quick example - however, you might want to check that you have the fully-qualified enum name (i.e. including the namespace).
[update] From [here](http://blog.rolpdog.com/2007/07/linq-to-sql-enum-mapping.html) it seems that the RTM version shipped with a bug when re... |
211,941 | <p>This is an extension of my <a href="https://stackoverflow.com/questions/205923">earlier XSS question</a>.</p>
<p>Assuming that there isn't a Regex strong enough to guarantee XSS saftey for user entered URLs I'm looking at using a redirect.</p>
<p>(Although if you do have one please add it under the other question)... | [
{
"answer_id": 211952,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 1,
"selected": false,
"text": "<p>It's not possible to log someone out in just one tab / window.</p>\n"
},
{
"answer_id": 212024,
"author": "Eri... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | This is an extension of my [earlier XSS question](https://stackoverflow.com/questions/205923).
Assuming that there isn't a Regex strong enough to guarantee XSS saftey for user entered URLs I'm looking at using a redirect.
(Although if you do have one please add it under the other question)
We have user input web add... | It's not possible to log someone out in just one tab / window. |
211,958 | <p><strong>EDIT: I missed a crucial point: .NET 2.0</strong></p>
<p>Consider the case where I have a list of unsorted items, for the sake of simplicity of a type like this:</p>
<pre><code>class TestClass
{
DateTime SomeTime;
decimal SomePrice;
// constructor
}
</code></pre>
<p>I need to create a report-... | [
{
"answer_id": 211977,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p>Crucial question: are you using .NET 3.5, thus allowing LINQ to be used? If so, you can group by SomeTime.Date and th... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17378/"
] | **EDIT: I missed a crucial point: .NET 2.0**
Consider the case where I have a list of unsorted items, for the sake of simplicity of a type like this:
```
class TestClass
{
DateTime SomeTime;
decimal SomePrice;
// constructor
}
```
I need to create a report-like output, where the total prices for each d... | [edit] Since you are using .NET 2.0 with C# 3.0, you can use [LINQBridge](http://www.albahari.com/nutshell/linqbridge.aspx) to enable this.
LINQ; something like:
```
var groups = from row in testList
group row by row.SomeTime;
foreach (var group in groups.OrderBy(group => group.Key))... |
211,971 | <p>WPF, Browserlike app.<br>
I got one page containing a ListView. After calling a PageFunction I add a line to the ListView, and want to scroll the new line into view:</p>
<pre><code> ListViewItem item = ItemContainerGenerator.ContainerFromIndex(index) as ListViewItem;
if (item != null)
ScrollIntoView(item);
<... | [
{
"answer_id": 211984,
"author": "EFrank",
"author_id": 28572,
"author_profile": "https://Stackoverflow.com/users/28572",
"pm_score": 5,
"selected": true,
"text": "<p>I think the problem here is that the ListViewItem is not created yet if the line is not visible. WPF creates the Visible ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7021/"
] | WPF, Browserlike app.
I got one page containing a ListView. After calling a PageFunction I add a line to the ListView, and want to scroll the new line into view:
```
ListViewItem item = ItemContainerGenerator.ContainerFromIndex(index) as ListViewItem;
if (item != null)
ScrollIntoView(item);
```
This works... | I think the problem here is that the ListViewItem is not created yet if the line is not visible. WPF creates the Visible on demand.
So in this case you probably get `null` for the item, do you?
(According to your comment, you do)
I have found a [link on MSDN forums that suggest accessing the Scrollviewer directly](ht... |
212,006 | <p>I have a c++ header file containing a class.
I want to use this class in several projects, bu I don't want to create a separate library for it, so I'm putting both methods declarations and definitions in the header file: </p>
<pre><code>// example.h
#ifndef EXAMPLE_H_
#define EXAMPLE_H_
namespace test_ns{
class ... | [
{
"answer_id": 212019,
"author": "QBziZ",
"author_id": 11572,
"author_profile": "https://Stackoverflow.com/users/11572",
"pm_score": 5,
"selected": false,
"text": "<p>Inside the class body is considered to be inline by the compiler.\nIf you implement outside of body, but still in header,... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15622/"
] | I have a c++ header file containing a class.
I want to use this class in several projects, bu I don't want to create a separate library for it, so I'm putting both methods declarations and definitions in the header file:
```
// example.h
#ifndef EXAMPLE_H_
#define EXAMPLE_H_
namespace test_ns{
class TestClass{
publi... | These are not equivalent. The second example given has an implicit 'inline' modifier on the method and so the compiler will reconcile multiple definitions itself (most likely with internal linkage of the method if it isn't inlineable).
The first example isn't inline and so if this header is included in multiple transl... |
212,028 | <p>I have a C# method which accepts a Predicate<Foo> and returns a list of matching items...</p>
<pre><code>public static List<Foo> FindAll( Predicate<Foo> filter )
{
...
}
</code></pre>
<p>The filter will often be one of a common set...</p>
<pre><code>public static class FooPredicates
{
pu... | [
{
"answer_id": 212090,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p>Delegate equality looks at each invocation in the invocation list, testing for equality of method to be invoked, and ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25028/"
] | I have a C# method which accepts a Predicate<Foo> and returns a list of matching items...
```
public static List<Foo> FindAll( Predicate<Foo> filter )
{
...
}
```
The filter will often be one of a common set...
```
public static class FooPredicates
{
public static readonly Predicate<Foo> IsEligible = ( foo ... | To perform your caching task, you can follow the other suggestions and create a Dictionary<Predicate<Foo>,List<Foo>> (static for global, or member field otherwise) that caches the results. Before actually executing the Predicate<Foo>, you would need to check if the result already exists in the dictionary.
The general ... |
212,031 | <p>I would like to break a long line of text assigned to the standard Label widget in GWT.
I was experimenting with inline <code><br /></code> elements but with no success.</p>
<p>Something like this: </p>
<pre><code>label = "My very very very long<br />long long text"
</code></pre>
| [
{
"answer_id": 212571,
"author": "jgindin",
"author_id": 17941,
"author_profile": "https://Stackoverflow.com/users/17941",
"pm_score": 5,
"selected": true,
"text": "<p>You need to use the HTML widget, which extends the standard Label widget, and adds support for interpreting HTML tags.</... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6482/"
] | I would like to break a long line of text assigned to the standard Label widget in GWT.
I was experimenting with inline `<br />` elements but with no success.
Something like this:
```
label = "My very very very long<br />long long text"
``` | You need to use the HTML widget, which extends the standard Label widget, and adds support for interpreting HTML tags.
See the [JavaDoc](http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/ui/HTML.html). |
212,048 | <p>I'm using the ListView control (ASP.NET 2008) to show a bunch of lines of data, and at the bottom I want some totals. I was initially going to define the header and footer in the LayoutTemplate and get the totals with some local function, i.e. <%#GetTheSum()%>, but it appears that the LayoutTemplate does not proc... | [
{
"answer_id": 212126,
"author": "craigmoliver",
"author_id": 12252,
"author_profile": "https://Stackoverflow.com/users/12252",
"pm_score": 1,
"selected": false,
"text": "<p>Use a literal and set the variable in the code-behind.</p>\n\n<pre><code><asp:Literal ID=\"litTotal\" runat=\"s... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23935/"
] | I'm using the ListView control (ASP.NET 2008) to show a bunch of lines of data, and at the bottom I want some totals. I was initially going to define the header and footer in the LayoutTemplate and get the totals with some local function, i.e. <%#GetTheSum()%>, but it appears that the LayoutTemplate does not process th... | It turns out that FindControl does work:
```
CType(MyListView.FindControl("litTotal"), Literal).Text = GetTheSum()
```
I'd still like to know if there might be a better way though. |
212,050 | <p>In a spring configuration, what is the difference between using name vs id? I'm aware that XML restricts the "id" attribute to be unique in a document and limits the characters for using in the id. But otherwise when declaring a bean, what is the difference between using the "name" attribute vs the "id" attribut... | [
{
"answer_id": 212126,
"author": "craigmoliver",
"author_id": 12252,
"author_profile": "https://Stackoverflow.com/users/12252",
"pm_score": 1,
"selected": false,
"text": "<p>Use a literal and set the variable in the code-behind.</p>\n\n<pre><code><asp:Literal ID=\"litTotal\" runat=\"s... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6580/"
] | In a spring configuration, what is the difference between using name vs id? I'm aware that XML restricts the "id" attribute to be unique in a document and limits the characters for using in the id. But otherwise when declaring a bean, what is the difference between using the "name" attribute vs the "id" attribute? | It turns out that FindControl does work:
```
CType(MyListView.FindControl("litTotal"), Literal).Text = GetTheSum()
```
I'd still like to know if there might be a better way though. |
212,089 | <p>This is the way I read file:</p>
<pre><code> public static string readFile(string path)
{
StringBuilder stringFromFile = new StringBuilder();
StreamReader SR;
string S;
SR = File.OpenText(path);
S = SR.ReadLine();
while (S != null)
{
stringF... | [
{
"answer_id": 212094,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>Leaving aside the horrible variable names and the lack of a using statement (you won't close the file if there are any... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] | This is the way I read file:
```
public static string readFile(string path)
{
StringBuilder stringFromFile = new StringBuilder();
StreamReader SR;
string S;
SR = File.OpenText(path);
S = SR.ReadLine();
while (S != null)
{
stringFromFile.Append... | Leaving aside the horrible variable names and the lack of a using statement (you won't close the file if there are any exceptions) that should be okay, and *certainly* shouldn't take 5 minutes to read 2.5 megs.
Where does the file live? Is it on a flaky network share?
By the way, the only difference between what you'... |
212,115 | <p>What is the best method for displaying major/minor versions in a C# console application?</p>
<p>The <code>System.Windows.Forms</code> namespace includes a <code>ProductVersion</code> class that can be used to display the name/version information set via the Visual Studio project properties (Assembly Information). A... | [
{
"answer_id": 212135,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 7,
"selected": true,
"text": "<pre><code>Assembly.GetExecutingAssembly().GetName().Version\n</code></pre>\n\n<p>Also, you can still use the class, you just h... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/644/"
] | What is the best method for displaying major/minor versions in a C# console application?
The `System.Windows.Forms` namespace includes a `ProductVersion` class that can be used to display the name/version information set via the Visual Studio project properties (Assembly Information). As such, here is my current mecha... | ```
Assembly.GetExecutingAssembly().GetName().Version
```
Also, you can still use the class, you just have to reference the containing assembly. It's no biggie. |
212,124 | <p>Some friends and colleagues of mine have a little running contest to find or write the longest class/variable/property/method names possible. Keep in mind, we try to be good boys and girls and keep the naming intelligible and concise, while still explaining what the thing does via its name.</p>
<p>Sometimes it jus... | [
{
"answer_id": 212132,
"author": "TheSmurf",
"author_id": 1975282,
"author_profile": "https://Stackoverflow.com/users/1975282",
"pm_score": 1,
"selected": false,
"text": "<p>Check out Apple's documentation. They're kings at that. Very descriptive, but sometimes miles long. A couple of ex... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8360/"
] | Some friends and colleagues of mine have a little running contest to find or write the longest class/variable/property/method names possible. Keep in mind, we try to be good boys and girls and keep the naming intelligible and concise, while still explaining what the thing does via its name.
Sometimes it just doesn't h... | This isn't a class name but an enum, but it's a lot longer:
```
VirtualMachineDeviceRuntimeInfoVirtualEthernetCardRuntimeStateVmDirectPathGen2InactiveReasonOther
```
from the VMware vSphere API. Google for it and you'll find the online documentation. |
212,125 | <p>Let's say I have a model like this</p>
<pre><code>class Foo(db.Model):
id = db.StringProperty()
bar = db.StringProperty()
baz = db.StringProperty()
</code></pre>
<p>And I'm going a GqlQuery like this</p>
<pre><code>foos = db.GqlQuery("SELECT * FROM Foo")
</code></pre>
<p><strong>I want to take the re... | [
{
"answer_id": 212351,
"author": "Alex Coventry",
"author_id": 1941213,
"author_profile": "https://Stackoverflow.com/users/1941213",
"pm_score": 1,
"selected": false,
"text": "<p>I can't do too much better than that, but here are a couple of ideas:</p>\n\n<pre><code>class Foo:\n id = ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] | Let's say I have a model like this
```
class Foo(db.Model):
id = db.StringProperty()
bar = db.StringProperty()
baz = db.StringProperty()
```
And I'm going a GqlQuery like this
```
foos = db.GqlQuery("SELECT * FROM Foo")
```
**I want to take the results of the GqlQuery and turn into some sort of JSON s... | Take a look at [google.appengine.api.datastore](http://code.google.com/p/googleappengine/source/browse/trunk/google/appengine/api/datastore.py). It's the lower level datastore API that google.appengine.ext.db builds on, and it returns Entity objects, which subclass dict. You can query it using GQL with [google.appengin... |
212,155 | <p>I'm encountering a strange memory read/write error while calling a compiled DLL from C#. I use DllImport to get a handle to the function we need, which writes a return value to a parametric pointer to an int (i.e., int* out). This function is called multiple times within a thread, and runs successfully over the exec... | [
{
"answer_id": 212200,
"author": "GregUzelac",
"author_id": 27068,
"author_profile": "https://Stackoverflow.com/users/27068",
"pm_score": 0,
"selected": false,
"text": "<p>It may be the [DllImport]. If you post the [DllImport] signature, and the DLL's ptototype, maybe we can spot a probl... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm encountering a strange memory read/write error while calling a compiled DLL from C#. I use DllImport to get a handle to the function we need, which writes a return value to a parametric pointer to an int (i.e., int\* out). This function is called multiple times within a thread, and runs successfully over the execut... | Given that the problem only occurs when multiple threads are involved, it may be that the command interpreter DLL is using some sort of thread-local storage and doing it incorrectly. It could also have to do with the COM initialization state of the second thread (the one that generates the error).
It would be interest... |
212,198 | <p>What is the purpose of the <code>Using</code> block in C#? How is it different from a local variable?</p>
| [
{
"answer_id": 212204,
"author": "Sam",
"author_id": 7021,
"author_profile": "https://Stackoverflow.com/users/7021",
"pm_score": 7,
"selected": false,
"text": "<p><code>Using</code> calls <code>Dispose()</code> after the <code>using</code>-block is left, even if the code throws an except... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17715/"
] | What is the purpose of the `Using` block in C#? How is it different from a local variable? | If the type implements IDisposable, it automatically disposes that type.
Given:
```
public class SomeDisposableType : IDisposable
{
...implmentation details...
}
```
These are equivalent:
```
SomeDisposableType t = new SomeDisposableType();
try {
OperateOnType(t);
}
finally {
if (t != null) {
((... |
212,201 | <p>A little benchmark with ASP.NET MVC. Viewpage code:</p>
<pre><code> public string Bechmark(Func<string> url)
{
var s = new Stopwatch();
var n = 1000;
s.Reset();
s.Start();
for (int i = 0; i < n; i++)
{
var u = url();
}
s.Sto... | [
{
"answer_id": 212243,
"author": "Ben Scheirman",
"author_id": 3381,
"author_profile": "https://Stackoverflow.com/users/3381",
"pm_score": 1,
"selected": false,
"text": "<p>Caching links would probably be a good suggestion for the team, as they won't change for the life of the process (f... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28917/"
] | A little benchmark with ASP.NET MVC. Viewpage code:
```
public string Bechmark(Func<string> url)
{
var s = new Stopwatch();
var n = 1000;
s.Reset();
s.Start();
for (int i = 0; i < n; i++)
{
var u = url();
}
s.Stop();
return s.... | I asked this question on the MS forums, which got an answer from an MS MVC developer.
[The post](http://forums.asp.net/t/1335585.aspx)
**The answer**
>
> From MVC Preview 2 to the recently released MVC Beta from yesterday there have been a lot of changes to Routing. Some of those changes include performance improve... |
212,215 | <p>I'm trying to display a loading icon while my iPhone app downloads a network resource, but I can't figure out how to make it show up correctly.</p>
<p>I searched around and found some details on the <code>UIActivityView</code> class, but the available example source code didn't work, and the documentation is kind o... | [
{
"answer_id": 212564,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 5,
"selected": true,
"text": "<p>Assuming you've got a view controller set up, and would like to add a <code>UIActivityIndicator</code> to it, here's ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to display a loading icon while my iPhone app downloads a network resource, but I can't figure out how to make it show up correctly.
I searched around and found some details on the `UIActivityView` class, but the available example source code didn't work, and the documentation is kind of terse.
Could someo... | Assuming you've got a view controller set up, and would like to add a `UIActivityIndicator` to it, here's how you could do it:
(assume you've got a member variable called `indicator`, which you can use later to clean up)
**For your interface (.h file):**
```
UIActivityIndicator *indicator;
```
**For your implement... |
212,228 | <p>I have read the GOLD Homepage ( <a href="http://www.devincook.com/goldparser/" rel="nofollow noreferrer">http://www.devincook.com/goldparser/</a> ) docs, FAQ and Wikipedia to find out what practical application there could possibly be for GOLD. I was thinking along the lines of having a programming language (easily)... | [
{
"answer_id": 212251,
"author": "Paul Nathan",
"author_id": 26227,
"author_profile": "https://Stackoverflow.com/users/26227",
"pm_score": 1,
"selected": false,
"text": "<p>GOLD can be used for any kind of application where you have to apply context-free grammars to input.</p>\n\n<p>elab... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3535708/"
] | I have read the GOLD Homepage ( <http://www.devincook.com/goldparser/> ) docs, FAQ and Wikipedia to find out what practical application there could possibly be for GOLD. I was thinking along the lines of having a programming language (easily) available to my systems such as ABAP on SAP or X++ on Axapta - but it doesn't... | Parsing really consists of two phases. The first is "lexing", which convert the raw strings of character in to something that the program can more readily understand (commonly called tokens).
Simple example, lex would convert:
if (a + b > 2) then
In to:
```
IF_TOKEN LEFT_PAREN IDENTIFIER(a) PLUS_SIGN IDENTIFIER(b... |
212,234 | <p>I am building an MS Access application in which all the forms are modal. However, after data change in a form, I want to refresh the parent form of this form with newer data. Is there any way to do it. To elaborate further :</p>
<p>Consider there are two forms, Form A and Form B. Both are modal form. From Form A, I... | [
{
"answer_id": 212303,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 3,
"selected": false,
"text": "<p>You can repaint and / or requery:</p>\n\n<p>On the close event of form B:</p>\n\n<pre><code>Forms!FormA.Requery\n</code... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6613/"
] | I am building an MS Access application in which all the forms are modal. However, after data change in a form, I want to refresh the parent form of this form with newer data. Is there any way to do it. To elaborate further :
Consider there are two forms, Form A and Form B. Both are modal form. From Form A, I initiate ... | >
> No, it is like I want to run Form\_Load
> of Form A,if it is possible
>
>
>
-- Varun Mahajan
The usual way to do this is to put the relevant code in a procedure that can be called by both forms. It is best put the code in a standard module, but you could have it on Form a:
Form B:
```
Sub RunFormALoad()
... |
212,257 | <p>It seems like this should be straightforward but I'm boggling. I've got my listview all setup and bound to my LINQ datasource. The source is dependent on a dropdown list which decides which branch information to show in the listview. My edit template works fine but my insert template won't work because it wants t... | [
{
"answer_id": 212341,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "<p>Use the OnSelectedIndexChanged (with AutoPostBack=True) callback for the DropDownList to manually set the values in ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12862/"
] | It seems like this should be straightforward but I'm boggling. I've got my listview all setup and bound to my LINQ datasource. The source is dependent on a dropdown list which decides which branch information to show in the listview. My edit template works fine but my insert template won't work because it wants the bra... | I ended up going with this, thanks twanfosson.
```
protected void ListView1_ItemInserting(object sender, System.Web.UI.WebControls.ListViewInsertEventArgs e)
{
e.Values["BranchID"] = DropDownList1.SelectedValue;
}
``` |
212,271 | <p>A person uses their cell phone multiple times per day, and the length of their calls vary. I am tracking the length of the calls in a table:</p>
<pre><code>Calls [callID, memberID, startTime, duration]
</code></pre>
<p>I need to a query to return the average call length for users <strong>per day</strong>. Per day ... | [
{
"answer_id": 212284,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 0,
"selected": false,
"text": "<pre><code>select average(duration) from calls group by date(startTime);\n</code></pre>\n"
},
{
"answer_id": 212285,
... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | A person uses their cell phone multiple times per day, and the length of their calls vary. I am tracking the length of the calls in a table:
```
Calls [callID, memberID, startTime, duration]
```
I need to a query to return the average call length for users **per day**. Per day means, if a user used the phone 3 times... | You need to convert the DATETIME to something you can make "per day" groups on, so this would produce "yy/mm/dd".
```
SELECT
memberId,
CONVERT(VARCHAR, startTime, 102) Day,
AVG(Duration) AvgDuration
FROM
Calls
WHERE
CONVERT(VARCHAR, startTime, 102) =
(
SELECT
CONVERT(VARCHAR, MAX(startTime), 10... |
212,321 | <p>Anyone know a simple way using Java calendar to subtract X days from a date?</p>
<p>I have not been able to find any function which allows me to directly subtract X days from a date in Java. Can someone point me to the right direction?</p>
| [
{
"answer_id": 212334,
"author": "Anson Smith",
"author_id": 28685,
"author_profile": "https://Stackoverflow.com/users/28685",
"pm_score": 9,
"selected": true,
"text": "<p>Taken from <a href=\"http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#add%28int,%20int%29\" rel=\"no... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26004/"
] | Anyone know a simple way using Java calendar to subtract X days from a date?
I have not been able to find any function which allows me to directly subtract X days from a date in Java. Can someone point me to the right direction? | Taken from [the docs here](http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#add%28int,%20int%29):
>
> Adds or subtracts the specified amount of time to the given calendar field, based on the calendar's rules. For example, to subtract 5 days from the current time of the calendar, you can achieve it by... |
212,350 | <p>The <code>JPA</code> (Java Persistence API) specification has 2 different ways to specify entity composite keys: <code>@IdClass</code> and <code>@EmbeddedId</code>. </p>
<p>I'm using both annotations on my mapped entities, but it turns out to be a big mess to people who aren't very familiar with <code>JPA</code>. <... | [
{
"answer_id": 212371,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 8,
"selected": true,
"text": "<p>I consider that <code>@EmbeddedId</code> is probably more verbose because with <code>@IdClass</code> you cannot acc... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28921/"
] | The `JPA` (Java Persistence API) specification has 2 different ways to specify entity composite keys: `@IdClass` and `@EmbeddedId`.
I'm using both annotations on my mapped entities, but it turns out to be a big mess to people who aren't very familiar with `JPA`.
I want to adopt only one way to specify composite key... | I consider that `@EmbeddedId` is probably more verbose because with `@IdClass` you cannot access the entire primary key object using any field access operator. Using the `@EmbeddedId` you can do like this:
```
@Embeddable class EmployeeId { name, dataOfBirth }
@Entity class Employee {
@EmbeddedId EmployeeId employee... |
212,358 | <p>Is there a library function that performs binary search on a list/tuple and return the position of the item if found and 'False' (-1, None, etc.) if not?</p>
<p>I found the functions bisect_left/right in the <a href="http://docs.python.org/library/bisect.html" rel="noreferrer">bisect module</a>, but they still retu... | [
{
"answer_id": 212413,
"author": "Moe",
"author_id": 3051,
"author_profile": "https://Stackoverflow.com/users/3051",
"pm_score": 6,
"selected": false,
"text": "<p>Why not look at the code for bisect_left/right and adapt it to suit your purpose.</p>\n\n<p>like this:</p>\n\n<pre class=\"la... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15682/"
] | Is there a library function that performs binary search on a list/tuple and return the position of the item if found and 'False' (-1, None, etc.) if not?
I found the functions bisect\_left/right in the [bisect module](http://docs.python.org/library/bisect.html), but they still return a position even if the item is not... | `bisect_left` finds the first position `p` at which an element could be inserted in a given sorted range while maintaining the sorted order. That will be the position of `x` if `x` exists in the range. If `p` is the past-the-end position, `x` wasn't found. Otherwise, we can test to see if `x` is there to see if `x` was... |
212,378 | <p>I have an embedded webserver that has a total of 2 Megs of space on it. Normally you gzip files for the clients benefit, but this would save us space on the server. I read that you can just gzip the js file and save it on the server. I tested that on IIS and I didn't have any luck at all. What exactly do I need ... | [
{
"answer_id": 212402,
"author": "Dave R",
"author_id": 6969,
"author_profile": "https://Stackoverflow.com/users/6969",
"pm_score": 1,
"selected": false,
"text": "<p>Using gzip compression on a webserver usually means compressing the output from it to conserve your bandwidth - not quite ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12448/"
] | I have an embedded webserver that has a total of 2 Megs of space on it. Normally you gzip files for the clients benefit, but this would save us space on the server. I read that you can just gzip the js file and save it on the server. I tested that on IIS and I didn't have any luck at all. What exactly do I need to do o... | As others have mentioned mod\_deflate does that for you, but I guess you need to do it manually since it is an embedded environment.
First of all you should leave the name of the file foo.js after you gzip it.
You should not change anything in your html files. Since the file is still foo.js
In the response header ... |
212,381 | <p>I am trying to create a multi dimensional array using this syntax:</p>
<pre><code>$x[1] = 'parent';
$x[1][] = 'child';
</code></pre>
<p>I get the error: <code>[] operator not supported for strings</code> because it is evaluating the <code>$x[1]</code> as a string as opposed to returning the array so I can append ... | [
{
"answer_id": 212396,
"author": "Marius",
"author_id": 1585,
"author_profile": "https://Stackoverflow.com/users/1585",
"pm_score": 3,
"selected": false,
"text": "<pre><code>$x = array();\n$x[1] = array();\n$x[1][] = 'child';\n</code></pre>\n"
},
{
"answer_id": 212399,
"autho... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to create a multi dimensional array using this syntax:
```
$x[1] = 'parent';
$x[1][] = 'child';
```
I get the error: `[] operator not supported for strings` because it is evaluating the `$x[1]` as a string as opposed to returning the array so I can append to it.
What is the correct syntax for doing it t... | The parent has to be an array!
```
$x[1] = array();
$x[1][] = 'child';
``` |
212,401 | <p>From Wikipedia, the free encyclopedia: <strong>Closure (computer science)</strong></p>
<blockquote>
<p>In computer science, a closure is a
function that is evaluated in an
environment containing one or more
bound variables. When called, the
function can access these variables.
The explicit use of closur... | [
{
"answer_id": 212417,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": false,
"text": "<p>Searching for \"javascript closures\" gave plenty of encouraging-looking links. The top three were these two (the thi... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | From Wikipedia, the free encyclopedia: **Closure (computer science)**
>
> In computer science, a closure is a
> function that is evaluated in an
> environment containing one or more
> bound variables. When called, the
> function can access these variables.
> The explicit use of closures is
> associated with fun... | (using an example from jQuery)
```
function SetClassOnHover(className){
$("td").hover(
function () {
$(this).addClass(className);
},
function () {
$(this).removeClass(className);
}
);
}
```
The closure comes into play when the variable className is used inside the scope of each functi... |
212,407 | <p>Is the singleton class in Ruby a class in and of itself? Is it the reason why all objects belong to "class?" The concept is <strong>fuzzy</strong>, but I believe it has something to do with why I can define a class method at all (<code>class foo; def foo.bar ...</code>).</p>
<p>What is the singleton class in Ruby?<... | [
{
"answer_id": 212924,
"author": "Gene T",
"author_id": 413049,
"author_profile": "https://Stackoverflow.com/users/413049",
"pm_score": 2,
"selected": false,
"text": "<p>The most pragmatic/action-oreinted way to think of it (IMHO) is: as an inheritance chain, or method lookup/resolution ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28914/"
] | Is the singleton class in Ruby a class in and of itself? Is it the reason why all objects belong to "class?" The concept is **fuzzy**, but I believe it has something to do with why I can define a class method at all (`class foo; def foo.bar ...`).
What is the singleton class in Ruby? | First, a little definition: a **singleton method** is a method that is defined only for a single object. Example:
```
irb(main):001:0> class Foo; def method1; puts 1; end; end
=> nil
irb(main):002:0> foo = Foo.new
=> #<Foo:0xb79fa724>
irb(main):003:0> def foo.method2; puts 2; end
=> nil
irb(main):004:0> foo.method1
1
... |
212,425 | <p>How can I go about making my routes recognise an optional prefix parameter as follows:</p>
<pre><code>/*lang/controller/id
</code></pre>
<p>In that the lang part is optional, and has a default value if it's not specified in the URL:</p>
<pre><code>/en/posts/1 => lang = en
/fr/posts/1 => lang = fr
/posts... | [
{
"answer_id": 212895,
"author": "Mike Woodhouse",
"author_id": 1060,
"author_profile": "https://Stackoverflow.com/users/1060",
"pm_score": 1,
"selected": false,
"text": "<p>I'm guessing (no time to test right now) that this might work:</p>\n\n<pre><code>map.connect ':language/posts/:id'... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12037/"
] | How can I go about making my routes recognise an optional prefix parameter as follows:
```
/*lang/controller/id
```
In that the lang part is optional, and has a default value if it's not specified in the URL:
```
/en/posts/1 => lang = en
/fr/posts/1 => lang = fr
/posts/1 => lang = en
```
*EDIT*
Ideally,... | OK, I've managed to sort out this problem:
THere is no way of doing this in Rails by default (at least, not yet). Instead of using namespaces and default values, I needed to install [Sven Fuchs' routing filter](http://github.com/svenfuchs/routing-filter/tree/master).
Once the plugin is installed, I added the followin... |
212,429 | <p>Scenario:</p>
<p>I'm currently writing a layer to abstract 3 similar webservices into one useable class. Each webservice exposes a set of objects that share commonality. I have created a set of intermediary objects which exploit the commonality. However in my layer I need to convert between the web service objects ... | [
{
"answer_id": 212437,
"author": "Tom Ritter",
"author_id": 8435,
"author_profile": "https://Stackoverflow.com/users/8435",
"pm_score": 2,
"selected": false,
"text": "<p>You can't convert an array like that - it's returning an array of objects, which is different from an object. Try <a ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4950/"
] | Scenario:
I'm currently writing a layer to abstract 3 similar webservices into one useable class. Each webservice exposes a set of objects that share commonality. I have created a set of intermediary objects which exploit the commonality. However in my layer I need to convert between the web service objects and my obj... | Alternative answer: generics.
```
public static T[] CreateProperties<T>(IProperty[] properties)
where T : class, new()
{
//Empty so return null
if (properties==null || properties.Length == 0)
return null;
//Check the type is allowed
CheckPropertyTypes("CreateProperties(Type,IProperty[])",t... |
212,434 | <p>As the title states, is there a way to prevent extra elements from showing up in VBA dynamic arrays when they are non-zero based? </p>
<p>For example, when using code similar to the following:</p>
<pre><code>While Cells(ndx, 1).Value <> vbNullString
ReDim Preserve data(1 To (UBound(data) + 1))
ndx = ... | [
{
"answer_id": 212497,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 1,
"selected": false,
"text": "<p>Visual Basic arrays are zero-based. This can be changed with the <code>Option Base</code> statement, though. </p>\n\n<p... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1185/"
] | As the title states, is there a way to prevent extra elements from showing up in VBA dynamic arrays when they are non-zero based?
For example, when using code similar to the following:
```
While Cells(ndx, 1).Value <> vbNullString
ReDim Preserve data(1 To (UBound(data) + 1))
ndx = ndx + 1
Wend
```
You have... | So this has turned out to be an annoying little problem as it looks like there really isn't a way to prevent the issue from coming up. Based upon the answers provided by the other users, I tired the following approaches to solving the problem.
**[Using a Collection](https://stackoverflow.com/questions/212434/is-there-... |
212,442 | <p>I want to do something very simple in C++ but i can't find how.
I want to create a function like a for loop where i will ideally enter a variable for the times the iteration should happen and some functions inside brackets my function will execute. I hope i was clear enough. Thanks...</p>
<p>Example</p>
<pre><code... | [
{
"answer_id": 212460,
"author": "FOR",
"author_id": 27826,
"author_profile": "https://Stackoverflow.com/users/27826",
"pm_score": 0,
"selected": false,
"text": "<pre><code>void DoSomethingRepeatedly(int numTimesTo Loop)\n{\n for(int i=0; i<numTimesToLoop; i++)\n { \n //do w... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28954/"
] | I want to do something very simple in C++ but i can't find how.
I want to create a function like a for loop where i will ideally enter a variable for the times the iteration should happen and some functions inside brackets my function will execute. I hope i was clear enough. Thanks...
Example
```
superFor (1)
{
//c... | What you want isn't possible in C++ because the (current version of the) language lacks some features that are required here: namely, creating function blocks “on the fly”.
The best you can do is pass a function pointer or function object to your function. The STL offers many examples of this. Consider:
```
void out(... |
212,481 | <p>I have a header file like this:</p>
<pre><code>#ifndef __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__
#define __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__
#ifdef _DEBUG
// macros for turning a number into a string
#define STRING2(x) #x
#define STRING(x) STRING2(x)
#ifdef TRIAGE_MESG_AS_WARNING
#defin... | [
{
"answer_id": 212686,
"author": "scootdawg",
"author_id": 25512,
"author_profile": "https://Stackoverflow.com/users/25512",
"pm_score": 0,
"selected": false,
"text": "<p>I may not be understanding your question correctly but I'll give it a shot anyway.</p>\n\n<p>Have you looked at the T... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28950/"
] | I have a header file like this:
```
#ifndef __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__
#define __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__
#ifdef _DEBUG
// macros for turning a number into a string
#define STRING2(x) #x
#define STRING(x) STRING2(x)
#ifdef TRIAGE_MESG_AS_WARNING
#define TRIAGE_TODO_... | I believe they just ***forgot*** about adding additional category: info.
At least it is not specified in output format for external tools.
Citation: "Category must be either '*error*' or '*warning*'. Case does not matter. Like origin, category must not be localized."
Link: <http://blogs.msdn.com/msbuild/archive/2006/... |
212,510 | <p>Currently I'm writing it in clear text <em>oops!</em>, it's an in house program so it's not that bad but I'd like to do it right. How should I go about encrypting this when writing to the registry and how do I decrypt it?</p>
<pre><code>OurKey.SetValue("Password", textBoxPassword.Text);
</code></pre>
| [
{
"answer_id": 212524,
"author": "Bogdan Maxim",
"author_id": 23795,
"author_profile": "https://Stackoverflow.com/users/23795",
"pm_score": 3,
"selected": false,
"text": "<p>One option would be to store the hash (SHA1, MD5) of the password instead of the clear-text password, and whenever... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Currently I'm writing it in clear text *oops!*, it's an in house program so it's not that bad but I'd like to do it right. How should I go about encrypting this when writing to the registry and how do I decrypt it?
```
OurKey.SetValue("Password", textBoxPassword.Text);
``` | You don't decrypt authentication passwords!
===========================================
Hash them using something like the SHA256 provider and when you have to challenge, hash the input from the user and see if the two hashes match.
```
byte[] data = System.Text.Encoding.ASCII.GetBytes(inputString);
data = new System... |
212,528 | <p>This Question is almost the same as the previously asked <a href="https://stackoverflow.com/questions/122208/get-the-ip-address-of-local-computer">How can I get the IP Address of a local computer?</a> -Question. However I need to find the IP address(es) of a <strong>Linux Machine</strong>.</p>
<p>So: How do I - prog... | [
{
"answer_id": 212688,
"author": "Steve Baker",
"author_id": 13566,
"author_profile": "https://Stackoverflow.com/users/13566",
"pm_score": 5,
"selected": false,
"text": "<ol>\n<li>Create a socket.</li>\n<li>Perform <code>ioctl(<socketfd>, SIOCGIFCONF, (struct ifconf)&buffer);</... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/999/"
] | This Question is almost the same as the previously asked [How can I get the IP Address of a local computer?](https://stackoverflow.com/questions/122208/get-the-ip-address-of-local-computer) -Question. However I need to find the IP address(es) of a **Linux Machine**.
So: How do I - programmatically in **C++** - detect ... | I found the ioctl solution problematic on os x (which is POSIX compliant so should be similiar to linux). However getifaddress() will let you do the same thing easily, it works fine for me on os x 10.5 and should be the same below.
I've done a quick example below which will print all of the machine's IPv4 address, (yo... |
212,562 | <p>Is there a good way to have a <code>Map<String, ?></code> get and put ignoring case?</p>
| [
{
"answer_id": 212583,
"author": "John M",
"author_id": 20734,
"author_profile": "https://Stackoverflow.com/users/20734",
"pm_score": 4,
"selected": false,
"text": "<p>You need a wrapper class for your String key with a case-insensitive equals() and hashCode() implementation. Use that i... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6013/"
] | Is there a good way to have a `Map<String, ?>` get and put ignoring case? | TreeMap extends Map and supports custom comparators.
String provides a default case insensitive comparator.
So:
```
final Map<String, ...> map = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
```
The comparator does not take locale into account. Read more about it in its JavaDoc. |
212,569 | <p>I'm using Spring's support for JDBC. I'd like to use <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/JdbcTemplate.html" rel="noreferrer">JdbcTemplate</a> (or SimpleJdbcTemplate) to execute a query and obtain the result as an instance of ResultSet.</p>
<p>The only way t... | [
{
"answer_id": 212632,
"author": "Miguel Ping",
"author_id": 22992,
"author_profile": "https://Stackoverflow.com/users/22992",
"pm_score": 3,
"selected": true,
"text": "<p>If you want to just perform a query and get the results, why don't you use plain jdbc and grab the resultset? Notice... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I'm using Spring's support for JDBC. I'd like to use [JdbcTemplate](http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/JdbcTemplate.html) (or SimpleJdbcTemplate) to execute a query and obtain the result as an instance of ResultSet.
The only way that I can see of achieving this is usi... | If you want to just perform a query and get the results, why don't you use plain jdbc and grab the resultset? Notice that you don't need spring to do just this.
```
Connection c = ...
c.prepareCall("select ...").getResultSet();
```
Besides, you get an advantage by using an object as a DTO. You don't need to ... |
212,603 | <p>I'm trying to write some SQL that will delete files of type '.7z' that are older than 7 days.</p>
<p>Here's what I've got that's not working:</p>
<pre><code>DECLARE @DateString CHAR(8)
SET @DateString = CONVERT(CHAR(8), DATEADD(d, -7, GETDATE()), 1)
EXECUTE master.dbo.xp_delete_file 0,
N'e:\Databa... | [
{
"answer_id": 212757,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 0,
"selected": false,
"text": "<p>Try changing the first parameter from 0 to 1.</p>\n\n<p>Here is a small <a href=\"http://nikeshikari.blogspot.com/2008/... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6624/"
] | I'm trying to write some SQL that will delete files of type '.7z' that are older than 7 days.
Here's what I've got that's not working:
```
DECLARE @DateString CHAR(8)
SET @DateString = CONVERT(CHAR(8), DATEADD(d, -7, GETDATE()), 1)
EXECUTE master.dbo.xp_delete_file 0,
N'e:\Database Backups',N'7z', ... | Had a similar problem, found various answers. Here's what I found.
You can't delete 7z files with xp\_delete\_file. This is an undocumented extended stored procedure that's a holdover from SQL 2000. It checks the first line of the file to be deleted to verify that it is either a SQL backup file or a SQL report file. I... |
212,604 | <p>I have a function that is effectively a replacement for print, and I want to call it without parentheses, just like calling print.</p>
<pre><code># Replace
print $foo, $bar, "\n";
# with
myprint $foo, $bar, "\n";
</code></pre>
<p>In Perl, you can create subroutines with parameter templates and it allows exactly t... | [
{
"answer_id": 212616,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": false,
"text": "<p>No, you can't do that in PHP.\nPrint isn't actually a function, it's a \"language construct\".</p>\n"
},
{
"answer... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8454/"
] | I have a function that is effectively a replacement for print, and I want to call it without parentheses, just like calling print.
```
# Replace
print $foo, $bar, "\n";
# with
myprint $foo, $bar, "\n";
```
In Perl, you can create subroutines with parameter templates and it allows exactly this behavior if you define... | print is not a [variable functions](http://ca.php.net/manual/en/functions.variable-functions.php)
>
> Because this is a language construct
> and not a function, it cannot be
> called using variable functions
>
>
>
And :
>
> Variable functions
>
>
> PHP supports the concept of variable
> functions. This mea... |
212,614 | <p>Should a method that implements an interface method be annotated with <code>@Override</code>?</p>
<p>The <a href="http://java.sun.com/javase/6/docs/api/java/lang/Override.html" rel="noreferrer">javadoc of the <code>Override</code> annotation</a> says: </p>
<blockquote>
<p>Indicates that a method declaration is i... | [
{
"answer_id": 212624,
"author": "jjnguy",
"author_id": 2598,
"author_profile": "https://Stackoverflow.com/users/2598",
"pm_score": 9,
"selected": true,
"text": "<p>You should use @Override whenever possible. It prevents simple mistakes from being made. Example:</p>\n\n<pre><code>class... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3565/"
] | Should a method that implements an interface method be annotated with `@Override`?
The [javadoc of the `Override` annotation](http://java.sun.com/javase/6/docs/api/java/lang/Override.html) says:
>
> Indicates that a method declaration is intended to override a method declaration in a superclass. If a method is anno... | You should use @Override whenever possible. It prevents simple mistakes from being made. Example:
```
class C {
@Override
public boolean equals(SomeClass obj){
// code ...
}
}
```
This doesn't compile because it doesn't properly override [`public boolean equals(Object obj)`](http://docs.oracle.co... |
212,657 | <p>Within a stored procedure, another stored procedure is being called within a cursor. For every call, the SQL Management Studio results window is showing a result. The cursor loops over 100 times and at that point the results window gives up with an error. Is there a way I can stop the stored procedure within the cur... | [
{
"answer_id": 212670,
"author": "Adam",
"author_id": 13320,
"author_profile": "https://Stackoverflow.com/users/13320",
"pm_score": 0,
"selected": false,
"text": "<p>Place:</p>\n\n<pre><code>SET ROWCOUNT OFF\n/* the internal SP */\nSET ROWCOUNT ON\n</code></pre>\n\n<p>wrap that around th... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6651/"
] | Within a stored procedure, another stored procedure is being called within a cursor. For every call, the SQL Management Studio results window is showing a result. The cursor loops over 100 times and at that point the results window gives up with an error. Is there a way I can stop the stored procedure within the cursor... | you could insert the results into a temp table, then drop the temp table
```
create table #tmp (columns)
while
...
insert into #tmp exec @RC=dbo.NoisyProc
...
end
drop table #tmp
```
otherwise, can you modify the proc being called to accept a flag telling it not to output a result-set? |
212,681 | <p>I have a SQL Server 2000 database with around a couple of hundred tables. There are several SQL user accounts that can access this database but each one has different permissions granted on tables in the DB. </p>
<p>How do I create a script to give me a report of the permissions granted to a particular user. i.e. t... | [
{
"answer_id": 212680,
"author": "Robert P",
"author_id": 18097,
"author_profile": "https://Stackoverflow.com/users/18097",
"pm_score": 3,
"selected": false,
"text": "<p>Wow, no.</p>\n\n<p>Modern C++ compilers are excellent. Massive memory usage is more of a symptom of a poor design or ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/419/"
] | I have a SQL Server 2000 database with around a couple of hundred tables. There are several SQL user accounts that can access this database but each one has different permissions granted on tables in the DB.
How do I create a script to give me a report of the permissions granted to a particular user. i.e. to generate... | I haven't read the book, but I have trouble believe that they wrote a book whose "basis ...is that Object Oriented Programming is highly wasteful memory-wise" (Full disclosure: Andy & Barbara are friends of mine).
Andy would never say the OOP is wasteful of memory. He WOULD say that a particular algorithm or techniqu... |
212,689 | <p>I have implemented a pretty simple picture viewer that will allow the user to browse through a collection of images. They are loaded from the Internet, and displayed on the device through a <code>UIImageView</code> object. Something like this:</p>
<pre><code>UIImage *image = [[UIImage alloc] initWithData:imageData]... | [
{
"answer_id": 213327,
"author": "Chris Lundie",
"author_id": 20685,
"author_profile": "https://Stackoverflow.com/users/20685",
"pm_score": 2,
"selected": false,
"text": "<p>The trick is you make two UIImageView instances. You swap them in between calls to UIView +beginAnimations and +co... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have implemented a pretty simple picture viewer that will allow the user to browse through a collection of images. They are loaded from the Internet, and displayed on the device through a `UIImageView` object. Something like this:
```
UIImage *image = [[UIImage alloc] initWithData:imageData];
[img setImage:image];
... | I was just going through your post and had exactly the same requirement. The problem with all above solutions is, you will have to incorporate the logic of transition into your controller. In the sense the approach is not modular. Instead I wrote this subclass of UIImageView:
**TransitionImageView.h file:**
```
#impo... |
212,697 | <p>Every class that wants to use java.util.logging generally needs to declare a logger like this:</p>
<pre><code>public class MyClass {
private static Logger _log = Logger.getLogger(MyClass.class.getName());
}
</code></pre>
<p>How do you avoid this MyClass.class.getName() boilerplate code?</p>
| [
{
"answer_id": 212743,
"author": "sk.",
"author_id": 16399,
"author_profile": "https://Stackoverflow.com/users/16399",
"pm_score": 2,
"selected": false,
"text": "<p>You don't need getName() if you're using a 1.2+ version of log4j, getLogger() accepts a Class argument. But as for the rest... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28604/"
] | Every class that wants to use java.util.logging generally needs to declare a logger like this:
```
public class MyClass {
private static Logger _log = Logger.getLogger(MyClass.class.getName());
}
```
How do you avoid this MyClass.class.getName() boilerplate code? | I have a template set up in Eclipse so that I only have to type a portion of the declaration, and then Eclipse will auto-complete the rest for me.
```
${:import(org.apache.log4j.Logger)}
private final static Logger log = Logger.getLogger(${enclosing_type}.class);
${cursor}
```
So, I only have to type `logger`, hit `... |
212,705 | <p>I have a <code><div></code> that I want to be on a line by itself. According to <a href="http://www.w3schools.com/Css/pr_class_clear.asp" rel="nofollow noreferrer">W3Schools</a>, this rule:</p>
<pre><code>div.foo {
clear: both;
}
</code></pre>
<p>...should mean this:</p>
<blockquote>
<p>"No floating ele... | [
{
"answer_id": 212716,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 5,
"selected": true,
"text": "<p>When you apply clear to an element, it will move THAT element so that it doesn't have items left or right of it.... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4376/"
] | I have a `<div>` that I want to be on a line by itself. According to [W3Schools](http://www.w3schools.com/Css/pr_class_clear.asp), this rule:
```
div.foo {
clear: both;
}
```
...should mean this:
>
> "No floating elements allowed on either the left or the right side."
>
>
>
However, if I float two `<div>` el... | When you apply clear to an element, it will move THAT element so that it doesn't have items left or right of it. It does not re-position any of the other elements, it simply moves the element to a position where nothing is around it.
**Edit**
Items above the item cleared are not moved, items below the element COULD b... |
212,706 | <p>What is the best way to reset a PIC18 using C code with the HiTech Pic18 C compiler?</p>
<p>Edit:</p>
<p>I am currenlty using</p>
<pre><code>void reset()
{
#asm
reset
#endasm
}
</code></pre>
<p>but there must be a better way</p>
| [
{
"answer_id": 212826,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 0,
"selected": false,
"text": "<p>Unless there's a library function defined by the compiler vendor's runtime library (if such a lib even exists in the mic... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17560/"
] | What is the best way to reset a PIC18 using C code with the HiTech Pic18 C compiler?
Edit:
I am currenlty using
```
void reset()
{
#asm
reset
#endasm
}
```
but there must be a better way | There's a [FAQ here](http://www.microchipc.com/HiTechCFAQ/index.php#_Toc475127553).
Q: How do I reset the micro?
>
> One way is to reset all variables to
> their defaults, as listed in the PIC
> manual. Then, use assembly language
> to jump to location 0x0000 in the
> micro.
>
>
> #asm ljmp 0x0000
>
>
> #en... |