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 |
|---|---|---|---|---|---|---|
307,774 | <p>How can I list the contents of a zipped folder in C#? For example how to know how many items are contained within a zipped folder, and what is their name?</p>
| [
{
"answer_id": 307778,
"author": "Chris Ballance",
"author_id": 1551,
"author_profile": "https://Stackoverflow.com/users/1551",
"pm_score": 4,
"selected": false,
"text": "<p>Check into <a href=\"http://icsharpcode.net/OpenSource/SharpZipLib\" rel=\"nofollow noreferrer\">SharpZipLib</a> <... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20837/"
] | How can I list the contents of a zipped folder in C#? For example how to know how many items are contained within a zipped folder, and what is their name? | [DotNetZip](http://www.codeplex.com/DotNetZip) - Zip file manipulation in .NET languages
DotNetZip is a small, easy-to-use class library for manipulating .zip files. It can enable .NET applications written in VB.NET, C#, any .NET language, to easily create, read, and update zip files.
sample code to read a zip:
```
... |
307,777 | <p>This is a really basic question but...</p>
<p>I have some code like this</p>
<pre><code>var arr = Array('blah.jpg','ha.jpg');
for (var i=0; i<array.length; i++)
{
$('div#blah' + i).click(function() {
$('img').attr('src', arr[i]); });
}
</code></pre>
<p>This should bind the div with <code>id="bla... | [
{
"answer_id": 307786,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 0,
"selected": false,
"text": "<p>Have 1 more variable inside the loop and increment it after using it in the closure.</p>\n\n<pre>\n<code>\nvar j = ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | This is a really basic question but...
I have some code like this
```
var arr = Array('blah.jpg','ha.jpg');
for (var i=0; i<array.length; i++)
{
$('div#blah' + i).click(function() {
$('img').attr('src', arr[i]); });
}
```
This should bind the div with `id="blah0"` to change all images to `'blah.jpg'`... | Declare a new variable inside a function that creates a new click handler that gets the current value of i as a parameter:
```
function makeClickHandler(arr, local_i) {
return function() {
$('img').attr('src', arr[local_i]);
};
}
var arr = Array('blah.jpg','ha.jpg');
for (var i=0; i<array.length; i++)... |
307,783 | <p>When using topfunky's <a href="http://nubyonrails.com/articles/automation-with-rstakeout" rel="nofollow noreferrer">RStakeout</a>, the color in the result of the <code>spec</code> command is lost. This happens even when adding the <code>--color</code> flag.</p>
| [
{
"answer_id": 307788,
"author": "Chris Lloyd",
"author_id": 42413,
"author_profile": "https://Stackoverflow.com/users/42413",
"pm_score": 2,
"selected": true,
"text": "<p>You have to set the environment variable <code>AUTOTEST</code> to true. Spec detects whether it is being run by a pr... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42413/"
] | When using topfunky's [RStakeout](http://nubyonrails.com/articles/automation-with-rstakeout), the color in the result of the `spec` command is lost. This happens even when adding the `--color` flag. | You have to set the environment variable `AUTOTEST` to true. Spec detects whether it is being run by a process and disables color if it is (to make the output easier to parse).
To set the environment variable in bash:
```
export AUTOTEST=true
```
or in fish:
```
set -x AUTOTEST true
```
(the -x exports the varia... |
307,796 | <p>Hopefully a nice simple one.</p>
<p>I've got a php3 website that I want to run on php 5.2</p>
<p>To start with I'd just like to have every reference to the current "index.php3" _within_each_file_ (recursively) changed to "index.php" and then move on to worrying about globals etc.</p>
<p>K. Go!</p>
<p>:) </p>
<p... | [
{
"answer_id": 307815,
"author": "Brian C. Lane",
"author_id": 27461,
"author_profile": "https://Stackoverflow.com/users/27461",
"pm_score": 2,
"selected": false,
"text": "<p><code>sed -i 's/php3/php/g' *</code></p>\n\n<p>Assuming you are using a unix-like operating system.</p>\n"
},
... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13007/"
] | Hopefully a nice simple one.
I've got a php3 website that I want to run on php 5.2
To start with I'd just like to have every reference to the current "index.php3" \_within\_each\_file\_ (recursively) changed to "index.php" and then move on to worrying about globals etc.
K. Go!
:)
Update: Thanks a lot! I realise t... | ```
find -type f -exec perl -pi -e 's/\bindex\.php3\b/index.php/g' {} \;
``` |
307,798 | <p>I'm working on a little web crawler that will run in the system tray and crawl a web site every hour on the hour.</p>
<p>What is the best way to get .NET to raise an event every hour or some other interval to perform some task. For example I want to run an event every 20 minutes based on the time. The event would b... | [
{
"answer_id": 307800,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 1,
"selected": false,
"text": "<p>System.Windows.Forms.Timer (or System.Timers.Timer)</p>\n\n<p>but since now you say you don't want to use Timers, ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] | I'm working on a little web crawler that will run in the system tray and crawl a web site every hour on the hour.
What is the best way to get .NET to raise an event every hour or some other interval to perform some task. For example I want to run an event every 20 minutes based on the time. The event would be raised a... | [System.Timers.Timer](http://msdn.microsoft.com/en-us/library/system.timers.timer.interval.aspx). If you want to run at specific times of the day, you will need to figure out how long it is until the next time and set that as your interval.
This is just the basic idea. Depending on how precise you need to be you can d... |
307,821 | <p>I am using my own custom authentication with IIS, and I want the server on <i>every</i> page load (no matter what type of file) to first check the Application variable to see if the user is authenticated and authorized to see the site. In global.asax this could be:</p>
<pre><code>void Application_Start(Object Sende... | [
{
"answer_id": 307822,
"author": "Alexander Bird",
"author_id": 10608,
"author_profile": "https://Stackoverflow.com/users/10608",
"pm_score": 4,
"selected": true,
"text": "<h1>HttpModules are an alternative to global.asax</h1>\n\n<p>(see also <a href=\"https://www.codeguru.com/csharp/.ne... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10608/"
] | I am using my own custom authentication with IIS, and I want the server on *every* page load (no matter what type of file) to first check the Application variable to see if the user is authenticated and authorized to see the site. In global.asax this could be:
```
void Application_Start(Object Sender, EventArgs e)
{
... | HttpModules are an alternative to global.asax
=============================================
(see also <https://www.codeguru.com/csharp/.net/net_asp/article.php/c19389/HTTP-Handlers-and-HTTP-Modules-in-ASPNET.htm>
<http://codebetter.com/blogs/karlseguin/archive/2006/06/12/146356.aspx> )
HttpModules are registered i... |
307,828 | <p>I accidentally committed an unwanted file (<code>filename.orig</code> while resolving a merge) to my repository several commits ago, without me noticing it until now. I want to completely delete the file from the repository history. </p>
<p>Is it possible to rewrite the change history such that <code>filename.orig<... | [
{
"answer_id": 308355,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 0,
"selected": false,
"text": "<p>This is what <a href=\"http://git-scm.com/docs/git-filter-branch\" rel=\"nofollow noreferrer\"><code>git filter-branch</... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27314/"
] | I accidentally committed an unwanted file (`filename.orig` while resolving a merge) to my repository several commits ago, without me noticing it until now. I want to completely delete the file from the repository history.
Is it possible to rewrite the change history such that `filename.orig` was never added to the re... | **Please don't use this recipe if your situation is not the one described in the question. This recipe is for fixing a bad merge, and replaying your good commits onto a fixed merge.**
Although `filter-branch` will do what you want, it is quite a complex command and I would probably choose to do this with `git rebase`.... |
307,830 | <p>I have a report with a lot of formulas that translate the word "TRUE" into an "X" and "FALSE" into a blank space.</p>
<p>I use these to put an "X" in a checkbox.</p>
<p>Sometimes there is text after my checkbox. To avoid slight shifts to the left and right, I print the "X" and the " " in a fixed width font. It i... | [
{
"answer_id": 307876,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 0,
"selected": false,
"text": "<p>From what I remember, you can set the Font using formula field where you can write</p>\n\n<p>if Uppercase({table.so... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/672/"
] | I have a report with a lot of formulas that translate the word "TRUE" into an "X" and "FALSE" into a blank space.
I use these to put an "X" in a checkbox.
Sometimes there is text after my checkbox. To avoid slight shifts to the left and right, I print the "X" and the " " in a fixed width font. It is very tedious to m... | No, this is not possible. The context of a formula is the property for which the formula is set only. You cannot access properties of the whole object e.g. a field. Perhaps you could think about using two images suppressed by a formula depending on the value of your field. Then you would get rid of the font problem. |
307,845 | <p>I am trying to add a <code>UIButton</code> at runtime however it is not visible. What am I doing wrong?</p>
<pre><code>- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
UIButton *btn = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
btn.frame = CGRectMake(... | [
{
"answer_id": 307883,
"author": "August",
"author_id": 30966,
"author_profile": "https://Stackoverflow.com/users/30966",
"pm_score": 4,
"selected": true,
"text": "<p>First, make sure the initWithFrame: method is being called. If your view is in a Nib, initWithCoder: is being called inst... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30099/"
] | I am trying to add a `UIButton` at runtime however it is not visible. What am I doing wrong?
```
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
UIButton *btn = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
btn.frame = CGRectMake(0, 0, 100, 25);
b... | First, make sure the initWithFrame: method is being called. If your view is in a Nib, initWithCoder: is being called instead.
Second, is the button the only subview (from your code it looks like it is, but you never know). The button could be hidden behind another subview. Call bringSubviewToFront: if you need to.
Fi... |
307,857 | <p>I would like to completely reset the scroll position of a UITableView, so that every time I open it, it is displaying the top-most items. In other words, I would like to scroll the table view to the top every time it is opened.</p>
<p>I tried using the following piece of code, but it looks like I misunderstood the ... | [
{
"answer_id": 307922,
"author": "August",
"author_id": 30966,
"author_profile": "https://Stackoverflow.com/users/30966",
"pm_score": 3,
"selected": false,
"text": "<p>The method you're using scrolls to (as the method name implies) the nearest selected row. In many cases, this won't be t... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35478/"
] | I would like to completely reset the scroll position of a UITableView, so that every time I open it, it is displaying the top-most items. In other words, I would like to scroll the table view to the top every time it is opened.
I tried using the following piece of code, but it looks like I misunderstood the documentat... | August got the UITableView-specific method. Another way to do it is:
```
[tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];
```
This method is defined in UIScrollView, the parent class to UITableView. The above example tells it to scroll to the 1x1 box at 0,0 - the top left corner, in other words. |
307,859 | <p>I'd like to skip the tests and create a (default) Makefile.</p>
| [
{
"answer_id": 307889,
"author": "Evan Teran",
"author_id": 13430,
"author_profile": "https://Stackoverflow.com/users/13430",
"pm_score": 2,
"selected": false,
"text": "<p>Of course you can write a makefile by hand. A quick googling shows LOTS of tutorials. <a href=\"http://mrbook.org/tu... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd like to skip the tests and create a (default) Makefile. | Of course you can write a makefile by hand. A quick googling shows LOTS of tutorials. [This one](http://mrbook.org/tutorials/make/) looks promising.
For the cliffs notes version, the example boils down this:
```
CC=g++
CFLAGS=-c -Wall
LDFLAGS=
SOURCES=main.cpp hello.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=hello
al... |
307,882 | <p>jQuery's <code>draggable</code> functionality doesn't seem to work on tables (in FF3 or Safari). It's kind of difficult to envision how this <em>would</em> work, so it's not really surprising that it doesn't.</p>
<pre><code><html>
<style type='text/css'>
div.table { display: table; }
div.row {... | [
{
"answer_id": 307926,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 6,
"selected": true,
"text": "<p>If you have truly tabular data, you should stick with table indeed.</p>\n\n<p>And if you want to drag rows <em>within</em> a ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] | jQuery's `draggable` functionality doesn't seem to work on tables (in FF3 or Safari). It's kind of difficult to envision how this *would* work, so it's not really surprising that it doesn't.
```
<html>
<style type='text/css'>
div.table { display: table; }
div.row { display: table-row; }
div.cell { displa... | If you have truly tabular data, you should stick with table indeed.
And if you want to drag rows *within* a table, this **[JQuery + "draggable row table" library](http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/)** works perfectly in FireFox3 |
307,891 | <p>I'm trying to put the following Google generated search box code into a Master page on a site:</p>
<pre><code><form action="http://www.google.com/cse" id="cse-search-box">
<div>
<input type="hidden" name="cx" value="partner-pub-xxxxxxxxxx:u3qsil-l6ut" />
<input type="hidden" name="ie"... | [
{
"answer_id": 307910,
"author": "Andrew ",
"author_id": 22586,
"author_profile": "https://Stackoverflow.com/users/22586",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://joyent.com/accelerator/pricing/\" rel=\"nofollow noreferrer\">Joyent</a> might be a good solution for ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | I'm trying to put the following Google generated search box code into a Master page on a site:
```
<form action="http://www.google.com/cse" id="cse-search-box">
<div>
<input type="hidden" name="cx" value="partner-pub-xxxxxxxxxx:u3qsil-l6ut" />
<input type="hidden" name="ie" value="ISO-8859-1" />
<input t... | [Joyent](http://joyent.com/accelerator/pricing/) might be a good solution for you. Honestly adding memcache to a LAMP stack is ridiculously easy and you should be able to do it with relative ease. Find a good VPS provider (linode and slicehost are so good I'll recommend them without my referral code) and you should be ... |
307,929 | <p>If I have a query such as <code>SELECT * from authors where name = @name_param</code>, is there a regex to parse out the parameter names (specifically the "name_param")?</p>
<p>Thanks</p>
| [
{
"answer_id": 307957,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 3,
"selected": false,
"text": "<p>This is tricky because params can also occur inside quoted strings.</p>\n\n<pre><code>SELECT * FROM authors WHERE n... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If I have a query such as `SELECT * from authors where name = @name_param`, is there a regex to parse out the parameter names (specifically the "name\_param")?
Thanks | This is tricky because params can also occur inside quoted strings.
```
SELECT * FROM authors WHERE name = @name_param
AND string = 'don\'t use @name_param';
```
How would the regular expression know to use the first `@name_param` but not the second?
It's a problem that can be solved, but it's not practical to d... |
307,936 | <p>I'm wondering how the concurrency in a web application actually works. Ive read several articles and to my understanding multiple instances of HttpApplication would be working at the same time. Now, I created a simple web app to test concurrency and put the following to global.asax:</p>
<pre><code>protected void Ap... | [
{
"answer_id": 307993,
"author": "msvcyc",
"author_id": 37450,
"author_profile": "https://Stackoverflow.com/users/37450",
"pm_score": 2,
"selected": false,
"text": "<p>Why don't you modify the sample to print the thread ID? That will tell you if multiple threads are serving the requests ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6846/"
] | I'm wondering how the concurrency in a web application actually works. Ive read several articles and to my understanding multiple instances of HttpApplication would be working at the same time. Now, I created a simple web app to test concurrency and put the following to global.asax:
```
protected void Application_Begi... | Each request that arrives is routed to a separate HttpApplication object. The HttpApplication object is either created from scratch or allocated from a pool. The maximum number of HttpApplication objects created is limited by the maximum number of threads available. In ASP.NET 1.x I think the default was 20 or so. Unde... |
307,939 | <p>In java, does <code>file.delete()</code> return <code>true</code> or <code>false</code> where <code>File file</code> refers to a non-existent file?</p>
<p>I realize this is kind of a basic question, and easy to very through test, but I'm getting strange results and would appreciate confirmation.</p>
| [
{
"answer_id": 307952,
"author": "Steve B.",
"author_id": 19479,
"author_profile": "https://Stackoverflow.com/users/19479",
"pm_score": 2,
"selected": false,
"text": "<p>The official javadoc:</p>\n\n<pre><code>Deletes the file or directory denoted by this abstract pathname. If this pathn... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20498/"
] | In java, does `file.delete()` return `true` or `false` where `File file` refers to a non-existent file?
I realize this is kind of a basic question, and easy to very through test, but I'm getting strange results and would appreciate confirmation. | Doesn't that result in a FileNotFoundException?
EDIT:
Indeed it does result in false:
```
import java.io.File;
public class FileDoesNotExistTest {
public static void main( String[] args ) {
final boolean result = new File( "test" ).delete();
System.out.println( "result: |" + result + "|" );
}
}
```
p... |
307,941 | <p>I've connected to a MySQL database using Perl DBI. I would like to find out which database I'm connected to.</p>
<p>I don't think I can use:</p>
<pre><code>$dbh->{Name}
</code></pre>
<p>because I call <a href="http://dev.mysql.com/doc/refman/5.0/en/use.html" rel="noreferrer"><code>USE new_database</code></a> ... | [
{
"answer_id": 307972,
"author": "ysth",
"author_id": 17389,
"author_profile": "https://Stackoverflow.com/users/17389",
"pm_score": 1,
"selected": false,
"text": "<p>You can ask mysql:</p>\n\n<pre><code>($dbname) = (each %{$dbh->selectrow_hashref(\"show tables\")}) =~ /^Tables_in_(.*)... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4704/"
] | I've connected to a MySQL database using Perl DBI. I would like to find out which database I'm connected to.
I don't think I can use:
```
$dbh->{Name}
```
because I call [`USE new_database`](http://dev.mysql.com/doc/refman/5.0/en/use.html) and `$dbh->{Name}` only reports the database that I initially connected to.
... | Try just executing the query
```
select DATABASE();
```
From what I could find, the DBH has access to the DSN that you initially connected with, but not after you made the change. (There's probably a better way to switch databases.) |
307,942 | <p>OK, so Sybase (12.5.4) will let me do the following to DROP a table if it already exists:</p>
<pre><code>IF EXISTS (
SELECT 1
FROM sysobjects
WHERE name = 'a_table'
AND type = 'U'
)
DROP TABLE a_table
GO
</code></pre>
<p>But if I try to do the same with table creation, I always get warned that the ... | [
{
"answer_id": 307958,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": -1,
"selected": false,
"text": "<pre><code>IF object_id('a_table') IS NULL\nBEGIN\n CREATE TABLE a_table (\n col1 int not null,\n co... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1030/"
] | OK, so Sybase (12.5.4) will let me do the following to DROP a table if it already exists:
```
IF EXISTS (
SELECT 1
FROM sysobjects
WHERE name = 'a_table'
AND type = 'U'
)
DROP TABLE a_table
GO
```
But if I try to do the same with table creation, I always get warned that the table already exists, beca... | The only workaround I've come up with so far is to use execute immediate:
```
IF NOT EXISTS (
SELECT 1
FROM sysobjects
WHERE name = 'a_table'
AND type = 'U'
)
EXECUTE("CREATE TABLE a_table (
col1 int not null,
col2 int null
)")
GO
```
works like a charm, feels like a dirty hack. |
307,951 | <p>I run an OpenSuse server that uploads zipped source code backups to a Microsoft FTP server every night. I have written a Bash script that does this through a cron job.</p>
<p>I want to delete backed up files that are older than a certain date. How could I do this?</p>
| [
{
"answer_id": 307958,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": -1,
"selected": false,
"text": "<pre><code>IF object_id('a_table') IS NULL\nBEGIN\n CREATE TABLE a_table (\n col1 int not null,\n co... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1264322/"
] | I run an OpenSuse server that uploads zipped source code backups to a Microsoft FTP server every night. I have written a Bash script that does this through a cron job.
I want to delete backed up files that are older than a certain date. How could I do this? | The only workaround I've come up with so far is to use execute immediate:
```
IF NOT EXISTS (
SELECT 1
FROM sysobjects
WHERE name = 'a_table'
AND type = 'U'
)
EXECUTE("CREATE TABLE a_table (
col1 int not null,
col2 int null
)")
GO
```
works like a charm, feels like a dirty hack. |
307,968 | <p>I lost my installation of Dave Gillespie's calc.el by reinstalling Cygwin. It is not included with the default Cygwin install of Emacs. Who is considered the master maintainer these days? Is version 2.02f still most current?</p>
| [
{
"answer_id": 308001,
"author": "Jouni K. Seppänen",
"author_id": 26575,
"author_profile": "https://Stackoverflow.com/users/26575",
"pm_score": 2,
"selected": false,
"text": "<p>In the Emacs CVS tree. See <a href=\"http://www.gnu.org/software/emacs/calc.html\" rel=\"nofollow noreferrer\... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39526/"
] | I lost my installation of Dave Gillespie's calc.el by reinstalling Cygwin. It is not included with the default Cygwin install of Emacs. Who is considered the master maintainer these days? Is version 2.02f still most current? | In the Emacs CVS tree. See [the calc page](http://www.gnu.org/software/emacs/calc.html) and the [Emacs project page](http://savannah.gnu.org/projects/emacs/). The root of the calc subtree is [here](http://cvs.savannah.gnu.org/viewvc/emacs/lisp/calc/?root=emacs) and you can get the latest version by typing
```
cvs -d:p... |
307,984 | <p>Is it possible to declare an instance of a generic without knowing the type at design-time?</p>
<p>Example:</p>
<pre><code>Int i = 1;
List<typeof(i)> list = new List<typeof(i)>();
</code></pre>
<p>where the type of i could be anything, instead of having to do:</p>
<pre><code>List<int> list = ne... | [
{
"answer_id": 308006,
"author": "Nathan",
"author_id": 24954,
"author_profile": "https://Stackoverflow.com/users/24954",
"pm_score": 1,
"selected": false,
"text": "<p>I think the best you are going to be able to do is something like this:</p>\n\n<pre><code>static void Main(string[] args... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4490/"
] | Is it possible to declare an instance of a generic without knowing the type at design-time?
Example:
```
Int i = 1;
List<typeof(i)> list = new List<typeof(i)>();
```
where the type of i could be anything, instead of having to do:
```
List<int> list = new List<int();
``` | If you don't know the type at compile-time, but you want the actual type (i.e. not `List<object>`) *and* you're not in a generic method/type with the appropriate type parameter, then you have to use reflection.
To make the reflection simpler, I've sometimes introduced a new generic type or method in my own code, so I ... |
308,019 | <p>I have this line of JavaScript and the behavior I am seeing is that the <code>selectedLi</code> instantly disappears without "sliding up". This is not the behavior that I expected.</p>
<p>What should I be doing so that the <code>selectedLi</code> slides up before it is removed?</p>
<pre><code>selectedLi.slideUp("... | [
{
"answer_id": 308034,
"author": "seanb",
"author_id": 3354,
"author_profile": "https://Stackoverflow.com/users/3354",
"pm_score": 9,
"selected": true,
"text": "<p>Might be able to fix it by putting the call to remove in a callback arg to slideUp? </p>\n\n<p>e.g </p>\n\n<pre><code>selec... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] | I have this line of JavaScript and the behavior I am seeing is that the `selectedLi` instantly disappears without "sliding up". This is not the behavior that I expected.
What should I be doing so that the `selectedLi` slides up before it is removed?
```
selectedLi.slideUp("normal").remove();
``` | Might be able to fix it by putting the call to remove in a callback arg to slideUp?
e.g
```
selectedLi.slideUp("normal", function() { $(this).remove(); } );
``` |
308,027 | <p>I think my eclipse's ctrl+clicking links might benefit greatly...</p>
<p><b>Edit:</b> I'm using eclipse PDT.</p>
<p><b>Edit 2:</b> I'm very happy with the solution of putting docblocks before functions (and variables) with an @return or @var statement, I've just updated the documentation of my app and now eclipse ... | [
{
"answer_id": 308033,
"author": "Edward Z. Yang",
"author_id": 23845,
"author_profile": "https://Stackoverflow.com/users/23845",
"pm_score": 3,
"selected": false,
"text": "<p>Short answer: no.</p>\n\n<p>Long answer: consider adding docblocks with @return declarations.</p>\n"
},
{
... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14966/"
] | I think my eclipse's ctrl+clicking links might benefit greatly...
**Edit:** I'm using eclipse PDT.
**Edit 2:** I'm very happy with the solution of putting docblocks before functions (and variables) with an @return or @var statement, I've just updated the documentation of my app and now eclipse is showing me what func... | ```
// [...]
/**
* Return the Request object
*
* @return Zend_Controller_Request_Abstract
*/
public function getRequest()
{
return $this->_request;
}
// [...]
```
works perfectly with Eclipse PDT. Which plugin do you use? |
308,044 | <p>The first thing I do when I incorporate any third party code into my application is reformat it to my personal coding preference:</p>
<pre><code>// Single line comments only
// I never put spaces inside my parenthesis
-(void)myOCDMethod
{
// If an if or for statement has only one instruction, I don't use ... | [
{
"answer_id": 308799,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 2,
"selected": false,
"text": "<p>I do a lot of this, with a few differences:</p>\n\n<p>I always insert spaces before and after parens:\n<code> -(void... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28106/"
] | The first thing I do when I incorporate any third party code into my application is reformat it to my personal coding preference:
```
// Single line comments only
// I never put spaces inside my parenthesis
-(void)myOCDMethod
{
// If an if or for statement has only one instruction, I don't use brackets
i... | I do a lot of this, with a few differences:
I always insert spaces before and after parens:
`-(void)myOCDMethod -> - (void) myOCDMethod`
I leave braces on the same line:
```
if (this)
{
//code
}
```
becomes
```
if (this) {
//code
}
```
If I'm feeling particularly OCD, I'll line up my locals:
```
float... |
308,046 | <p>So I'm doing this in PHP but it is a logic issue so I'll try to write it as generically as possible.</p>
<p>To start here's how this pagination script works:</p>
<ol>
<li>for (<em>draw first three pages links</em>)</li>
<li>if (<em>draw ellipsis (...) if there are pages between #1's pages and #3's pages</em>)</li>... | [
{
"answer_id": 308106,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 2,
"selected": false,
"text": "<p>This is probably an overcomplicated solution, but it works. </p>\n\n<p>I've used an array here instead of just pri... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] | So I'm doing this in PHP but it is a logic issue so I'll try to write it as generically as possible.
To start here's how this pagination script works:
1. for (*draw first three pages links*)
2. if (*draw ellipsis (...) if there are pages between #1's pages and #3's pages*)
3. for (*draw current page and two pages on ... | ```
<?php
/**
* windowsize must be odd
*
* @param int $totalItems
* @param int $currentPage
* @param int $windowSize
* @param int $anchorSize
* @param int $itemsPerPage
* @return void
*/
function paginate($totalItems, $currentPage=1, $windowSize=3, $anchorSize=3, $itemsPerPage=10) {
$halfWindowSize =... |
308,054 | <p>It's kind of embarassing that I find it so difficult to learn JavaScript, but .. </p>
<p>Let's say I have a really simple controller like this:</p>
<pre><code>class front extends Controller {
public function __construct()
{
parent::Controller();
}
public function index()
{
... | [
{
"answer_id": 308127,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 4,
"selected": false,
"text": "<p>you would just print it out basically, and re-capture that information via javascript:</p>\n\n<pre><code>public function tes... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | It's kind of embarassing that I find it so difficult to learn JavaScript, but ..
Let's say I have a really simple controller like this:
```
class front extends Controller {
public function __construct()
{
parent::Controller();
}
public function index()
{
//nothing!
}
... | you would just print it out basically, and re-capture that information via javascript:
```
public function test() {
$somenumber = $this->input->post('someNumber');
if ($somenumber == 12) {
print "Number is 12";
} else {
print "Number is not 12";
}
}
```
your javascript might look some... |
308,059 | <p>I am trying to set up apache instead of IIS because <a href="https://stackoverflow.com/questions/188896/why-does-iis-crash-when-i-print-to-stderr-in-perl">IIS needlessly crashes</a> all the time, and it would be nice to be able to have my own checkout of the source instead of all of us editing a common checkout.</p>... | [
{
"answer_id": 308070,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 5,
"selected": true,
"text": "<p>HTTP and CGI are different things. The Perl CGI module calls what it does an \"HTTP header\", but it's really ju... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12448/"
] | I am trying to set up apache instead of IIS because [IIS needlessly crashes](https://stackoverflow.com/questions/188896/why-does-iis-crash-when-i-print-to-stderr-in-perl) all the time, and it would be nice to be able to have my own checkout of the source instead of all of us editing a common checkout.
In IIS we *must*... | HTTP and CGI are different things. The Perl CGI module calls what it does an "HTTP header", but it's really just a CGI header for the server to fix up before it goes back to the client. They look a lot alike which is why people get confused and why the CGI.pm docs don't help by calling them the wrong thing.
Apache fix... |
308,061 | <p>I was of the opinion that virtualization doesnt work in the super class constructor as per the design of OOP. For example, consider the following C# code. </p>
<pre><code>using System;
namespace Problem
{
public class BaseClass
{
public BaseClass()
{
Console.WriteLine("Hello, W... | [
{
"answer_id": 308075,
"author": "Nick",
"author_id": 26240,
"author_profile": "https://Stackoverflow.com/users/26240",
"pm_score": 3,
"selected": true,
"text": "<p>In native C++, the program works as expected: you get the call to the base class version of the virtual function within the... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30341/"
] | I was of the opinion that virtualization doesnt work in the super class constructor as per the design of OOP. For example, consider the following C# code.
```
using System;
namespace Problem
{
public class BaseClass
{
public BaseClass()
{
Console.WriteLine("Hello, World!");
... | In native C++, the program works as expected: you get the call to the base class version of the virtual function within the base class constructor. At the time of the constructor call, only the base class and its virtual functions exist, so you get the lowest-level version of the virtual function defined at the time. T... |
308,076 | <p>I want to spruce up some areas of my website with a few jQuery animations here and there, and I'm looking to replace my AJAX code entirely since my existing code is having some cross-browser compatibility issues. However, since jQuery is a JavaScript library, I'm worried about my pages not functioning correctly when... | [
{
"answer_id": 308104,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 4,
"selected": true,
"text": "<p>If you consider the \"Cascading Order\" of css, could you not just add a css style at the very end of all your previous css d... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19521/"
] | I want to spruce up some areas of my website with a few jQuery animations here and there, and I'm looking to replace my AJAX code entirely since my existing code is having some cross-browser compatibility issues. However, since jQuery is a JavaScript library, I'm worried about my pages not functioning correctly when Ja... | If you consider the "Cascading Order" of css, could you not just add a css style at the very end of all your previous css definition in order to cancel any css effect you currently have for tooltip effect ?
That css rule would only be declared if Javascript is activated and JQuery detected.
That way, you are sure you... |
308,085 | <p>I have a DataGridView that I want to query using Linq (C# WinForm). I want to "count" rows where a certain criteria is met. For example, </p>
<pre><code>variable1 = "count rows where ColumnBoxAge > 3 || < 5"
label1.Text = variable1
</code></pre>
<p>How to do this in C# WinForm using Linq?</p>
| [
{
"answer_id": 308148,
"author": "Ali Ersöz",
"author_id": 4215,
"author_profile": "https://Stackoverflow.com/users/4215",
"pm_score": 3,
"selected": true,
"text": "<p>I don't know if it could work but you can try this;</p>\n\n<pre><code>dataSet.Tables[0].AsEnumerable().Where(c => c.F... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10385/"
] | I have a DataGridView that I want to query using Linq (C# WinForm). I want to "count" rows where a certain criteria is met. For example,
```
variable1 = "count rows where ColumnBoxAge > 3 || < 5"
label1.Text = variable1
```
How to do this in C# WinForm using Linq? | I don't know if it could work but you can try this;
```
dataSet.Tables[0].AsEnumerable().Where(c => c.Field<int>("ageColumn") > 3 ||
c.Field<int>("ageColumn") < 5).Count();
```
Edit : Where instead of Select. |
308,109 | <p>I've noticed that in some lines of rails views, this is used:</p>
<pre><code><% # Code... -%>
</code></pre>
<p>instead of:</p>
<pre><code><% # Code... %>
</code></pre>
<p>What is the difference?</p>
| [
{
"answer_id": 308114,
"author": "dylanfm",
"author_id": 38795,
"author_profile": "https://Stackoverflow.com/users/38795",
"pm_score": 4,
"selected": false,
"text": "<pre><code> <ul>\n <% @posts.each do |post| -%> \n <li><%=post.title%></li>\n ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36049/"
] | I've noticed that in some lines of rails views, this is used:
```
<% # Code... -%>
```
instead of:
```
<% # Code... %>
```
What is the difference? | ```
<ul>
<% @posts.each do |post| -%>
<li><%=post.title%></li>
<% end -%>
</ul>
```
There will be no new lines in between the `<ul>` and first `<li>` and the last closing `</li>` and `</ul>`. If the - was omitted, there would. |
308,122 | <p>What is the regular expression for a decimal with a precision of 2?</p>
<p><em>Valid examples</em>:</p>
<pre><code>123.12
2
56754
92929292929292.12
0.21
3.1
</code></pre>
<p><em>Invalid examples:</em></p>
<pre><code>12.1232
2.23332
e666.76
</code></pre>
<p>The decimal point may be optional, and integers may als... | [
{
"answer_id": 308124,
"author": "DocMax",
"author_id": 6234,
"author_profile": "https://Stackoverflow.com/users/6234",
"pm_score": 10,
"selected": true,
"text": "<p>Valid regex tokens vary by implementation. A generic form is:</p>\n\n<pre><code>[0-9]+(\\.[0-9][0-9]?)?\n</code></pre>\n\n... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39221/"
] | What is the regular expression for a decimal with a precision of 2?
*Valid examples*:
```
123.12
2
56754
92929292929292.12
0.21
3.1
```
*Invalid examples:*
```
12.1232
2.23332
e666.76
```
The decimal point may be optional, and integers may also be included. | Valid regex tokens vary by implementation. A generic form is:
```
[0-9]+(\.[0-9][0-9]?)?
```
More compact:
```
\d+(\.\d{1,2})?
```
Both assume that both have at least one digit before and one after the decimal place.
To require that the whole string is a number of this form, wrap the expression in start and end ... |
308,154 | <p>I've got some <a href="http://code.google.com/p/protobuf-net/" rel="nofollow noreferrer">library code</a> that works on a range of .NET runtimes (regular, CF, Silverlight, etc) - but a small block of code is breaking <strong>only</strong> on CF 2.0, with a <code>MethodAccessException</code>. I'm pretty sure it is a ... | [
{
"answer_id": 308169,
"author": "Chris Kimpton",
"author_id": 48310,
"author_profile": "https://Stackoverflow.com/users/48310",
"pm_score": 3,
"selected": true,
"text": "<p>Have you tried writing your own sort - perhaps the built in one is doing some reflection shenanigans... Not with ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23354/"
] | I've got some [library code](http://code.google.com/p/protobuf-net/) that works on a range of .NET runtimes (regular, CF, Silverlight, etc) - but a small block of code is breaking **only** on CF 2.0, with a `MethodAccessException`. I'm pretty sure it is a runtime bug, but does anybody know any good workarounds? It work... | Have you tried writing your own sort - perhaps the built in one is doing some reflection shenanigans... Not with a view to using your own in the long term - but as a means of debugging the problem. It should be quick to code in something else and at least see whats then.
I presume you don't get a stack trace when it g... |
308,158 | <p>When reviewing our codebase, I found an inheritance structure that resembles the following pattern:</p>
<pre><code>interface IBase
{
void Method1();
void Method2();
}
interface IInterface2 : IBase
{
void Method3();
}
class Class1 : IInterface2
{
...
}
class Class2 : IInterface2
{
...
}
class... | [
{
"answer_id": 308164,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 4,
"selected": true,
"text": "<p>Well, first of all, I'm generally against implementing an interface by throwing NotImplementedException exceptions.... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2822/"
] | When reviewing our codebase, I found an inheritance structure that resembles the following pattern:
```
interface IBase
{
void Method1();
void Method2();
}
interface IInterface2 : IBase
{
void Method3();
}
class Class1 : IInterface2
{
...
}
class Class2 : IInterface2
{
...
}
class Class3 : IInt... | Well, first of all, I'm generally against implementing an interface by throwing NotImplementedException exceptions. It is basically like saying "Well, this class can also function as a calculator, err, almost".
But in some cases it really is the only way to do something "the right way", so I'm not 100% against it.
Ju... |
308,175 | <p>I can't tell if this is a result of the jQuery I'm using, but this is what I'm trying to do:</p>
<pre><code><div class="info" style="display: inline;"
onMouseOut="$(this).children('div').hide('normal');"
onMouseOver="$(this).children('div').show('normal');"
>
<... | [
{
"answer_id": 308195,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 0,
"selected": false,
"text": "<p>Did you follow this <strong><a href=\"http://www.kriesi.at/archives/create-simple-tooltips-with-css-and-jquery\" rel=\"nofol... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19521/"
] | I can't tell if this is a result of the jQuery I'm using, but this is what I'm trying to do:
```
<div class="info" style="display: inline;"
onMouseOut="$(this).children('div').hide('normal');"
onMouseOver="$(this).children('div').show('normal');"
>
<img src="images/target.png">
<div class="tooltiptwo" id="to... | **edit**: actually this is a much better solution ([credit](https://stackoverflow.com/questions/308411/#308720)):
```
$('.info').bind('mouseenter', function() {
$('div', this).show('normal');
});
$('.info').bind('mouseleave', function() {
$('div', this).hide('normal');
});
// hide the tooltip to start off
$(... |
308,187 | <p>how do I translate this code into jython?</p>
<pre><code> ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(file + ".zip"));
byte[] buf = new byte[1024];
int len;
//Create a new Zip entry with the file's name.
ZipEntry zipEntry = new ZipEntry(file.toString());
//Create a bu... | [
{
"answer_id": 308210,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": true,
"text": "<p>Here's an exact translation of that function (except, like your case, using <code>bin</code> instead of reserved keyword <... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21537/"
] | how do I translate this code into jython?
```
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(file + ".zip"));
byte[] buf = new byte[1024];
int len;
//Create a new Zip entry with the file's name.
ZipEntry zipEntry = new ZipEntry(file.toString());
//Create a buffered input s... | Here's an exact translation of that function (except, like your case, using `bin` instead of reserved keyword `in`).
```
from jarray import zeros
from java.io import BufferedInputStream, FileInputStream, FileOutputStream
from java.util.zip import ZipEntry, ZipOutputStream
def test(file):
zos = ZipOutputStream(Fil... |
308,188 | <p>I'm trying to use <a href="http://www.jboss.org/community/docs/DOC-10032" rel="noreferrer">this method</a> for receiving mail in our EJB3 app. In short, that means creating an MDB with the following annotations:</p>
<pre><code>@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "mailServer"... | [
{
"answer_id": 337473,
"author": "Brett Hannah",
"author_id": 42491,
"author_profile": "https://Stackoverflow.com/users/42491",
"pm_score": 5,
"selected": true,
"text": "<p>You can externalise the annotations into the ejb-jar.xml that you deploy in the META-INF of your jar file as follow... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6400/"
] | I'm trying to use [this method](http://www.jboss.org/community/docs/DOC-10032) for receiving mail in our EJB3 app. In short, that means creating an MDB with the following annotations:
```
@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "mailServer", propertyValue = "imap.company.com"),
... | You can externalise the annotations into the ejb-jar.xml that you deploy in the META-INF of your jar file as follows:
```
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="3.0">
<enterprise-beans>
<message-driven>
<ejb-name>YourMDB</ejb-name>
<ejb-class>MailMessageBean</ejb-... |
308,191 | <p>I have a group of strings in Javascript and I need to write a function that detects if another specific string belongs to this group or not.</p>
<p>What is the fastest way to achieve this? Is it alright to put the group of values into an array, and then write a function that searches through the array?</p>
<p>I th... | [
{
"answer_id": 308199,
"author": "Chris Kimpton",
"author_id": 48310,
"author_profile": "https://Stackoverflow.com/users/48310",
"pm_score": 0,
"selected": false,
"text": "<p>Using a hash table might be a quicker option. </p>\n\n<p>Whatever option you go for its definitely worth testing... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11384/"
] | I have a group of strings in Javascript and I need to write a function that detects if another specific string belongs to this group or not.
What is the fastest way to achieve this? Is it alright to put the group of values into an array, and then write a function that searches through the array?
I think if I keep the... | Use a hash table, and do this:
```
// Initialise the set
mySet = {};
// Add to the set
mySet["some string value"] = true;
...
// Test if a value is in the set:
if (testValue in mySet) {
alert(testValue + " is in the set");
} else {
alert(testValue + " is not in the set");
}
``` |
308,203 | <p>I'm trying to figure out how to execute a custom query with Castle ActiveRecord. </p>
<p>I was able to run simple query that returns my entity, but what I really need is the query like that below (with custom field set):</p>
<p><em>select count(1) as cnt, data from workstationevent where serverdatetime >= :minDate... | [
{
"answer_id": 318100,
"author": "Neil Hewitt",
"author_id": 22178,
"author_profile": "https://Stackoverflow.com/users/22178",
"pm_score": 4,
"selected": true,
"text": "<p>In this case what you want is <code>HqlBasedQuery</code>. Your query will be a projection, so what you'll get back w... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22680/"
] | I'm trying to figure out how to execute a custom query with Castle ActiveRecord.
I was able to run simple query that returns my entity, but what I really need is the query like that below (with custom field set):
*select count(1) as cnt, data from workstationevent where serverdatetime >= :minDate and serverdatetime ... | In this case what you want is `HqlBasedQuery`. Your query will be a projection, so what you'll get back will be an `ArrayList` of tuples containing the results (the content of each element of the ArrayList will depend on the query, but for more than one value will be `object[]`).
```
HqlBasedQuery query = new HqlBased... |
308,204 | <p>I would like to hear from you guys on how do you decide when you should be using concrete parameterized type vs. bounded parameterized type when designing API, esp. (that I care most) of defining a class/interface.</p>
<p>For instance,</p>
<pre><code>public interface Event<S>{
void setSource(S s);
}
publi... | [
{
"answer_id": 308229,
"author": "Miserable Variable",
"author_id": 18573,
"author_profile": "https://Stackoverflow.com/users/18573",
"pm_score": 0,
"selected": false,
"text": "<p>If I understand right this does not have much to do with generics in itself, but rather to do with parallel ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36397/"
] | I would like to hear from you guys on how do you decide when you should be using concrete parameterized type vs. bounded parameterized type when designing API, esp. (that I care most) of defining a class/interface.
For instance,
```
public interface Event<S>{
void setSource(S s);
}
public interface UserEvent exten... | I think your commented-out `UserEvent<S extends User>` approach is the right one -- then you can declare `AdminUserEvent extends UserEvent<AdminUser>`. Is that all you need? |
308,219 | <p>I'm trying to build a multi-level dropdrown CSS menu for a website I'm doing on the umbraco content management system.</p>
<p>I need to build it to have the following structure:</p>
<pre><code><ul id="nav">
<li><a href="..">Page #1</a></li>
<li>
<a href="..">Page #... | [
{
"answer_id": 308651,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 4,
"selected": true,
"text": "<p>First off, no need pass the a <code>parent</code> parameter around. The context will transport this information.</p>\n\... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to build a multi-level dropdrown CSS menu for a website I'm doing on the umbraco content management system.
I need to build it to have the following structure:
```
<ul id="nav">
<li><a href="..">Page #1</a></li>
<li>
<a href="..">Page #2</a>
<ul>
<li><a href="..">Subpage #1</a></li>
... | First off, no need pass the a `parent` parameter around. The context will transport this information.
Here is the XSL stylesheet that should solve your problem:
```
<!-- update this variable on how deep your menu should be -->
<xsl:variable name="maxLevelForMenu" select="4"/>
<!--- match the document root --->
<xsl:... |
308,227 | <p>Two snippets of MySQL: </p>
<pre><code>SELECT * FROM annoyingly_long_left_hand_table
LEFT JOIN annoyingly_long_right_hand_table
ON annoyingly_long_left_hand_table.id = annoyingly_long_right_hand_table.id;
</code></pre>
<p>vs</p>
<pre><code>SELECT * FROM annoyingly_long_left_hand_table
LEFT JOIN... | [
{
"answer_id": 308242,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 4,
"selected": true,
"text": "<p>There is a small functional difference between the two, in that instead of getting 2 ID columns, you only get one. ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20074/"
] | Two snippets of MySQL:
```
SELECT * FROM annoyingly_long_left_hand_table
LEFT JOIN annoyingly_long_right_hand_table
ON annoyingly_long_left_hand_table.id = annoyingly_long_right_hand_table.id;
```
vs
```
SELECT * FROM annoyingly_long_left_hand_table
LEFT JOIN annoyingly_long_right_hand_table
US... | There is a small functional difference between the two, in that instead of getting 2 ID columns, you only get one.
SELECT \* FROM foo JOIN bar ON ( foo.id == bar.id )
id , fooname, id, barname
SELECT \* FROM foo JOIN bar USING ( id )
id, fooname, barname
So there are at least some additional knowledge requirem... |
308,254 | <p>I am running an Ubuntu 8.10, using Python 2.5 out of the box. This is fine from the system point of view, but I need Python2.4 since I dev on Zope / Plone.</p>
<p>Well, installing python2.4 is no challenge, but I can't find a (clean) way to make iPython use it : no option in the man nor in the config file.</p>
<p>... | [
{
"answer_id": 308260,
"author": "e-satis",
"author_id": 9951,
"author_profile": "https://Stackoverflow.com/users/9951",
"pm_score": 5,
"selected": true,
"text": "<p>Ok, I answer my own question : I'm dumb :-)</p>\n\n<pre><code>ls /usr/bin/ipython*\n/usr/bin/ipython /usr/bin/ipython2.4 ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9951/"
] | I am running an Ubuntu 8.10, using Python 2.5 out of the box. This is fine from the system point of view, but I need Python2.4 since I dev on Zope / Plone.
Well, installing python2.4 is no challenge, but I can't find a (clean) way to make iPython use it : no option in the man nor in the config file.
Before, there was... | Ok, I answer my own question : I'm dumb :-)
```
ls /usr/bin/ipython*
/usr/bin/ipython /usr/bin/ipython2.4 /usr/bin/ipython2.5
```
Now it's built-in... |
308,258 | <p>How do I tell the Vim editor about my include files path so that it can auto complete the function names when I press <kbd>CTRL</kbd>+<kbd>N</kbd>?</p>
<p>For example, I have a C program like below:</p>
<pre><code>#include<stdio.h>
int main()
{
sca // here I press control+N, it does not complete to scanf... | [
{
"answer_id": 308274,
"author": "Rob Wells",
"author_id": 2974,
"author_profile": "https://Stackoverflow.com/users/2974",
"pm_score": 5,
"selected": true,
"text": "<p>In your <code>.vimrc</code>, add the paths to your <code>.vimrc</code>:</p>\n\n<pre><code>set path+=/usr/include/**\nset... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39615/"
] | How do I tell the Vim editor about my include files path so that it can auto complete the function names when I press `CTRL`+`N`?
For example, I have a C program like below:
```
#include<stdio.h>
int main()
{
sca // here I press control+N, it does not complete to scanf
}
``` | In your `.vimrc`, add the paths to your `.vimrc`:
```
set path+=/usr/include/**
set path+=/my_include_dir/include
set path+=/my_include_dir/srclib/apr/**
set path+=/my_other_include_dir/srclib/apr-util/**
** means all sub-directories.
* means all contained directories
. means all files in the directory of the found... |
308,276 | <p>As a <a href="http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29" rel="noreferrer">C#</a> developer I'm used to running through constructors:</p>
<pre class="lang-cs prettyprint-override"><code>class Test {
public Test() {
DoSomething();
}
public Test(int count) : this() {
... | [
{
"answer_id": 308287,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 0,
"selected": false,
"text": "<p>If I understand your question correctly, you're asking if you can call multiple constructors in C++?</p>\n\n<p>If that's w... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2090/"
] | As a [C#](http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29) developer I'm used to running through constructors:
```cs
class Test {
public Test() {
DoSomething();
}
public Test(int count) : this() {
DoSomethingWithCount(count);
}
public Test(int count, string name) :... | **C++11: Yes!**
C++11 and onwards has this same feature (called [delegating constructors](https://secure.wikimedia.org/wikipedia/en/wiki/C++11#Object_construction_improvement)).
The syntax is slightly different from C#:
```
class Foo {
public:
Foo(char x, int y) {}
Foo(int y) : Foo('a', y) {}
};
```
**C++03:... |
308,277 | <p>I am working on a C++ project and I noticed that we have a number of warnings about unused parameters.</p>
<p>What effect could it have if these warnings are ignored?</p>
| [
{
"answer_id": 308281,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 1,
"selected": false,
"text": "<p>None. except [EDIT]: as others have pointed out, You could have an unassigned output parameter.</p>\n\n<p>You shoul... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24459/"
] | I am working on a C++ project and I noticed that we have a number of warnings about unused parameters.
What effect could it have if these warnings are ignored? | The function with an unused parameter may have a real bug in the following cases:
1. There is an **output** parameter, which is not being assigned or written into, resulting in undefined value for the caller.
2. One of parameters is a callback function pointer, which you must invoke and forget to do so. May happen if ... |
308,279 | <p>Been thinking, what's the difference between declaring a variable with [] or * ? The way I see it:</p>
<pre><code>char *str = new char[100];
char str2[] = "Hi world!";
</code></pre>
<p>.. should be the main difference, though Im unsure if you can do something like</p>
<pre><code>char *str = "Hi all";
</code></pre... | [
{
"answer_id": 308312,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": -1,
"selected": false,
"text": "<p>The first option dynamically allocates 100 bytes.</p>\n\n<p>The second option statically allocates 10 bytes (9 for the st... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25745/"
] | Been thinking, what's the difference between declaring a variable with [] or \* ? The way I see it:
```
char *str = new char[100];
char str2[] = "Hi world!";
```
.. should be the main difference, though Im unsure if you can do something like
```
char *str = "Hi all";
```
.. since the pointer should the reference ... | Let's look into it (for the following, note `char const` and `const char` are the same in C++):
String literals and char \*
---------------------------
`"hello"` is an array of 6 const characters: `char const[6]`. As every array, it can convert implicitly to a pointer to its first element: `char const * s = "hello";`... |
308,298 | <p>Using <strong>sc</strong> command we can query, start , stop windows services.<br>
For ex: </p>
<pre><code>sc query "windows service name"
</code></pre>
<p>The <strong>sc config</strong> command changes the configuration of the service, but I don't know how to use it. </p>
<p>Could someone tell me how we can se... | [
{
"answer_id": 308319,
"author": "Andrew Ferrier",
"author_id": 27641,
"author_profile": "https://Stackoverflow.com/users/27641",
"pm_score": 8,
"selected": true,
"text": "<p>This works:</p>\n\n<pre><code>sc.exe config \"[servicename]\" obj= \"[.\\username]\" password= \"[password]\"\n</... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32670/"
] | Using **sc** command we can query, start , stop windows services.
For ex:
```
sc query "windows service name"
```
The **sc config** command changes the configuration of the service, but I don't know how to use it.
Could someone tell me how we can set the username and password for any windows service? | This works:
```
sc.exe config "[servicename]" obj= "[.\username]" password= "[password]"
```
Where each of the [bracketed] items are replaced with the true arguments. (Keep the quotes, but don't keep the brackets.)
Just keep in mind that:
* The spacing in the above example matters. `obj= "foo"` is correct; `obj="f... |
308,301 | <p>I've got code similar to the following...</p>
<pre><code><p><label>Do you have buffet facilities?</label>
<asp:RadioButtonList ID="blnBuffetMealFacilities:chk" runat="server">
<asp:ListItem Text="Yes" Value="1"></asp:ListItem>
<asp:ListItem Text="No" Value="0"><... | [
{
"answer_id": 308327,
"author": "Andrew Bullock",
"author_id": 28543,
"author_profile": "https://Stackoverflow.com/users/28543",
"pm_score": 6,
"selected": true,
"text": "<p>this:</p>\n\n<pre><code>$('#rblDiv input').click(function(){\n alert($('#rblDiv input').index(this));\n});\n</... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5055/"
] | I've got code similar to the following...
```
<p><label>Do you have buffet facilities?</label>
<asp:RadioButtonList ID="blnBuffetMealFacilities:chk" runat="server">
<asp:ListItem Text="Yes" Value="1"></asp:ListItem>
<asp:ListItem Text="No" Value="0"></asp:ListItem>
</asp:RadioButtonList></p>
<div id="HasBu... | this:
```
$('#rblDiv input').click(function(){
alert($('#rblDiv input').index(this));
});
```
will get you the index of the radio button that was clicked (i think, untested) (note you've had to wrap your RBL in #rblDiv
you could then use that to display the corresponding div like this:
```
$('.divCollection di... |
308,324 | <p>I want to generate a CSV file for user to use Excel to open it.</p>
<p>If I want to escape the comma in values, I can write it as "640,480".</p>
<p>If I want to keep the leading zeros, I can use ="001234".</p>
<p>But if I want to keep both comma and leading zeros in the value, writing as ="001,002" will be splitt... | [
{
"answer_id": 308340,
"author": "Nick Fortescue",
"author_id": 5346,
"author_profile": "https://Stackoverflow.com/users/5346",
"pm_score": 2,
"selected": false,
"text": "<p>Do</p>\n\n<pre><code>\"\"\"001,002\"\"\"\n</code></pre>\n\n<p>I found this out by typing \"001,002\" and then doin... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/288936/"
] | I want to generate a CSV file for user to use Excel to open it.
If I want to escape the comma in values, I can write it as "640,480".
If I want to keep the leading zeros, I can use ="001234".
But if I want to keep both comma and leading zeros in the value, writing as ="001,002" will be splitted as two columns. It se... | Kent Fredric's answer contains the solution:
```
"=""001,002"""
```
(I'm bothering to post this as a separate answer because it's not clear from Kent's answer that it is a valid Excel solution.) |
308,342 | <p>I have a table with the following columns:</p>
<pre>
A B C
---------
1 10 X
1 11 X
2 15 X
3 20 Y
4 15 Y
4 20 Y
</pre>
<p>I want to group the data based on the B and C columns and count the distinct values of the A column. But if there are two ore more rows where the value on the A column is... | [
{
"answer_id": 308387,
"author": "Dheer",
"author_id": 17266,
"author_profile": "https://Stackoverflow.com/users/17266",
"pm_score": 0,
"selected": false,
"text": "<p>Check this out. This should work in Oracle, although I haven't tested it;</p>\n\n<pre><code>select count(a), BB, CC from\... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24065/"
] | I have a table with the following columns:
```
A B C
---------
1 10 X
1 11 X
2 15 X
3 20 Y
4 15 Y
4 20 Y
```
I want to group the data based on the B and C columns and count the distinct values of the A column. But if there are two ore more rows where the value on the A column is the same I wan... | I like to work in steps: first get rid of duplicate A records, then group. Not the most efficient, but it works on your example.
```
with t1 as (
select A, max(B) as B, C
from YourTable
group by A, C
)
select count(A) as CountA, B, C
from t1
group by B, C
``` |
308,349 | <p>I've created a a folder and after I open a file inside of that folder a write on it.
It happens that after that I try to open the file but I have no permissions thus I have to change it manually.</p>
<pre><code>/* str1 has tha name of the folder */
/* str the bytes I want to write in the file inside the folder*/
..... | [
{
"answer_id": 308374,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 3,
"selected": false,
"text": "<p>You are forgetting the third argument to <code>open()</code>.</p>\n\n<p>The third argument to <code>open()</code> with <... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've created a a folder and after I open a file inside of that folder a write on it.
It happens that after that I try to open the file but I have no permissions thus I have to change it manually.
```
/* str1 has tha name of the folder */
/* str the bytes I want to write in the file inside the folder*/
...
mkdir(st... | You are forgetting the third argument to `open()`.
The third argument to `open()` with `O_CREAT` is precisely the permissions the newly created file will have.
References:
* <http://www.opengroup.org/onlinepubs/009695399/functions/open.html> |
308,359 | <p>Is either:</p>
<pre><code><a href="#"><h1>text here</h1></a>
</code></pre>
<p>or</p>
<pre><code><h1><a href="#">text here</a></h1>
</code></pre>
<p>"correct". Is there any benefit of using the first one, it seems more logical to me. Perhaps from an SEO point?</p>
| [
{
"answer_id": 308375,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 5,
"selected": true,
"text": "<pre><code><h1><a href=\"#\">text here</a></h1>\n</code></pre>\n\n<p>is correct, as HTML does not allow ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26823/"
] | Is either:
```
<a href="#"><h1>text here</h1></a>
```
or
```
<h1><a href="#">text here</a></h1>
```
"correct". Is there any benefit of using the first one, it seems more logical to me. Perhaps from an SEO point? | ```
<h1><a href="#">text here</a></h1>
```
is correct, as HTML does not allow a block element (`<h1>`) within an inline element (`<a>`) ([src](http://www.w3.org/TR/REC-html40/struct/global.html#h-7.5.3)). your first example will fail [validation](http://validator.w3.org/#validate_by_input).
>
> Generally, block-lev... |
308,364 | <p>I've just done a test with bitfields, and the results are surprising me. </p>
<pre><code>class test1 {
public:
bool test_a:1;
bool test_b:1;
bool test_c:1;
bool test_d:1;
bool test_e:1;
bool test_f:1;
bool test_g:1;
bool test_h:1;
};
class test2 {
public:
int test_a:1;
int t... | [
{
"answer_id": 308383,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 6,
"selected": true,
"text": "<p>your compiler has arranged all of the members of test3 on integer size boundaries. Once a block has been used for a give... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1737/"
] | I've just done a test with bitfields, and the results are surprising me.
```
class test1 {
public:
bool test_a:1;
bool test_b:1;
bool test_c:1;
bool test_d:1;
bool test_e:1;
bool test_f:1;
bool test_g:1;
bool test_h:1;
};
class test2 {
public:
int test_a:1;
int test_b:1;
i... | your compiler has arranged all of the members of test3 on integer size boundaries. Once a block has been used for a given type (integer bit-field, or boolean bit-field), the compiler does not allocate any further bit fields of a different type until the next boundary.
I doubt it is a bug. It probably has something to ... |
308,386 | <p>I have a web application (.war) that contains some static files (e.g. MS word documents). When I try to download these files, JBoss automatically sets some HTTP-headers in the response. Is there a way to configure JBoss (version 3.2.7) to set these headers to specific values (or omit them)?
I'm especially intereste... | [
{
"answer_id": 308503,
"author": "Chris Kimpton",
"author_id": 48310,
"author_profile": "https://Stackoverflow.com/users/48310",
"pm_score": 0,
"selected": false,
"text": "<p>An option that comes to mind is to wrap a servlet (or similar) around it - so that the URL that gets called calls... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4497/"
] | I have a web application (.war) that contains some static files (e.g. MS word documents). When I try to download these files, JBoss automatically sets some HTTP-headers in the response. Is there a way to configure JBoss (version 3.2.7) to set these headers to specific values (or omit them)?
I'm especially interested i... | [Here](http://www.jboss.org/community/docs/DOC-9578) is a description on the JBoss community wiki on how to disable the Cache-Control behaviour.
I wasn't aware of this IE6 feature until now. Does this also apply to IE7? |
308,390 | <p>I know this may be simple but being C++ I doubt it will be. How do I convert a string in the form 01/01/2008 to a date so I can manipulate it? I am happy to break the string into the day month year constituents. Also happy if solution is Windows only.</p>
| [
{
"answer_id": 308399,
"author": "kenny",
"author_id": 3225,
"author_profile": "https://Stackoverflow.com/users/3225",
"pm_score": 4,
"selected": false,
"text": "<pre><code>#include <time.h>\nchar *strptime(const char *buf, const char *format, struct tm *tm);\n</code></pre>\n"
},... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39634/"
] | I know this may be simple but being C++ I doubt it will be. How do I convert a string in the form 01/01/2008 to a date so I can manipulate it? I am happy to break the string into the day month year constituents. Also happy if solution is Windows only. | ```
#include <time.h>
char *strptime(const char *buf, const char *format, struct tm *tm);
``` |
308,417 | <p>I have some issue with a Perl script. It modifies the content of a file, then reopen it to write it, and in the process some characters are lost. All words starting with '%' are deleted from the file. That's pretty annoying because the % expressions are variable placeholders for dialog boxes.</p>
<p>Do you have any ... | [
{
"answer_id": 308434,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 6,
"selected": true,
"text": "<p>You're using <code>printf</code> there and it thinks its first argument is a format string. See the <a href=\"ht... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29568/"
] | I have some issue with a Perl script. It modifies the content of a file, then reopen it to write it, and in the process some characters are lost. All words starting with '%' are deleted from the file. That's pretty annoying because the % expressions are variable placeholders for dialog boxes.
Do you have any idea why?... | You're using `printf` there and it thinks its first argument is a format string. See the [`printf` documentation](http://perldoc.perl.org/functions/printf.html) for details. When I run into this sort of problem, I always ensure that I'm using the functions correctly. :)
You probably want just [print](http://perldoc.pe... |
308,427 | <p>I need a collection that </p>
<ul>
<li>contains a set of objects linked to a double.</li>
<li>The sequence of these pairs should be arbitrary set by me (based on an int I get from the database) and be static throughout the lifecycle.</li>
<li>The number of entries will be small (0 ~ 20) but varying.</li>
<li>The co... | [
{
"answer_id": 308441,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p>It sounds like you may just want an equivalent of <code>KeyValuePair</code>, but mutable. Given that you're only usin... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | I need a collection that
* contains a set of objects linked to a double.
* The sequence of these pairs should be arbitrary set by me (based on an int I get from the database) and be static throughout the lifecycle.
* The number of entries will be small (0 ~ 20) but varying.
* The collection should be itteratable.
* I... | It sounds like you may just want an equivalent of `KeyValuePair`, but mutable. Given that you're only using it as a pair of values rather than a key-value pair, you could just do:
```
public class MutablePair<TFirst, TSecond>
{
public TFirst First { get; set; }
public TSecond Second { get; set; }
public M... |
308,428 | <p>If I type the command:</p>
<pre><code>mvn dependency:list
</code></pre>
<p>The <a href="http://maven.apache.org/plugins/maven-dependency-plugin/" rel="nofollow noreferrer">docs</a> suggest that I'll get a list of my project's dependencies. Instead though, I get this:</p>
<pre><code>[INFO] Searching repository for... | [
{
"answer_id": 308480,
"author": "Ivan Dubrov",
"author_id": 31118,
"author_profile": "https://Stackoverflow.com/users/31118",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried <code>mvn -cpu dependency:list</code> (or: <code>mvn --check-plugin-updates dependency:list</code>)?... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/974/"
] | If I type the command:
```
mvn dependency:list
```
The [docs](http://maven.apache.org/plugins/maven-dependency-plugin/) suggest that I'll get a list of my project's dependencies. Instead though, I get this:
```
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] --------------------------------... | To answer my own question, thanks to some comments that were made on it, the settings.xml file had been customized and did not list the central maven repository.
Oops. |
308,436 | <p>How to (programmatically, without xml config) configure multiple loggers with Log4Net?
I need them to write to different files.</p>
| [
{
"answer_id": 308544,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 7,
"selected": true,
"text": "<p><a href=\"http://mail-archives.apache.org/mod_mbox/logging-log4net-user/200602.mbox/%3CDDEB64C8619AC64DBC074208B04661... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35425/"
] | How to (programmatically, without xml config) configure multiple loggers with Log4Net?
I need them to write to different files. | [This thread at the log4net Dashboard details an approach](http://mail-archives.apache.org/mod_mbox/logging-log4net-user/200602.mbox/%3CDDEB64C8619AC64DBC074208B046611C769745@kronos.neoworks.co.uk%3E).
To summarize a little, hopefully without ripping off too much code:
```
using log4net;
using log4net.Appender;
using... |
308,438 | <p>I am using tinyMCE and, rather annoyingly, it replaces all of my apostrophes with their HTML numeric equivalent. Now most of the time this isn't a problem but for some reason I am having a problem storing the apostrophe replacement. So i have to search through the string and replace them all. Any help would be much ... | [
{
"answer_id": 308439,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 4,
"selected": true,
"text": "<p>did you try:</p>\n\n<pre><code>$string = str_replace(\"&#39;\", \"<replacement>\", $string);\n</code></pre>\n"
},... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31677/"
] | I am using tinyMCE and, rather annoyingly, it replaces all of my apostrophes with their HTML numeric equivalent. Now most of the time this isn't a problem but for some reason I am having a problem storing the apostrophe replacement. So i have to search through the string and replace them all. Any help would be much app... | did you try:
```
$string = str_replace("'", "<replacement>", $string);
``` |
308,456 | <p>I have a table containing the runtimes for generators on different sites, and I want to select the most recent entry for each site. Each generator is run once or twice a week.</p>
<p>I have a query that will do this, but I wonder if it's the best option. I can't help thinking that using WHERE x IN (SELECT ...) is... | [
{
"answer_id": 308471,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 0,
"selected": false,
"text": "<p>In MYSQL it could be problematic because Last i Checked it was unable to optimise subqueries effectively ( Ie: by ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33161/"
] | I have a table containing the runtimes for generators on different sites, and I want to select the most recent entry for each site. Each generator is run once or twice a week.
I have a query that will do this, but I wonder if it's the best option. I can't help thinking that using WHERE x IN (SELECT ...) is lazy and no... | I would use joins as they perform much better then "IN" clause:
```
select gl.id, gl.site_id, gl.start, gl."end", gl.duration
from
generator_logs gl
inner join (
select max(start) as start, site_id
from generator_logs
group by site_id
) gl2
on gl.site_id = gl2.site_id
... |
308,466 | <p>I have to delete some rows from a data table. I've heard that it is not ok to change a collection while iterating through it. So instead of a for loop in which I check if a row meets the demands for deletion and then mark it as deleted, I should first iterate through the data table and add all of the rows in a list,... | [
{
"answer_id": 308486,
"author": "bruno conde",
"author_id": 31136,
"author_profile": "https://Stackoverflow.com/users/31136",
"pm_score": 5,
"selected": true,
"text": "<p>You can remove elements from a collection if you use a simple <code>for</code> loop.</p>\n\n<p>Take a look at this e... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1360/"
] | I have to delete some rows from a data table. I've heard that it is not ok to change a collection while iterating through it. So instead of a for loop in which I check if a row meets the demands for deletion and then mark it as deleted, I should first iterate through the data table and add all of the rows in a list, th... | You can remove elements from a collection if you use a simple `for` loop.
Take a look at this example:
```
var l = new List<int>();
l.Add(0);
l.Add(1);
l.Add(2);
l.Add(3);
l.Add(4);
l.Add(5);
l.Add(6);
for (int i = 0; i < l.Count; i++)
... |
308,476 | <p>What is the fastest way to find out whether two <code>ICollection<T></code> collections contain precisely the same entries? Brute force is clear, I was wondering if there is a more elegant method.</p>
<p>We are using C# 2.0, so no extension methods if possible, please!</p>
<p>Edit: the answer would be intere... | [
{
"answer_id": 308490,
"author": "Chris Kimpton",
"author_id": 48310,
"author_profile": "https://Stackoverflow.com/users/48310",
"pm_score": 0,
"selected": false,
"text": "<p>Brute force takes O(n) - comparing all elements (assuming they are sorted), which I would think is the best you c... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6091/"
] | What is the fastest way to find out whether two `ICollection<T>` collections contain precisely the same entries? Brute force is clear, I was wondering if there is a more elegant method.
We are using C# 2.0, so no extension methods if possible, please!
Edit: the answer would be interesting both for ordered and unorder... | use C5
<http://www.itu.dk/research/c5/>
[ContainsAll](http://www.itu.dk/research/c5/Release1.1/c5doc/types/C5.ICollection_1.htm#T:C5.ICollection%601|M:C5.ICollection%601.ContainsAll%60%601(System.Collections.Generic.IEnumerable%7B%60%600%7D))
>
> " Check if all items in a
> supplied collection is in this bag
>
... |
308,481 | <p>I often use this recursive 'visitor' in F#</p>
<pre><code>let rec visitor dir filter=
seq { yield! Directory.GetFiles(dir, filter)
for subdir in Directory.GetDirectories(dir) do yield! visitor subdir filter}
</code></pre>
<p>Recently I've started working on implementing some F# functionality in C#,... | [
{
"answer_id": 308610,
"author": "Sunlight",
"author_id": 33650,
"author_profile": "https://Stackoverflow.com/users/33650",
"pm_score": 5,
"selected": true,
"text": "<p><code>yield!</code> does a 'flatten' operation, so it integrates the sequence you passed it into the outer sequence, im... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] | I often use this recursive 'visitor' in F#
```
let rec visitor dir filter=
seq { yield! Directory.GetFiles(dir, filter)
for subdir in Directory.GetDirectories(dir) do yield! visitor subdir filter}
```
Recently I've started working on implementing some F# functionality in C#, and I'm trying to reprodu... | `yield!` does a 'flatten' operation, so it integrates the sequence you passed it into the outer sequence, implicitly performing a `foreach` over each element of the sequence and `yield` on each one. |
308,491 | <p>Is it possible to get Mercurial to show progress of long-running push or pull operation? Google tells me basically "no", but does somebody know better? I was expecting something like <code>hg pull -v</code>...</p>
| [
{
"answer_id": 308515,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 6,
"selected": true,
"text": "<pre><code>hg pull -v \n</code></pre>\n\n<p>-v / --verbose</p>\n\n<p>is a global option that applies to all sub-functi... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6846/"
] | Is it possible to get Mercurial to show progress of long-running push or pull operation? Google tells me basically "no", but does somebody know better? I was expecting something like `hg pull -v`... | ```
hg pull -v
```
-v / --verbose
is a global option that applies to all sub-functions.
If you want extra data:
```
hg --debug -v pull
``` |
308,492 | <p>In Postgresql you can create additional Aggregate Functions with </p>
<pre><code>CREATE AGGREGATE name(...);
</code></pre>
<p>But this gives an error if the aggregate already exists inside the database, so how can I check if a Aggregate already exists in the Postgres Database? </p>
| [
{
"answer_id": 308500,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 4,
"selected": true,
"text": "<pre><code>SELECT * FROM pg_proc WHERE proname = 'name' AND proisagg; \n</code></pre>\n\n<ul>\n<li><a href=\"http://ww... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39644/"
] | In Postgresql you can create additional Aggregate Functions with
```
CREATE AGGREGATE name(...);
```
But this gives an error if the aggregate already exists inside the database, so how can I check if a Aggregate already exists in the Postgres Database? | ```
SELECT * FROM pg_proc WHERE proname = 'name' AND proisagg;
```
* <http://www.postgresql.org/docs/8.3/interactive/catalogs-overview.html>
* <http://www.postgresql.org/docs/8.3/interactive/catalog-pg-aggregate.html>
* <http://www.postgresql.org/docs/8.3/interactive/catalog-pg-proc.html> |
308,499 | <p>I want to float a div to the right at the top of my page. It contains a 50px square image, but currently it impacts on the layout of the top 50px on the page.</p>
<p>Currently its:</p>
<pre><code><div style="float: right;">
...
</div>
</code></pre>
<p>I tried z-index as I thought that would be the a... | [
{
"answer_id": 308519,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 2,
"selected": false,
"text": "<p>Try setting its <code>position</code> to absolute. That takes it out of the flow of the document.</p>\n"
},
{
"answ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39643/"
] | I want to float a div to the right at the top of my page. It contains a 50px square image, but currently it impacts on the layout of the top 50px on the page.
Currently its:
```
<div style="float: right;">
...
</div>
```
I tried z-index as I thought that would be the answer, but I couldn't get it going.
I know i... | What do you mean by impacts? Content will flow around a float. That's how they work.
If you want it to appear above your design, try setting:
```
z-index: 10;
position: absolute;
right: 0;
top: 0;
``` |
308,501 | <p>I want to check that two passwords are the same using Dojo.</p>
<p>Here is the HTML I have:</p>
<p><code></p>
<blockquote>
<p><code><form id="form" action="." dojoType="dijit.form.Form" /</code>></p>
<p><code><p</code>>Password: <code><input type="password"<br>
name="password1"<br>
id=... | [
{
"answer_id": 308666,
"author": "Richard Garside",
"author_id": 31569,
"author_profile": "https://Stackoverflow.com/users/31569",
"pm_score": 1,
"selected": false,
"text": "<p>I've solved it!</p>\n\n<p>This <a href=\"http://dojotoolkit.org/forum/dijit-dijit-0-9/dijit-support/password-co... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31569/"
] | I want to check that two passwords are the same using Dojo.
Here is the HTML I have:
>
> `<form id="form" action="." dojoType="dijit.form.Form" /`>
>
>
> `<p`>Password: `<input type="password"
>
> name="password1"
>
> id="password1"
>
> dojoType="dijit.form.ValidationTextBox"
>
> required="true"
... | This will get you a lot closer
* setting intermediateChanges=false keeps the validator running at every keystroke.
* the validation dijit's constraint object is passed to its validator. Use this to pass in the other password entry
* dijit.form.Form automatically calls isValid() on all its child dijits when it's submit... |
308,511 | <p>I have a .Net 1.1 web application sitting in a folder called C:\inetpub\wwwroot\MyTestApp, where 'MyTestApp' is a virtual directory and is configured to be on ASP.Net version 1.1.4322 in IIS 5.1.</p>
<p>In the root directory (C:\inetpub\wwwroot) there is a web.config file for a .Net2.0 application, because the root... | [
{
"answer_id": 308542,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 1,
"selected": false,
"text": "<p>I think you need to configure your virtual directory for your 1.1 app as a "application" directory.</p>\n<p>I ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7585/"
] | I have a .Net 1.1 web application sitting in a folder called C:\inetpub\wwwroot\MyTestApp, where 'MyTestApp' is a virtual directory and is configured to be on ASP.Net version 1.1.4322 in IIS 5.1.
In the root directory (C:\inetpub\wwwroot) there is a web.config file for a .Net2.0 application, because the root folder co... | I think you need to configure your virtual directory for your 1.1 app as a "application" directory.
I am on IIS7, so I am providing this from memory!
If you right click it in IIS, and then click "**Create Application**" that should do the trick.
`Web.config` is always read based on proximity (closest to application ... |
308,514 | <p>In firefox when you add an onclick event handler to a method an event object is automatically passed to that method. This allows, among other things, the ability to detect which specific element was clicked. For example</p>
<pre><code>document.body.onclick = handleClick;
function handleClick(e)
{
// this works... | [
{
"answer_id": 308523,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 0,
"selected": false,
"text": "<p>I think IE uses a variable called <code>event</code>. See if that works?</p>\n"
},
{
"answer_id": 308526,
"auth... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28882/"
] | In firefox when you add an onclick event handler to a method an event object is automatically passed to that method. This allows, among other things, the ability to detect which specific element was clicked. For example
```
document.body.onclick = handleClick;
function handleClick(e)
{
// this works if FireFox
... | Here is how would I do it in case I cannot use jQuery
```
document.body.onclick = handleClick;
function handleClick(e)
{
//If "e" is undefined use the global "event" variable
e = e || event;
var target = e.srcElement || e.target;
alert(target.className);
}
```
And here is a jQuery solution
```
$(d... |
308,547 | <p>I am using a custom validator to compare value in two text box. This is comparing the values fine. But it says "025" and "25" are different.. can this do a float comparision.</p>
<p>the custom validator i am using is </p>
<pre><code><asp:CompareValidator id="compval" runat="server" ControlToValidate="txtBox1"
... | [
{
"answer_id": 308603,
"author": "Andrew Bullock",
"author_id": 28543,
"author_profile": "https://Stackoverflow.com/users/28543",
"pm_score": 0,
"selected": false,
"text": "<p>use a compare validator with a type of int?</p>\n"
},
{
"answer_id": 308607,
"author": "wimh",
"... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20951/"
] | I am using a custom validator to compare value in two text box. This is comparing the values fine. But it says "025" and "25" are different.. can this do a float comparision.
the custom validator i am using is
```
<asp:CompareValidator id="compval" runat="server" ControlToValidate="txtBox1"
Error... | Use System.Double.Parse(value) to convert both to a floating point number, and compare those numbers.
You can also use TryParse if you don't want to handle exceptions if the value is not a valid floating point number.
See also:
* <http://msdn.microsoft.com/en-us/library/system.double.parse.aspx>
* <http://msdn.micr... |
308,555 | <p>I have this Java code (JPA):</p>
<pre><code>String queryString = "SELECT b , sum(v.votedPoints) as votedPoint " +
" FROM Bookmarks b " +
" LEFT OUTER JOIN Votes v " +
" on (v.organizationId = b.organizationId) " +
... | [
{
"answer_id": 308564,
"author": "Chris Kimpton",
"author_id": 48310,
"author_profile": "https://Stackoverflow.com/users/48310",
"pm_score": 2,
"selected": false,
"text": "<p>Stab in the dark - Are you sure you have a consistent set of jars - perhaps you need to get the antlr jar that co... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39626/"
] | I have this Java code (JPA):
```
String queryString = "SELECT b , sum(v.votedPoints) as votedPoint " +
" FROM Bookmarks b " +
" LEFT OUTER JOIN Votes v " +
" on (v.organizationId = b.organizationId) " +
"WHERE b.user... | You definitely have an issue with the version of hibernate and ANTLR jars that you are using. The recover method wasn't present in the ANTLR Parser class until version 2.7.6? If you are using an earlier version of ANTLR, such as 2.7.2, then you will see this problem.
Using maven can cause this sort of situation, where... |
308,588 | <p>I am struggling to get an Epson "ESC/POS" printer to print barcodes (Using Delphi) and want to test if the printer is not faulty. Do you know where I can find a program to print a barcode in "ESC/POS"? I suppose as a last resort an OPOS program will also be OK.</p>
<p>Also, a demo Delphi Program that works will als... | [
{
"answer_id": 308646,
"author": "Miki Watts",
"author_id": 16172,
"author_profile": "https://Stackoverflow.com/users/16172",
"pm_score": 1,
"selected": false,
"text": "<p>Get the Microsoft POS For .Net 1.11, it's got an SDK that includes a sample application that performs all the basic ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3535708/"
] | I am struggling to get an Epson "ESC/POS" printer to print barcodes (Using Delphi) and want to test if the printer is not faulty. Do you know where I can find a program to print a barcode in "ESC/POS"? I suppose as a last resort an OPOS program will also be OK.
Also, a demo Delphi Program that works will also be fine.... | I Have a full tests program written in Delphi 5 for the TMT88's but the source is abit big for here so here is the barcode bits
Please note that as its snippets from the full object some vars/functions may be missing
To get the barcode chars
```
{**
* @param a ean13 barcode numeric value
* @return the escpos c... |
308,609 | <p>As as part of my daily routine, I have the misfortune of administering an ancient, once "just internal" JSP web application that relies on the following authentication schema:</p>
<pre><code>...
// Validate the user name and password.
if ((user != null) && (password != null) && (
(user.equals("... | [
{
"answer_id": 308618,
"author": "Marko",
"author_id": 31141,
"author_profile": "https://Stackoverflow.com/users/31141",
"pm_score": 2,
"selected": false,
"text": "<p>First of all you should move that logic from jsp to a separate class.</p>\n\n<p>Second, you shouldn't keep plain text pas... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6992/"
] | As as part of my daily routine, I have the misfortune of administering an ancient, once "just internal" JSP web application that relies on the following authentication schema:
```
...
// Validate the user name and password.
if ((user != null) && (password != null) && (
(user.equals("brianmay") && password.equals(... | It is hard to understand the exact scheme you are thinking about but I assume the password is coming in from a request and you want to calculate the MD5 hash in a JSP that the request is being sent to. After that you can compare it to the pre-computed MD5 version. You could even be more secure if it isn't being done wi... |
308,615 | <p>Please feel free to correct me if I am wrong at any point...</p>
<p>I am trying to read a <a href="http://en.wikipedia.org/wiki/Comma-separated_values" rel="nofollow noreferrer">CSV</a> (comma separated values) file using .NET file I/O classes. Now the problem is, this CSV file may contain some fields with soft car... | [
{
"answer_id": 308633,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 0,
"selected": false,
"text": "<p>How about simply preprocessing the file?</p>\n\n<p>Replace the soft carriage returns with something unique.</p>\n\... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39648/"
] | Please feel free to correct me if I am wrong at any point...
I am trying to read a [CSV](http://en.wikipedia.org/wiki/Comma-separated_values) (comma separated values) file using .NET file I/O classes. Now the problem is, this CSV file may contain some fields with soft carriage returns (i.e. solitary \r or \n markers r... | It probably is. In terms of order, it goes through each char once only, so it would be O(n) (where n is the length of the stream) so that's not a problem. To read a single character a BinaryReader is your best bet.
What I would do is make a class
```
public class LineReader : IDisposable
{
private Stream stream;
... |
308,619 | <p>With a vector defined as <code>std::vector<std::string></code>,
Wondering why the following is valid:</p>
<pre><code>if ( vecMetaData[0] != "Some string" )
{
...
</code></pre>
<p>But not this:</p>
<pre><code>switch ( vecMetaData[1] )
{
...
</code></pre>
<p>Visual studio complains :</p>
<pre>... | [
{
"answer_id": 308629,
"author": "schnaader",
"author_id": 34065,
"author_profile": "https://Stackoverflow.com/users/34065",
"pm_score": 2,
"selected": false,
"text": "<p>You can use switch only for basic datatypes (int, char etc.).</p>\n"
},
{
"answer_id": 308630,
"author": ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18664/"
] | With a vector defined as `std::vector<std::string>`,
Wondering why the following is valid:
```
if ( vecMetaData[0] != "Some string" )
{
...
```
But not this:
```
switch ( vecMetaData[1] )
{
...
```
Visual studio complains :
```
error C2450: switch expression of type 'std::basic_string<_Elem,_Traits,_Ax>... | switch() needs an integral type (like int, char, ...)
string is not an integral type, neither does string have an implicit conversion to an integral type, so it can't be used in a switch statement |
308,620 | <p>I have a simple database with two tables. Users and Configurations. A user has a foreign key to link it to a particular configuration.</p>
<p>I am having a strange problem where the following query always causes an inner join to the Configuration table regardless of the second parameter value. As far as I can tell,... | [
{
"answer_id": 308629,
"author": "schnaader",
"author_id": 34065,
"author_profile": "https://Stackoverflow.com/users/34065",
"pm_score": 2,
"selected": false,
"text": "<p>You can use switch only for basic datatypes (int, char etc.).</p>\n"
},
{
"answer_id": 308630,
"author": ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a simple database with two tables. Users and Configurations. A user has a foreign key to link it to a particular configuration.
I am having a strange problem where the following query always causes an inner join to the Configuration table regardless of the second parameter value. As far as I can tell, even thou... | switch() needs an integral type (like int, char, ...)
string is not an integral type, neither does string have an implicit conversion to an integral type, so it can't be used in a switch statement |
308,650 | <p>Anyone got any insight as to select x number of non-consecutive days worth of data? Dates are standard sql datetime. So for example I'd like to select 5 most recent days worth of data, but there could be many days gap between records, so just selecting records from 5 days ago and more recent will not do.</p>
| [
{
"answer_id": 308670,
"author": "Tony Andrews",
"author_id": 18747,
"author_profile": "https://Stackoverflow.com/users/18747",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know the SQL Server syntax, but you need to:</p>\n\n<p>1) Select the dates (with time component truncated)... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39655/"
] | Anyone got any insight as to select x number of non-consecutive days worth of data? Dates are standard sql datetime. So for example I'd like to select 5 most recent days worth of data, but there could be many days gap between records, so just selecting records from 5 days ago and more recent will not do. | Following the approach [Tony Andrews](https://stackoverflow.com/questions/308650/select-x-most-recent-non-consecutive-days-worth-of-data#308670) suggested, here is a way of doing it in T-SQL:
```
SELECT
Value,
ValueDate
FROM
Data
WHERE
ValueDate >=
(
SELECT
CONVERT(DATETIME, MIN(TruncatedDate))
... |
308,695 | <p>I'm working in C, and I have to concatenate a few things.</p>
<p>Right now I have this:</p>
<pre><code>message = strcat("TEXT ", var);
message2 = strcat(strcat("TEXT ", foo), strcat(" TEXT ", bar));
</code></pre>
<p>Now if you have experience in C I'm sure you realize that this gives you a segmentation fault whe... | [
{
"answer_id": 308712,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 10,
"selected": true,
"text": "<p>In C, \"strings\" are just plain <code>char</code> arrays. Therefore, you can't directly concatenate them with oth... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] | I'm working in C, and I have to concatenate a few things.
Right now I have this:
```
message = strcat("TEXT ", var);
message2 = strcat(strcat("TEXT ", foo), strcat(" TEXT ", bar));
```
Now if you have experience in C I'm sure you realize that this gives you a segmentation fault when you try to run it. So how do I ... | In C, "strings" are just plain `char` arrays. Therefore, you can't directly concatenate them with other "strings".
You can use the `strcat` function, which appends the string pointed to by `src` to the end of the string pointed to by `dest`:
```
char *strcat(char *dest, const char *src);
```
Here is an [example fr... |
308,703 | <p>Is there a way to change all the numeric keys to "Name" without looping through the array (so a php function)?</p>
<pre><code>[
0 => 'blabla',
1 => 'blabla',
2 => 'blblll',
// etc ...
]
</code></pre>
| [
{
"answer_id": 308731,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 5,
"selected": false,
"text": "<p>No, there is not, for starters, it is impossible to have an array with elements sharing the same key</p>\n\n<pre><... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there a way to change all the numeric keys to "Name" without looping through the array (so a php function)?
```
[
0 => 'blabla',
1 => 'blabla',
2 => 'blblll',
// etc ...
]
``` | If you have an array of keys that you want to use then use [`array_combine`](http://ca3.php.net/manual/en/function.array-combine.php)
Given $keys = array('a', 'b', 'c', ...) and your array, $list, then do this:
```
$list = array_combine($keys, array_values($list));
```
List will now be array('a' => 'blabla 1', ...)... |
308,746 | <p>I'm getting a segmentation fault in the following C code:</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#... | [
{
"answer_id": 308763,
"author": "Graeme Perrow",
"author_id": 1821,
"author_profile": "https://Stackoverflow.com/users/1821",
"pm_score": 3,
"selected": false,
"text": "<p>You are calling <code>strcat( m, \"NICK\" );</code> before you have initialized m. before the strcat, try <code>m[0... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] | I'm getting a segmentation fault in the following C code:
```
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define PORT 6667
#define MAXDATASIZE 1024
... | You are calling `strcat( m, "NICK" );` before you have initialized m. before the strcat, try `m[0] = '\0';` or `memset( m, 0, sizeof( m ) );`, or change the first `strcat` to `strcpy`
Also, after you send the NICK line out on the socket, you call `strcat` again, which will append the USER line to the NICK line. Again,... |
308,749 | <p>In many languages there's a pair of functions, <code>chr()</code> and <code>ord()</code>, which convert between numbers and character values. In some languages, <code>ord()</code> is called <code>asc()</code>.</p>
<p>Ruby has <code>Integer#chr</code>, which works great:</p>
<pre><code>>> 65.chr
A
</code></pr... | [
{
"answer_id": 308764,
"author": "GregD",
"author_id": 38317,
"author_profile": "https://Stackoverflow.com/users/38317",
"pm_score": 2,
"selected": false,
"text": "<p>How about </p>\n\n<blockquote>\n <p>puts ?A</p>\n</blockquote>\n"
},
{
"answer_id": 308804,
"author": "dylan... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39223/"
] | In many languages there's a pair of functions, `chr()` and `ord()`, which convert between numbers and character values. In some languages, `ord()` is called `asc()`.
Ruby has `Integer#chr`, which works great:
```
>> 65.chr
A
```
Fair enough. But how do you go the other way?
```
"A".each_byte do |byte|
puts byte... | If String#ord didn't exist in 1.9, it does in 2.0:
```
"A".ord #=> 65
``` |
308,756 | <p>Is it possible to check if a dynamically loaded assembly has been signed with a specific strong name?</p>
<p>Is it enough / secure to compare the values returned from <strong>AssemblyName.GetPublicKey()</strong> method?</p>
<pre><code>Assembly loaded = Assembly.LoadFile(path);
byte[] evidenceKey = loaded.GetName(... | [
{
"answer_id": 308762,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 2,
"selected": false,
"text": "<h2>Inside VS</h2>\n\n<p>Comments are relatively simple.</p>\n\n<p>You can use for <strong>single line</strong>... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25319/"
] | Is it possible to check if a dynamically loaded assembly has been signed with a specific strong name?
Is it enough / secure to compare the values returned from **AssemblyName.GetPublicKey()** method?
```
Assembly loaded = Assembly.LoadFile(path);
byte[] evidenceKey = loaded.GetName().GetPublicKey();
if (evidenceKey... | This is quite interesting to do with the xml comments: <http://thoughtpad.net/alan-dean/cs-xml-documentation.html>
These get read by [sandcastle](http://blogs.msdn.com/sandcastle/) too... :o) |
308,813 | <p>I am using Apache Felix and its Declarative Services (SCR) to wire the service dependencies between bundles.</p>
<p>For example, if I need access to a java.util.Dictionary I can say the following to have SCR provide one:</p>
<pre><code>/**
* @scr.reference name=properties interface=java.util.Dictionary
*/
protect... | [
{
"answer_id": 322471,
"author": "Danail Nachev",
"author_id": 3219,
"author_profile": "https://Stackoverflow.com/users/3219",
"pm_score": 1,
"selected": false,
"text": "<p>In standard DS, you can use target attribute of the reference element. In Felix world, where annotations can be use... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14955/"
] | I am using Apache Felix and its Declarative Services (SCR) to wire the service dependencies between bundles.
For example, if I need access to a java.util.Dictionary I can say the following to have SCR provide one:
```
/**
* @scr.reference name=properties interface=java.util.Dictionary
*/
protected void bindPropertie... | I think
```
target="(name=myDictionary)"
```
should do the trick in the `@scr.reference` annotation. See <http://felix.apache.org/site/apache-felix-maven-scr-plugin.html> |
308,820 | <p>I have big issue with url-rewriting for IIS 7.0.</p>
<p>I've written simple module for rewriting for my NET3.5/IIS7 web application. Here is a part of the code.</p>
<pre><code> public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
void... | [
{
"answer_id": 322471,
"author": "Danail Nachev",
"author_id": 3219,
"author_profile": "https://Stackoverflow.com/users/3219",
"pm_score": 1,
"selected": false,
"text": "<p>In standard DS, you can use target attribute of the reference element. In Felix world, where annotations can be use... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39656/"
] | I have big issue with url-rewriting for IIS 7.0.
I've written simple module for rewriting for my NET3.5/IIS7 web application. Here is a part of the code.
```
public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
void context_BeginRequest... | I think
```
target="(name=myDictionary)"
```
should do the trick in the `@scr.reference` annotation. See <http://felix.apache.org/site/apache-felix-maven-scr-plugin.html> |
308,823 | <p>I have to define the grammar of a file like the one shown below.</p>
<p>//Sample file<br>
NameCount = 4<br>
Name = a<br>
Name = b<br>
Name = c<br>
Name = d<br>
//End of file<br></p>
<p>Now I am able to define tokens for <strong>NameCount</strong> and <strong>Name</strong>. But i have to define the file structure i... | [
{
"answer_id": 308937,
"author": "boutta",
"author_id": 15108,
"author_profile": "https://Stackoverflow.com/users/15108",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure this is a context free grammar. If it isn't, you cannot tell ANTLR to parse the language.</p>\n"
},
{
... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27784/"
] | I have to define the grammar of a file like the one shown below.
//Sample file
NameCount = 4
Name = a
Name = b
Name = c
Name = d
//End of file
Now I am able to define tokens for **NameCount** and **Name**. But i have to define the file structure including the valid number of instances of token **N... | This cannot be expressed in the grammar itself. If the number was fix you could express the number of expected tokens. But the token stream changes based on the value. What you can do is to include this into the lexer/parser combination. But you cannot create this construct by just the plain grammar syntax. You probabl... |
308,826 | <p>The code below works. But if I comment out the line <code>Dim objRequest As MSXML2.XMLHTTP</code> and uncomment the line <code>Dim objRequest As Object</code> it fails with the error message :</p>
<blockquote>
<p>The parameter is incorrect</p>
</blockquote>
<p>Why, and what (if anything) can I do about it?</p>
... | [
{
"answer_id": 308841,
"author": "Corey Trager",
"author_id": 9328,
"author_profile": "https://Stackoverflow.com/users/9328",
"pm_score": 2,
"selected": false,
"text": "<p>If you use the Dim objRequest As Object then you would need to code:<br>\n Set objRequest = CreateObject(\"MSXML2... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39665/"
] | The code below works. But if I comment out the line `Dim objRequest As MSXML2.XMLHTTP` and uncomment the line `Dim objRequest As Object` it fails with the error message :
>
> The parameter is incorrect
>
>
>
Why, and what (if anything) can I do about it?
```
Public Function GetSessionId(strApiId, strUserName, st... | For some reason, this works:
```
Dim strPostData As String
Dim objRequest As Object
strPostData = "api_id=" & strApiId & "&user=" & strUserName & "&password=" & strPassword
Set objRequest = New MSXML2.XMLHTTP
With objRequest
.Open "POST", "https://api.clickatell.com/http/auth", False
.setRequestHeader "Content-T... |
308,832 | <p>How do I detect when an iOS app is launched for the first time?</p>
| [
{
"answer_id": 308846,
"author": "Marc Charbonneau",
"author_id": 35136,
"author_profile": "https://Stackoverflow.com/users/35136",
"pm_score": 2,
"selected": false,
"text": "<p>You can set a boolean value in the user defaults to do this. Set the key to false when you call <code>register... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36182/"
] | How do I detect when an iOS app is launched for the first time? | Pretty much what Marc and Chris said, though I prefer to change the value when the app quits in case there're multiple areas of the application that need to know about it.
In code:
**Objective-C**
```
// -applicationDidFinishLaunching:
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWi... |
308,833 | <p>I need to transform an Oracle SQL statement into a Stored Procedure therefore users with less privileges can access certain data field:</p>
<pre><code>SELECT
info_field, data_field
FROM
table_one
WHERE
some_id = '<id>' -- I need this <id> to be the procedure's parameter
UNION ALL
SELECT
... | [
{
"answer_id": 308883,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 1,
"selected": false,
"text": "<p>Is the expectation that, among all these tables, only one will have a match for a given ID?</p>\n\n<p>If no: You need... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6992/"
] | I need to transform an Oracle SQL statement into a Stored Procedure therefore users with less privileges can access certain data field:
```
SELECT
info_field, data_field
FROM
table_one
WHERE
some_id = '<id>' -- I need this <id> to be the procedure's parameter
UNION ALL
SELECT
info_field, data_field
FR... | If you just want to restrict users' access you could create a view and grant them select on the view but not the tables:
```
CREATE VIEW info_and_data AS
SELECT info_field, data_field
FROM table_one
UNION ALL
SELECT info_field, data_field
FROM table_two
UNION ALL
SELECT info_fie... |
308,835 | <p>I'm finding myself doing a lot of things with associative arrays in PHP.</p>
<p>I was doing this:</p>
<pre><code> foreach ($item as $key=>$value) {
if ($arr[$key] == null) {
$arr[$key] = 0;
}
$arr[$key] += $other_arr[$value];
}
</code></pre>
<p>But then I realised that it works fine i... | [
{
"answer_id": 308852,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 4,
"selected": true,
"text": "<p>It is safe but I'd recommend against it.\nIf you put your error reporting up to E_NOTICES you'll see your code producing a ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11522/"
] | I'm finding myself doing a lot of things with associative arrays in PHP.
I was doing this:
```
foreach ($item as $key=>$value) {
if ($arr[$key] == null) {
$arr[$key] = 0;
}
$arr[$key] += $other_arr[$value];
}
```
But then I realised that it works fine if I exclude the line that initialize... | It is safe but I'd recommend against it.
If you put your error reporting up to E\_NOTICES you'll see your code producing a lot of them, masking any real errors (such as a mistyped variable name).
What you should really be doing is:
```
if (!isset($arr[$key]))
$arr[$key] = 0;
```
This won't raise a notice (but b... |
308,837 | <p>I have the following table</p>
<pre><code><td class="style2">
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Location</asp:ListItem>
<asp:ListItem>Name</asp:ListItem>
<asp:ListItem>SSN</asp:ListItem>
</asp:DropDow... | [
{
"answer_id": 308852,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 4,
"selected": true,
"text": "<p>It is safe but I'd recommend against it.\nIf you put your error reporting up to E_NOTICES you'll see your code producing a ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38230/"
] | I have the following table
```
<td class="style2">
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Location</asp:ListItem>
<asp:ListItem>Name</asp:ListItem>
<asp:ListItem>SSN</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
... | It is safe but I'd recommend against it.
If you put your error reporting up to E\_NOTICES you'll see your code producing a lot of them, masking any real errors (such as a mistyped variable name).
What you should really be doing is:
```
if (!isset($arr[$key]))
$arr[$key] = 0;
```
This won't raise a notice (but b... |
308,850 | <p>Windows Forms:</p>
<p>For <code>System.Drawing</code> there is a way to get the font height. </p>
<pre><code>Font font = new Font("Arial", 10 , FontStyle.Regular);
float fontHeight = font.GetHeight();
</code></pre>
<p>But how do you get the other text metrics like average character width?</p>
| [
{
"answer_id": 308858,
"author": "Ramesh Soni",
"author_id": 191,
"author_profile": "https://Stackoverflow.com/users/191",
"pm_score": 3,
"selected": true,
"text": "<p>Use Graphics.MeasureString Method</p>\n\n<pre><code>private void MeasureStringMin(PaintEventArgs e)\n{\n\n // Set up ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28343/"
] | Windows Forms:
For `System.Drawing` there is a way to get the font height.
```
Font font = new Font("Arial", 10 , FontStyle.Regular);
float fontHeight = font.GetHeight();
```
But how do you get the other text metrics like average character width? | Use Graphics.MeasureString Method
```
private void MeasureStringMin(PaintEventArgs e)
{
// Set up string.
string measureString = "Measure String";
Font stringFont = new Font("Arial", 16);
// Measure string.
SizeF stringSize = new SizeF();
stringSize = e.Graphics.MeasureString(measureString, s... |
308,860 | <p>Are there any tools that auto-generate the hibernate POJOs by gathering information from the database?</p>
<p>I made a perl script to do this after the schema got changed for the third or fourth time in a project i'm working with and just wondered if there is any established tool that will do this for me as my scri... | [
{
"answer_id": 308899,
"author": "Paul Whelan",
"author_id": 3050,
"author_profile": "https://Stackoverflow.com/users/3050",
"pm_score": 0,
"selected": false,
"text": "<p>See hibernate tools</p>\n\n<p><a href=\"http://www.hibernate.org/hib_docs/tools/reference/en/html_single/\" rel=\"nof... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7780/"
] | Are there any tools that auto-generate the hibernate POJOs by gathering information from the database?
I made a perl script to do this after the schema got changed for the third or fourth time in a project i'm working with and just wondered if there is any established tool that will do this for me as my script is rath... | See [hibernate reverse engineering](https://docs.jboss.org/tools/latest/en/hibernatetools/html/reverseengineering.html) |
308,876 | <p>I am connecting to a MySQL DB trough a terminal who only have a program with an ODBC connection to a MySQL DB. I can put querys in the program, but not access MySQL directly.</p>
<p>I there a way to query the DB to obtain the list of fields in a table other than</p>
<pre><code>select * from table
</code></pre>
<p... | [
{
"answer_id": 308882,
"author": "Sebastian Hoitz",
"author_id": 9535,
"author_profile": "https://Stackoverflow.com/users/9535",
"pm_score": 2,
"selected": true,
"text": "<pre><code>describe *tablename*\n</code></pre>\n"
},
{
"answer_id": 308890,
"author": "Tomalak",
"aut... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2385/"
] | I am connecting to a MySQL DB trough a terminal who only have a program with an ODBC connection to a MySQL DB. I can put querys in the program, but not access MySQL directly.
I there a way to query the DB to obtain the list of fields in a table other than
```
select * from table
```
??
(don't know why but the sele... | ```
describe *tablename*
``` |
308,905 | <p>I've been reading that some devs/dbas recommend using transactions in all database calls, even read-only calls. While I understand inserting/updating within a transaction what is the benefit of reading within a transaction?</p>
| [
{
"answer_id": 308910,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 7,
"selected": true,
"text": "<p>So you get a consistent view of the database. Imagine you have two tables that link to each other, but for some reason you... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34133/"
] | I've been reading that some devs/dbas recommend using transactions in all database calls, even read-only calls. While I understand inserting/updating within a transaction what is the benefit of reading within a transaction? | So you get a consistent view of the database. Imagine you have two tables that link to each other, but for some reason you do 2 selects... in pseuodocode:
```
myRows = query(SELECT * FROM A)
moreRows = query(SELECT * FROM B WHERE a_id IN myRows[id])
```
If between the two queries, someone changes B to delete some ro... |
308,908 | <p>I have a data set that is organized in the following manner:</p>
<pre><code>Timestamp|A0001|A0002|A0003|A0004|B0001|B0002|B0003|B0004 ...
---------+-----+-----+-----+-----+-----+-----+-----+-----
2008-1-1 | 1 | 2 | 10 | 6 | 20 | 35 | 300 | 8
2008-1-2 | 5 | 2 | 9 | 3 | 50 | 38 | 290 | 2
2008... | [
{
"answer_id": 309274,
"author": "Brettski",
"author_id": 5836,
"author_profile": "https://Stackoverflow.com/users/5836",
"pm_score": 1,
"selected": false,
"text": "<p>OK, I have come up with one solution which should get you started. It will probably take some time to put together, but... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31326/"
] | I have a data set that is organized in the following manner:
```
Timestamp|A0001|A0002|A0003|A0004|B0001|B0002|B0003|B0004 ...
---------+-----+-----+-----+-----+-----+-----+-----+-----
2008-1-1 | 1 | 2 | 10 | 6 | 20 | 35 | 300 | 8
2008-1-2 | 5 | 2 | 9 | 3 | 50 | 38 | 290 | 2
2008-1-4 | 7 | ... | Same kinda answer here, that was fun:
```
-- Get column names from system table
DECLARE @phCols NVARCHAR(2000)
SELECT @phCols = COALESCE(@phCols + ',[' + name + ']', '[' + name + ']')
FROM syscolumns WHERE id = (select id from sysobjects where name = 'Test' and type='U')
-- Get rid of the column we don't want
SE... |
308,926 | <p>How can I verify a given xpath string is valid in C#/.NET?</p>
<p>I'm not sure just running the XPath and catching exceptions is a valid solution (putting aside the bile in my throat for a moment) - what if tomorrow I run into some other input I haven't tested against?</p>
| [
{
"answer_id": 308953,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 5,
"selected": true,
"text": "<blockquote>\n <p>How can I verify a given XPath string is valid in C#/.NET?</p>\n</blockquote>\n\n<p>You try to build an ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11236/"
] | How can I verify a given xpath string is valid in C#/.NET?
I'm not sure just running the XPath and catching exceptions is a valid solution (putting aside the bile in my throat for a moment) - what if tomorrow I run into some other input I haven't tested against? | >
> How can I verify a given XPath string is valid in C#/.NET?
>
>
>
You try to build an `XPathExpression` from it and catch the exception.
```
try
{
XPathExpression.Compile(xPathString);
}
catch (XPathException ex)
{
MessageBox.Show("XPath syntax error: " + ex.Message);
}
``` |
308,931 | <p>All, </p>
<p>I currently have my solution comprising of 2 Class librarys and a Web Site building within teamCity using Msbuild. Now I want to precompile the website and make it available as an artifact. However when i try to Precompile it using </p>
<pre><code><Target Name="PrecompileWeb" DependsOnTargets="Buil... | [
{
"answer_id": 308975,
"author": "Cory Foy",
"author_id": 4083,
"author_profile": "https://Stackoverflow.com/users/4083",
"pm_score": 3,
"selected": true,
"text": "<p>Is this a Web Site or Web Application Project? If the latter, instead of doing an AspNetCompiler task, do an MSBuild task... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11802/"
] | All,
I currently have my solution comprising of 2 Class librarys and a Web Site building within teamCity using Msbuild. Now I want to precompile the website and make it available as an artifact. However when i try to Precompile it using
```
<Target Name="PrecompileWeb" DependsOnTargets="Build">
<AspNetCompiler
... | Is this a Web Site or Web Application Project? If the latter, instead of doing an AspNetCompiler task, do an MSBuild task to the csproj/vbproj file, calling the targets `Rebuild;ResolveReferences;_CopyWebApplication` and specifying the `OutDir` property.
If you are using a website, then specify the VirtualPath to be a... |
308,935 | <p>I'm preparing a string that will be <code>eval</code>'ed. The string will contain a clause built from an existing <code>Array</code>. I have the following:</p>
<pre><code>def stringify(arg)
return "[ '" + arg.join("', '") + "' ]" if arg.class == Array
"'#{arg}'"
end
a = [ 'a', 'b', 'c' ]
eval_str = 'p ' + ... | [
{
"answer_id": 308956,
"author": "dylanfm",
"author_id": 38795,
"author_profile": "https://Stackoverflow.com/users/38795",
"pm_score": 0,
"selected": false,
"text": "<p>I may be misunderstanding you, but does this look better at all?</p>\n\n<pre><code>>> a = %w[a b c]\n=> [\"a\"... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39443/"
] | I'm preparing a string that will be `eval`'ed. The string will contain a clause built from an existing `Array`. I have the following:
```
def stringify(arg)
return "[ '" + arg.join("', '") + "' ]" if arg.class == Array
"'#{arg}'"
end
a = [ 'a', 'b', 'c' ]
eval_str = 'p ' + stringify(a)
eval(eval_str)
```
wh... | `inspect` should accomplish what you are wanting.
```
>> a = %w(a b c)
=> ["a", "b", "c"]
>> a.inspect
=> "[\"a\", \"b\", \"c\"]"
``` |