qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
307,502 | <p>When you run <code>top</code> and see all running processes, I've always wanted to know just what everything actually means. e.g. all the various single-letter state codes for a running process (R = Running, S = Sleeping, etc...)</p>
<p>Where can I find this?</p>
| [
{
"answer_id": 307506,
"author": "SMB",
"author_id": 26029,
"author_profile": "https://Stackoverflow.com/users/26029",
"pm_score": 4,
"selected": false,
"text": "man top"
},
{
"answer_id": 307529,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stac... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39529/"
] |
307,503 | <p>I've got a few Unix shell scripts where I need to check that certain environment variables are set before I start doing stuff, so I do this sort of thing:</p>
<pre><code>if [ -z "$STATE" ]; then
echo "Need to set STATE"
exit 1
fi
if [ -z "$DEST" ]; then
echo "Need to set DEST"
exit 1
fi
</code></pre>
<p>which is a lot of typing. Is there a more elegant idiom for checking that a set of environment variables is set?</p>
<p>EDIT: I should mention that these variables have no meaningful default value - the script should error out if any are unset.</p>
| [
{
"answer_id": 307527,
"author": "Vincent Van Den Berghe",
"author_id": 39259,
"author_profile": "https://Stackoverflow.com/users/39259",
"pm_score": 5,
"selected": false,
"text": "${MyVariable:=SomeDefault}\n"
},
{
"answer_id": 307540,
"author": "David Schlosnagle",
"aut... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2994/"
] |
307,512 | <pre><code>public static IQueryable<TResult> ApplySortFilter<T, TResult>(this IQueryable<T> query, string columnName)
where T : EntityObject
{
var param = Expression.Parameter(typeof(T), "o");
var body = Expression.PropertyOrField(param,columnName);
var sortExpression = Expression.Lambda(body, param);
return query.OrderBy(sortExpression);
}
</code></pre>
<p>Because the type for OrderBy is not inferred from sortExpression I need to specify it something like this at run time:</p>
<pre><code>var sortExpression = Expression.Lambda<T, TSortColumn>(body, param);
</code></pre>
<p>Or</p>
<pre><code>return query.OrderBy<T, TSortColumn>(sortExpression);
</code></pre>
<p>I don't think this is possible however as TSortColumn can only be determined during runtime.</p>
<p>Is there a way around this?</p>
| [
{
"answer_id": 307599,
"author": "JTew",
"author_id": 25372,
"author_profile": "https://Stackoverflow.com/users/25372",
"pm_score": 3,
"selected": false,
"text": "// ***** OrderBy(company => company) *****\n// Create an expression tree that represents the expression\n// 'whereCallExpress... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25372/"
] |
307,514 | <p>Can you program/configure Visual Studio to produce custom intellisense for your own server controls.</p>
<p>eg can you get it to do this:</p>
<p><a href="http://www.yart.com.au/test/vs.gif" rel="nofollow noreferrer">alt text http://www.yart.com.au/test/vs.gif</a></p>
<p>for a tag of your own like:</p>
<pre><code><MyCompany:MyTag ...
</code></pre>
| [
{
"answer_id": 307585,
"author": "HectorMac",
"author_id": 1400,
"author_profile": "https://Stackoverflow.com/users/1400",
"pm_score": 3,
"selected": true,
"text": "[EditorBrowsableAttribute (EditorBrowsableState.Never)] \n"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/307514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24696/"
] |
307,531 | <p>With code like the following, sometimes the child controls correctly finish their animation and sometimes they stop at random places in the middle. Why don't they work correctly?</p>
<pre><code>var t:Tween;
t = new Tween(child1,"x",Elastic.easeOut,0,100,2,true);
t = new Tween(child1,"y", Elastic.easeOut,0,100,2,true);
t = new Tween(child2,"x",Strong.easeOut,300,400,1,true);
t = new Tween(child2,"y", Strong.easeOut,300,400,1,true);
</code></pre>
| [
{
"answer_id": 307535,
"author": "Eric",
"author_id": 4540,
"author_profile": "https://Stackoverflow.com/users/4540",
"pm_score": 2,
"selected": false,
"text": "var t1:Tween = new Tween(child1,\"x\",Elastic.easeOut,0,100,2,true);\nvar t2:Tween = new Tween(child1,\"y\", Elastic.easeOut,0,... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4540/"
] |
307,579 | <p>I've got two branches that are fully merged together.</p>
<p>However, after the merge is done, I realise that one file has been messed up by the merge (someone else did an auto-format, gah), and it would just be easier to change to the new version in the other branch, and then reinsert my one line change after bringing it over into my branch.</p>
<p>So what's the easiest way in Git to do this?</p>
| [
{
"answer_id": 307872,
"author": "madlep",
"author_id": 14160,
"author_profile": "https://Stackoverflow.com/users/14160",
"pm_score": 12,
"selected": true,
"text": "git checkout otherbranch myfile.txt\n"
},
{
"answer_id": 2392772,
"author": "RzR",
"author_id": 149841,
... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14160/"
] |
307,581 | <p>Relatively new to rails and trying to model a very simple family "tree" with a single Person model that has a name, gender, father_id and mother_id (2 parents). Below is basically what I want to do, but obviously I can't repeat the :children in a has_many (the first gets overwritten).</p>
<pre><code>class Person < ActiveRecord::Base
belongs_to :father, :class_name => 'Person'
belongs_to :mother, :class_name => 'Person'
has_many :children, :class_name => 'Person', :foreign_key => 'mother_id'
has_many :children, :class_name => 'Person', :foreign_key => 'father_id'
end
</code></pre>
<p>Is there a simple way to use has_many with 2 foreign keys, or maybe change the foreign key based on the object's gender? Or is there another/better way altogether?</p>
<p>Thanks!</p>
| [
{
"answer_id": 307660,
"author": "Gordon Wilson",
"author_id": 23071,
"author_profile": "https://Stackoverflow.com/users/23071",
"pm_score": 3,
"selected": false,
"text": "class Person < ActiveRecord::Base\n has_one :father, :class_name => 'Person', :foreign_key => 'father_id'\n has_on... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13636/"
] |
307,582 | <p>I have code running in a loop and it's saving state based on the current time. Sometimes this can be just milliseconds apart, but for some reason it seems that DateTime.Now will always return values of at least 10 ms apart even if it's only 2 or 3 ms later. This presents a major problem since the state i'm saving depends on the time it was saved (e.g. recording something)</p>
<p>My test code that returns each value 10 ms apart:</p>
<pre><code>public static void Main()
{
var dt1 = DateTime.Now;
System.Threading.Thread.Sleep(2);
var dt2 = DateTime.Now;
// On my machine the values will be at least 10 ms apart
Console.WriteLine("First: {0}, Second: {1}", dt1.Millisecond, dt2.Millisecond);
}
</code></pre>
<p>Is there another solution on how to get the accurate current time up to the millisecond ?</p>
<p>Someone suggested to look at the Stopwatch class. Although the Stopwatch class is very accurate it does not tell me the current time, something i need in order to save the state of my program.</p>
| [
{
"answer_id": 4962857,
"author": "Roman Starkov",
"author_id": 33080,
"author_profile": "https://Stackoverflow.com/users/33080",
"pm_score": 5,
"selected": false,
"text": "Thread.Sleep(1)"
},
{
"answer_id": 28867997,
"author": "Hesein Burg",
"author_id": 4302185,
"au... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
307,596 | <p>Does anyone know how to calculate time difference in C++ in milliseconds?
I used <a href="http://linux.die.net/man/3/difftime" rel="noreferrer"><code>difftime</code></a> but it doesn't have enough precision for what I'm trying to measure.</p>
| [
{
"answer_id": 307604,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 2,
"selected": false,
"text": "gettimeofday"
},
{
"answer_id": 307607,
"author": "Tyler McHenry",
"author_id": 39375,
"author_profile... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23084/"
] |
307,610 | <p>I keep seeing people say that exceptions are slow, but I never see any proof. So, instead of asking if they are, I will ask how do exceptions work behind the scenes, so I can make decisions of when to use them and whether they are slow.</p>
<p>From what I know, exceptions are the same as doing a return bunch of times, except that it also checks after each return whether it needs to do another one or to stop. How does it check when to stop returning? I guess there is a second stack that holds the type of the exception and a stack location, it then does returns until it gets there. I am also guessing that the only time this second stack is touched is on a throw and on each try/catch. AFAICT implementing a similar behaviour with return codes would take the same amount of time. But this is all just a guess, so I want to know what really happens.</p>
<p>How do exceptions really work?</p>
| [
{
"answer_id": 307716,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 8,
"selected": true,
"text": "class MyException\n{\npublic:\n MyException() { }\n ~MyException() { }\n};\n\nvoid my_throwing_function(bool throwit)\... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
307,619 | <p>My code works (yeah!) which sends json to a server.. would appreciate any thoughts on refactoring</p>
<p>1) My C# code sends this json to the server</p>
<p>{\"firstName\":\"Bill\",\"lastName\":\"Gates\",\"email\":\"asdf@hotmail.com\",\"deviceUUID\":\"abcdefghijklmnopqrstuvwxyz\"}</p>
<p>Which I have to get rid of the slashes on the server side....not good.</p>
<p>2) I'm using application/x-www-form-urlencoded and probably want to be using application/json</p>
<pre><code>Person p = new Person();
p.firstName = "Bill";
p.lastName = "Gates";
p.email = "asdf@hotmail.com";
p.deviceUUID = "abcdefghijklmnopqrstuvwxyz";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(targetUri + "newuser.php");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
//TODO request.ContentType = "application/json";
JavaScriptSerializer serializer = new JavaScriptSerializer();
string s = serializer.Serialize(p);
textBox3.Text = s;
string postData = "json=" + HttpUtility.UrlEncode(s);
byte[] byteArray = Encoding.ASCII.GetBytes(postData);
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close ();
WebResponse response = request.GetResponse();
//textBox4.Text = (((HttpWebResponse)response).StatusDescription);
dataStream = response.GetResponseStream ();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd ();
textBox4.Text += responseFromServer;
reader.Close ();
dataStream.Close ();
response.Close ();
</code></pre>
<p>PHP Code on Server:</p>
<pre><code>$inbound = $_POST['json'];
// this strips out the \
$stripped = stripslashes($inbound);
$json_object = json_decode($stripped);
echo $json_object->{'firstName'};
echo $json_object->{'lastName'};
echo $json_object->{'email'};
echo $json_object->{'deviceUUID'};
</code></pre>
| [
{
"answer_id": 307683,
"author": "Dave Mateer",
"author_id": 26086,
"author_profile": "https://Stackoverflow.com/users/26086",
"pm_score": 0,
"selected": false,
"text": "$inbound = $_POST['json'];\nvar_dump($inbound);\n"
},
{
"answer_id": 307878,
"author": "Dave Mateer",
... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26086/"
] |
307,623 | <p>I'm writing some RSS feeds in PHP and stuggling with character-encoding issues. Should I utf8_encode() before or after htmlentities() encoding? For example, I've got both ampersands and Chinese characters in a description element, and I'm not sure which of these is proper:</p>
<pre><code>$output = utf8_encode(htmlentities($source)); or
$output = htmlentities(utf8_encode($source));
</code></pre>
<p>And why?</p>
| [
{
"answer_id": 307630,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 1,
"selected": false,
"text": "$output = htmlentities(utf8_encode($source));"
},
{
"answer_id": 307641,
"author": "Eran Galperin",
"autho... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17307/"
] |
307,636 | <p>I am able to create and execute a DTS package that copies tables from a remote Oracle database to a local SQL server, but want to setup the connection to the Oracle database as a linked server.</p>
<p>The DTS package currently uses the <em>Microsoft OLE DB Provider for Oracle</em> with the following properties:</p>
<ul>
<li>Data Source: <code>SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.3.42)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=acc)));uid=*UserName*;pwd=*UserPassword*;</code></li>
<li>Password: <em>UserPassword</em></li>
<li>User ID: <em>UserName</em></li>
<li>Allow saving password: true</li>
</ul>
<p>How do I go about setting a linked server to an Oracle database using the data source defined above?</p>
| [
{
"answer_id": 319018,
"author": "Oppositional",
"author_id": 2029,
"author_profile": "https://Stackoverflow.com/users/2029",
"pm_score": 6,
"selected": true,
"text": "C:\\Oracle"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/307636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2029/"
] |
307,640 | <p><strong>Edited:</strong>
What is the easiest way to <s>scrape</s> extract SharePoint list data to a separate SQL Server table? One condition: you're in a work environment where you don't control the SQL Server behind the SharePoint Server, so you can't just pull from the <em>UserData</em> table. </p>
<p>Is there there any utilities that you can use to schedule a nightly extract? </p>
<p>Is Microsoft planning any improvement here for "SharePoint 4"?</p>
<p><strong>Update Jan 06, 2009:</strong><br>
<a href="http://connectionstrings.com/sharepoint" rel="noreferrer">http://connectionstrings.com/sharepoint</a><br>
For servers where office is not installed you will need:<br>
<a href="http://www.microsoft.com/downloads/details.aspx?familyid=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en" rel="noreferrer">this download</a></p>
| [
{
"answer_id": 4301806,
"author": "Ulf",
"author_id": 523618,
"author_profile": "https://Stackoverflow.com/users/523618",
"pm_score": 2,
"selected": false,
"text": "My Custom SharePoint List"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/307640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] |
307,650 | <p>How can I remove duplicate values from an array in PHP?</p>
| [
{
"answer_id": 307655,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 9,
"selected": true,
"text": "$array = array(1, 2, 2, 3);\n$array = array_unique($array); // Array is now (1, 2, 3)\n"
},
{
"answer_id": 2397157,... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39539/"
] |
307,656 | <p>I have a C#.net winform program which runs with a SQL Server database. I am using LINQ-to-SQL. Is it possible to rollback the call to one or more stored procedures inside a transaction within my program using LINQ-to-SQL? </p>
<p>Initially I thought it would make sense to manage the transaction inside the stored procedure but if I need to rollback more than one stored procedure call as part of a single transaction it would need to be done in my C# program.</p>
<p>Can someone point me to a code snippet on how to do this or provide some insight into an alternative?</p>
| [
{
"answer_id": 307682,
"author": "Andre Gallo",
"author_id": 14401,
"author_profile": "https://Stackoverflow.com/users/14401",
"pm_score": -1,
"selected": false,
"text": " public Response<SomeObject> SaveSomething(Object yourObject)\n {\n DbTransaction dbTransaction = null;\... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
307,658 | <p>I find myself running scripts and copy-pasting the output of these runs into emails or into some other documents. Is there a way such that I can make the copy-to-clipboard step a part of the script itself? Most of my scripts are either Perl or bat files and I work on Windows. </p>
<p>Thanks.</p>
| [
{
"answer_id": 307668,
"author": "digitalsanctum",
"author_id": 22436,
"author_profile": "https://Stackoverflow.com/users/22436",
"pm_score": 0,
"selected": false,
"text": "somescript.bat > output.txt\n"
},
{
"answer_id": 307690,
"author": "Blair Conrad",
"author_id": 119... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27928/"
] |
307,664 | <p>Say I have a user control like the one below, how would I bind something to the <code>ActualWidth</code> of the "G1" grid from outside of the control?</p>
<pre><code><UserControl x:Class="Blah">
<WrapPanel>
<Grid x:Name="G1">
...
</Grid>
<Grid>
...
</Grid>
</WrapPanel>
</UserControl>
</code></pre>
| [
{
"answer_id": 307677,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 1,
"selected": false,
"text": "DependencyProperty"
},
{
"answer_id": 308385,
"author": "Arcturus",
"author_id": 900,
"author_profile":... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36074/"
] |
307,669 | <p>I am trying to write an rspec test for a controller that accesses a
model Group.</p>
<pre>
@request.env['HTTP_REFERER'] = group_url(@mock_group) ### Line 49
</pre>
<p>I get this:</p>
<pre>
NoMethodError in 'ActsController responding to create should redirect to :back'
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.rewrite
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:621:in `url_for'
(eval):17:in `group_url'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/test_process.rb:464:in `send!'
/Library/Ruby/Gems/1.8/gems/actionpack-2.1.0/lib/action_controller/test_process.rb:464:in `method_missing'
</pre>
<p>This line in url_for is the problem; specfically @url is nil.</p>
<pre>
@url.rewrite(rewrite_options(options))
</pre>
<p>And it seems that @url is initialized here:</p>
<pre>
def initialize_current_url
@url = UrlRewriter.new(request, params.clone)
end
</pre>
| [
{
"answer_id": 344892,
"author": "Matt Burke",
"author_id": 29691,
"author_profile": "https://Stackoverflow.com/users/29691",
"pm_score": 2,
"selected": false,
"text": "it \"should do whatever when referrer is group thing\" do\n @request.env[\"HTTP_REFERER\"] = url_for(@mock_group)\n g... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
307,674 | <p>How can I remove duplicate values from a multi-dimensional array in PHP?</p>
<p>Example array:</p>
<pre><code>Array
(
[0] => Array
(
[0] => abc
[1] => def
)
[1] => Array
(
[0] => ghi
[1] => jkl
)
[2] => Array
(
[0] => mno
[1] => pql
)
[3] => Array
(
[0] => abc
[1] => def
)
[4] => Array
(
[0] => ghi
[1] => jkl
)
[5] => Array
(
[0] => mno
[1] => pql
)
)
</code></pre>
| [
{
"answer_id": 307701,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 4,
"selected": false,
"text": "\nfunction multi_unique($array) {\n foreach ($array as $k=>$na)\n $new[$k] = serialize($na);\n $uniq = array_... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39539/"
] |
307,679 | <p>On PHP, they have a way to restrict file size AFTER uploading, but not BEFORE uploading. I use the <a href="http://malsup.com/jquery/form/" rel="noreferrer">Malsup jQuery Form Plugin</a> for my form posting, and it supports image file posting.</p>
<p>I was wondering if perhaps there's a restriction where I can set how many bytes can pass through that AJAX stream up to the server? That could permit me to check that file size and return an error if the file is too big. </p>
<p>By doing this on the client side, it blocks those newbies who take a 10MB photo shot from their Pentax and try to upload that.</p>
| [
{
"answer_id": 307861,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "Requested content-length of 4000107 is larger than the configured limit of 2097152\n"
},
{
"answer_id": 3243161,
"... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
307,688 | <p>What is a simple way of downloading a file from a URL path?</p>
| [
{
"answer_id": 307697,
"author": "vbroto",
"author_id": 20837,
"author_profile": "https://Stackoverflow.com/users/20837",
"pm_score": 7,
"selected": false,
"text": "System.Net.WebClient.DownloadFile"
},
{
"answer_id": 308336,
"author": "Raj Kumar",
"author_id": 38931,
... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20837/"
] |
307,692 | <p>I would like to know the simplest and most effective way to open and write data to a socket in the C programming language for network programming.</p>
| [
{
"answer_id": 35681089,
"author": "Ciro Santilli OurBigBook.com",
"author_id": 895245,
"author_profile": "https://Stackoverflow.com/users/895245",
"pm_score": 3,
"selected": false,
"text": "./server.out\n"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/307692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] |
307,695 | <p>Being new to Cocoa, and probably not knowing all of the potential classes available that already have this functionality neatly wrapped in an OO class, here's an algorithm inquiry. What's the best bet to count how many times a particular key occurs in an array of multiple <code>NSDictionary</code> instances?</p>
<p>Essentially my data structure (in this case an <code>NSArray</code>) might contain several <code>NSDictionary</code> instances at any given time, each one having the same keys, potentially different values. Some values repeat. I'd like to be able to know how many times a particular key/value appears. Example:</p>
<pre><code>{
foo => 1,
bar => 2
}
{
foo => 1,
bar => 3
}
{
foo => 2,
bar => 1
}
</code></pre>
<p>In this case I'm interested that <code>foo=>1</code> occured 2 times and <code>foo=>2</code> occured 1 time. Is building an instance of <code>NSCountedSet</code> the best way to go about this? Perhaps a C linked-list?</p>
| [
{
"answer_id": 307824,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 3,
"selected": true,
"text": "NSDictionary * dict1 = [[NSDictionary alloc] initWithObjectsAndKeys:\n [NSNumber numberWithInt:1], @... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
307,706 | <p>Is there any easy way to add a using statement to every class I create in a project without having to write</p>
<pre><code>using SomeNamespace;
</code></pre>
<p>in every file?</p>
<p>[edit]
I could add a template I realise but I'm talking about doing it for every file in an existing project.</p>
| [
{
"answer_id": 307710,
"author": "EndangeredMassa",
"author_id": 106,
"author_profile": "https://Stackoverflow.com/users/106",
"pm_score": 0,
"selected": false,
"text": "<system.web>\n <pages>\n <namespaces>\n <add namespace=\"System.IO\" />\n ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6084/"
] |
307,709 | <p>When working with Silverlight, I've noticed that Firefox will cache the XAP file, so if I do an update, a user may be stuck using an outdated version. Is there a way to force the browser to either re-download the XAP file every time, or maybe only force it to after an update has been published? Or is there a setting in the Silverlight config that stops the browser from caching the XAP file altogether?</p>
<p>Thanks,
jeff</p>
| [
{
"answer_id": 307781,
"author": "Jarett Millard",
"author_id": 15882,
"author_profile": "https://Stackoverflow.com/users/15882",
"pm_score": 2,
"selected": false,
"text": "Cache-control: no-cache\nPragma: no-cache\n"
},
{
"answer_id": 310523,
"author": "Kevin Moore",
"au... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12172/"
] |
307,729 | <pre><code>class Ball:
a = []
def __init__(self):
pass
def add(self,thing):
self.a.append(thing)
def size(self):
print len(self.a)
for i in range(3):
foo = Ball()
foo.add(1)
foo.add(2)
foo.size()
</code></pre>
<p>I would expect a return of :</p>
<pre><code>2
2
2
</code></pre>
<p>But I get :</p>
<pre><code>2
4
6
</code></pre>
<p>Why is this? I've found that by doing a=[] in the <strong>init</strong>, I can route around this behavior, but I'm less than clear why.</p>
| [
{
"answer_id": 307775,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "class Ball:\n def __init__(self):\n self.a = []\n"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/307729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35335/"
] |
307,737 | <p>I've got this problem with dynamically created TextBox.</p>
<p>When the TextBox is created in PageLoad, it's TextChanged event was fired.<br>
But when I dynamically delete and recreated the TextBox, the TextChanged was not fired.</p>
<p>This is the code:</p>
<p><strong>.aspx file</strong></p>
<pre><code><body>
<form id="form1" runat="server">
<div>
<asp:Table ID="Table1" runat="server">
<asp:TableRow>
<asp:TableCell ColumnSpan="2">Fixed content</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>
</code></pre>
<p><strong>.cs file</strong></p>
<pre><code>public partial class test : System.Web.UI.Page
{
string myText = "a";
protected void Page_Load(object sender, EventArgs e)
{
WriteRows();
}
private void WriteRows()
{
TableRow tr = new TableRow();
TableCell tc = new TableCell();
TextBox txt = new TextBox();
txt.Text = myText;
txt.TextChanged += new EventHandler(txt_TextChanged); // Assign event handler
tc.Controls.Add(txt);
tr.Controls.Add(tc);
tc = new TableCell();
tc.Text = txt.Text;
tr.Controls.Add(tc);
Table1.Controls.AddAt(1, tr);
}
private void txt_TextChanged(object sender, EventArgs e)
{
myText = ((TextBox)sender).Text;
RedrawTable(); // Delete the row (incl. the TextBox) and rewrite it
}
private void RedrawTable()
{
Table1.Controls.RemoveAt(1);
WriteRows();
}
}
</code></pre>
<p>Does anyone have a solution so that the event is always fired?</p>
| [
{
"answer_id": 307817,
"author": "Howard Pinsley",
"author_id": 7961,
"author_profile": "https://Stackoverflow.com/users/7961",
"pm_score": 1,
"selected": false,
"text": " \"The process that matches controls to posted values occurs \n after page_load completes, so it has to o... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36036/"
] |
307,740 | <p>In asp.net mvc, when do we use:</p>
<p>and</p>
<p>Do we ever need to put a ; (colon) ?</p>
| [
{
"answer_id": 307754,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": true,
"text": "<%= %>"
},
{
"answer_id": 307834,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "h... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] |
307,763 | <p>In VB6, ActiveX DLL is listed as a project template but in VS 2005+ there is no such thing. Where is my good old ActiveX DLL template? Many thanks in advance.</p>
| [
{
"answer_id": 308741,
"author": "RS Conley",
"author_id": 7890,
"author_profile": "https://Stackoverflow.com/users/7890",
"pm_score": 2,
"selected": false,
"text": "<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _\nPublic Class ComClass1\n\n#Region \"COM GUIDs\... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8203/"
] |
307,765 | <p>I was thinking along the lines of using <code>typeid()</code> but I don't know how to ask if that type is a subclass of another class (which, by the way, is abstract)</p>
| [
{
"answer_id": 307779,
"author": "Howard Pinsley",
"author_id": 7961,
"author_profile": "https://Stackoverflow.com/users/7961",
"pm_score": -1,
"selected": false,
"text": "if (myObj is Car) {\n\n}\n"
},
{
"answer_id": 307793,
"author": "Dima",
"author_id": 13313,
"aut... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39189/"
] |
307,766 | <p>I'm trying to convert a Web Site to the Web Application project model and I'm running into compile errors that do not seem to be covered by the guidance I found at <a href="http://msdn.microsoft.com/en-us/library/aa983476.aspx" rel="nofollow noreferrer">Converting a Web Site Project to a Web Application Project</a>.</p>
<p>The issue is that standard ASP.NET controls that are embedded as child controls within the ContentTemplate of the Ajax Control Toolkit's TabContainer/TabPanel are no longer visible to the page (and result in compile errors). It appears that they can only be referenced with a call to FindControl whereas, when the project was a Web Site, they were directly accessible in the page's code behind file as properties.</p>
<p>Unfortunately, we have a lot of webforms that utilize the TabContainer, and converting all the references to child controls from simple property refences to FindControl calls will be quite burdensome.</p>
<p>While researching the problem I found a reference to a property called TemplateInstance in <a href="http://www.nikhilk.net/SingleInstanceTemplates.aspx" rel="nofollow noreferrer">Single Instance Templates</a> that seemed promising, but I understand that this is applicable to control designers, not control users. Any help would be much appreciated.</p>
| [
{
"answer_id": 307779,
"author": "Howard Pinsley",
"author_id": 7961,
"author_profile": "https://Stackoverflow.com/users/7961",
"pm_score": -1,
"selected": false,
"text": "if (myObj is Car) {\n\n}\n"
},
{
"answer_id": 307793,
"author": "Dima",
"author_id": 13313,
"aut... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7961/"
] |
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": "ZipInputStream inStream = new ZipInputStream(File.OpenRead(fileName));\n\nwhile (inStream.GetNextEntry())\n{\n\n ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20837/"
] |
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="blah0"</code> to change all images to <code>'blah.jpg'</code> when clicked.
Similarly, clicking the div with <code>id ="blah1"</code> should change all images to <code>'ha.jpg'</code>.</p>
<p>However, the anonymous function won't work because it will use the value of 'i' at the time of execution, i.e. 2. This means that clicking either div will try and set all images to arr[2] - a non-existent element (interestingly not throwing a JS error on my machine but that's another story...).</p>
<p>How can I get the anonymous function to be created using the value of 'i' at declaration time?</p>
<p>As a simpler example:</p>
<pre><code>for (var i=0; i<10; i++)
{
$('div#blah'+i).click(function() {
alert(i)); });
}
</code></pre>
<p>This should display '0' when I click 'blah0', '1' when I click 'blah1' etc.</p>
<p>However, by default it will display '10' no matter which 'blah' i click.</p>
| [
{
"answer_id": 307786,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 0,
"selected": false,
"text": "\nvar j = 0;\nfor (var i=0; i<array.length; i++)\n{\n $('div#blah' + j).click(function() {\n $('img').att... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] |
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": "AUTOTEST"
},
{
"answer_id": 4435801,
"author": "sent-hil",
"author_id": 236655,
"author_profile": "... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42413/"
] |
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>Update: Thanks a lot! I realise that my question missed the fact that the references are in each file of a website and I wanted to do it recursively in all files/folders.</p>
| [
{
"answer_id": 307815,
"author": "Brian C. Lane",
"author_id": 27461,
"author_profile": "https://Stackoverflow.com/users/27461",
"pm_score": 2,
"selected": false,
"text": "sed -i 's/php3/php/g' *"
},
{
"answer_id": 307816,
"author": "Jonathan Leffler",
"author_id": 15168,... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13007/"
] |
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 be raised at:</p>
<pre><code>00:20
00:40
01:00
01:20
01:40
</code></pre>
<p>and so on. The best way I can think of to do this is by creating a loop on a thread, that constantly checks if the time is divisible by a given interval and raises a callback event if the time is reached. I feel like there has got to be a better way. </p>
<p>I'd use a <code>Timer</code> but I'd prefer something that follows a "schedule" that runs on the hour or something along those lines. </p>
<p>Without setting up my application in the windows task scheduler is this possible?</p>
<p><strong>UPDATE:</strong><br>
I'm adding my algorithm for calculating the time interval for a timer. This method takes a "<code>minute</code>" parameter, which is what time the timer should trigger a tick. For example, if the "<code>minute</code>" parameter is 20, then the timer will tick at the intervals in the timetable above.</p>
<pre><code>int CalculateTimerInterval(int minute)
{
if (minute <= 0)
minute = 60;
DateTime now = DateTime.Now;
DateTime future = now.AddMinutes((minute - (now.Minute % minute))).AddSeconds(now.Second * -1).AddMilliseconds(now.Millisecond * -1);
TimeSpan interval = future - now;
return (int)interval.TotalMilliseconds;
}
</code></pre>
<p>This code is used as follows: </p>
<pre><code>static System.Windows.Forms.Timer t;
const int CHECK_INTERVAL = 20;
static void Main()
{
t = new System.Windows.Forms.Timer();
t.Interval = CalculateTimerInterval(CHECK_INTERVAL);
t.Tick += new EventHandler(t_Tick);
t.Start();
}
static void t_Tick(object sender, EventArgs e)
{
t.Interval = CalculateTimerInterval(CHECK_INTERVAL);
}
</code></pre>
| [
{
"answer_id": 307806,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 6,
"selected": true,
"text": "int minutes = DateTime.Now.Minute;\nint adjust = 10 - (minutes % 10);\ntimer.Interval = adjust * 60 * 1000; \n"
},
... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] |
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 Sender, EventArgs e)
{
if(Application["username"] == null)
{
Response.redirect("login.aspx");
}
}
</code></pre>
<p>The problem is that this site has multiple sub-roots. That is, <a href="http://example.com/site1" rel="noreferrer">http://example.com/site1</a> is a completely different website from <a href="http://example.com/site2" rel="noreferrer">http://example.com/site2</a> . Therefore, I would like said Application_Start function to work on site1 but not affect site2.</p>
<p>If global.asax was customizable at directory level, then this wouldn't be a problem. But since there is only one global.asax per <i>server</i> I cannot implement this solution.</p>
<p>What alternatives are there to global.asax? or can global.asax be different somehow for each directory?</p>
| [
{
"answer_id": 307822,
"author": "Alexander Bird",
"author_id": 10608,
"author_profile": "https://Stackoverflow.com/users/10608",
"pm_score": 4,
"selected": true,
"text": "response.redirect(\"login.aspx\")"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/307821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10608/"
] |
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</code> was never added to the repository in the first place?</p>
| [
{
"answer_id": 308355,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 0,
"selected": false,
"text": "git filter-branch"
},
{
"answer_id": 308684,
"author": "CB Bailey",
"author_id": 19563,
"author_profile... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27314/"
] |
307,832 | <p>I would like to learn the best practices in reloading the application state, such that when my app is started, it should automatically load the "correct" view/subview when it is opened again.</p>
<p>In my particular case, my app has a bunch of view controllers, each taking care of a UITableView. I would like for my app to "jump" to the correct node within my table view hierarchy when it is opened again.</p>
| [
{
"answer_id": 307880,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 4,
"selected": true,
"text": "[navigationController pushViewController: viewController animated: NO]"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/307832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35478/"
] |
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(0, 0, 100, 25);
btn.backgroundColor = [UIColor clearColor];
[btn setTitle:@"Play" forState:UIControlStateNormal];
[btn addTarget:self action:@selector(buttonClick:)
forControlEvents:UIControlEventTouchUpInside];
btn.center = self.center;
[self addSubview:btn];
}
return self;
}
</code></pre>
| [
{
"answer_id": 3888919,
"author": "NguyenHungA5",
"author_id": 470028,
"author_profile": "https://Stackoverflow.com/users/470028",
"pm_score": 1,
"selected": false,
"text": "btn"
},
{
"answer_id": 9774714,
"author": "kumar123",
"author_id": 579511,
"author_profile": "... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30099/"
] |
307,855 | <p>So, I'm working on some network programming in C, and it would seem that I am missing a bunch of standard C/C++ header files. For example, <code>sys/socket.h</code> is not there. A few otheres are missing too like <code>netdb.h</code>, and <code>unistd.h</code>. Is there a pack I need to install to get these on windows?</p>
<p>Thanks</p>
| [
{
"answer_id": 307902,
"author": "Alex B",
"author_id": 23643,
"author_profile": "https://Stackoverflow.com/users/23643",
"pm_score": 3,
"selected": true,
"text": "#define strtok_r strtok_s"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/307855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] |
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 documentation:</p>
<pre><code>- (void)viewWillAppear:(BOOL)animated {
[tableView scrollToNearestSelectedRowAtScrollPosition:UITableViewScrollPositionTop animated:NO];
}
</code></pre>
<p>Is this the wrong approach here?</p>
| [
{
"answer_id": 307922,
"author": "August",
"author_id": 30966,
"author_profile": "https://Stackoverflow.com/users/30966",
"pm_score": 3,
"selected": false,
"text": "scrollToRowAtIndexPath:atScrollPosition:animated:\n"
},
{
"answer_id": 307960,
"author": "Mike McMaster",
"... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35478/"
] |
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": "CC=g++\nCFLAGS=-c -Wall\nLDFLAGS=\nSOURCES=main.cpp hello.cpp\nOBJECTS=$(SOURCES:.cpp=.o)\nEXECUTABLE=hello\n\nall: $(S... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
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 { display: table-row; }
div.cell { display: table-cell; }
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://dev.jquery.com/view/tags/ui/latest/ui/ui.core.js"></script>
<script src="http://dev.jquery.com/view/tags/ui/latest/ui/ui.draggable.js"></script>
<script>
$(document).ready(function(){
$(".row").draggable();
});
</script>
<body>
<div class='table'>
<div class='row'>
<div class='cell'>Foo</div>
<div class='cell'>Bar</div>
</div>
<div class='row'>
<div class='cell'>Spam</div>
<div class='cell'>Eggs</div>
</div>
</div>
<table>
<tr class'row'><td>Foo</td><td>Bar</td></tr>
<tr class='row'><td>Spam</td><td>Eggs</td></tr>
</table>
</body>
</html>
</code></pre>
<p>I'm was wondering a) if there's any specific reason why this doesn't work (from a w3c/HTML spec perspective) and b) what the right way to go about getting draggable table rows is.</p>
<p>I like real tables because of the border collapsing and row height algorithm -- any alternative that can do those things would work fine.</p>
| [
{
"answer_id": 2231845,
"author": "Ariel Popovsky",
"author_id": 29804,
"author_profile": "https://Stackoverflow.com/users/29804",
"pm_score": 5,
"selected": false,
"text": "helper: function(event){\nreturn $('<div class=\"drag-cart-item\"><table></table></div>').find('table').append($(e... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] |
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": "SELECT * FROM authors WHERE name = @name_param \n AND string = 'don\\'t use @name_param';\n"
},
{
"answer_id"... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
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": "Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a directory, then the directory... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20498/"
] |
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> and <code>$dbh->{Name}</code> only reports the database that I initially connected to.</p>
<p>Is there any trick or do I need to keep track of the database name?</p>
| [
{
"answer_id": 307972,
"author": "ysth",
"author_id": 17389,
"author_profile": "https://Stackoverflow.com/users/17389",
"pm_score": 1,
"selected": false,
"text": "($dbname) = (each %{$dbh->selectrow_hashref(\"show tables\")}) =~ /^Tables_in_(.*)/;\n"
},
{
"answer_id": 307975,
... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4704/"
] |
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 table already exists, because it went ahead and tried to create my table and ignored the conditional statement. Just try running the following statement twice, you'll see what I mean:</p>
<pre><code>IF NOT EXISTS (
SELECT 1
FROM sysobjects
WHERE name = 'a_table'
AND type = 'U'
)
CREATE TABLE a_table (
col1 int not null,
col2 int null
)
GO
</code></pre>
<p>Running the above produces the following error:</p>
<blockquote>
<p><em>SQL Server Error on (localhost)
Error:2714 at Line:7 Message:There is
already an object named 'a_table' in
the database.</em></p>
</blockquote>
<p>What's the deal with that?!</p>
| [
{
"answer_id": 307958,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": -1,
"selected": false,
"text": "IF object_id('a_table') IS NULL\nBEGIN\n CREATE TABLE a_table (\n col1 int not null,\n col2 int null... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1030/"
] |
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": "IF object_id('a_table') IS NULL\nBEGIN\n CREATE TABLE a_table (\n col1 int not null,\n col2 int null... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1264322/"
] |
307,964 | <p>I am developing an online examination using servlets/jsp.I need to add a count down (hh/mm/ss) timer to the questions page that would end the exam and redirects to results page.</p>
<p>I am done with all the other functionalities except the timer one.</p>
<p>Can someone provide some help on this.</p>
<p>Thanks</p>
| [
{
"answer_id": 6072810,
"author": "sachin",
"author_id": 762833,
"author_profile": "https://Stackoverflow.com/users/762833",
"pm_score": 1,
"selected": false,
"text": "<html>\n<%@page session=\"false\" %>\n<%\nHttpSession s=request.getSession(false);\n\nif(s==null) { %>\n\n <jsp:forwa... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11193/"
] |
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": "cvs -d:pserver:anonymous@cvs.sv.gnu.org:/sources/emacs co emacs/lisp/calc\n"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/307968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39526/"
] |
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 = new List<int();
</code></pre>
| [
{
"answer_id": 308006,
"author": "Nathan",
"author_id": 24954,
"author_profile": "https://Stackoverflow.com/users/24954",
"pm_score": 1,
"selected": false,
"text": "static void Main(string[] args)\n{\n int i = 1;\n var thelist = CreateList(i);\n}\n\npublic static List<T> CreateList... | 2008/11/21 | [
"https://Stackoverflow.com/questions/307984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4490/"
] |
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("normal").remove();
</code></pre>
| [
{
"answer_id": 308034,
"author": "seanb",
"author_id": 3354,
"author_profile": "https://Stackoverflow.com/users/3354",
"pm_score": 9,
"selected": true,
"text": "selectedLi.slideUp(\"normal\", function() { $(this).remove(); } );\n"
},
{
"answer_id": 310278,
"author": "Communit... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] |
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 is showing me what functions are available to what objects!</p>
<p>Awesome.</p>
| [
{
"answer_id": 308137,
"author": "Stefan Gehrig",
"author_id": 11354,
"author_profile": "https://Stackoverflow.com/users/11354",
"pm_score": 5,
"selected": true,
"text": "// [...]\n/**\n * Return the Request object\n *\n * @return Zend_Controller_Request_Abstract\n */\npublic function ge... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14966/"
] |
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 brackets
if(this)
[self that];
else
[self somethingElse];
// If I do have to use brackets, they go on their own lines so that they line up
if(this)
{
[self that];
[self andThat];
}
// I always put the pointer asterisk next to the instance name
NSObject *variable = [[NSObject alloc] init];
// I always put spaces around operators
if(i == 0)
x = 2;
}
</code></pre>
<p>What OCD coding format do you use?</p>
| [
{
"answer_id": 308799,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 2,
"selected": false,
"text": " -(void)myOCDMethod -> - (void) myOCDMethod"
},
{
"answer_id": 308909,
"author": "Sergey Borodavkin",
... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28106/"
] |
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>
<li>for (<em>draw current page and two pages on each side of it links</em>)</li>
<li>if (<em>draw elipsis (...) if there are pages between #3's pages and #5's pages</em>)</li>
<li>for (<em>draw final three pages links</em>)</li>
</ol>
<p>The problem is that when there are low amounts of pages (I noticed this when the page count was at 10) there should be an ellipsis but none is drawn.</p>
<p>Onto the code:</p>
<pre><code>$page_count = 10; //in actual code this is set properly
$current_page = 1; //in actual code this is set properly
for ($i = 1;$i <= 3;$i++)
{
if ($page_count >= $i)
echo $i;
}
if ($page_count > 3 && $current_page >= 7)
echo "...";
for ($i = $current_page - 2;$i <= current_page + 2;$i++)
{
if ($i > 3 && $i < $page_count - 2)
echo $i;
}
if ($page_count > 13 && $current_page < $page_count - 5)
echo "...";
for ($i = $page_count - 2;$i <= $page_count;$i++)
{
if ($page_count > 3)
echo $i;
}
</code></pre>
<p>So I figure the best idea would to be to modify one of the two ellipsis if statements to include a case like this, however I've tried and am stumped.</p>
<p>Also please note that I condensed this code for readability sake so please don't give tips like "those for loops are ineffective because they will recalculate current_page - 2 for each iteration" because I know :)</p>
<hr>
<p>For those whom want to see a breakdown of how this logic currently works, here is example output ( modified ) with iterating $page_count and $current_page.
<a href="http://rafb.net/p/TNa56h71.html" rel="nofollow noreferrer">http://rafb.net/p/TNa56h71.html</a></p>
| [
{
"answer_id": 308106,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 2,
"selected": false,
"text": "function cdotinator ( $current_page, $page_count ) \n{\n $stepsize = 3; \n $elipse = '...';\n # Simple Case. \n i... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] |
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()
{
//nothing!
}
public function test () {
$someNumber = $this->input->post('someNumber');
if ($someNumber == 12) { return TRUE; }
}
}
</code></pre>
<p>Yes, that could probably be written better, haha. </p>
<p>What I want to know is - how could I use JavaScript to submit a number in a form (I'll worry about validation and models later), how should I write my test() function so that it returns something readable by the JavaScript (I'm assuming return TRUE probably wouldn't work, perhaps XML or JSON or something like that?), and how do I access the data with the JavaScript? </p>
<p>I know there are frameworks like jQuery that will help with this, but right now I'd just like to understand it at the simplest level and all the tutorials and guides I've found so far are way too in depth for me. An example in jQuery or whatever would be good too. </p>
<p>Thanks a lot :)</p>
| [
{
"answer_id": 308127,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 4,
"selected": false,
"text": "public function test() {\n $somenumber = $this->input->post('someNumber');\n if ($somenumber == 12) {\n print \"Nu... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
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>
<p>In IIS we <em>must</em> do something like this at the beginning of each file:</p>
<pre><code>use CGI;
my $input = new CGI();
print "HTTP/1.0 200 OK";
print $input->header();
</code></pre>
<p>whereas with apache we <em>must</em> leave off the 200 OK line. The following works with both:</p>
<pre><code>use CGI;
my $input = new CGI();
print $input->header('text/html','200 OK');
</code></pre>
<p>Can anyone explain why? And I was under the impression that the CGI module was supposed to figure out these kind of details automatically...</p>
<p>Thanks!</p>
<p><strong>Update</strong>: brian is right, nph fixes the problem for IIS, but it is still broken for Apache. I don't think it's worth it to have conditionals all over the code so I will just stick with the last method, which works with and without nph.</p>
| [
{
"answer_id": 308070,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 5,
"selected": true,
"text": "-nph"
},
{
"answer_id": 11138279,
"author": "Derek P",
"author_id": 1172324,
"author_profile": ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12448/"
] |
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, World!");
this.PrintRandom();
}
public virtual void PrintRandom()
{
Console.WriteLine("0");
}
}
public class Descendent : BaseClass
{
private Random randomValue;
public Descendent()
{
Console.WriteLine("Bonjour, Monde!");
randomValue = new Random();
}
public override void PrintRandom()
{
Console.WriteLine(randomValue.NextDouble().ToString());
}
public static void Main()
{
Descendent obj = new Descendent();
obj.PrintRandom();
Console.ReadLine();
}
}
}
</code></pre>
<p>This code breaks because when the object of Descendent is made, it calls the base class constructor and we have a virtual method call in Base Class constructor which in turn calls the Derived class's method and hence, it crashes since randomValue is not intialized by that time.</p>
<p>A similar code works in C++ because the call to PrintRandom is not routed to the derived class since IMO, the order in C++ is something like:</p>
<p><br>1. call for base class constructor
<br>2. Update V - Table for this class
<br>3. call the constructor code</p>
<p>My Question is that firstly whether I am right that as per OOP principles, virtualization shouldn't/doesn't work in the super class constructor and secondly if I am right, then why the behavior is different in all .NET languages ( I have tested it with C#, VB.NET and MC++)</p>
| [
{
"answer_id": 308092,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "random"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/308061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30341/"
] |
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 JavaScript is turned off or doesn't exist in a user's browser.</p>
<p>I'll give an example: Currently, I'm using a pure CSS tooltip to give my users (players, the site is a browser game) information on other users. For example, if the other players in the game satisfy one or more conditions, a target icon is displayed next to their name, and upon hovering over that target icon information regarding the reasons behind the target is displayed. This is useful information, as it helps my players to know who they should plan to attack next in the game.</p>
<p>Currently, I do such tooltips using CSS. I have a parent div that holds the image of the target icon of class "info". I then have a div inside of that with class "tooltip" that, on the hover state of the "info" class that it is contained in, is shown, but on the normal state is hidden. I thought it was rather clever when I read about it, and since no JavaScript is used it works on any CSS compliant browser.</p>
<p>I would like to use jQuery to achieve the same effect, mostly because it would look much cleaner, but also because I believe quick and subtle animations can make such things "randomly appearing" make a lot more sense to the user, especially on the first encounter. I'm just wondering if the two will conflict. This is only one example of this, there are numerous other examples where the inability to use JavaScript would hinder the site.</p>
<p>So what I'm asking I guess is, how does one make a jQuery site degrade gracefully on browsers that do not support JavaScript, but otherwise <em>do</em> support most CSS? My goal is for the site to function on a basic level for all users, regardless of choice in browser. The animation is a good example, but I'm also worried about the more dynamic bits, like the auto-updating with AJAX, etc. Are there any good resources on how to achieve this, or do you have any advice about the best way such degradability could be achieved?</p>
<p>Thanks</p>
<p>PS: Totally irrelevant, but Firefox seems to think that "degradability" isn't a word, but "biodegradability" (with the "bio" prefix) is. Weird...</p>
| [
{
"answer_id": 308104,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 4,
"selected": true,
"text": "a.info:hover span{ display:none}\n"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/308076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19521/"
] |
308,081 | <p>For the iPhone, is it possible to configure a UITableView such that it will allow multiple-selection?</p>
<p>I've tried overriding <code>-setSelected:animated:</code> for each UITableViewCell, but trying to fudge the required behavior is tricky as it's difficult to separate the real unselections from the ones where the UITableView thinks I've unselected due to selection of another cell!</p>
<p>Hope someone can help!</p>
<p>Thanks,</p>
<p>Nick.</p>
| [
{
"answer_id": 675215,
"author": "Benjamin Ortuzar",
"author_id": 71560,
"author_profile": "https://Stackoverflow.com/users/71560",
"pm_score": 5,
"selected": false,
"text": " - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {\n\n UITableV... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1221378/"
] |
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": "dataSet.Tables[0].AsEnumerable().Where(c => c.Field<int>(\"ageColumn\") > 3 ||\n c.Field<int>(\"ageColumn\") < 5).Count... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10385/"
] |
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": " <ul>\n <% @posts.each do |post| -%> \n <li><%=post.title%></li>\n <% end -%>\n </ul>\n"
},
{
"an... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36049/"
] |
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 also be included.</p>
| [
{
"answer_id": 308124,
"author": "DocMax",
"author_id": 6234,
"author_profile": "https://Stackoverflow.com/users/6234",
"pm_score": 10,
"selected": true,
"text": "[0-9]+(\\.[0-9][0-9]?)?\n"
},
{
"answer_id": 308132,
"author": "spacemonkeys",
"author_id": 32336,
"autho... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39221/"
] |
308,125 | <p>Is there anything like Firebug that you can use within Google Chrome?</p>
<p>Essential features I would like:</p>
<ul>
<li>Inspect HTML source (select elements, delete them, etc.)</li>
<li>check CSS values (the built-in solution is weird, somehow)</li>
</ul>
| [
{
"answer_id": 1707770,
"author": "Manuel",
"author_id": 50770,
"author_profile": "https://Stackoverflow.com/users/50770",
"pm_score": 3,
"selected": false,
"text": "javascript:var firebug=document.createElement('script');firebug.setAttribute('src','http://getfirebug.com/releases/lite/1.... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9535/"
] |
308,133 | <p>I'm using PHP 5.2. I'd like to find a way to output a unique id for every object, so it's easy when looking over logs to see which objects are the same.</p>
<p>In Ruby, I'd just say object.object_id to get Ruby's internal identifier for the object. There doesn't seem to be an obvious way to do this in PHP.</p>
<p>Is there is a built-in way of doing this? If there isn't, can you offer any other suggestions?</p>
| [
{
"answer_id": 308145,
"author": "azkotoki",
"author_id": 28581,
"author_profile": "https://Stackoverflow.com/users/28581",
"pm_score": 7,
"selected": true,
"text": "spl_object_hash()"
},
{
"answer_id": 34599839,
"author": "rolacja",
"author_id": 4307374,
"author_prof... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31092/"
] |
308,156 | <p>I have created one sample PHP script to upload excel sheets of very bigger sizes. Also the process happening with each records given in the excel sheets is bit complex. To allow bigger sizes, I have added necessary PHP ini values in the Apache configuration file to override the actual PHP ini values.</p>
<p>The problem is, once I upload the bigger files, it takes longer time say 2 minutes or so, after that i am seeing the blank page instead of results page. When I tailed the Apache logs, I didn't see any such lines related to this issue.</p>
<p>Just wanted to know, are there any case/possibilities when Apache could serves blank page? </p>
<p>But when I tailed my application level logs, it is very clear the script has completes the job perfectly. My suspect, may be what could have happen is, once the job completes, while Apache about to serve back the results page something would have happened, but I am not sure about it.</p>
| [
{
"answer_id": 308225,
"author": "Mojah",
"author_id": 30330,
"author_profile": "https://Stackoverflow.com/users/30330",
"pm_score": 1,
"selected": false,
"text": "error_reporting(E_ALL);\n"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/308156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
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 Class3 : IInterface2
{
...
}
</code></pre>
<p>In <code>Class2</code>, <code>Method1</code> throws <code>NotImplementedException</code>.</p>
<p>Questions:</p>
<ul>
<li>What do you think in general about inheriting interfaces?</li>
<li>Does the relationship between <code>IBase</code> and <code>Class2</code> violate the Liskov Substitution Principle?</li>
</ul>
| [
{
"answer_id": 308183,
"author": "Greg Beech",
"author_id": 13552,
"author_profile": "https://Stackoverflow.com/users/13552",
"pm_score": 2,
"selected": false,
"text": "NotImplementedException"
},
{
"answer_id": 308245,
"author": "Jorge Córdoba",
"author_id": 2695,
"a... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2822/"
] |
308,174 | <p>I have just moved job and gone from VB 6 to VB.Net and found the learning jump fairly steep, have more a problem with the object / conceptual side of things .. but getting there now ... but as I was a assembler / C++ 10/15 years ago and was considering learning C++/C# .Net (XNA games library calls my name) but not sure if it would hinder my VB.NET learning .... or should I just get myself certified</p>
| [
{
"answer_id": 963852,
"author": "Binoj Antony",
"author_id": 33015,
"author_profile": "https://Stackoverflow.com/users/33015",
"pm_score": 1,
"selected": false,
"text": "Sub"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/308174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32336/"
] |
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');"
>
<img src="images/target.png">
<div class="tooltiptwo" id="tooltip"
style="font-weight: normal; font-size: 0.8em;" >TOOLTIP TEXT</div>
</div>
</code></pre>
<p>To anyone familiar with basic CSS and jQuery, I'm trying to add a simple animation to my tooltips. The problem is the triggering of such an animation. It seems that when the animation happens, if the user moves their mouse over the tooltip, the animation will go into a loop of showing and hiding until the user moves the mouse away. This is an undesired effect, as I want the animation to go away just once, when the mouse moves out of the <em>parent</em> div. I've positioned my CSS so that the tooltip appears away from the parent div, but regardless the actions should be triggering only on the parent, and not any of its children.</p>
<p>So basically, how would I go about achieving this? I want my hover/out state on my parent element to trigger a function (an animation) on the children of that parent, without the hover/out states of the children doing anything. It seems that the normal method of <code>onMouseOver</code> and <code>onMouseOut</code> is triggering even for the children of the parent that the method belongs to, which is causing some rather undesirable effects.</p>
<p>Note that I'm new to jQuery (although its amazing so far, I want to coat my site in its goodness if I can) and if there is a better way to achieve the hover/out states using jQuery I probably don't know about them.</p>
| [
{
"answer_id": 308209,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 4,
"selected": true,
"text": "$('.info').bind('mouseenter', function() {\n $('div', this).show('normal');\n});\n\n$('.info').bind('mouseleave', function() ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19521/"
] |
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 buffered input stream out of the file
//we're trying to add into the Zip archive.
FileInputStream fin = new FileInputStream(file);
BufferedInputStream in = new BufferedInputStream(fin);
zos.putNextEntry(zipEntry);
//Read bytes from the file and write into the Zip archive.
while ((len = in.read(buf)) >= 0) {
zos.write(buf, 0, len);
}
//Close the input stream.
in.close();
//Close this entry in the Zip stream.
zos.closeEntry();
</code></pre>
<p>this is what I have but it Fails badly</p>
<pre><code> buf=None <<<< ?
len=None <<<< ?
zipEntry=ZipEntry(file.toString())
fin=FileInputStream(file)
bin=BufferedInputStream(fin)
self._zos.putNextEntry(zipEntry)
while (len=bin.helpme_im_dying(buf)) >= 0): <<<< ?
self._zos.write(buf,0,len) <<<< ?
len = bin.read(buf) <<<< ?
bin.close()
self._zos.closeEntry()
</code></pre>
<p>refer to this page for information <a href="https://www.acm.org/crossroads/xrds6-3/ovp63.html" rel="nofollow noreferrer">https://www.acm.org/crossroads/xrds6-3/ovp63.html</a></p>
| [
{
"answer_id": 308210,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": true,
"text": "bin"
},
{
"answer_id": 308462,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverfl... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21537/"
] |
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", propertyValue = "imap.company.com"),
@ActivationConfigProperty(propertyName = "mailFolder", propertyValue = "INBOX"),
@ActivationConfigProperty(propertyName = "storeProtocol", propertyValue = "imap"),
@ActivationConfigProperty(propertyName = "debug", propertyValue = "false"),
@ActivationConfigProperty(propertyName = "userName", propertyValue = "username"),
@ActivationConfigProperty(propertyName = "password", propertyValue = "pass") })
@ResourceAdapter("mail-ra.rar")
@Name("mailMessageBean")
public class MailMessageBean implements MailListener {
public void onMessage(final Message msg) {
...snip...
}
}
</code></pre>
<p>I have this working, but the situation is less than ideal: The hostname, username and password are hardcoded. Short of using ant and build.properties to replace those values before compilation, I don't know how to externalize them. </p>
<p>It would be ideal to use an MBean, but I have no idea how to get the values from the MBean to the MDB configuration.</p>
<p>How should I do this?</p>
| [
{
"answer_id": 337473,
"author": "Brett Hannah",
"author_id": 42491,
"author_profile": "https://Stackoverflow.com/users/42491",
"pm_score": 5,
"selected": true,
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<ejb-jar version=\"3.0\">\n <enterprise-beans>\n <message-driv... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6400/"
] |
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 think if I keep the values sorted and do a binary search, it should work fast enough. Or is there some other smart way of doing this, which can work faster?</p>
| [
{
"answer_id": 308201,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 3,
"selected": false,
"text": "// prepare a mock-up object\nsetOfValues = {};\nfor (var i = 0; i < 100; i++)\n setOfValues[\"example value \" + i] = tru... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11384/"
] |
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 and serverdatetime < :maxDate and userId = 1 group by data having count(1) > :threshold</em></p>
<p>Thanks!</p>
| [
{
"answer_id": 318100,
"author": "Neil Hewitt",
"author_id": 22178,
"author_profile": "https://Stackoverflow.com/users/22178",
"pm_score": 4,
"selected": true,
"text": "HqlBasedQuery"
},
{
"answer_id": 840387,
"author": "enriquein",
"author_id": 88868,
"author_profile... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22680/"
] |
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);
}
public interface UserEvent extends EVent<User> // OR: UserEvent<S extends User> extends Event<S>
// It will therefore be void setSource(User s);
}
</code></pre>
<p>The problem of using concrete parameter is that, I can't bring this compile-time benefit I earn when using setSource() to a new interface say,</p>
<pre><code>public interface AdminUserEvent extends UserEvent{
void setSource(AdminUser s); // WHERE: AdminUser extends User. This is a method overloading, we also have a void setSource(User s) inherited from UserEvent.
}
</code></pre>
<p>What I can work around for this is to do a type checking on the <code>User</code> object when <code>AdminUserEvent.setSource()</code> is called.</p>
<p>Have you ever had this question raised when you design your API? And what are the practices or rules that you will go for when this sort of situation arises? Thanks.</p>
<p>yc</p>
| [
{
"answer_id": 308229,
"author": "Miserable Variable",
"author_id": 18573,
"author_profile": "https://Stackoverflow.com/users/18573",
"pm_score": 0,
"selected": false,
"text": "B extends A"
},
{
"answer_id": 1277054,
"author": "David Moles",
"author_id": 27358,
"autho... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36397/"
] |
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 #2</a>
<ul>
<li><a href="..">Subpage #1</a></li>
<li><a href="..">Subpage #2</a></li>
</ul>
</li>
</ul>
</code></pre>
<p>So now I'm trying to figure out how to do the nesting using XSLT. This is what I have so far:</p>
<pre><code><xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<!-- update this variable on how deep your menu should be -->
<xsl:variable name="maxLevelForMenu" select="4"/>
<xsl:template match="/">
<ul id="nav">
<xsl:call-template name="drawNodes">
<xsl:with-param
name="parent"
select="$currentPage/ancestor-or-self::node [@level=1]"
/>
</xsl:call-template>
</ul>
</xsl:template>
<xsl:template name="drawNodes">
<xsl:param name="parent"/>
<xsl:if test="umbraco.library:IsProtected($parent/@id, $parent/@path) = 0 or (umbraco.library:IsProtected($parent/@id, $parent/@path) = 1 and umbraco.library:IsLoggedOn() = 1)">
<xsl:for-each select="$parent/node [string(./data [@alias='umbracoNaviHide']) != '1' and @level &lt;= $maxLevelForMenu]">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
<xsl:if test="count(./node [string(./data [@alias='umbracoNaviHide']) != '1' and @level &lt;= $maxLevelForMenu]) &gt; 0">
<xsl:call-template name="drawNodes">
<xsl:with-param name="parent" select="."/>
</xsl:call-template>
</xsl:if>
</li>
</xsl:for-each>
</xsl:if>
</xsl:template>
</code></pre>
<p>What I can't seem to figure out is how to check if the first level (here Page #1 and Page #2) has any children, and if they do add the extra <code><ul></code> to contain the <code><li></code> children.</p>
<p>Anyone out there to point me in the right direction?</p>
| [
{
"answer_id": 308651,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 4,
"selected": true,
"text": "parent"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/308219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
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 annoyingly_long_right_hand_table
USING (id);
</code></pre>
<p>Given that both tables have an <code>id</code> field, is there any disadvantage to using the second version. It isn't just laziness - the version with USING seems far clearer to me.</p>
<p>(Please don't mention aliasing - I want to know if there is any reason to favour one conditional structure over the other)</p>
| [
{
"answer_id": 1493614,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 1,
"selected": false,
"text": "USING"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/308227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20074/"
] |
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>Before, there was a ipython2.4 package but it is deprecated.</p>
| [
{
"answer_id": 308260,
"author": "e-satis",
"author_id": 9951,
"author_profile": "https://Stackoverflow.com/users/9951",
"pm_score": 5,
"selected": true,
"text": "ls /usr/bin/ipython*\n/usr/bin/ipython /usr/bin/ipython2.4 /usr/bin/ipython2.5\n"
},
{
"answer_id": 5293422,
"a... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9951/"
] |
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
}
</code></pre>
| [
{
"answer_id": 308274,
"author": "Rob Wells",
"author_id": 2974,
"author_profile": "https://Stackoverflow.com/users/2974",
"pm_score": 5,
"selected": true,
"text": ".vimrc"
},
{
"answer_id": 308293,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "http... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39615/"
] |
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() {
DoSomethingWithCount(count);
}
public Test(int count, string name) : this(count) {
DoSomethingWithName(name);
}
}
</code></pre>
<p>Is there a way to do this in C++?</p>
<p>I tried calling the Class name and using the 'this' keyword, but both fail.</p>
| [
{
"answer_id": 308309,
"author": "Cyrille Ka",
"author_id": 39622,
"author_profile": "https://Stackoverflow.com/users/39622",
"pm_score": 7,
"selected": false,
"text": "class SomeType\n{\n int number;\n \npublic:\n SomeType(int newNumber) : number(newNumber) {}\n SomeType() : SomeType... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2090/"
] |
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": 308286,
"author": "Alex B",
"author_id": 23643,
"author_profile": "https://Stackoverflow.com/users/23643",
"pm_score": 7,
"selected": true,
"text": "#ifdef"
},
{
"answer_id": 308314,
"author": "Wilka",
"author_id": 1367,
"author_profile": "https://Stack... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24459/"
] |
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>
<p>.. since the pointer should the reference to a static member, which I don't know if it can?</p>
<p>Anyways, what's really bugging me is knowing the difference between:</p>
<pre><code>void upperCaseString(char *_str) {};
void upperCaseString(char _str[]) {};
</code></pre>
<p>So, would be much appreciated if anyone could tell me the difference? I have a hunch that both might be compiled down the same, except in some special cases?</p>
<p>Ty</p>
| [
{
"answer_id": 308312,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": -1,
"selected": false,
"text": "upperCaseString()"
},
{
"answer_id": 308315,
"author": "Timbo",
"author_id": 1810,
"author_profile": "ht... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25745/"
] |
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 set the username and password for any windows service?</p>
| [
{
"answer_id": 308319,
"author": "Andrew Ferrier",
"author_id": 27641,
"author_profile": "https://Stackoverflow.com/users/27641",
"pm_score": 8,
"selected": true,
"text": "sc.exe config \"[servicename]\" obj= \"[.\\username]\" password= \"[password]\"\n"
},
{
"answer_id": 1363027... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32670/"
] |
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"></asp:ListItem>
</asp:RadioButtonList></p>
<div id="HasBuffet">
<p><label>What is the capacity for the buffet?</label>
<asp:RadioButtonList ID="radBuffetCapacity" runat="server">
<asp:ListItem Text="Suitable for upto 30 guests" value="0 to 30"></asp:ListItem>
<asp:ListItem Text="Suitable for upto 50 guests" value="30 to 50"></asp:ListItem>
<asp:ListItem Text="Suitable for upto 75 guests" value="50 to 75"></asp:ListItem>
<asp:ListItem Text="Suitable for upto 100 guests" value="75 to 100"></asp:ListItem>
<asp:ListItem Text="Suitable for upto 150 guests" value="100 to 150"></asp:ListItem>
<asp:ListItem Text="Suitable for upto 250 guests" value="150 to 250"></asp:ListItem>
<asp:ListItem Text="Suitable for upto 400 guests" value="250 to 400"></asp:ListItem>
</asp:RadioButtonList></p>
</div>
</code></pre>
<p>I want to capture an event when the radio list blBuffetMealFacilities:chk changes client side and perform a slide down function on the HasBuffet div from jQuery. What's the best way to create this, bearing in mind there are several similar sections on the page, where I want questions to be revealed depending on a yes no answer in a radio list.</p>
| [
{
"answer_id": 308327,
"author": "Andrew Bullock",
"author_id": 28543,
"author_profile": "https://Stackoverflow.com/users/28543",
"pm_score": 6,
"selected": true,
"text": "$('#rblDiv input').click(function(){\n alert($('#rblDiv input').index(this));\n});\n"
},
{
"answer_id": 7... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5055/"
] |
308,307 | <p>Can anyone point me in the right direction how to configure Visual Studio 2005 with our C++ console project how we can include a 'File Version' in the details section of the file properties.</p>
<p>I've tried resource files without any luck. This is with a C++ project just for clarification, and big thank you for the guys you responded with C# suggestions.</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 308380,
"author": "user33675",
"author_id": 33675,
"author_profile": "https://Stackoverflow.com/users/33675",
"pm_score": 3,
"selected": false,
"text": "VS_VERSION_INFO"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/308307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
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 splitted as two columns. It seems no solution to express the correct data.</p>
<p>Is there any way to express <strong>001, 002</strong> in CSV for Excel?</p>
| [
{
"answer_id": 308340,
"author": "Nick Fortescue",
"author_id": 5346,
"author_profile": "https://Stackoverflow.com/users/5346",
"pm_score": 2,
"selected": false,
"text": "\"\"\"001,002\"\"\"\n"
},
{
"answer_id": 308352,
"author": "Kent Fredric",
"author_id": 15614,
"a... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/288936/"
] |
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 the same I want to get the maximum value from the B column.</p>
<p>If I do a simple group by the result would be:</p>
<pre>
B C Count
--------------
10 X 1
11 X 1
15 X 1
20 Y 2
15 Y 1
</pre>
<p>What I want is this result:</p>
<pre>
B C Count
--------------
11 X 1
15 X 1
20 Y 2
</pre>
<p>Is there any query that can return this result. Server is SQL Server 2005.</p>
| [
{
"answer_id": 308387,
"author": "Dheer",
"author_id": 17266,
"author_profile": "https://Stackoverflow.com/users/17266",
"pm_score": 0,
"selected": false,
"text": "select count(a), BB, CC from\n(\nselect a, max(B) BB, Max(C) CC\nfrom yourtable\ngroup by a\n)\ngroup by BB,CC\n"
},
{
... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24065/"
] |
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*/
...
mkdir(str1,0777);
if (filefd < 0) {
strncpy(auxstr, str, MAX_MSG + 1);
strcat(str1,"\\");
strcat(str1, auxstr);
filefd = open (str1, O_RDWR | O_CREAT | O_TRUNC);
nbytes -= (strlen(str) + 1);
memcpy(auxstr, &str[strlen(str)+1], nbytes);
memcpy(str, auxstr, nbytes);
}
/*write to the file */
if ((nwritten = write(filefd, str, nbytes)) != nbytes) {
printf ("can't write on file\n");
break;
}
</code></pre>
<p>What should I change in order to have permissions to open the created file?</p>
<p>Thanks a lot,</p>
<hr>
<p>:s</p>
<p>with = 0_CREATE I STILL have the problem of no having permissions to read the file.
I have to set them manually</p>
<hr>
<p>And I already have the 0_CREAT at the open</p>
<p>open (str1, O_RDWR | O_CREAT | O_TRUNC);</p>
| [
{
"answer_id": 308374,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 3,
"selected": false,
"text": "open()"
},
{
"answer_id": 308575,
"author": "wimh",
"author_id": 33499,
"author_profile": "https://Stac... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
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": "<h1><a href=\"#\">text here</a></h1>\n"
},
{
"answer_id": 308378,
"author": "Tamas Czinege",
"author_id": 8954,
... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26823/"
] |
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 test_b:1;
int test_c:1;
int test_d:1;
int test_e:1;
int test_f:1;
int test_g:1;
int test_h:1;
};
class test3 {
public:
int test_a:1;
bool test_b:1;
int test_c:1;
bool test_d:1;
int test_e:1;
bool test_f:1;
int test_g:1;
bool test_h:1;
};
</code></pre>
<p>The results were:-</p>
<pre><code>sizeof(test1) = 1 // This is what I'd expect. 8 bits in a byte
sizeof(test2) = 4 // Reasonable. Maybe padded out to the size of an int.
sizeof(test3) = 16 // What???
</code></pre>
<p>Is this what you'd expect, or a compiler bug? (Codegear C++ Builder 2007, btw...)</p>
| [
{
"answer_id": 308393,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": false,
"text": "#ifndef __cplusplus\n#include <stdbool.h>\n#endif\n#include <stdio.h>\n\nstruct test1 {\n bool test_a:1;\n bool test_b... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1737/"
] |
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": "#include <time.h>\nchar *strptime(const char *buf, const char *format, struct tm *tm);\n"
},
{
"answer_id": 308916,
... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39634/"
] |
308,401 | <p>When I maximize 1 MDI child form, all MDI child forms would be maximized too. Is it possible to have 1 form maximized and another one not?</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 4186597,
"author": "jp2code",
"author_id": 153923,
"author_profile": "https://Stackoverflow.com/users/153923",
"pm_score": 0,
"selected": false,
"text": "Child1.Show()"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/308401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39635/"
] |
308,406 | <p>One of my custom developed <a href="http://en.wikipedia.org/wiki/ASP.NET" rel="nofollow noreferrer">ASP.NET</a> sites was hacked today: "Hacked By Swan (Please Stop Wars !.. )"
It is using ASP.NET and SQL Server 2005 and IIS 6.0 and Windows 2003 server.
I am not using Ajax and I think I am using stored procedures everywhere I am connecting to the database so I dont think it is <a href="http://en.wikipedia.org/wiki/SQL_injection" rel="nofollow noreferrer">SQL injection</a>.
I have now removed the write permission on the folders. </p>
<p>How can I find out what they did to hack the site and what to do to prevent it from happening again?</p>
<p>The server is up to date with all Windows updates. </p>
<p>What they have done is uploading 6 files (index.asp, index.html, index.htm,...) to the main directory for the website.</p>
<p>What log files should I upload?
I have log files for IIS from this folder: <code>c:\winnt\system32\LogFiles\W3SVC1</code>.
I am willing to show it to some of you but don't think it is good to post on the Internet. Anyone willing to take a look at it?</p>
<p>I have already searched on Google but the only thing I find there are other sites that have been hacked - I haven't been able to see any discussion about it.</p>
<p>I know this is not strictly related to programming but this is still an important thing for programmers and a lot of programmers have been hacked like this.</p>
| [
{
"answer_id": 308634,
"author": "digiguru",
"author_id": 5055,
"author_profile": "https://Stackoverflow.com/users/5055",
"pm_score": 3,
"selected": false,
"text": "Dim strSQL As String = \"Select * FROM USERS Where name = '\" & Response.Querystring(\"name\") \"'\"\n"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/308406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26817/"
] |
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 idea why? Source file is an XML with default encoding</p>
<p>Here is the code:</p>
<pre><code>undef $/;
open F, $file or die "cannot open file $file\n";
my $content = <F>;
close F;
$content =~s{status=["'][\w ]*["']\s*}{}gi;
printf $content;
open F, ">$file" or die "cannot reopen $file\n";
printf F $content;
close F or die "cannot close file $file\n";
</code></pre>
| [
{
"answer_id": 308434,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 6,
"selected": true,
"text": "printf"
},
{
"answer_id": 308437,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29568/"
] |
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 collection should be itteratable.</li>
<li>I don't have to search the collection for anything.</li>
<li>The double will be changed after intialization of the collection.</li>
<li>I would like to work with existing datatypes (no new classes) since it will be used in my asp.net mvc controllers, views and services and I don't want them to all to have a dependency on a library just for this stupid holder class.</li>
</ul>
<p>I thought </p>
<pre><code>IDictionary<int, KeyvaluePair<TheType, double>>
</code></pre>
<p>would do the trick, but then I can't set the double after init.</p>
<p><strong>--Edit--</strong><br>
I found out that the classes generated by the linq 2 sql visual studio thingy are actually partial classes so you can add to them whatever you want. I solved my question by adding a double field to the partial class.<br>
Thanks all for the answers you came up with.</p>
| [
{
"answer_id": 308441,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "KeyValuePair"
},
{
"answer_id": 308445,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_prof... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] |
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 plugin with prefix: 'dependency'.
[INFO] -----------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] -----------------------------------------------------------
[INFO] Required goal not found: dependency:list
</code></pre>
<p>Call me a hopeful naive, but I had hoped maven would download any plugins it didn't have. Does anyone know what might be leading to this error? Does anyone know where maven stores information about what plugins it has installed, and where they're stored in the maven repository?</p>
| [
{
"answer_id": 308480,
"author": "Ivan Dubrov",
"author_id": 31118,
"author_profile": "https://Stackoverflow.com/users/31118",
"pm_score": 2,
"selected": false,
"text": "mvn -cpu dependency:list"
},
{
"answer_id": 308663,
"author": "Michael Rutherfurd",
"author_id": 33889... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/974/"
] |
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": "using log4net;\nusing log4net.Appender;\nusing log4net.Layout;\nusing log4net.Repository.Hierarchy;\n\n// Set the level ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35425/"
] |
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 appreciated</p>
| [
{
"answer_id": 308439,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 4,
"selected": true,
"text": "$string = str_replace(\"'\", \"<replacement>\", $string);\n"
},
{
"answer_id": 308574,
"author": "RJHunter",
... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31677/"
] |
308,454 | <p>What is the difference between web reference and service reference in WCF?
Which is preferable in WCF?</p>
| [
{
"answer_id": 2973819,
"author": "Christian Hayter",
"author_id": 115413,
"author_profile": "https://Stackoverflow.com/users/115413",
"pm_score": 6,
"selected": false,
"text": "basicHttpBinding"
}
] | 2008/11/21 | [
"https://Stackoverflow.com/questions/308454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.