qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
335,781 | <p>We are in the process of converting our main build process from ant to maven. We use TeamCity for our Continuous Integration server (CI).</p>
<p>We'd like to use the CI server to kick off (nightly) builds whose version contain a build number, as in 1.0.0.build#. These builds would be installed in our local maven repository to be used by other projects. So the CI server would manage the versions, maven would build the project, and the maven repository would make the builds accessible to other projects.</p>
<p>I intended to initiate the build from the CI server using the following command:</p>
<pre><code>mvn -Dversion=1.0.0.25 install
</code></pre>
<p>The project's pom would have a bogus version number, and the -D flag would override it, as in:</p>
<pre><code><version>0.0.0.0</version>
</code></pre>
<p>The problem with this method is that the maven install plugin only uses the version in the pom file, not the version passed in on the command line. This is noted in <a href="http://jira.codehaus.org/browse/MINSTALL-30" rel="noreferrer">this maven issue</a>.</p>
<p>So since this issue has existed since 08/2006 and has not been fixed, I assume that this is somehow not '<em>the maven way</em>'. So my question is, how can maven be used in a continuous integration situation to install versioned artifacts in the repository?</p>
| [
{
"answer_id": 336080,
"author": "shek",
"author_id": 40618,
"author_profile": "https://Stackoverflow.com/users/40618",
"pm_score": 4,
"selected": true,
"text": "<version>#.#.#-SNAPSHOT</version>\n"
},
{
"answer_id": 350865,
"author": "Matthew Jaskula",
"author_id": 4356,... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4356/"
] |
335,792 | <p>In visual studio 2008, when I drag a database table into my dbml screen, any tables that end with the letter s automatcially get the s removed from the dbml object. Is there any way to disable this?</p>
<p>Also, the collection of rows also gets an s appended to the collection property name. Is there a way to change that as well?</p>
<p>Thanks</p>
| [
{
"answer_id": 27265070,
"author": "Nicholas Petersen",
"author_id": 264031,
"author_profile": "https://Stackoverflow.com/users/264031",
"pm_score": 0,
"selected": false,
"text": " [Table(\"QTPhotos\")]\n public class QTPhoto \n"
}
] | 2008/12/02 | [
"https://Stackoverflow.com/questions/335792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
335,799 | <p>Is there an HTML editor which automatically changes the end tag when you edit the start tag?</p>
| [
{
"answer_id": 29274948,
"author": "ROMANIA_engineer",
"author_id": 3885376,
"author_profile": "https://Stackoverflow.com/users/3885376",
"pm_score": 0,
"selected": false,
"text": "div"
}
] | 2008/12/02 | [
"https://Stackoverflow.com/questions/335799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6691/"
] |
335,805 | <p>I have a 'reference' SQL Server 2005 database that is used as our global standard. We're all set up for keeping general table schema and data properly synchronized, but don't yet have a good solution for other objects like views, stored procedures, and user-defined functions.</p>
<p>I'm aware of products like <a href="http://www.red-gate.com/products/SQL_Compare/index.htm" rel="nofollow noreferrer">Redgate's SQL Compare</a>, but we don't really want to rely on (any further) 3rd-party tools right now.</p>
<p>Is there a way to ensure that a given stored procedure or view on the reference database, for example, is up to date on the target databases? Can this be scripted?</p>
<p>Edit for clarification: when I say 'scripted', I mean running a script that pushes out any changes to the target servers. Not running the same CREATE/ALTER script multiple times on multiple servers.</p>
<p>Any advice/experience on how to approach this would be much appreciated.</p>
| [
{
"answer_id": 456196,
"author": "Nathan",
"author_id": 24954,
"author_profile": "https://Stackoverflow.com/users/24954",
"pm_score": 3,
"selected": true,
"text": "select * from sys.syscomments\n"
}
] | 2008/12/02 | [
"https://Stackoverflow.com/questions/335805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1354/"
] |
335,807 | <p>I was working on some code recently and came across a method that had 3 for-loops that worked on 2 different arrays. </p>
<p>Basically, what was happening was a foreach loop would walk through a vector and convert a DateTime from an object, and then another foreach loop would convert a long value from an object. Each of these loops would store the converted value into lists.</p>
<p>The final loop would go through these two lists and store those values into yet another list because one final conversion needed to be done for the date. </p>
<p>Then after all that is said and done, The final two lists are converted to an array using ToArray().</p>
<p>Ok, bear with me, I'm finally getting to my question. </p>
<p>So, I decided to make a single for loop to replace the first two foreach loops and convert the values in one fell swoop (the third loop is quasi-necessary, although, I'm sure with some working I could also put it into the single loop). </p>
<p>But then I read the article "What your computer does while you wait" by Gustav Duarte and started thinking about memory management and what the data was doing while it's being accessed in the for-loop where two lists are being accessed simultaneously. </p>
<p>So my question is, what is the best approach for something like this? Try to condense the for-loops so it happens in as little loops as possible, causing multiple data access for the different lists. Or, allow the multiple loops and let the system bring in data it's anticipating. These lists and arrays can be potentially large and looping through 3 lists, perhaps 4 depending on how ToArray() is implemented, can get very costy (O(n^3) ??). But from what I understood in said article and from my CS classes, having to fetch data can be expensive too. </p>
<p>Would anyone like to provide any insight? Or have I completely gone off my rocker and need to relearn what I have unlearned?</p>
<p>Thank you</p>
| [
{
"answer_id": 335859,
"author": "jalf",
"author_id": 33213,
"author_profile": "https://Stackoverflow.com/users/33213",
"pm_score": 2,
"selected": false,
"text": "for (...){\n // Do A\n}\n\nfor (...){\n // Do B\n}\n\nfor (...){\n // Do C\n}\n"
},
{
"answer_id": 335944,
"au... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13064/"
] |
335,812 | <p>I'm having an issue with CruiseControl.net where the web dashboard just won't work in IIS. I have tried switching ASP.Net between 64 and 32 bit modes and reinstalling cruise control, but nothing seems to work. Has anyone else had issues with CruiseControl.Net on 64 bit platforms?</p>
<p>Cheers,
Jamie</p>
<p>[Edit]</p>
<p>Thought I should clarify, I am getting a 404 error when I try access the website. I am using the correct address because it asks for authentication. The .aspx handler is working because I don't see the default.aspx page from the ccnet directory.</p>
<p>[Edit2]</p>
<p>I am using the default web.config that comes with ccnet, but here it is:</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!-- Change this if (for example) you want to keep your dashboard config file under source control -->
<add key="DashboardConfigLocation" value="dashboard.config" />
</appSettings>
<system.web>
<httpHandlers>
<!-- Yes, we are overriding .aspx - don't delete this! We are using .aspx since we know it is already bound to ASP.NET. In future we might use a
different extension so that people can add their own ASP.NET pages if they want to, but we should make sure in that case to change how
URLs are created -->
<add verb="*" path="*.aspx" type="ThoughtWorks.CruiseControl.WebDashboard.MVC.ASPNET.HttpHandler,ThoughtWorks.CruiseControl.WebDashboard"/>
<add verb="*" path="*.xml" type="ThoughtWorks.CruiseControl.WebDashboard.MVC.ASPNET.HttpHandler,ThoughtWorks.CruiseControl.WebDashboard"/>
</httpHandlers>
<compilation defaultLanguage="c#" debug="true" />
<customErrors mode="RemoteOnly" />
<authentication mode="Windows" />
<!-- APPLICATION-LEVEL TRACE LOGGING
Application-level tracing enables trace log output for every page within an application.
Set trace enabled="true" to enable application trace logging. If pageOutput="true", the
trace information will be displayed at the bottom of each page. Otherwise, you can view the
application trace log by browsing the "trace.axd" page from your web application
root.
-->
<trace
enabled="false"
requestLimit="10"
pageOutput="true"
traceMode="SortByTime"
localOnly="true"
/>
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false" timeout="20" />
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</system.web>
</code></pre>
<p></p>
| [
{
"answer_id": 335821,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 1,
"selected": false,
"text": "<add verb=\"*\" path=\"*.aspx\" type=\"ThoughtWorks.CruiseControl.WebDashboard.MVC.ASPNET.HttpHandler,ThoughtWorks.CruiseCon... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68230/"
] |
335,817 | <p>Is there a way to access the DOM of the document in an iframe from parent doc if the doc in the iframe is on another domain? I can easily access it if both parent and child pages are on the same domain, but I need to be able to do that when they are on different domains.</p>
<p>If not, maybe there is some other way to READ the contents of an iframe (one consideration was to create an ActiveX control, since this would be for internal corporate use only, but I would prefer it to be cross-browser compatible)?</p>
| [
{
"answer_id": 335877,
"author": "Kornel",
"author_id": 27009,
"author_profile": "https://Stackoverflow.com/users/27009",
"pm_score": 3,
"selected": true,
"text": "document.domain"
},
{
"answer_id": 523944,
"author": "Luca Tettamanti",
"author_id": 42448,
"author_prof... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41877/"
] |
335,833 | <p>I'd appreciate some feedback on a particular approach I'm thinking of using. The scenario is below.</p>
<p>I have an object (lets call it MObject) that has a number of properties, say, x and y coordinates, height and width. The properties are named according to the KVC guidelines (MObject.x; MObject.height, etc). My next task, is to read in an XML file that describes this MObject. Unfortunately, the XML elements are named differently -- X and Y, Height and Width (note the capitalization). </p>
<p>Ideally, the XML elements would match up with MObject's properties. In this case, I could use KVC and avoid a whole whack of code:</p>
<pre><code>for (xmlProperty in xmlElement)
{
[MObject setValue:xmlProperty.value forKey:xmlProperty.name].
}
</code></pre>
<p>One way of approaching this would be to make use of case-insensitive keys. Where would I start with that? Are there any other, better solutions?</p>
<p>Suggestions very much appreciated.</p>
| [
{
"answer_id": 335904,
"author": "Marc Charbonneau",
"author_id": 35136,
"author_profile": "https://Stackoverflow.com/users/35136",
"pm_score": 2,
"selected": false,
"text": "lowercaseString"
},
{
"answer_id": 336014,
"author": "Peter Hosey",
"author_id": 30461,
"auth... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38753/"
] |
335,839 | <p>Note that this function does not have a "{" and "}" body. Just a try/catch block:</p>
<pre><code>void func( void )
try
{
...
}
catch(...)
{
...
}
</code></pre>
<p>Is this intentionally part of C++, or is this a g++ extension?</p>
<p>Is there any purpose to this other than bypass 1 level of {}?</p>
<p>I'd never heard of this until I ran into <a href="http://stupefydeveloper.blogspot.com/2008/10/c-function-try-catch-block.html" rel="noreferrer">http://stupefydeveloper.blogspot.com/2008/10/c-function-try-catch-block.html</a></p>
| [
{
"answer_id": 335860,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": false,
"text": "return x;"
}
] | 2008/12/02 | [
"https://Stackoverflow.com/questions/335839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13022/"
] |
335,841 | <p>I've tried this both with and without the 'ExceptionType' parameter. I have an Error.aspx page in both the Views/Shared folder and the Views/thisController folder. But everytime I run this I get a "Server Error in '/' Application." error page, rather than the nice one in Views/Shared.</p>
<p>Any idea what could be going wrong here?</p>
<pre><code>[HandleError(View="Error",ExceptionType=typeof(FormatException))]
public ActionResult Create()
{
throw new Exception();
//int breakMe = int.Parse("not a number");
return View();
}
</code></pre>
| [
{
"answer_id": 335982,
"author": "Todd Smith",
"author_id": 31624,
"author_profile": "https://Stackoverflow.com/users/31624",
"pm_score": 1,
"selected": false,
"text": "// If custom errors are disabled, we need to let the normal ASP.NET exception handler\n// execute so that the user can ... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40814/"
] |
335,847 | <p>This is not to be confused with <a href="https://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible">"How to tell if a DOM element is visible?"</a></p>
<p>I want to determine if a given DOM element is visible on the page.
E.g. if the element is a child of a parent which has <code>display:none;</code> set, then it won't be visible.</p>
<p>(This has nothing to do with whether the element is in the viewport or not)</p>
<p>I could iterate through each parent of the element, checking the <code>display</code> style, but I'd like to know if there is a more direct way?</p>
| [
{
"answer_id": 335864,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "display:none"
},
{
"answer_id": 335961,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6691/"
] |
335,849 | <p>I have run into an issue with WPF and Commands that are bound to a Button inside the DataTemplate of an ItemsControl. The scenario is quite straight forward. The ItemsControl is bound to a list of objects, and I want to be able to remove each object in the list by clicking a Button. The Button executes a Command, and the Command takes care of the deletion. The CommandParameter is bound to the Object I want to delete. That way I know what the user clicked. A user should only be able to delete their "own" objects - so I need to do some checks in the "CanExecute" call of the Command to verify that the user has the right permissions.</p>
<p>The problem is that the parameter passed to CanExecute is NULL the first time it's called - so I can't run the logic to enable/disable the command. However, if I make it allways enabled, and then click the button to execute the command, the CommandParameter is passed in correctly. So that means that the binding against the CommandParameter is working.</p>
<p>The XAML for the ItemsControl and the DataTemplate looks like this:</p>
<pre><code><ItemsControl
x:Name="commentsList"
ItemsSource="{Binding Path=SharedDataItemPM.Comments}"
Width="Auto" Height="Auto">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button
Content="Delete"
FontSize="10"
Command="{Binding Path=DataContext.DeleteCommentCommand, ElementName=commentsList}"
CommandParameter="{Binding}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</code></pre>
<p>So as you can see I have a list of Comments objects. I want the CommandParameter of the DeleteCommentCommand to be bound to the Command object.</p>
<p>So I guess my question is: have anyone experienced this problem before? CanExecute gets called on my Command, but the parameter is always NULL the first time - why is that?</p>
<p><strong>Update:</strong> I was able to narrow the problem down a little. I added an empty Debug ValueConverter so that I could output a message when the CommandParameter is data bound. Turns out the problem is that the CanExecute method is executed before the CommandParameter is bound to the button. I have tried to set the CommandParameter before the Command (like suggested) - but it still doesn't work. Any tips on how to control it.</p>
<p><strong>Update2:</strong> Is there any way to detect when the binding is "done", so that I can force re-evaluation of the command? Also - is it a problem that I have multiple Buttons (one for each item in the ItemsControl) that bind to the same instance of a Command-object?</p>
<p><strong>Update3:</strong> I have uploaded a reproduction of the bug to my SkyDrive: <a href="http://cid-1a08c11c407c0d8e.skydrive.live.com/self.aspx/Code%20samples/CommandParameterBinding.zip" rel="noreferrer">http://cid-1a08c11c407c0d8e.skydrive.live.com/self.aspx/Code%20samples/CommandParameterBinding.zip</a></p>
| [
{
"answer_id": 340755,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "CommandParameter=\n \"{Binding RelativeSource={RelativeSource AncestorType=ContextMenu},\n Path=Pl... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199387/"
] |
335,855 | <p>I'm writing a GUI application that will let users interact with command-line programs. The programs are crystallography programs, in this case. They take a long time to run.</p>
<p>There's a certain common workflow using the command-line programs. The output from one program is typically processed and then is used by other programs. The user needs to be able to fill in various text boxes and select options that are sent to the command-line programs.</p>
<p>As I'm lazy and don't want to do more work than I need to, what tools are out there that will help me in doing this? The software needs to work initially on Linux, but also running on Windows at some point would be neat. </p>
<p>Would also be neat if there was some sort of DSL for non-programmers to be able to extend/modify the GUI application (to add new programs and change the options and so on).</p>
| [
{
"answer_id": 335878,
"author": "Din",
"author_id": 41214,
"author_profile": "https://Stackoverflow.com/users/41214",
"pm_score": -1,
"selected": false,
"text": "object console = WShell.Exec(cmdLine);\nif (console.StdOut.AtEndOfStream)\n s = Pipe.StdOut.ReadLine();\n"
}
] | 2008/12/02 | [
"https://Stackoverflow.com/questions/335855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17076/"
] |
335,863 | <p>/dev/md1 6068992 5204648 551080 91% /</p>
<p>I have 91% taken and am trying to discover what files are taking up space. I'm using linux. Does any one know the command?</p>
<p>thanks</p>
| [
{
"answer_id": 335865,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 3,
"selected": false,
"text": "du -k -S -x / | sort -n -r | head -10"
},
{
"answer_id": 335869,
"author": "Alnitak",
"author_id": 6782,
... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
335,873 | <p>Is there a limitation in the length of a query that SQL Server can handle?</p>
<p>I have a normal SqlCommand object and pass a very long select statement as a string. </p>
<p>The query seems to be fine when running against an SQL Server 2005/2008 engine but doesn't execute against an SQL Server 2000 engine. </p>
<p>I don't have any error details as I only have this information 3rd hand but my application isn't working as expected. I could go to the trouble of installing an SQL Server 2000 instance but I was just wondering if anyone has a quick. Yes there is a 4K or 8K limit in SQL Server 2000 but not in 2005 type answer.</p>
<p>I'm aware that I could use stored procedures but lets assume I have a valid reason for not using them :-)</p>
| [
{
"answer_id": 335912,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 3,
"selected": false,
"text": "SQLCommand command = new SqlCommand(\"exec sp_executeSQL @CMD\");\ncommand.Parameters.Add(new SqlParameter(\"@CMD\",YourDyna... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4403/"
] |
335,885 | <p>I am looking for a way to slide a UIPickerView (and UIDatePickerView) up over a view (UITableView in particular) when a particular button press takes place.</p>
<p>I understand how to get the events for clicks into the UITableView, but there doesn't seem to be a good way to have the UIPickerView slide up on top of it...</p>
<p>All the examples I have seen so far just have it snapped to the bottom of another view and I am able to do this without issue.</p>
<p>Thoughts?</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 501019,
"author": "Brad Parks",
"author_id": 26510,
"author_profile": "https://Stackoverflow.com/users/26510",
"pm_score": 2,
"selected": false,
"text": "UIWindow *window = [[Director sharedDirector] window];\n\n[UIView beginAnimations:nil context:nil];\n[UIView setAnimati... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
335,886 | <p>I want to do something like</p>
<pre><code>select * from tvfHello(@param) where @param in (Select ID from Users)
</code></pre>
| [
{
"answer_id": 335895,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 0,
"selected": false,
"text": "SELECT * FROM dbo.tvfHello(@param) WHERE @param IN (SELECT ID FROM Users)\n"
},
{
"answer_id": 335903,
"auth... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30546/"
] |
335,888 | <p>I have a user table in my mysql database that has a password column. Currently, I use the MD5 algorithm to hash the users' password for storage in the database. Now I like to think that I am a security conscience person. I noticed while reading the MySQL docs that they don't recommend MD5 or the SHA/SHA1 hashing methods, but don't offer an alternative. </p>
<p>What would be the best way to hash my passwords in MySQL? A function that is natively supported in both PHP and MySQL would be ideal and necessary with my current implementation.</p>
<p>Thanks!</p>
| [
{
"answer_id": 335913,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 2,
"selected": false,
"text": "hash()"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/335888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42135/"
] |
335,891 | <p>I have the following shell script registered in my "Login Items" preferences but it does not seem to have any effect. It is meant to launch the moinmoin wiki but only works when it is run by hand from a terminal window, after which it runs until the machine is next shut down.</p>
<pre><code>#!/bin/bash
cd /Users/stuartcw/Documents/Wiki/moin-1.7.2
/usr/bin/python wikiserver.py >> logs/`date +"%d%b%Y"`.log 2>&1 &
</code></pre>
<p>I would really like the Wiki to be available after restarting so any help in understanding this would be appreciated.</p>
| [
{
"answer_id": 336239,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 3,
"selected": true,
"text": "/Library/LaunchDaemons"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/335891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27065/"
] |
335,896 | <p>I am trying to write my first real python function that does something real. What i want to accomplish is searching a given folder, and then open all images and merging them together so they make a filmstrip image. Imagine 5 images stacked on top of eachother in one image.</p>
<p>I have this code now, which should be pretty much ok, but propably needs some modification:</p>
<pre><code>import os
import Image
def filmstripOfImages():
imgpath = '/path/here/'
files = glob.glob(imgpath + '*.jpg')
imgwidth = files[0].size[0]
imgheight = files[0].size[1]
totalheight = imgheight * len(files)
filename = 'filmstrip.jpg'
filmstrip_url = imgpath + filename
# Create the new image. The background doesn't have to be white
white = (255,255,255)
filmtripimage = Image.new('RGB',(imgwidth, totalheight),white)
row = 0
for file in files:
img = Image.open(file)
left = 0
right = left + imgwidth
upper = row*imgheight
lower = upper + imgheight
box = (left,upper,right,lower)
row += 1
filmstripimage.paste(img, box)
try:
filmstripimage.save(filename, 'jpg', quality=90, optimize=1)
except:
filmstripimage.save(miniature_filename, 'jpg', quality=90)")
</code></pre>
<p>How do i modify this so that it saves the new filmstrip.jpg in the same directory as I loaded the images from? And it probably has some things that are missing or wrong, anybody got a clue?</p>
<p>Related question: <a href="https://stackoverflow.com/questions/334827/how-to-generate-a-filmstrip-image-in-python-from-a-folder-of-images">How to generate a filmstrip image in python from a folder of images?</a></p>
| [
{
"answer_id": 335916,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 1,
"selected": false,
"text": "try"
},
{
"answer_id": 335921,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://St... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42546/"
] |
335,928 | <p>I am attempting to link an application with g++ on this Debian lenny system. ld is complaining it cannot find specified libraries. The specific example here is ImageMagick, but I am having similar problems with a few other libraries too.</p>
<p>I am calling the linker with:</p>
<pre><code>g++ -w (..lots of .o files/include directories/etc..) \
-L/usr/lib -lmagic
</code></pre>
<p>ld complains:</p>
<pre><code>/usr/bin/ld: cannot find -lmagic
</code></pre>
<p>However, libmagic exists:</p>
<pre><code>$ locate libmagic.so
/usr/lib/libmagic.so.1
/usr/lib/libmagic.so.1.0.0
$ ls -all /usr/lib/libmagic.so.1*
lrwxrwxrwx 1 root root 17 2008-12-01 03:52 /usr/lib/libmagic.so.1 -> libmagic.so.1.0.0
-rwxrwxrwx 1 root root 84664 2008-09-09 00:05 /usr/lib/libmagic.so.1.0.0
$ ldd /usr/lib/libmagic.so.1.0.0
linux-gate.so.1 => (0xb7f85000)
libz.so.1 => /usr/lib/libz.so.1 (0xb7f51000)
libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7df6000)
/lib/ld-linux.so.2 (0xb7f86000)
$ sudo ldconfig -v | grep "libmagic"
libmagic.so.1 -> libmagic.so.1.0.0
</code></pre>
<p>How do I diagnose this problem further, and what could be wrong? Am I doing something completely stupid?</p>
| [
{
"answer_id": 335958,
"author": "grepsedawk",
"author_id": 14388,
"author_profile": "https://Stackoverflow.com/users/14388",
"pm_score": 9,
"selected": true,
"text": "libmagic.so"
},
{
"answer_id": 335960,
"author": "Brian Gianforcaro",
"author_id": 3415,
"author_pro... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10733/"
] |
335,930 | <p>Suppose there´s a template function in C++ that does some useful work but also outputs a sequence of values via an output iterator. Now suppose that that sequence of values sometimes is interesting, but at others is not useful. Is there a ready-to-use iterator class in the STL that can be instantiated and passed to the function and will ignore any values the function tries to assign to the output iterator? To put in another way, send all data to /dev/null?</p>
| [
{
"answer_id": 335950,
"author": "Mark Ransom",
"author_id": 5987,
"author_profile": "https://Stackoverflow.com/users/5987",
"pm_score": 2,
"selected": false,
"text": "template<typename T>\nclass NullOutputIterator\n{\npublic:\n NullOutputIterator() {}\n NullOutputIterator& operato... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/78828/"
] |
335,932 | <p>I am working on an ASP.NET MVC application that contains a header and menu on each page. The menu and header are dynamic. In other words, the menu items and header information are determined at runtime.</p>
<p>My initial thought is to build a base Controller from which all other controllers derive. In the base controller, I will obtain the menu and header data and insert the required information into the ViewData. Finally, I will use a ViewUserControl to display the header and menu through a master page template.</p>
<p>So, I'm trying to determine the best practice for building such functionality. Also, if this is the recommended approach, which method should I override (I'm guessing Execute) when obtaining the data for insertion into the ViewData.</p>
<p>I'm sure this is a common scenario, so any advice/best-practices would be appreciated! Thanks in advance!</p>
<p>EDIT:
I did find the following resources after posting this (of course), but any additional anecdotes would be awesome!</p>
<p><a href="http://www.singingeels.com/Blogs/Nullable/2008/08/14/How_to_Handle_Side_Content_in_ASPNET_MVC.aspx" rel="nofollow noreferrer">http://www.singingeels.com/Blogs/Nullable/2008/08/14/How_to_Handle_Side_Content_in_ASPNET_MVC.aspx</a></p>
<p><a href="https://stackoverflow.com/questions/326987/how-do-you-use-usercontrols-in-aspnet-mvc-that-display-an-island-of-data">How do you use usercontrols in asp.net mvc that display an "island" of data?</a></p>
| [
{
"answer_id": 3465822,
"author": "Anthony Johnston",
"author_id": 122232,
"author_profile": "https://Stackoverflow.com/users/122232",
"pm_score": 1,
"selected": false,
"text": "public static HtmlString MainMenu(this HtmlHelper helper)\n"
},
{
"answer_id": 3503876,
"author": ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2657/"
] |
335,933 | <p>I traditionally deploy a set of web pages which allow for manual validation of core application functionality. One example is LoggerTest.aspx which generates and logs a test exception. I've always chosen to raise a DivideByZeroException using an approach similar to the following code snippet: </p>
<pre><code>try
{
int zero = 0;
int result = 100 / zero;
}
catch (DivideByZeroException ex)
{
LogHelper.Error("TEST EXCEPTION", ex);
}
</code></pre>
<p>The code works just fine but I feel like there must be a more elegant solution. Is there a best way to raise an exception in C#?</p>
| [
{
"answer_id": 335936,
"author": "Jesse Millikan",
"author_id": 7526,
"author_profile": "https://Stackoverflow.com/users/7526",
"pm_score": 5,
"selected": false,
"text": "throw new Exception(\"Test Exception\");\n"
},
{
"answer_id": 335939,
"author": "asleep",
"author_id"... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4115/"
] |
335,951 | <p>For a web application, when creating the user which will connect to the MySQL database, you have the choice of privileges. Assuming that the only actions intended to be done by that user are SELECT/INSERT/UPDATE/DELETE, it seems to make sense to only provide those privileges, however I've never seen that recommended anywhere - what are the reasons for and against this method?</p>
| [
{
"answer_id": 335964,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 4,
"selected": true,
"text": "SELECT * FROM mytable, mytable, mytable, mytable, mytable ORDER BY 1;\n"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/335951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
335,955 | <p>I've been slowly working my way through the list of Project Euler problems, and I've come to one that I know how to solve, but it seems like I can't (given the way my solution was written).</p>
<p>I am using Common Lisp to do this with and my script has been running for over 24 hours (well over their one minute goal).</p>
<p>For the sake of conciseness, here's my solution (it's a spoiler, but only if you have one hell of a fast processor):</p>
<pre><code>(defun square? (num)
(if (integerp (sqrt num)) T))
(defun factors (num)
(let ((l '()))
(do ((current 1 (1+ current)))
((> current (/ num current)))
(if (= 0 (mod num current))
(if (= current (/ num current))
(setf l (append l (list current)))
(setf l (append l (list current (/ num current)))))))
(sort l #'< )))
(defun o_2 (n)
(reduce #'+ (mapcar (lambda (x) (* x x)) (factors n))))
(defun sum-divisor-squares (limit)
(loop for i from 1 to limit when (square? (o_2 i)) summing i))
(defun euler-211 ()
(sum-divisor-squares 64000000))
</code></pre>
<p>The time required to solve the problem using smaller, more friendly, test arguments seems to grow larger than exponentialy... which is a real problem.</p>
<p>It took:</p>
<ul>
<li>0.007 seconds to solve for 100</li>
<li>0.107 seconds to solve for 1000</li>
<li>2.020 seconds to solve for 10000</li>
<li>56.61 seconds to solve for 100000</li>
<li>1835.385 seconds to solve for 1000000</li>
<li>24+ hours to solve for 64000000</li>
</ul>
<p>I'm really trying to figure out which part(s) of the script is causing it to take so long. I've put some thought into memoizing the factors function, but I'm at a loss as to how to actually implement that.</p>
<p>For those that want to take a look at the problem itself, <a href="http://projecteuler.net/index.php?section=problems&id=211" rel="nofollow noreferrer">here it be</a>.</p>
<p>Any ideas on how to make this thing go faster would be greatly appreciated.</p>
<p>**sorry if this is a spoiler to anyone, it's not meant to be.... but if you have the computing power to run this in a decent amount of time, more power to you.</p>
| [
{
"answer_id": 336020,
"author": "Svante",
"author_id": 31615,
"author_profile": "https://Stackoverflow.com/users/31615",
"pm_score": 2,
"selected": false,
"text": "l"
},
{
"answer_id": 336322,
"author": "Josh Sandlin",
"author_id": 13293,
"author_profile": "https://S... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13293/"
] |
335,963 | <p>I'm using VSTS Database Edition GDR Version 9.1.31024.02</p>
<p>I've got a project where we will be creating multiple databases with identical schema, on the fly, as customers are added to the system. It's one DB per customer. I thought I should be able to use the deploy script to do this. Unfortunately I always get the full filenames specified on the CREATE DATABASE statement. For example:</p>
<pre><code>CREATE DATABASE [$(DatabaseName)]
ON
PRIMARY(NAME = [targetDBName], FILENAME = N'$(DefaultDataPath)targetDBName.mdf')
LOG ON (NAME = [targetDBName_log], FILENAME = N'$(DefaultDataPath)targetDBName_log.ldf')
GO
</code></pre>
<p>I'd expected something more like this </p>
<pre><code>CREATE DATABASE [$(DatabaseName)]
ON
PRIMARY(NAME = [targetDBName], FILENAME = N'$(DefaultDataPath)$(DatabaseName).mdf')
LOG ON (NAME = [targetDBName_log], FILENAME = N'$(DefaultDataPath)$(DatabaseName)_log.ldf')
GO
</code></pre>
<p>Or even </p>
<pre><code>CREATE DATABASE [$(DatabaseName)]
</code></pre>
<p>I'm not going to be running this on an on-going basis so I'd like to make it as simple as possible, for the next guy. There are a bunch of options for deployment in the project properties, but I can't get this to work the way I'd like.</p>
<p>Any one know how to set this up?</p>
| [
{
"answer_id": 1690719,
"author": "Rory MacLeod",
"author_id": 1016,
"author_profile": "https://Stackoverflow.com/users/1016",
"pm_score": 2,
"selected": false,
"text": "$(DefaultDataPath)$(DatabaseName)"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/335963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5130/"
] |
335,965 | <p>I am working on adding in a settings bundle for my application as a cheap way of getting a GUI on my preferences. Is it possible to launch this from a button in my application or will my users always have to access it manually via the built in settings application?</p>
| [
{
"answer_id": 446430,
"author": "Rhubarb",
"author_id": 20479,
"author_profile": "https://Stackoverflow.com/users/20479",
"pm_score": 2,
"selected": false,
"text": "// Invoked after the application has been launched and initialized but before it has received its first event.\n- (void)ap... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8918/"
] |
335,966 | <p>Here's the scenario</p>
<p>I have a Grid with some TextBlock controls, each in a separate cell in the grid. Logically I want to be able to set the Visibility on them bound to a property in my ViewModel. But since they're each in a separate cell in the grid, I have to set each TextBlock's Visibility property.</p>
<p>Is there a way of having a non-visual group on which I can set common properties of its children? Or am I dreaming?</p>
| [
{
"answer_id": 336005,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 2,
"selected": false,
"text": "public class Singleton :INotifyPropertyChanged\n{\n private Singleton() { }\n public static Singleton Instance\n {... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14537/"
] |
335,971 | <p>Are there instances where switch(case) is is a good design choice (except for simplicity) over strategy or similar patterns... </p>
| [
{
"answer_id": 335995,
"author": "lacker",
"author_id": 2652,
"author_profile": "https://Stackoverflow.com/users/2652",
"pm_score": 3,
"selected": false,
"text": "\nvector<string> possible_forms;\npossible_forms.push_back(word);\nchar last_letter = word[word.size() - 1];\nswitch (last_le... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30917/"
] |
335,987 | <p>A few times already, I got into situations where one of my SVN repository got corrupt and we could do anything with some versions or branches of the project without really knowing what we did. So I'm asking what can cause a repository to become corrupt?</p>
<hr>
<p>It seems that incompatibilities between clients may cause problems, more specifically with character sets.</p>
| [
{
"answer_id": 336011,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "kill -9"
},
{
"answer_id": 336135,
"author": "PostMan",
"author_id": 18405,
"author_profile": "https://Sta... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39057/"
] |
336,018 | <p>I have a class <code>Page</code> that creates an instance of <code>DB</code>, which is named <code>$db</code>.</p>
<p>In the <code>__construct()</code> of <code>Page</code>, I create the new <code>$db</code> object and I pull a bunch of config data from a file.</p>
<p>Now the DB class has a method <code>_connectToDB()</code> which (attempts) to connect to the database.</p>
<p>Is there a way in the DB class to call the parent class's config array? I don't want to make global variables if I don't have to and I don't want to grab the config data twice.</p>
<p>Pseudo code might look something like this...</p>
<pre><code>$dbUsername = get_calling_class_vars(configArray['dbUserName']);
</code></pre>
| [
{
"answer_id": 336036,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 1,
"selected": false,
"text": "debug_backtrace()"
},
{
"answer_id": 336041,
"author": "JW.",
"author_id": 4321,
"author_profile":... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31671/"
] |
336,035 | <p>I have a DataGridViewComboBoxColumn in a DataGridView that's based on a lookup table.</p>
<p>The ValueMember and DisplayMember fields are bound to string columns in the DataTable. All rows have a value for both fields - except for a special record where the value field is deliberately set to NULL.</p>
<p>However, when I choose this record an empty string is used instead of DBNull.Value in the DataTable bound to the DataGridView. This is happening at data entry time, before the data is pushed to the database. </p>
<p>I've checked out the DataGridViewComboBoxColumn and DataGridView classes - there appears to be no simple way to customise this behaviour. Does anybody know if this is possible?</p>
| [
{
"answer_id": 336569,
"author": "Mitkins",
"author_id": 23401,
"author_profile": "https://Stackoverflow.com/users/23401",
"pm_score": 3,
"selected": true,
"text": "void Schedule_ColumnChanging(object sender, DataColumnChangeEventArgs e)\n{\n if \n ( \n e.Column.ColumnName =... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23401/"
] |
336,073 | <p>I keep finding that if I have nested divs inside each other, and one of the inner ones is floated, the outer one won't expand around it.</p>
<p>Example:</p>
<pre><code><div style='background-color:red; '>
asdfasdf
<div style='float:left; background-color:blue; width:400px; height:400px;'>
asdfasdfasdfasdfasdfasdfasdf<br />
asdfasdfasdfasdfasdfasdfasdf<br />
asdfasdfasdfasdfasdfasdfasdf<br />
asdfasdfasdfasdfasdfasdfasdf<br />
asdfasdfasdfasdfasdfasdfasdf<br />
asdfasdfasdfasdfasdfasdfasdf<br />
asdfasdfasdfasdfasdfasdfasdf<br />
asdfasdfasdfasdfasdfasdfasdf<br />
asdfasdfasdfasdfasdfasdfasdf<br />
asdfasdfasdfasdfasdfasdfasdf<br />
asdfasdfasdfasdfasdfasdfasdf<br />
</div>
asdfasdf
</div>
</code></pre>
<p>What do I need to do to the outer div to make it cover the inner one? IE: Put it's border/background color all the way around it?</p>
<p>Also, is there a general principle I am bumping up against here? If so, what should I look up to get a solid understanding of what it is?</p>
<p>Thanks!</p>
<p><strong>Edit</strong></p>
<p>Hi All, </p>
<p>Thanks for the answers, semantically correct and no, and for the links.</p>
<p>Though I will end up using overflow in the final work, I will leave Ant P's answer as accepted, as it was the first one that really worked, and got me out of a short term jam, even though it offends semantic sensibilities.</p>
<p>As a long-time html hack trying to move to decent css layouts, I can certainly understand, and sympathize with, using semantically incorrect hack that gets the job done, though I am sure he will change that habit after this =o)</p>
| [
{
"answer_id": 336177,
"author": "themis",
"author_id": 42706,
"author_profile": "https://Stackoverflow.com/users/42706",
"pm_score": 5,
"selected": true,
"text": "<div style='background-color:red;overflow:hidden;'>\n...\n</div>\n"
},
{
"answer_id": 336301,
"author": "Darko",... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27580/"
] |
336,078 | <p>I use <em>lazy connection</em> to connect to my DB within my DB object. This basically means that it doesn't call mysql_connect() until the first query is handed to it, and it subsequently skips reconnecting from then on after.</p>
<p>Now I have a method in my DB class called <code>disconnectFromDB()</code> which pretty much calls <code>mysql_close()</code> and sets <code>$_connected = FALSE</code> (so the <code>query()</code> method will know to connect to the DB again). Should this be called after every query (as a private function) or externally via the object... because I was thinking something like (code is an example only)</p>
<pre><code>$students = $db->query('SELECT id FROM students');
$teachers = $db->query('SELECT id FROM teachers');
</code></pre>
<p>Now if it was closing after every query, would this slow it down a lot as opposed to me just adding this line to the end</p>
<pre><code>$db->disconnectFromDB();
</code></pre>
<p>Or should I just include that line above at the very end of the page?</p>
<p>What advantages/disadvantages do either have? What has worked best in your situation? Is there anything really wrong with forgetting to close the mySQL connection, besides a small loss of performance?</p>
<p>Appreciate taking your time to answer.</p>
<p>Thank you!</p>
| [
{
"answer_id": 336109,
"author": "too much php",
"author_id": 28835,
"author_profile": "https://Stackoverflow.com/users/28835",
"pm_score": 3,
"selected": false,
"text": "$_connected"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/336078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31671/"
] |
336,127 | <p>I need a method for adding "business days" in PHP. For example, Friday 12/5 + 3 business days = Wednesday 12/10.</p>
<p>At a minimum I need the code to understand weekends, but ideally it should account for US federal holidays as well. I'm sure I could come up with a solution by brute force if necessary, but I'm hoping there's a more elegant approach out there. Anyone?</p>
<p>Thanks.</p>
| [
{
"answer_id": 336155,
"author": "Tim",
"author_id": 33914,
"author_profile": "https://Stackoverflow.com/users/33914",
"pm_score": 4,
"selected": false,
"text": "$busDays = 3;\n$day = date(\"w\");\nif( $day > 2 && $day <= 5 ) { /* if between Wed and Fri */\n $day += 2; /* add 2 more day... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1103/"
] |
336,138 | <p>Are all the additions to C# for version 4 (dynamic, code contracts etc) expected to run on the current .NET CLR, or is there a planned .NET upgrade as well?</p>
| [
{
"answer_id": 336278,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "dynamic"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/336138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5302/"
] |
336,144 | <p>I have an application where I would like to have mixed Java and Scala source (actually its migrating a java app to scala - but a bit at a time). </p>
<p>I can make this work in IDEs just fine, very nice. But I am not sure how to do this with maven - scalac can compile java and scala intertwined, but how to I set up maven for the module? </p>
<p>Also, does my scala source have to be a different folder to the java? </p>
| [
{
"answer_id": 336187,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 4,
"selected": false,
"text": "src/main/scala"
},
{
"answer_id": 336398,
"author": "lindelof",
"author_id": 1428,
"author_profile": "ht... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/699/"
] |
336,148 | <p>I've been told that the java class TreeMap uses an implementation of a RB tree. If this is the case, how does one do an inorder, preorder and postorder tree-walk on a TreeMap?</p>
<p>Or is this not possible?</p>
| [
{
"answer_id": 336164,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 4,
"selected": true,
"text": "printTree()"
},
{
"answer_id": 338815,
"author": "Rich",
"author_id": 42897,
"author_profile": "h... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] |
336,205 | <p>I tried to precompile my ASP.NET MVC application and deploy it to an IIS6 box (with wildcard mapping), however I am getting an error with rendering partial views (user controls). Its working fine on my dev machine before precompiling.</p>
<p>The error is:</p>
<blockquote>
<p>Server Error in '/' Application.<br />
<br />
The partial view 'ListGrid' could not<br />
be found. The following locations were<br />
searched:<br />
~/Views/Initiative/ListGrid.aspx<br />
~/Views/Initiative/ListGrid.ascx<br />
~/Views/Shared/ListGrid.aspx<br />
~/Views/Shared/ListGrid.ascx<br /></p>
</blockquote>
<p>I checked Views\Shared for the file and it was not there, which I thought was normal because its precompiled. But just for giggles I put a blank file in that folder names ListGrid.ascx, but then I got this error:</p>
<blockquote>
<p>Server Error in '/' Application.<br />
<br />
The file '/Views/Shared/ListGrid.ascx'<br />
has not been pre-compiled, and cannot<br />
be requested.</p>
</blockquote>
<p>I googled and searched SO but could not find any similar problems, but had no luck.</p>
| [
{
"answer_id": 4494229,
"author": "mgerety",
"author_id": 122007,
"author_profile": "https://Stackoverflow.com/users/122007",
"pm_score": 4,
"selected": false,
"text": "C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\aspnet_compiler -p \"$(ProjectDir).\" -v /$(ProjectName)\n"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/336205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37786/"
] |
336,210 | <p>Is there a regular expression which checks if a string contains only upper and lowercase letters, numbers, and underscores?</p>
| [
{
"answer_id": 336214,
"author": "Drew Hall",
"author_id": 23934,
"author_profile": "https://Stackoverflow.com/users/23934",
"pm_score": 4,
"selected": false,
"text": "^([A-Za-z]|[0-9]|_)+$\n"
},
{
"answer_id": 336215,
"author": "BenAlabaster",
"author_id": 40650,
"au... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
336,226 | <p>Stupid questions but cant get my head around it...
I have a string in this format 20081119</p>
<p>And I have a C# method that converts the string to a DateTime to be entered into a SQL Server DB </p>
<pre><code>public static DateTime MyDateConversion(string dateAsString)
{
return System.DateTime.ParseExact(dateAsString, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
}
</code></pre>
<p>The problem is that the Date is coming out like this: Date = 19/11/2008 12:00:00 AM and I need it to be a DateTime of type yyyyMMdd as I am mapping it into a schema to call a stored proc.</p>
<p>Thanks in advance guys.</p>
<p>Cheers,
Con</p>
| [
{
"answer_id": 336249,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": false,
"text": "DbParameter param = cmd.CreateParameter();\nparam.ParameterName = \"@foo\";\nparam.DbType = DbType.DateTime;\nparam.V... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
336,235 | <p>I have installed VS 2008 SP1 on W2k3 OS. After I installed ASP.NET MVC beta and tried creating ASP.NET MVC type project I get the following error.</p>
<p>"the project type is not supported by this installation"</p>
<p>Let me know if you have fixed this issue.</p>
| [
{
"answer_id": 696120,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 4,
"selected": false,
"text": "devenv /setup\n"
},
{
"answer_id": 1573448,
"author": "Vivek Ayer",
"author_id": 128263,
"author_profil... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26788/"
] |
336,240 | <p>I am using Zend Framework(MVC part of it), and need to either redirect user to SSL enabled page or to force SSL from controller somehow and don't quite see how to do that? Maybe someone can share the knowledge? </p>
<p>Thanks!</p>
| [
{
"answer_id": 336261,
"author": "Matt Howell",
"author_id": 2321,
"author_profile": "https://Stackoverflow.com/users/2321",
"pm_score": 3,
"selected": false,
"text": "RewriteEngine On\nRewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}\n"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/336240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35520/"
] |
336,250 | <p>EDIT: I've tagged this C in a hope to get more response. It's more the theory I'm interested in than a specific language implementation. So if you're a C coder please treat the following PHP as pseudo-code and feel free to respond with an answer written in C.</p>
<p>I am trying to speed up a PHP CLI script by having it execute its tasks in parallel instead of serial. The tasks are completely independent of each other so it doesn't matter which order they start/finish in.</p>
<p>Here's the original script (note all these examples are stripped-back for clarity):</p>
<pre><code><?php
$items = range(0, 100);
function do_stuff_with($item) { echo "$item\n"; }
foreach ($items as $item) {
do_stuff_with($item);
}
</code></pre>
<p>I've managed to make it work on the <code>$items</code> in parallel with <a href="http://php.net/pcntl_fork" rel="nofollow noreferrer"><code>pcntl_fork()</code></a> as shown below:</p>
<pre><code><?php
ini_set('max_execution_time', 0);
ini_set('max_input_time', 0);
set_time_limit(0);
$items = range(0, 100);
function do_stuff_with($item) { echo "$item\n"; }
$pids = array();
foreach ($items as $item) {
$pid = pcntl_fork();
if ($pid == -1) {
die("couldn't fork()");
} elseif ($pid > 0) {
// parent
$pids[] = $pid;
} else {
// child
do_stuff_with($item);
exit(0);
}
}
foreach ($pids as $pid) {
pcntl_waitpid($pid, $status);
}
</code></pre>
<p>Now I want to extend this so there's a maximum of, say, 10 children active at once. What's the best way of handling this? I've tried a few things but haven't had much luck.</p>
| [
{
"answer_id": 336330,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 2,
"selected": false,
"text": "socket_select()"
},
{
"answer_id": 336471,
"author": "qrdl",
"author_id": 28494,
"author_profile... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
336,268 | <p>I thought these were synonomous, but I wrote the following in Microsoft SQL:</p>
<pre><code>Select Unique col from
(select col from table1 union select col from table2) alias
</code></pre>
<p>And it failed. Changing it to </p>
<pre><code>Select Distinct col from
(select col from table1 union select col from table2) alias
</code></pre>
<p>fixed it. Can someone explain?</p>
| [
{
"answer_id": 336273,
"author": "BenAlabaster",
"author_id": 40650,
"author_profile": "https://Stackoverflow.com/users/40650",
"pm_score": 7,
"selected": false,
"text": "Create Table Employee( \n Emp_PKey Int Identity(1, 1) Constraint PK_Employee_Emp_PKey Primary Key, \n Emp_SS... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42712/"
] |
336,288 | <p>Presently I'm starting to introduce the concept of Mock objects into my Unit Tests. In particular I'm using the Moq framework. However, one of the things I've noticed is that suddenly the classes I'm testing using this framework are showing code coverage of 0%.</p>
<p>Now I understand that since I'm just mocking the class, its not running the actual class itself....but how do I write these tests and have Code Coverage return accurate results? Do I have to write one set of tests that use Mocks and one set to instantiate the class directly.</p>
<p>Perhaps I am doing something wrong without realizing it?</p>
<p>Here is an example of me trying to Unit Test a class called "MyClass":</p>
<pre><code>using Moq;
using NUnitFramework;
namespace MyNameSpace
{
[TestFixture]
public class MyClassTests
{
[Test]
public void TestGetSomeString()
{
const string EXPECTED_STRING = "Some String!";
Mock<MyClass> myMock = new Mock<MyClass>();
myMock.Expect(m => m.GetSomeString()).Returns(EXPECTED_STRING);
string someString = myMock.Object.GetSomeString();
Assert.AreEqual(EXPECTED_STRING, someString);
myMock.VerifyAll();
}
}
public class MyClass
{
public virtual string GetSomeString()
{
return "Hello World!";
}
}
}
</code></pre>
<p>Does anyone know what I should be doing differently?</p>
| [
{
"answer_id": 336314,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 5,
"selected": true,
"text": "using Moq;\nusing NUnitFramework;\n\nnamespace MyNameSpace\n {\n [TestFixture]\n public class MyClassTests\... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39532/"
] |
336,289 | <p>In vc++ i am using MScomm for serial communication,
i received data in this format 02120812550006050.0,
i am not gettng how to read this ,in which format it is,
begning starting frame and at the end ending file, remaing i dont know.</p>
<p>EDIT 1:</p>
<p>it contains date time and data how i can seperate this one</p>
| [
{
"answer_id": 336323,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "static void extract (char *buff, char *date, char *time, float *val) {\n // format is \"\\x01\\x0fDDMMYYhhmmss\\x02vv... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
336,303 | <p>I'm writing a <a href="http://en.wikipedia.org/wiki/VoiceXML" rel="nofollow noreferrer">VoiceXML</a> application where we have a speech grammar and a <a href="http://en.wikipedia.org/wiki/DTMF" rel="nofollow noreferrer">DTMF</a> grammar. If the caller is calling from a particularly noisy environment, we need to disable the speech grammar. Is there a way to do this which doesn't involve copying the entire form into another form and deleting the speech grammar?</p>
| [
{
"answer_id": 435869,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 3,
"selected": false,
"text": "inputmodes"
},
{
"answer_id": 5870264,
"author": "Neel",
"author_id": 180551,
"author_profile": "ht... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
336,309 | <p>I have a MySQL database that I want to <em>archive</em>. What is the best way to do this?</p>
<p>Note: I <em>don't</em> want to just do a <em>backup</em>. I want to do a one time export of the data for long term storage in a way that I can get at on a later date. Particularly, I want to not be tied to MySQL, a database or preferably any given software (I'd really like it to be trivial to wright a program that can read it back in, something like a few dozen lines of C or perl).</p>
<p>My current plan is to dump stuff to a table using the CSV engine and then burn that to DVD. The is nice because CSV can be loaded by so many different programs. The only gotcha in this is that the bulk of the data is in Blob columns as in binary so I'll need to decode how that is encoded.</p>
| [
{
"answer_id": 26879956,
"author": "zloctb",
"author_id": 1673376,
"author_profile": "https://Stackoverflow.com/users/1673376",
"pm_score": 0,
"selected": false,
"text": "mysql> ALTER TABLE arch2 ENGINE='ARCHIVE';\n"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/336309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] |
336,311 | <p>I am building a web application which uses an externally built class to handle much of the work and rules for the site. Most pages will require access to this class to get the information it needs to display. In the past I would put such a class in a session variable, so it's easily accessible when required and not need to be continually re-instantiated. </p>
<p>First Question, is this a bad idea to stuff this class into a session variable (it's not very big)?</p>
<p>Second question, if it's not a bad idea to store the sites app layer class in a session, then is there a way I can write a centralized method to use to grab or store the class into the session? I don't want to use a bunch of repeated code page after page getting the class, checking its there, creating if it's not, etc.</p>
| [
{
"answer_id": 414908,
"author": "Brettski",
"author_id": 5836,
"author_profile": "https://Stackoverflow.com/users/5836",
"pm_score": 0,
"selected": false,
"text": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Web;\nusing System.Configuration;\n\nnam... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5836/"
] |
336,327 | <p>I am trying to build a CAML query for SharePoint 2007 environment, to get items from a calendar list. Want to query items with a given 'From date' and 'To date', the calendar list contains 'EventDate' and 'EndDate' in Datetime format. I am only interested in the date part of the datetime field.</p>
<p>How can I trim the "EventDate" DateTime field of Calendar list to just Date and compare?</p>
<p>Is there any other way to get this done apart from CAML.</p>
| [
{
"answer_id": 336406,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "<Where>\n <Gt>\n <FieldRef Name='EventDate' />\n <Value IncludeTimeValue='FALSE' Type='DateTime'>2008-12-03T12:00... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35366/"
] |
336,333 | <p>Is there a way to use add-as-link when dragging and dropping source files or entire source trees into a C# project?</p>
<p>Currently, dragging a tree of source files onto a C# project will cause Visual Studio to copy all files to mirror tree below my solution file.</p>
<p>This can be avoided with the the add-as-link option as depicted in the picture below. However, it gets tedious for large trees or when some files in a directory are already part of the project.</p>
<p>
<a href="http://jaapsuter.com/images/add_cs_file.jpg" rel="nofollow noreferrer">Screenshot of the add-as-link functionality in Visual Studio http://jaapsuter.com/images/add_cs_file.jpg</a>
</p>
<p>I've looked in Tools->Options, searched the web, and held various magic key combinations when dragging and dropping, to no avail.</p>
<p>I'm tempted to write a script that just globs my .cs files and runs a regular expression over my .csproj file. I'm aware of NAnt, Premake, and other solutions - but I'd like something lightweight.</p>
| [
{
"answer_id": 533773,
"author": "Coincoin",
"author_id": 42,
"author_profile": "https://Stackoverflow.com/users/42",
"pm_score": 2,
"selected": true,
"text": "<ItemGroup>\n <Compile Include=\"SomeDirectory\\**\\*.cs\"/>\n</ItemGroup>\n"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/336333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27234/"
] |
336,348 | <p>I've got a web page that's using jquery to receive some product information as people are looking at things and then displays the last product images that were seen. This is in a jquery AJAX callback that looks pretty much like this:</p>
<pre><code>if(number_of_things_seen > 10) {
$('#shots li:last-child').remove();
}
$('<li><img src="' + p.ProductImageSmall + '"></li>').prependTo('#shots');
</code></pre>
<p>However, it seems to leak quite a bit of memory. Visually, it does the right thing, but the footprint grows indefinitely.</p>
<p>Safari's DOM inspector shows the DOM is how I would expect it to be, but it seems to maintain references to every image that it has displayed (as seen in <a href="http://skitch.com/dlsspy/7m5k/img-leaks" rel="nofollow noreferrer">this screenshot</a> in case anyone is interested).</p>
<p>I've added</p>
<pre><code>$('#shots li:last-child img').remove();
</code></pre>
<p>to the removal statement to no noticable effect.</p>
<p>Is there some magic necessary to let the browser release some of this stuff?</p>
| [
{
"answer_id": 336374,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 1,
"selected": false,
"text": "//not tested\n\nvar $list=$('#shots>li');\n$list.filter(':last-child').children('img')\n.attr('src', p.ProductImageSmall)\... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39975/"
] |
336,387 | <p>i've got some binary data which i want to save as an image. When i try to save the image, it throws an exception if the memory stream used to create the image, was closed before the save. The reason i do this is because i'm dynamically creating images and as such .. i need to use a memory stream.</p>
<p>this is the code:</p>
<pre><code>[TestMethod]
public void TestMethod1()
{
// Grab the binary data.
byte[] data = File.ReadAllBytes("Chick.jpg");
// Read in the data but do not close, before using the stream.
Stream originalBinaryDataStream = new MemoryStream(data);
Bitmap image = new Bitmap(originalBinaryDataStream);
image.Save(@"c:\test.jpg");
originalBinaryDataStream.Dispose();
// Now lets use a nice dispose, etc...
Bitmap2 image2;
using (Stream originalBinaryDataStream2 = new MemoryStream(data))
{
image2 = new Bitmap(originalBinaryDataStream2);
}
image2.Save(@"C:\temp\pewpew.jpg"); // This throws the GDI+ exception.
}
</code></pre>
<p>Does anyone have any suggestions to how i could save an image with the stream closed? I cannot rely on the developers to remember to close the stream after the image is saved. In fact, the developer would have NO IDEA that the image was generated using a memory stream (because it happens in some other code, elsewhere).</p>
<p>I'm really confused :(</p>
| [
{
"answer_id": 2555670,
"author": "Brian Low",
"author_id": 46039,
"author_profile": "https://Stackoverflow.com/users/46039",
"pm_score": 2,
"selected": false,
"text": " public static Image ToImage(this byte[] bytes)\n {\n using (var stream = new MemoryStream(bytes))\n ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] |
336,391 | <p>Javascripts are in <code>script.js</code> file which I have called in the xhtml file.</p>
<p>But it is throwing error at line where I have calling <code>onpageload</code> function saying " object expected.</p>
<p>However, if I have the scripts on same XHTML file, it is working fine.</p>
| [
{
"answer_id": 2555670,
"author": "Brian Low",
"author_id": 46039,
"author_profile": "https://Stackoverflow.com/users/46039",
"pm_score": 2,
"selected": false,
"text": " public static Image ToImage(this byte[] bytes)\n {\n using (var stream = new MemoryStream(bytes))\n ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
336,414 | <p>Is it possible somehow to close StreamReader after calling ReadToEnd method in construction like this:</p>
<pre><code>string s = new StreamReader("filename", Encoding.UTF8).ReadToEnd();
</code></pre>
<p>Any alternative elegant construction with the same semantics will be also accepted.</p>
| [
{
"answer_id": 336419,
"author": "Scott Saad",
"author_id": 4916,
"author_profile": "https://Stackoverflow.com/users/4916",
"pm_score": 2,
"selected": false,
"text": "string s = null; \nusing ( StreamReader reader = new StreamReader( \"filename\", Encoding.UTF8 ) { s = reader.ReadToEn... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] |
336,416 | <p>I have the following piece of code which replaces "template markers" such as %POST_TITLE% with the contents of a variable called $post_title.</p>
<pre><code>function replaceTags( $template, $newtext ) {
$template = preg_replace( '/%MYTAG%/', $newtext, $template );
return $template;
}
</code></pre>
<p>The issue is that when $post_full has a '$' in it, the returned result has this removed. For example:</p>
<pre><code>$template = "Replace this: %MYTAG";
$newtext = "I earn $1,000,000 a year";
print replaceTags( $template, $newtext );
// RESULT
Replace this: I earn ,000,000 a year";
</code></pre>
<p>I know this has something to do with not properly escaping the $1 in the $newtext. I have tried using preg_quote() but it doesn't have the desired effect.</p>
| [
{
"answer_id": 336421,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": true,
"text": "$1"
},
{
"answer_id": 336436,
"author": "derobert",
"author_id": 27727,
"author_profile": "https://Stackover... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2136/"
] |
336,452 | <p>I'd like to write a functional test of a RESTful web service I'm working on in a Ruby on Rails app. </p>
<p>The test is of a POST request where the body of the request is a plain XML doc and not a form. Any pointers on how to do this? The problem I'm encountering is how to specify the body XML in the call to the post method.</p>
| [
{
"answer_id": 337111,
"author": "Matt Burke",
"author_id": 29691,
"author_profile": "https://Stackoverflow.com/users/29691",
"pm_score": 1,
"selected": false,
"text": "@request.env['RAW_POST_BODY']"
},
{
"answer_id": 339542,
"author": "Community",
"author_id": -1,
"a... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
336,453 | <p>I've written a Custom User Control which returns some user specific data.
To load the Custom User Control I use the following line of code:</p>
<pre><code>UserControl myUC = (UserControl).Load("~/customUserControl.ascx");
</code></pre>
<p>But how can I access <code>string user</code> inside the User Control <code>myUC</code>? </p>
| [
{
"answer_id": 336480,
"author": "Aleris",
"author_id": 20417,
"author_profile": "https://Stackoverflow.com/users/20417",
"pm_score": 0,
"selected": false,
"text": "MyUserControl myUCTyped = (MyUserControl)myUC;\nmyUCTyped.ThePublicProperty = \"some value\";\n"
},
{
"answer_id": ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37972/"
] |
336,466 | <p>Does any one know of a free tool or library to convert multi page tiffs to pdf in Asp.Net 1.1?</p>
| [
{
"answer_id": 736404,
"author": "lothar",
"author_id": 44434,
"author_profile": "https://Stackoverflow.com/users/44434",
"pm_score": 1,
"selected": false,
"text": "convert screenshot.tiff screenshot.pdf\n"
},
{
"answer_id": 18227722,
"author": "Sundaram",
"author_id": 26... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1688440/"
] |
336,475 | <p>I am writing some new code that will throw a custom exception - I want to include an error string and a status code. Which class should be exception derive from? <code>std::exception</code>? <code>std::runtime_error</code>? Any other 'gotchas' to worry about? I'm thinking of something like the following:</p>
<pre><code>class MyException : public std::exception(?)
{
public:
enum Status
{
ERROR_FOO,
ERROR_BAR,
...
};
MyException(const std::string& error, Status code) :
error_(error), code_(code)
{
...
}
virtual const char* what() const
{
return error_.c_str();
}
Status code() const
{
return code_;
}
private:
std::string error_;
Status code_;
};
</code></pre>
<p>Then in the code:</p>
<pre><code>throw MyException("Ooops!", MyException::ERROR_BAR);
</code></pre>
| [
{
"answer_id": 336507,
"author": "efotinis",
"author_id": 12320,
"author_profile": "https://Stackoverflow.com/users/12320",
"pm_score": 2,
"selected": false,
"text": "invalid_argument, range_error, bad_cast"
},
{
"answer_id": 336527,
"author": "Evgeny Lazin",
"author_id":... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] |
336,495 | <p>Working with Microsoft SQL Server I found extremely useful SQL Server Profiler and Estimated Execution Plan (available in Management Studio) to optimize queries during development and production system monitoring.</p>
<p>Are there similar tools (open source or commercial) or techniques available for MySQL?</p>
| [
{
"answer_id": 336520,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": true,
"text": "EXPLAIN"
},
{
"answer_id": 25915819,
"author": "Yvan",
"author_id": 781153,
"author_profile": "https://Sta... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42512/"
] |
336,517 | <p>Ive decided that I really dont like microsoft and their ways. Please could you give me directions on how to handle winmail.dat in emails, is there a jython library or a java library that will allow me to handle this.</p>
<p>Ive just completed a email processing program, written in jython 2.2.1 on java 5. During the final load test, I realised that attachments that should have been in a standard MIME email format is now tied up in some blasted winmail.dat, which means many different outlook clients pollute the internet with this winmail.dat, so that means i need to support winmail.dat. Thus my program failed to process the data correctly.</p>
<p>Please could you give a short description on what winmail.dat is and why it is here to annoy us.</p>
<p>What other surprises can be expected!? what else do I have to watch out for, so far standard MIME emails are catered for. Are there any other jack in the boxes? </p>
<p>Thanks so much for your time.</p>
| [
{
"answer_id": 11262382,
"author": "Bob Rivers",
"author_id": 51754,
"author_profile": "https://Stackoverflow.com/users/51754",
"pm_score": 3,
"selected": false,
"text": " <dependency>\n <groupId>org.apache.poi</groupId>\n <artifactId>poi-scratchpad</artifactId>\n ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336517",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21537/"
] |
336,553 | <p>Somewhere in the code, a waitHandle is used to perfom some actions. However the thing with waithandle is that the form freezes while waiting for some action to complete. So the following code would not work:</p>
<pre><code>frmProgressBar.show();
int successOrFail = PerformSynchronousActionUsingWaitHandle();
frmProgressBar.close();
frmMainScreen.show();
</code></pre>
<p>It won't work, since the frmProgressBar would be frozen instead.
I really need to keep line #1, line #3 and line #4, but how do I rewrite PerformSynchronousActionUsingWaitHandle() such that the operation is still synchronous but the progress bar is displayed. I may be able to get around this by showing the progress bar on a different thread, but the design of the system is such that this would be very messy.</p>
| [
{
"answer_id": 336885,
"author": "Hath",
"author_id": 5186,
"author_profile": "https://Stackoverflow.com/users/5186",
"pm_score": 1,
"selected": false,
"text": " public event EventHandler<WorkCompleteArgs> WorkComplete;\n private void StartClick(object sender, EventArgs e)\n {\n... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
336,572 | <p>How do we filter an xml document based on another xml document. I have to remove all the elements which are not there in the lookup xml. Both the input xml and lookup xml has the same root elements, we are using XSLT 1.0.</p>
<p>Ex Input</p>
<pre><code><Root>
<E1 a="1">V1</E1>
<E2>V2</E2>
<E3>V3</E3>
<E5>
<SE51>SEV1</SE51>
<SE52>SEV2</SE52>
</E5>
<E6>
<SE61>SEV3</SE61>
<SE62>SEV4</SE62>
</E6>
</Root>
</code></pre>
<p>Filter Xml</p>
<pre><code><Root>
<E1 a="1"></E1>
<E2></E2>
<E5>
<SE51></SE51>
<SE52></SE52>
</E5>
</Root>
</code></pre>
<p>Expected Output</p>
<pre><code><Root>
<E1 a="1">V1</E1>
<E2>V2</E2>
<E5>
<SE51>SEv1</SE51>
<SE52>SEV2</SE52>
</E5>
</Root>
</code></pre>
| [
{
"answer_id": 339609,
"author": "Dimitre Novatchev",
"author_id": 36305,
"author_profile": "https://Stackoverflow.com/users/36305",
"pm_score": 3,
"selected": true,
"text": "<SE511>SEV11</SE511>"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/336572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26036/"
] |
336,575 | <p>I would like to know whether it is possible to force LWP::UserAgent to accept an expired SSL certificate for a single, well-known server. The issue is slightly complicated by the Squid proxy in between.</p>
<p>I went as far as to set up a debugging environment like:</p>
<pre><code>use warnings;
use strict;
use Carp;
use LWP::UserAgent;
use LWP::Debug qw(+);
use HTTP::Cookies;
my $proxy = 'http://proxy.example.net:8118';
my $cookie_jar = HTTP::Cookies->new( file => 'cookies.tmp' );
my $agent = LWP::UserAgent->new;
$agent->proxy( [ 'http' ], $proxy );
$agent->cookie_jar( $cookie_jar );
$ENV{HTTPS_PROXY} = $proxy;
$ENV{HTTPS_DEBUG} = 1;
$ENV{HTTPS_VERSION} = 3;
$ENV{HTTPS_CA_DIR} = '/etc/ssl/certs';
$ENV{HTTPS_CA_FILE} = '/etc/ssl/certs/ca-certificates.crt';
$agent->get( 'https://www.example.com/');
exit;
</code></pre>
<p>Fortunately the issue was eventually fixed on the remote server before I was able to come up with my own solution, but I would like to be able to optionally circumvent the problem should it arise again (the underlying service had been disrupted for several hours before I was called into action).</p>
<p>I would favor a solution at the LWP::UserAgent level over one based on the underlying Crypt::SSLeay or openSSL implementations, if such a solution exists, since I prefer not to relax security for other unrelated applications. Of course I am still looking for such a solution myself, in my copious free time.</p>
| [
{
"answer_id": 338550,
"author": "joshperry",
"author_id": 30587,
"author_profile": "https://Stackoverflow.com/users/30587",
"pm_score": 5,
"selected": true,
"text": "$agent->ssl_opts(verify_hostname => 0);\n"
},
{
"answer_id": 15528718,
"author": "André Fernandes",
"auth... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36218/"
] |
336,578 | <p>We have a Hibernate/Spring application that have the following Spring beans:</p>
<pre><code><bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" />
</code></pre>
<p>When wiring the application together we get the following error when using private constructors in our hibernate entities:</p>
<pre><code>Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No visible constructors in class 'ourclass'
</code></pre>
<p>The entities are typical domain objects such as an Employee or the like. </p>
<p>When changing the constructor's visibility modifier to package (or public) the application runs fine and the entities gets stored/loaded in the database. How do we/can we use private constructors/static factory methods with Spring/Hibernate transaction management?</p>
<p>We use Hibernate annotations to map the entities/relationships. No bean definitions are declared in the applicationContext.xml for the domain class that is related to the problem. It is a pojo that should have a static factory method and a private constructor.</p>
<p>How can we make Hibernate (org.springframework.spring-orm.hibernate3 classes i guess) make use of the static factory method instead of the constructor? Or possibly make it call a private constructor if necessary?</p>
<p>Using the spring factory-method configuration would make sense but the entities are not mapped as beans in our applicationContext.xml. They are only annotated with the @Entity annotation for Hibernate persistence.</p>
<p>Hope this edit clearifies (rather than mystifies) the question. :)</p>
| [
{
"answer_id": 337408,
"author": "Chochos",
"author_id": 10165,
"author_profile": "https://Stackoverflow.com/users/10165",
"pm_score": 0,
"selected": false,
"text": "public"
},
{
"answer_id": 347953,
"author": "deterb",
"author_id": 15585,
"author_profile": "https://S... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/382264/"
] |
336,585 | <p>I know the rule-of-thumb to read declarations right-to-left and I was fairly sure I knew what was going on until a colleague told me that:</p>
<pre><code>const MyStructure** ppMyStruct;
</code></pre>
<p>means "ppMyStruct is <strong>a pointer to a const pointer to a (mutable) MyStructure</strong>" (in C++).</p>
<p>I would have thought it meant "ppMyStruct is <strong>a pointer to a pointer to a const MyStructure</strong>".
I looked for an answer in the C++ spec, but apparently I'm not very good at that...</p>
<p>What does in mean in C++, and does it mean the same thing in C?</p>
| [
{
"answer_id": 336657,
"author": "flolo",
"author_id": 36472,
"author_profile": "https://Stackoverflow.com/users/36472",
"pm_score": 6,
"selected": false,
"text": " [flolo@titan ~]$ cdecl explain \"const struct s** ppMyStruct\"\n declare ppMyStruct as pointer to pointer to const ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15323/"
] |
336,605 | <p>Is there a fast algorithm for finding the Largest Common Substring in two <code>strings</code> or is it an NPComplete problem?</p>
<p>In PHP I can find a needle in a haystack:</p>
<pre><code><?php
if (strstr("there is a needle in a haystack", "needle")) {
echo "found<br>\n";
}
?>
</code></pre>
<p>I guess I could do this in a loop over one of the <code>strings</code> but that would be very expensive! Especially since my application of this is to search a database of email and look for spam (i.e. similar emails sent by the same person). </p>
<p>Does anyone have any PHP code they can throw out there?</p>
| [
{
"answer_id": 336617,
"author": "Tom",
"author_id": 42754,
"author_profile": "https://Stackoverflow.com/users/42754",
"pm_score": 3,
"selected": true,
"text": "<?php\n// Gather all messages by a user into two identical associative arrays\n$getMsgsRes = mysql_query(SELECT * FROM email_me... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42754/"
] |
336,628 | <p>One thing that annoys me when debugging programs in Visual Studio (2005 in my case) is that when I use "step over" (by pressing <kbd>F10</kbd>) to execute to the next line of code, I often end up reaching that particular line of code in a totally different thread than the one I was looking at. This means that all the context of what I was doing was lost.</p>
<p>How do I work around this?</p>
<p>If this is possible to do in later versions of Visual Studio, I'd like to hear about it as well.</p>
<p>Setting a breakpoint on the next line of code which has a conditional to only break for this thread is not the answer I'm looking for since it is way too much work to be useful for me :)</p>
| [
{
"answer_id": 378584,
"author": "Aaron",
"author_id": 28950,
"author_profile": "https://Stackoverflow.com/users/28950",
"pm_score": 6,
"selected": true,
"text": "$TID"
},
{
"answer_id": 26012873,
"author": "helb",
"author_id": 2383264,
"author_profile": "https://Stac... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11758/"
] |
336,633 | <p>In a <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="noreferrer">.NET</a> 2.0 C# application I use the following code to detect the operating system platform:</p>
<pre><code>string os_platform = System.Environment.OSVersion.Platform.ToString();
</code></pre>
<p>This returns "Win32NT". The problem is that it returns "Win32NT" even when running on Windows Vista 64-bit.</p>
<p>Is there any other method to know the correct platform (32 or 64 bit)?</p>
<p>Note that it should also detect 64 bit when run as a 32 bit application on Windows 64 bit.</p>
| [
{
"answer_id": 336645,
"author": "BobbyShaftoe",
"author_id": 38426,
"author_profile": "https://Stackoverflow.com/users/38426",
"pm_score": 4,
"selected": false,
"text": "if(IntPtr.Size == 8) {\n // 64 bit machine\n} else if(IntPtr.Size == 4) {\n // 32 bit machine\n} \n"
},
{
... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34022/"
] |
336,640 | <p>If you check my earlier questions you may have noticed I just don't get the SelectList and Html.DropDown(). I find it intrigueing that I seem to be the only one in this. So maybe I should try to change my mindset or maybe there are things I don't know that will clear this all up. I really love the whole MVC framework, but SelectList just doesn't want to fit in my head. So here's my list:</p>
<p><strong>SelectList</strong></p>
<ul>
<li>Why can't I set the selected value after instantiation</li>
<li>Why can't I set selectedValue by index of items</li>
<li>Why is the selectedvalue sometimes a string, sometimes the class I put into it and sometimes a ListItem</li>
<li>Why are the items only accesible through GetItems()</li>
<li>Why don't the types of selectedItem and the listItems match?</li>
<li>Why are the items you put in the list converted to listItem and the selectedItem not?</li>
<li>Why can't I get the count of the items without usint the GetItems() method</li>
</ul>
<p><strong>Html.DropDownList()</strong></p>
<ul>
<li>Why doesn't modelbinding work with it</li>
<li>Why is there no behaviour for defaulting selection when there's only one option </li>
<li>Why doesn't making an item SelectedValue in the source selectLIst make it the marked item</li>
</ul>
<p>Before ppl suggest me to write my own:<br>
Since this will be shipped with the MVC product, I would rather have the offical support for a basic controll then to roll my own and have all the troubles that come with it.</p>
| [
{
"answer_id": 369917,
"author": "argibson",
"author_id": 40130,
"author_profile": "https://Stackoverflow.com/users/40130",
"pm_score": 2,
"selected": false,
"text": "IEnumerable<T>"
},
{
"answer_id": 427195,
"author": "GONeale",
"author_id": 41211,
"author_profile": ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] |
336,654 | <p>I've found the following code from here "<a href="http://www.boyet.com/Articles/CodeFromInternet.html" rel="nofollow noreferrer"><a href="http://www.boyet.com/Articles/CodeFromInternet.html" rel="nofollow noreferrer">http://www.boyet.com/Articles/CodeFromInternet.html</a></a>".<br/>
It returns the speed of the CPU in GHz but works only on 32bit Windows. </p>
<pre><code>using System;
using System.Management;
namespace CpuSpeed
{
class Program
{
static double? GetCpuSpeedInGHz()
{
double? GHz = null;
using (ManagementClass mc = new ManagementClass("Win32_Processor"))
{
foreach (ManagementObject mo in mc.GetInstances())
{
GHz = 0.001 * (UInt32) mo.Properties["CurrentClockSpeed"].Value;
break;
}
}
return GHz;
}
static void Main(string[] args)
{
Console.WriteLine("The current CPU speed is {0}", (GetCpuSpeedInGHz() ?? -1.0).ToString());
Console.ReadLine();
}
}
}
</code></pre>
<p><br/>
I've searched for 64bit management classes, but without success.<br/>
Is there any other method to get the CPU speed under 64bit Windows?</p>
| [
{
"answer_id": 359576,
"author": "Binoj Antony",
"author_id": 33015,
"author_profile": "https://Stackoverflow.com/users/33015",
"pm_score": 3,
"selected": false,
"text": " RegistryKey registrykeyHKLM = Registry.LocalMachine;\n string keyPath = @\"HARDWARE\\DESCRIPTION\\System\\CentralP... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34022/"
] |
336,664 | <p>I'm working on a java web application that uses thousands of small files to build artifacts in response to requests. I think our system could see performance improvements if we could map these files into memory rather than run all over the disk to find them all the time. </p>
<p>I have heard of mmap in linux, and my basic understanding of that concept is that when a file is read from disk the file's contents get cached somewhere in memory for quicker subsequent access. What I have in mind is similar to that idea, except I'd like to read the whole mmap-able set of files into memory as my web app is initializing for minimal request-time responses.</p>
<p>One aspect of my thought-train here is that we'd probably get the files into jvm memory faster if they were all tarred up and somehow mounted in the JVM as a virtual file system. As it stands it can take several minutes for our current implementation to walk through the set of source files and just figure out what all is on the disk.. this is because we're essentially doing file stats for upwards of 300,000 files.</p>
<p>I have found the apache VFS project which can read information from a tar file, but I'm not sure from their documentation if you can specify something such as "also, read the entire tar into memory and hold it there..". </p>
<p>We're talking about a multithreaded environment here serving artifacts that usually piece together about 100 different files out of a complete set of 300,000+ source files to make one response. So whatever the virtual file system solution is, it needs to be thread safe and performant. We're only talking about reading files here, no writes. </p>
<p>Also, we're running a 64 bit OS with 32 gig of RAM, our 300,000 files take up about 1.5 to 2.5 gigs of space. We can surely read a 2.5 gigabyte file into memory much quicker than 300K small several-kilobyte-sized files.</p>
<p>Thanks for input!</p>
<ul>
<li>Jason</li>
</ul>
| [
{
"answer_id": 336697,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 0,
"selected": false,
"text": "mmap()"
},
{
"answer_id": 336704,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stack... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
336,665 | <p>I have a VB6 class with a method which raises an error:</p>
<pre><code>Public Sub DoSomething
...
err.Raise 12345, description:="Error message"
...
End Sub
</code></pre>
<p>This method is called from a form:</p>
<pre><code>Public Sub ErrTest()
On Error Goto err1
obj.DoSomething
Exit Sub
err1:
MsgBox err.Description
End Sub
</code></pre>
<p>This works fine at runtime, but at design time the error handling does not work. Instead the VB6 IDE displays its standard message box from where I can go into debug mode or end the program.</p>
<p>Why does this happen? Can I prevent it?</p>
| [
{
"answer_id": 336784,
"author": "onedaywhen",
"author_id": 15354,
"author_profile": "https://Stackoverflow.com/users/15354",
"pm_score": 4,
"selected": true,
"text": "Err.Raise"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/336665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23368/"
] |
336,670 | <p>I'm using xslt to transform xml to an aspx file. In the xslt, I have a script tag to include a jquery.js file. To get it to work with IE, the script tag must have an explicit closing tag. For some reason, this doesn't work with xslt below.</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
xmlns:asp="remove">
<xsl:output method="html"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TEST</title>
<script type="text/javascript" src="jquery-1.2.6.js"></script>
</code></pre>
<p>But if I change the script tag as shown below, it works. </p>
<pre><code> <script type="text/javascript" src="jquery-1.2.6.js">
// <![CDATA[ // ]]>
</script>
</code></pre>
<p>I thought that the <code><xsl:output method="html" /></code> would do the trick, but it doesn't seem to work?</p>
<p>/Jonas</p>
| [
{
"answer_id": 505612,
"author": "Chris Chilvers",
"author_id": 35233,
"author_profile": "https://Stackoverflow.com/users/35233",
"pm_score": 3,
"selected": false,
"text": "XmlDocument doc = new XmlDocument();\ndoc.LoadXml(\"<book><author>Trudi Canavan</author><title>Voice of the Gods</t... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
336,682 | <p>Can I use LoadLibrary method for to import a data of type struct??
excuse me for my English.
thanks.</p>
| [
{
"answer_id": 336752,
"author": "Johann Gerell",
"author_id": 6345,
"author_profile": "https://Stackoverflow.com/users/6345",
"pm_score": 3,
"selected": false,
"text": "bool GetFlubber(Flubber* flubber)"
},
{
"answer_id": 351660,
"author": "reuben",
"author_id": 41646,
... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42746/"
] |
336,695 | <p>is there a free set of controls to be used for representing the OLAP cubes in aspx pages? something like the ones from Dundas, but free and (if possible) cross-browser.</p>
<p>Thanks,
Lucian</p>
| [
{
"answer_id": 336752,
"author": "Johann Gerell",
"author_id": 6345,
"author_profile": "https://Stackoverflow.com/users/6345",
"pm_score": 3,
"selected": false,
"text": "bool GetFlubber(Flubber* flubber)"
},
{
"answer_id": 351660,
"author": "reuben",
"author_id": 41646,
... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11464/"
] |
336,696 | <p>This java program I am working on seems to hang on startup, so I tried using jconsole to debug the problem.
As it turns out it is waiting on a call to a method which is declared as -</p>
<pre><code>synchronized void stopQuery()
</code></pre>
<p>But here is the crazy part, the lock for the 'synchronized' method is already held by the thread which is blocked for it.
I have attached a screenshot from JConsole after executing the getThreadInfo() MXBean method.<br/><br/>
Notice that the lockOwnerId and threadId are same! How is this even possible?</p>
<p><a href="https://i.stack.imgur.com/TYWk9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TYWk9.png" alt="alt text"></a>
</p>
<p>
<b>Edit:</b> <br/>
<b><a href="http://placidsystems.com/files/stacktrace.txt" rel="nofollow noreferrer"> Link </a></b> to one of the stack traces of this situation.
Note that after looking at the stacktrace it might appear that even the 'org.eclipse.jdt.internal.ui.text.JavaReconciler' thread is trying to lock on to the same DiskIndex object, but if you look at the object address you will see that it is in fact a different DiskIndex object.
</p>
<p><b>Edit 2:</b> <br/>
<b><a href="http://placidsystems.com/files/stacktrace2.txt" rel="nofollow noreferrer">Another Link </a></b> to a different stacktrace I obtained when I reproduced this problem. It should be helpful to compare the two to see what is common.</p>
<p>
</p>
| [
{
"answer_id": 336803,
"author": "Chris Kimpton",
"author_id": 48310,
"author_profile": "https://Stackoverflow.com/users/48310",
"pm_score": 0,
"selected": false,
"text": "\"Worker-2\" prio=10 tid=0x00002aad1da66400 nid=0x5165 waiting for monitor entry [0x0000000041b43000..0x0000000041b4... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14316/"
] |
336,712 | <p>What's the query syntax to determine the exact version number of the MySQL server software?</p>
| [
{
"answer_id": 336718,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 5,
"selected": true,
"text": "SHOW VARIABLES"
},
{
"answer_id": 336874,
"author": "Pawka",
"author_id": 33599,
"author_profile": "https:... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2899/"
] |
336,714 | <p>I'm beginner in Java. I'm reading data from device through serial port. I'm getting data for every one minute, but first reading is coming half, after that data is coming correctly.</p>
<p>Output I'm getting is: </p>
<blockquote>
<p>6050.003120815340006050.003120815350006050.0</p>
</blockquote>
<p>Correct output should be like this: </p>
<blockquote>
<p>03120815340006050.003120815350006050.0</p>
</blockquote>
<p><br>
My code is:</p>
<pre><code>import java.io.*;
import java.util.*; //import gnu.io.*;
import javax.comm.*;
public class SimpleRead implements Runnable, SerialPortEventListener {
static CommPortIdentifier portId;
static Enumeration portList;
InputStream inputStream;
SerialPort serialPort;
Thread readThread;
byte[] readBuffer;
public static void main(String[] args) {
portList = CommPortIdentifier.getPortIdentifiers();
System.out.println("portList... " + portList);
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
System.out.println("port identified is Serial.. "
+ portId.getPortType());
if (portId.getName().equals("COM2")) {
System.out.println("port identified is COM2.. "
+ portId.getName());
// if (portId.getName().equals("/dev/term/a")) {
SimpleRead reader = new SimpleRead();
} else {
System.out.println("unable to open port");
}
}
}
}
public SimpleRead() {
try {
System.out.println("In SimpleRead() contructor");
serialPort = (SerialPort) portId.open("SimpleReadApp1111",500);
System.out.println(" Serial Port.. " + serialPort);
} catch (PortInUseException e) {
System.out.println("Port in use Exception");
}
try {
inputStream = serialPort.getInputStream();
System.out.println(" Input Stream... " + inputStream);
} catch (IOException e) {
System.out.println("IO Exception");
}
try {
serialPort.addEventListener(this);
} catch (TooManyListenersException e) {
System.out.println("Tooo many Listener exception");
}
serialPort.notifyOnDataAvailable(true);
try {
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
// no handshaking or other flow control
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
// timer on any read of the serial port
serialPort.enableReceiveTimeout(500);
System.out.println("................");
} catch (UnsupportedCommOperationException e) {
System.out.println("UnSupported comm operation");
}
readThread = new Thread(this);
readThread.start();
}
public void run() {
try {
System.out.println("In run() function ");
Thread.sleep(500);
// System.out.println();
} catch (InterruptedException e) {
System.out.println("Interrupted Exception in run() method");
}
}
public void serialEvent(SerialPortEvent event) {
// System.out.println("In Serial Event function().. " + event +
// event.getEventType());
switch (event.getEventType()) {
/*
* case SerialPortEvent.BI: case SerialPortEvent.OE: case
* SerialPortEvent.FE: case SerialPortEvent.PE: case SerialPortEvent.CD:
* case SerialPortEvent.CTS: case SerialPortEvent.DSR: case
* SerialPortEvent.RI: case SerialPortEvent.OUTPUT_BUFFER_EMPTY: break;
*/
case SerialPortEvent.DATA_AVAILABLE:
readBuffer = new byte[8];
try {
while (inputStream.available()>0) {
int numBytes = inputStream.read(readBuffer);
// System.out.println("Number of bytes read " + numBytes);
}
System.out.print(new String(readBuffer));
} catch (IOException e) {
System.out.println("IO Exception in SerialEvent()");
}
break;
}
// System.out.println();
/* String one = new String(readBuffer);
char two = one.charAt(0);
System.out.println("Character at three: " + two);*/
}
}
</code></pre>
| [
{
"answer_id": 336836,
"author": "kgiannakakis",
"author_id": 24054,
"author_profile": "https://Stackoverflow.com/users/24054",
"pm_score": 2,
"selected": false,
"text": "while (inputStream.available()>0) {\n int numBytes = inputStream.read(readBuffer);\n System.out.print(new String(re... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
336,716 | <p>How can I assert my <a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="noreferrer">Ajax</a> request and test the JSON output from Ruby on Rails functional tests?</p>
| [
{
"answer_id": 395912,
"author": "nicholaides",
"author_id": 48424,
"author_profile": "https://Stackoverflow.com/users/48424",
"pm_score": 8,
"selected": true,
"text": "ActionDispatch::TestResponse#parsed_body"
},
{
"answer_id": 2481515,
"author": "Eric",
"author_id": 297... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16371/"
] |
336,731 | <p>How do I create a view dynamically in SQL Server using C#?</p>
| [
{
"answer_id": 336740,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": 2,
"selected": false,
"text": "query = \" Create View [Viewname] Select ....\";\n"
},
{
"answer_id": 336863,
"author": "Coolcoder",
"aut... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18709/"
] |
336,755 | <p>In C# is it guaranteed that expressions are evaluated left to right? </p>
<p>For example:</p>
<pre><code>myClass = GetClass();
if (myClass == null || myClass.Property > 0)
continue;
</code></pre>
<p>Are there any languages that do not comply?</p>
| [
{
"answer_id": 336770,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 0,
"selected": false,
"text": "||"
},
{
"answer_id": 336772,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stack... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
336,756 | <p>This code is not working on IE8 at all. FF3 is executing but the page is blank and seems loading not ending.</p>
<p>My code is:</p>
<pre><code>$("#leaderBoard").html("<script2 language=\"javascript2\"> document.write('<scr'+'ipt language=\"javascript21.1\">alert(1)</scri'+'pt>'); </script2>".replace(/script2/gi, "script"));
</code></pre>
<p>I want to let page load ad on ready.</p>
| [
{
"answer_id": 336807,
"author": "adam",
"author_id": 33604,
"author_profile": "https://Stackoverflow.com/users/33604",
"pm_score": 0,
"selected": false,
"text": "$(document).ready(function() {\n // your code here\n});\n"
},
{
"answer_id": 336812,
"author": "Tomalak",
"au... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
336,759 | <p>I am curious to know How the Loader Maps DLL in to Process Address Space. How loader does that magic. Example is highly appreciated.</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 6375826,
"author": "0xC0000022L",
"author_id": 476371,
"author_profile": "https://Stackoverflow.com/users/476371",
"pm_score": 3,
"selected": false,
"text": "DLLMain()"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/336759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38038/"
] |
336,771 | <p>I'd like to run some C++ code while the Windows Mobile PocketPC is (or seems) being suspended. An example what I mean is the HTC Home plugin that shows (among others) a tab where the HTC Audio Manager can be used to play back mp3 files. When I press the on/off button, the display goes black, but the audio keeps playing. The only button to switch back on is the on/off button, as expected.</p>
<p>What I tried so far is to capture hardware button presses (works) and switch off the video display (works). What doesn't work with this approach is that when (accidentally) pressing any key on the device, the video display is switched on. I think this isn't the approach taken in the HTC Audio Manager.</p>
<p>I'm guessing on some low-level API magic for this to work, or that the code to play back audio runs at some interrupt level, or the device goes into a different suspend mode.</p>
| [
{
"answer_id": 917695,
"author": "vividos",
"author_id": 23740,
"author_profile": "https://Stackoverflow.com/users/23740",
"pm_score": 3,
"selected": true,
"text": "PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE)"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/336771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23740/"
] |
336,775 | <p>Continuing <a href="https://stackoverflow.com/questions/308481/writing-the-f-recursive-folder-visitor-in-c-seq-vs-ienumerable">my investigation</a> of expressing F# ideas in C#, I wanted a pipe forward operator. For anything wrapped in a IEnumerable, we already have it, as you can .NextFunc() to your heart's content. But for example if you have any fold-like reduction at the end, you can't feed the result of that into a function.</p>
<p>Here are two extension methods, I wondered if anyone else had tried this, and if it's a good idea or not (EDIT: now with <a href="http://#337846" rel="noreferrer">Earwicker's Maybe</a> included):</p>
<pre><code>public static void Pipe<T>(this T val, Action<T> action) where T : class
{ if (val!=null) action(val); }
public static R Pipe<T, R>(this T val, Func<T, R> func) where T : class where R : class
{ return val!=null?func(val):null; }
</code></pre>
<p>You can then write something like: </p>
<pre><code>Func<string, string[]> readlines = (f) => File.ReadAllLines(f);
Action<string, string> writefile = (f, s) => File.WriteAllText(f, s);
Action<string, string> RemoveLinesContaining = (file, text) =>
{
file.Pipe(readlines)
.Filter(s => !s.Contains(text))
.Fold((val, sb) => sb.AppendLine(val), new StringBuilder())
.Pipe((o) => o.ToString())
.Pipe((s) => writefile(file, s));
};
</code></pre>
<p>(I know, Filter == Where in C#, and Fold==Aggregate, but I wanted to roll my own, and I could have done WriteAllLines, but that's not the point)</p>
<p>EDIT: corrections as per Earwicker's comment (if I've understood correctly).</p>
| [
{
"answer_id": 336805,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "IEnumerable<T>"
},
{
"answer_id": 337846,
"author": "Daniel Earwicker",
"author_id": 27423,
"author_... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] |
336,781 | <p>How can I read a Chinese text file using C#, my current code can't display the correct characters:</p>
<pre><code>try
{
using (StreamReader sr = new StreamReader(path,System.Text.Encoding.UTF8))
{
// This is an arbitrary size for this example.
string c = null;
while (sr.Peek() >= 0)
{
c = null;
c = sr.ReadLine();
Console.WriteLine(c);
}
}
}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
}
</code></pre>
| [
{
"answer_id": 336786,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 1,
"selected": false,
"text": "Encoding.Unicode"
},
{
"answer_id": 336797,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile"... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
336,813 | <p>I understand they both don't change the URL that the client sees. Is there anything in them that makes one of them preferable over the other?<br>
I'm planning to use it in the Application_BeginRequest in Global.asax, but also in regular aspx page.</p>
| [
{
"answer_id": 336829,
"author": "netadictos",
"author_id": 31791,
"author_profile": "https://Stackoverflow.com/users/31791",
"pm_score": 4,
"selected": true,
"text": "Context.RewritePath()"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/336813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/278/"
] |
336,814 | <p>Session transcript:</p>
<pre><code>> type lookma.c
int main() {
printf("%s", "no stdio.h");
}
> cl lookma.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
lookma.c
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.
/out:lookma.exe
lookma.obj
> lookma
no stdio.h
</code></pre>
| [
{
"answer_id": 336825,
"author": "Chris Young",
"author_id": 9417,
"author_profile": "https://Stackoverflow.com/users/9417",
"pm_score": 5,
"selected": false,
"text": "int printf();\n"
},
{
"answer_id": 336844,
"author": "qrdl",
"author_id": 28494,
"author_profile": "... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20310/"
] |
336,817 | <p>I have a user control that I'm building. It's purpose is to display the status of a class to the user. Obviously, this does not matter, and will slow things down when the control runs in the IDE, as it does as soon as you add it to a form.</p>
<p>One way to work around this would be to have the control created and added to the controls collection of the form at run-time. But this seems less than perfect.</p>
<p>Is there a way to set a flag in the control so that it can skip certain sections of code based on how it is running?</p>
<p>p.s. I'm using C# and VS 2008</p>
| [
{
"answer_id": 336830,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 5,
"selected": true,
"text": "public static bool IsInRuntimeMode( IComponent component ) {\n bool ret = IsInDesignMode( component );\n return !ret;\n}... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6389/"
] |
336,826 | <p>SQL Server Full Text Search uses language specific Word Breakers. </p>
<p>For the German language this is used to break/split words including compound words. However, it appears not all known compound words are included in the Word Breaker. I would like to know if a list is available of the words the Word Breaker does know about.</p>
| [
{
"answer_id": 336830,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 5,
"selected": true,
"text": "public static bool IsInRuntimeMode( IComponent component ) {\n bool ret = IsInDesignMode( component );\n return !ret;\n}... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42434/"
] |
336,854 | <p>Specifically, once I get the WCAG Anaylsis warnings for a website into my warnings window I can't get rid of them, until I close down studio. When building another project in the same solution they stay there.</p>
<p>Anyone got any ideas?</p>
| [
{
"answer_id": 336972,
"author": "Hath",
"author_id": 5186,
"author_profile": "https://Stackoverflow.com/users/5186",
"pm_score": 0,
"selected": false,
"text": "website -> property pages -> accessibility -> uncheck \"show warnings\"\n"
}
] | 2008/12/03 | [
"https://Stackoverflow.com/questions/336854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39643/"
] |
336,859 | <p>I've recently started maintaining someone else's JavaScript code. I'm fixing bugs, adding features and also trying to tidy up the code and make it more consistent.</p>
<p>The previous developer used two ways of declaring functions and I can't work out if there is a reason behind it or not.</p>
<p>The two ways are:</p>
<pre><code>var functionOne = function() {
// Some code
};
</code></pre>
<pre><code>function functionTwo() {
// Some code
}
</code></pre>
<p>What are the reasons for using these two different methods and what are the pros and cons of each? Is there anything that can be done with one method that can't be done with the other?</p>
| [
{
"answer_id": 336868,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 13,
"selected": true,
"text": "functionOne"
},
{
"answer_id": 338053,
"author": "Eugene Lazutkin",
"author_id": 26394,
"author_profile":... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31569/"
] |
336,866 | <p>I want to create a very simple HTML/AJAX based GUI for a Python program. So the frontend is a HTML page which communicates with the program via AJAX. Can you give me a minimal implementation for the server-side using the python <code>SimpleHTTPServer.SimpleHTTPRequestHandler</code>?</p>
<p>A simple example would be a textfield and a button. When the button is pressed the content of the field is send to the server which then sends back a corresponding answer. I am aware that there are many powerful solutions for this in Python, but I would like to keep this very simple.
I already found some nice examples for such a server (e.g. <a href="http://msdl.cs.mcgill.ca/people/julien/04Ajax" rel="noreferrer">here</a>), but so far I could not come up with a truly minimal one.</p>
<p>In case you wonder why I want to implement the GUI in such a way: My focus for this application is to display lots of data in a nice layout with only minimal interaction - so using HTML+CSS seems most convenient (and I have been already using it for non-interactive data display).</p>
| [
{
"answer_id": 336894,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 4,
"selected": false,
"text": "from wsgiref.simple_server import make_server, demo_app\n\nhttpd = make_server('', 8000, demo_app)\nprint \"Serving HTTP on... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11992/"
] |
336,884 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/390900/cant-operator-be-applied-to-generic-types-in-c">Can’t operator == be applied to generic types in C#?</a> </p>
</blockquote>
<p>I've got the following generic class and the compiler complains that "<code>Operator '!=' cannot be applied to operands of type 'TValue' and 'TValue'</code>" (see <a href="http://msdn.microsoft.com/en-us/library/a63h61ky.aspx" rel="nofollow noreferrer">CS0019</a>):</p>
<pre><code>public class Example<TValue>
{
private TValue _value;
public TValue Value
{
get { return _value; }
set
{
if (_value != value) // <<-- ERROR
{
_value= value;
OnPropertyChanged("Value");
}
}
}
}
</code></pre>
<p>If I constrain <code>TValue</code> to <code>class</code>, I could use <code>Object.Equals()</code>. Since I need this for boths structs and classes I'd be very happy if I could avoid that though. </p>
<p>So the question is, how can I compare two elements of the same but unconstrained generic type for equality?</p>
| [
{
"answer_id": 336913,
"author": "Sergiu Damian",
"author_id": 41345,
"author_profile": "https://Stackoverflow.com/users/41345",
"pm_score": 5,
"selected": true,
"text": "public class Example<TValue>\n{\n private TValue _value;\n public TValue Value\n {\n get { return _va... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4918/"
] |
336,897 | <p>In a webservice I see this code:</p>
<pre><code><WebMethod()> _
Public Function dosomething() As Boolean
Try
If successful Then
Return True
Else
Return False
End If
Catch ex As Exception
Throw ex
End Try
End Function
</code></pre>
<p>What's the point of catching the exception and just throwing it again? Do I miss something?</p>
<p>Edit:
Thanks for the answers! I thought it was something like that, but wasn't sure if I could/would refactor those away without any implications.</p>
| [
{
"answer_id": 336914,
"author": "GEOCHET",
"author_id": 5640,
"author_profile": "https://Stackoverflow.com/users/5640",
"pm_score": 6,
"selected": false,
"text": "throw;"
},
{
"answer_id": 336934,
"author": "Dennis C",
"author_id": 40214,
"author_profile": "https://S... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19307/"
] |
336,903 | <p>Is there in Windows API or in MFC any analog to <code>atoh()</code> function?</p>
<p><code>atoh()</code> converts a string containing a hexadecimal number into an unsigned number like</p>
<pre><code>unsigned x = atoh("A");
</code></pre>
<p>and x = 10 after the operation.</p>
<p>In Windows I have a CString, containing "A". How can I convert it to int?</p>
| [
{
"answer_id": 336908,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 2,
"selected": false,
"text": "unsigned long ten = strtoul(\"a\", NULL, 16);"
},
{
"answer_id": 336910,
"author": "activout.se",
"author_i... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4378/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.