qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
150,114 | <p>I know plenty about the different ways of handling parsing text for information. For parsing integers for example, what kind of performance can be expected. I am wondering if anyone knows of any good stats on this. I am looking for some real numbers from someone who has tested this.</p>
<p>Which of these offers the best performance in which situations?</p>
<pre><code>Parse(...) // Crash if the case is extremely rare .0001%
If (SomethingIsValid) // Check the value before parsing
Parse(...)
TryParse(...) // Using TryParse
try
{
Parse(...)
}
catch
{
// Catch any thrown exceptions
}
</code></pre>
| [
{
"answer_id": 150123,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 7,
"selected": true,
"text": "Failure Rate Try-Catch TryParse Slowdown\n 0% 00:00:00.0131758 00:00:00.0120421 0.1\n... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22381/"
] |
150,129 | <p>Could someone provide a good description of what a Lambda is? We have a tag for them and they're on the secrets of C# question, but I have yet to find a good definition and explanation of what they are in the first place.</p>
| [
{
"answer_id": 150155,
"author": "rfunduk",
"author_id": 210,
"author_profile": "https://Stackoverflow.com/users/210",
"pm_score": 3,
"selected": false,
"text": "f = lambda { return \"this is a function with no name\" }\nputs f.call\n"
},
{
"answer_id": 7089352,
"author": "cm... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/177/"
] |
150,150 | <p>I have a defined MenuItem that I would like to share between two different menus on one page. The menu contains functionallity that is the same between both menus and I do not want two copies of it. Is there anyway to define a MenuItem in the Page.Resources and reference it in the ContextMenu XAML below?</p>
<pre><code><Page.Resources>
<MenuItem x:Key="123"/>
</Page.Resources>
<ContextMenu>
<MenuItem>Something hardcoded</MenuItem>
<!-- include shared menu here -->
</ContextMenu>
</code></pre>
| [
{
"answer_id": 150706,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 4,
"selected": true,
"text": "<MenuItem x:Key=\"myMenuItem\" x:Shared=\"False\" />\n"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1514/"
] |
150,153 | <p>Using NHibernate ICriteria and adding .AddOrder ... I want to sort by a property that is sometimes null with all the populated ones at the top. Will .AddOrder allow me to do this? If not is there an alternative? </p>
<p>The sorting options for ILists leave a lot to be desired. </p>
| [
{
"answer_id": 150168,
"author": "wprl",
"author_id": 17847,
"author_profile": "https://Stackoverflow.com/users/17847",
"pm_score": 3,
"selected": false,
"text": "IList cats = sess.CreateCriteria(typeof(Cat))\n .AddOrder( Order.Desc(\"PropertyName\") )\n .List();\n"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4140/"
] |
150,161 | <p>I have searched but apparently my google foo is weak. What I need is a way to prompt for user input in the console and have the request time out after a period of time and continue executing the script if no input comes in. As near as I can tell, Read-Host does not provide this functionality. Neither does $host.UI.PromptForChoice() nor does $host.UI.RawUI.ReadKey(). Thanks in advance for any pointers.</p>
<p>EDIT: Much thanks to Lars Truijens for finding the answer. I have taken the code that he pointed out and encapsulated it into a function. Note that the way that I have implemented it means there could be up to one second of delay between when the user hits a key and when script execution continues.</p>
<pre><code>function Pause-Host
{
param(
$Delay = 1
)
$counter = 0;
While(!$host.UI.RawUI.KeyAvailable -and ($counter++ -lt $Delay))
{
[Threading.Thread]::Sleep(1000)
}
}
</code></pre>
| [
{
"answer_id": 150326,
"author": "Lars Truijens",
"author_id": 1242,
"author_profile": "https://Stackoverflow.com/users/1242",
"pm_score": 5,
"selected": true,
"text": "$counter = 0\nwhile(!$Host.UI.RawUI.KeyAvailable -and ($counter++ -lt 600))\n{\n [Threading.Thread]::Sleep( 1000 )... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1358/"
] |
150,167 | <p>How do I list and export a private key from a keystore?</p>
| [
{
"answer_id": 150181,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 6,
"selected": true,
"text": " // Load input stream into keystore\n keystore.load(is, password.toCharArray());\n\n // List the aliases\n Enumer... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1310/"
] |
150,177 | <p>I was helping out some colleagues of mine with an SQL problem. Mainly they wanted to move all the rows from table A to table B (both tables having the same columns (names and types)). Although this was done in Oracle 11g I don't think it really matters.</p>
<p>Their initial naive implementation was something like </p>
<pre><code>BEGIN
INSERT INTO B SELECT * FROM A
DELETE FROM A
COMMIT;
END
</code></pre>
<p>Their concern was if there were INSERTs made to table A during copying from A to B and the "DELETE FROM A" (or TRUNCATE for what was worth) would cause data loss (having the newer inserted rows in A deleted).</p>
<p>Ofcourse I quickly recommended storing the IDs of the copied rows in a temporary table and then deleting just the rows in A that matched the IDS in the temporary table.</p>
<p>However for curiosity's sake we put up a little test by adding a wait command (don't remember the PL/SQL syntax) between INSERT and DELETE. THen from a different connection we would insert rows <em>DURING THE WAIT</em>.</p>
<p>We observed that was a data loss by doing so. I reproduced the whole context in SQL Server and wrapped it all in a transaction but still the fresh new data was lost too in SQL Server. This made me think there is a systematic error/flaw in the initial approach.</p>
<p>However I can't tell if it was the fact that the TRANSACTION was not (somehow?) isolated from the fresh new INSERTs or the fact that the INSERTs came during the WAIT command.</p>
<p>In the end it was implemented using the temporary table suggested by me but we couldn't get the answer to "Why the data loss". Do you know why?</p>
| [
{
"answer_id": 150187,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 1,
"selected": false,
"text": "begin tran\n....\ncommit\n"
},
{
"answer_id": 150207,
"author": "Guy Starbuck",
"author_id": 2194,
... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1796/"
] |
150,186 | <p>I'm trying to build a new .NET C++ project from scratch. I am planning to mix managed and unmanaged code in this project.</p>
<p>this forum thread
<a href="http://www.daniweb.com/forums/thread29742.html" rel="nofollow noreferrer">IDataObject : ambiguous symbol error</a> answers a problem I've seen multiple times.</p>
<p>Post #4 states
"Move all 'using namespace XXXX' from .h to .cpp"</p>
<p>this looks like a good idea but now in my header files I need to reference parameters from the .NET Framework like</p>
<pre><code>void loadConfigurations(String^ pPathname);
</code></pre>
<p>How am I supposed to move using statements in the .cpp file and use the according namespaces in the .h file?</p>
| [
{
"answer_id": 150245,
"author": "itsmatt",
"author_id": 7862,
"author_profile": "https://Stackoverflow.com/users/7862",
"pm_score": 0,
"selected": false,
"text": "namespace TestClassNS\n{\n class TestClass;\n}\n"
},
{
"answer_id": 150249,
"author": "Greg Hewgill",
"auth... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6367/"
] |
150,192 | <p>Even nowadays I often see underscores in Java variables and methods. An example are member variables (like "m_count" or "_count"). As far as I remember, to use underscores in these cases is called bad style by <a href="https://en.wikipedia.org/wiki/Sun_Microsystems" rel="nofollow noreferrer">Sun</a>.</p>
<p>The only place they should be used is in constants (like in "public final static int IS_OKAY = 1;"), because constants should be all upper case and not <a href="https://en.wikipedia.org/wiki/Camel_case" rel="nofollow noreferrer">camel case</a>. Here, the underscore should make the code more readable.</p>
<p>Do you think using underscores in Java is bad style? If so (or not), why?</p>
| [
{
"answer_id": 150226,
"author": "Chris Cudmore",
"author_id": 18907,
"author_profile": "https://Stackoverflow.com/users/18907",
"pm_score": 2,
"selected": false,
"text": "setBar( int bar)\n{\n _bar = bar;\n}\n"
},
{
"answer_id": 150291,
"author": "Community",
"author_i... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13209/"
] |
150,201 | <p>My client wants me to enable a "Remember Me" checkbox when the user logs in. I am encrypting and storing both the username and password in a cookie.</p>
<p>However, you cannot write to a textbox when it's in password mode.</p>
<p>I've seen this done numerous times, so how are they doing it?</p>
<p>thanks in advance!</p>
| [
{
"answer_id": 150280,
"author": "Chris Cudmore",
"author_id": 18907,
"author_profile": "https://Stackoverflow.com/users/18907",
"pm_score": 2,
"selected": false,
"text": "Page_Load( ...)\n {\n ... process cookie ...\n if (cookie is good) Response.Redirect(\"content.aspx\");\n }\n"... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23576/"
] |
150,208 | <p>Is there a free third-party or .NET class that will convert HTML to RTF (for use in a rich-text enabled Windows Forms control)?</p>
<p>The "free" requirement comes from the fact that I'm only working on a prototype and can just load the BrowserControl and just render HTML if need be (even if it is slow) and that Developer Express is going to be releasing their own such control soon-ish.</p>
<p>I don't want to learn to write RTF by hand, and I already know HTML, so I figure this is the quickest way to get some demonstrable code out the door quickly.</p>
| [
{
"answer_id": 155112,
"author": "Andrew",
"author_id": 20118,
"author_profile": "https://Stackoverflow.com/users/20118",
"pm_score": 2,
"selected": false,
"text": "public static string ConvertHtmlToText(string source) {\n\n string result;\n\n // Remove HTML Develop... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/549/"
] |
150,213 | <p>I'm trying to chart the number of registrations per day in our registration system. I have an Attendee table in sql server that has a smalldatetime field A_DT, which is the date and time the person registered.</p>
<p>I started with this:</p>
<pre><code>var dailyCountList =
(from a in showDC.Attendee
let justDate = new DateTime(a.A_DT.Year, a.A_DT.Month, a.A_DT.Day)
group a by justDate into DateGroup
orderby DateGroup.Key
select new RegistrationCount
{
EventDateTime = DateGroup.Key,
Count = DateGroup.Count()
}).ToList();
</code></pre>
<p>That works great, but it won't include the dates where there were no registrations, because there are no attendee records for those dates. I want every date to be included, and when there is no data for a given date, the count should just be zero.</p>
<p>So this is my current working solution, but I KNOW THAT IT IS TERRIBLE.
I added the following to the code above:</p>
<pre><code>// Create a new list of data ranging from the beginning to the end of the first list, specifying 0 counts for missing data points (days with no registrations)
var allDates = new List<RegistrationCount>();
for (DateTime date = (from dcl in dailyCountList select dcl).First().EventDateTime; date <= (from dcl in dailyCountList select dcl).Last().EventDateTime; date = date.AddDays(1))
{
DateTime thisDate = date; // lexical closure issue - see: http://www.managed-world.com/2008/06/13/LambdasKnowYourClosures.aspx
allDates.Add(new RegistrationCount
{
EventDateTime = date,
Count = (from dclInner in dailyCountList
where dclInner.EventDateTime == thisDate
select dclInner).DefaultIfEmpty(new RegistrationCount
{
EventDateTime = date,
Count = 0
}).Single().Count
});
}
</code></pre>
<p>So I created ANOTHER list, and loop through a sequence of dates I generate based on the first and last registrations in the query, and for each item in the sequence of dates, I QUERY the results of my first QUERY for the information regarding the given date, and supply a default if nothing comes back. So I end up doing a subquery here and I want to avoid this.</p>
<p>Can anyone thing of an elegant solution? Or at least one that is less embarrassing?</p>
| [
{
"answer_id": 150334,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 2,
"selected": true,
"text": " if (!dailyCountList.Any())\n return;\n\n //make a dictionary to provide O(1) lookups for later\n\n Dictionary<DateTime... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13700/"
] |
150,250 | <p>I was recently tasked with debugging a strange problem within an e-commerce application. After an application upgrade the site started to hang from time to time and I was sent in to debug. After checking the event log I found that the SQL-server wrote ~200 000 events in a couple of minutes with the message saying that a constraint had failed. After much debugging and some tracing I found the culprit. I've removed some unnecessary code and cleaned it up a bit but essentially this is it</p>
<pre><code>WHILE EXISTS (SELECT * FROM ShoppingCartItem WHERE ShoppingCartItem.PurchID = @PurchID)
BEGIN
SELECT TOP 1
@TmpGFSID = ShoppingCartItem.GFSID,
@TmpQuantity = ShoppingCartItem.Quantity,
@TmpShoppingCartItemID = ShoppingCartItem.ShoppingCartItemID,
FROM
ShoppingCartItem INNER JOIN GoodsForSale on ShoppingCartItem.GFSID = GoodsForSale.GFSID
WHERE ShoppingCartItem.PurchID = @PurchID
EXEC @ErrorCode = spGoodsForSale_ReverseReservations @TmpGFSID, @TmpQuantity
IF @ErrorCode <> 0
BEGIN
Goto Cleanup
END
DELETE FROM ShoppingCartItem WHERE ShoppingCartItem.ShoppingCartItemID = @TmpShoppingCartItemID
-- @@ROWCOUNT is 1 after this
END
</code></pre>
<p>Facts:</p>
<ol>
<li>There's only one or two records matching the first select-clause</li>
<li>RowCount from the DELETE statement indicates that it has been removed</li>
<li>The WHILE-clause will loop forever</li>
</ol>
<p>The procedure has been rewritten to select the rows that should be deleted into a temporary in-memory table instead so the immediate problem is solved but this really sparked my curiosity.</p>
<p>Why does it loop forever?</p>
<p><strong>Clarification</strong>: The delete doesn't fail (@@rowcount is 1 after the delete stmt when debugged)
<strong>Clarification 2</strong>: It shouldn't matter whether or not the SELECT TOP ... clause is ordered by any specific field since the record with the returned id will be deleted so in the next loop it should get another record.</p>
<p><strong>Update</strong>: After checking the subversion logs I found the culprit commit that made this stored procedure to go haywire. The only real difference that I can find is that there previously was no join in the SELECT TOP 1 statement i.e. without that join it worked without any transaction statements surrounding the delete. It appears to be the introduction of the join that made SQL server more picky.</p>
<p><strong>Update clarification</strong>: <a href="https://stackoverflow.com/questions/150250/while-clause-in-t-sql-that-loops-forever#150400">brien</a> pointed out that there's no need for the join but we actually do use some fields from the GoodsForSale table but I've removed them to keep the code simply so that we can concentrate on the problem at hand</p>
| [
{
"answer_id": 150297,
"author": "brien",
"author_id": 4219,
"author_profile": "https://Stackoverflow.com/users/4219",
"pm_score": 3,
"selected": true,
"text": "WHILE EXISTS (SELECT * FROM ShoppingCartItem WHERE ShoppingCartItem.PurchID = @PurchID)\nBEGIN\n SELECT TOP 1 \n ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2114/"
] |
150,284 | <p>I understand that these methods are for pickling/unpickling and have no relation to the reduce built-in function, but what's the difference between the 2 and why do we need both?</p>
| [
{
"answer_id": 150309,
"author": "Adriano Varoli Piazza",
"author_id": 22184,
"author_profile": "https://Stackoverflow.com/users/22184",
"pm_score": 6,
"selected": true,
"text": "__reduce__()"
},
{
"answer_id": 150318,
"author": "Armin Ronacher",
"author_id": 19990,
"... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3051/"
] |
150,294 | <p>I'd like my program to read the cache line size of the CPU it's running on in C++.</p>
<p>I know that this can't be done portably, so I will need a solution for Linux and another for Windows (Solutions for other systems could be usefull to others, so post them if you know them).</p>
<p>For Linux I could read the content of /proc/cpuinfo and parse the line begining with cache_alignment. Maybe there is a better way involving a call to an API.</p>
<p>For Windows I simply have no idea.</p>
| [
{
"answer_id": 150300,
"author": "Nick",
"author_id": 1490,
"author_profile": "https://Stackoverflow.com/users/1490",
"pm_score": 5,
"selected": true,
"text": "GetLogicalProcessorInformation"
},
{
"answer_id": 150328,
"author": "rami",
"author_id": 9629,
"author_profi... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5861/"
] |
150,329 | <p>I recently migrated a website to a new CMS (Umbraco). A lot of the links have changed, but they can be easily corrected by searching for patters in the url, so I would like to write something that will redirect to the correct page if the old one is not found. That part isn't a problem. </p>
<p>How can I obtain the requested URL after the browser is redirected to my custom 404 page. I tried using:</p>
<pre><code>request.ServerVariables("HTTP_REFERER") 'sorry i corrected the typo from system to server.
</code></pre>
<p>But that didn't work.</p>
<p>Any Ideas?</p>
<p>The site is on IIS 6.0.
We did consider using 301 redirects, but we don't have any way of knowing what pages people have bookmarked and there are a few hundred pages, so no one is keen on spending the time to create the 301's.</p>
| [
{
"answer_id": 150336,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 0,
"selected": false,
"text": "Request.QueryString(\"aspxerrorpath\")\n"
},
{
"answer_id": 150337,
"author": "LordHits",
"author_id": 8088,
"... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20483/"
] |
150,332 | <p>If I have variable of type <code>IEnumerable<List<string>></code> is there a LINQ statement or lambda expression I can apply to it which will combine the lists returning an <code>IEnumerable<string></code>? </p>
| [
{
"answer_id": 150343,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": true,
"text": " IEnumerable<List<string>> someList = ...;\n IEnumerable<string> all = someList.SelectMany(x => x);\n"
... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
150,333 | <p>We need to remotely create an Exchange 2007 distribution list from Asp.Net.</p>
<p>Near as I can tell, the only way to create a distribution list in the GAL is via the exchange management tools. Without installing this on our web server, is there any way to create a distribution list remotely? There are some third party components that allow you to create personal distribution lists, but these only live in a users Contacts folder and are not available to all users within the company.</p>
<p>Ideally there would be some kind of web services call to exchange or an API we could work with. The Exchange SDK provides the ability to managing Exchange data (e.g. emails, contacts, calendars etc.). There doesn't appear to be an Exchange management API.</p>
<p>It looks like the distribution lists are stored in AD as group objects with a special Exchange attributes, but there doesn't seem to be any documentation on how they are supposed to work. </p>
<p>Edit: We could reverse engineer what Exchange is doing with AD, but my concern is that with the next service pack of Exchange this will all break. </p>
<p>Is there an API that I can use to manage the distribution lists in Active Directory without going through Exchange? </p>
| [
{
"answer_id": 150343,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": true,
"text": " IEnumerable<List<string>> someList = ...;\n IEnumerable<string> all = someList.SelectMany(x => x);\n"
... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23583/"
] |
150,339 | <p>I am about to add a section to an ASP.NET app (VB.NET codebehind) that will allow a user to get data returned to them as an Excel file, which I will generate based on database data. While there are several ways of doing this, each has its own drawbacks. How would <em>you</em> return the data? I'm looking for something that's as clean and straightforward as possible.</p>
| [
{
"answer_id": 150364,
"author": "SpoiledTechie.com",
"author_id": 7644,
"author_profile": "https://Stackoverflow.com/users/7644",
"pm_score": 4,
"selected": false,
"text": "public static void DataTabletoXLS(DataTable DT, string fileName)\n{\n HttpContext.Current.Response.Clear();\n ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18009/"
] |
150,341 | <p>How do people approach mocking out TcpClient (or things like TcpClient)?</p>
<p>I have a service that takes in a TcpClient. Should I wrap that in something else more mockable? How should I approach this?</p>
| [
{
"answer_id": 150480,
"author": "Doron Yaacoby",
"author_id": 3389,
"author_profile": "https://Stackoverflow.com/users/3389",
"pm_score": 6,
"selected": true,
"text": "public interface ITcpClient\n{\n Stream GetStream(); \n // Anything you need here \n}\npublic class TcpClient... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3285/"
] |
150,355 | <p>Is there a way to determine how many cores a machine has from C/C++ in a platform-independent way? If no such thing exists, what about determining it per-platform (Windows/*nix/Mac)?</p>
| [
{
"answer_id": 150393,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 8,
"selected": false,
"text": "#include <thread>\n\nunsigned int nthreads = std::thread::hardware_concurrency();\n"
},
{
"answer_id": 150394,
... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5066/"
] |
150,359 | <p>I'm trying to use Exchange Web Services to update a calendar item. I'm creating an ItemChangeType, and then an ItemIdType. I have a unique ID to use for ItemIdType.Id, but I have nothing to use for the ChangeKey. When I leave it out, I get an ErrorChangeKeyRequiredForWriteOperations. But when i try to just put something in there, I get an ErrorInvalidChangeKey. </p>
<p>What can I use for this to get it to work?</p>
<p>I'm also trying to determine what is the best implementation of BaseItemIdType to use for ItemChangeType.Item. So far, I'm using ItemIdType, and I'm guessing that's correct, but I haven't been able to find any particularly helpful documentation on this.</p>
| [
{
"answer_id": 289684,
"author": "Hauge",
"author_id": 17368,
"author_profile": "https://Stackoverflow.com/users/17368",
"pm_score": 2,
"selected": false,
"text": "ItemIdType.ChangeKey"
},
{
"answer_id": 1286796,
"author": "Ivan G.",
"author_id": 80858,
"author_profil... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3018/"
] |
150,375 | <p>What do you insert into Python source code to have it break into pdb (when execution gets to that spot)? </p>
| [
{
"answer_id": 150376,
"author": "Daryl Spitzer",
"author_id": 4766,
"author_profile": "https://Stackoverflow.com/users/4766",
"pm_score": 6,
"selected": true,
"text": "import pdb; pdb.set_trace()\n"
},
{
"answer_id": 59365802,
"author": "Adam Baxter",
"author_id": 229631... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4766/"
] |
150,384 | <p>I have a website in which I provide tool-tips for certain things using a hidden <code><span></code> tag and JavaScript to track various mouse events. It works excellently. This site somewhat caters towards people with vision issues, so I try to make things degrade as well as possible if there is no JavaScript or CSS and generally I would say that it is successful in this regard.</p>
<p>So my question is, is it possible for these <code><span></code> to only exist if CSS is being used? I have thought about writing out the tool-tips in JavaScript on document load. But I was wondering if there is a better solution.</p>
| [
{
"answer_id": 150391,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 3,
"selected": true,
"text": "<span>"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13430/"
] |
150,404 | <p>The examples I've seen online seem much more complex than I expected <em>(manually parsing &/?/= into pairs, using regular expressions, etc).</em> We're using asp.net ajax <em>(don't see anything in their client side reference)</em> and would consider adding jQuery if it would really help.</p>
<p>I would think there is a more elegant solution out there - so far <a href="http://www.bloggingdeveloper.com/post/JavaScript-QueryString-ParseGet-QueryString-with-Client-Side-JavaScript.aspx" rel="noreferrer">this is the best code I've found</a> but I would love to find something more along the lines of the HttpRequest.QueryString object <em>(asp.net server side)</em>. Thanks in advance,</p>
<p>Shane</p>
| [
{
"answer_id": 403463,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "window.location.search.parseQuery();\n"
},
{
"answer_id": 3388168,
"author": "Chris Jacob",
"author_id": 11414... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21261/"
] |
150,416 | <p>With our next major release we are looking to globalize our ASP.Net application and I was asked to think of a way to keep track of what code has been already worked on in this effort. </p>
<p>My thought was to use a custom Attribute and place it on all classes that have been "fixed".</p>
<p>What do you think? </p>
<p>Does anyone have a better idea?</p>
| [
{
"answer_id": 188774,
"author": "Jason Z",
"author_id": 2470,
"author_profile": "https://Stackoverflow.com/users/2470",
"pm_score": 0,
"selected": false,
"text": "foreach (System.Web.UI.Control c in Page.Controls)\n{\n //Do work here\n}\n"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5551/"
] |
150,423 | <p>What's the accepted way of storing quoted data in XML?</p>
<p>For example, for a node, which is correct?</p>
<ul>
<li>(a) <name>Jesse "The Body" Ventura</name></li>
<li>(b) <name>Jesse \"The Body\" Ventura</name></li>
<li>(c) <name>Jesse &quot;The Body&quot; Ventura</name></li>
<li>(d) none of the above (please specify)</li>
</ul>
<p>If (a), what do you do for attributes? If (c), is it really appropriate to mix HTML & XML? Similarly, how do you handle single and curly quotes?</p>
| [
{
"answer_id": 150441,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 5,
"selected": false,
"text": "\""
},
{
"answer_id": 150537,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
150,446 | <p>I want to react when somebody shakes the iPhone. I don't particularly care how they shake it, just that it was waved vigorously about for a split second. Does anyone know how to detect this?</p>
| [
{
"answer_id": 159610,
"author": "millenomi",
"author_id": 6061,
"author_profile": "https://Stackoverflow.com/users/6061",
"pm_score": 7,
"selected": false,
"text": "// Ensures the shake is strong enough on at least two axes before declaring it a shake.\n// \"Strong enough\" means \"grea... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7944/"
] |
150,454 | <p>In light of Michael Carman's comment, I have decided to rewrite the question. Note that 11 comments appear before this edit, and give credence to Michael's observation that I did not write the question in a way that made it clear what I was asking.
<hr/>
<em>Question:</em> What is the standard--or <em>cleanest</em> way--to fake the special status that <code>$a</code> and <code>$b</code> have in regard to strict by simply importing a module? </p>
<p>First of all some setup. The following works: </p>
<pre><code>#!/bin/perl
use strict;
print "\$a=$a\n";
print "\$b=$b\n";
</code></pre>
<p>If I add one more line: </p>
<pre><code>print "\$c=$c\n";
</code></pre>
<p>I get an error at compile time, which means that none of my <em>dazzling</em> print code gets to run. </p>
<p>If I comment out <code>use strict;</code> it runs fine. Outside of strictures, <code>$a</code> and <code>$b</code> are mainly special in that <code>sort</code> passes the two values to be compared with those names. </p>
<pre><code>my @reverse_order = sort { $b <=> $a } @unsorted;
</code></pre>
<p>Thus the main <em>functional</em> difference about <code>$a</code> and <code>$b</code>--even though Perl "knows their names"--is that you'd better know this when you sort, or use some of the functions in <a href="http://search.cpan.org/module?List::Util" rel="nofollow noreferrer">List::Util</a>. </p>
<p>It's only when you use strict, that <code>$a</code> and <code>$b</code> become special variables in a whole new way. They are the only variables that strict will pass over without complaining that they are not declared.</p>
<p><em>:</em> Now, I like strict, but it strikes me that if TIMTOWTDI (There is more than one way to do it) is Rule #1 in Perl, this is not very TIMTOWDI. It says that <code>$a</code> and <code>$b</code> are special and that's it. If you want to use variables you don't have to declare <code>$a</code> and <code>$b</code> are your guys. If you want to have three variables by adding <code>$c</code>, suddenly there's a whole other way to do it.</p>
<p>Nevermind that in manipulating hashes <code>$k</code> and <code>$v</code> might make more sense:</p>
<pre><code>my %starts_upper_1_to_25
= skim { $k =~ m/^\p{IsUpper}/ && ( 1 <= $v && $v <= 25 ) } %my_hash
;`
</code></pre>
<p>Now, I use and I like strict. But I just want <code>$k</code> and <code>$v</code> to be visible to <code>skim</code> for the most compact syntax. And I'd like it to be visible simply by </p>
<pre><code>use Hash::Helper qw<skim>;
</code></pre>
<p>I'm not asking this question to know how to black-magic it. My "answer" below, should let you know that I know enough Perl to be dangerous. I'm asking if there is a way to make strict accept other variables, or what is the <em>cleanest</em> solution. The answer could well be no. If that's the case, it simply does not seem very TIMTOWTDI. </p>
| [
{
"answer_id": 150483,
"author": "moritz",
"author_id": 14132,
"author_profile": "https://Stackoverflow.com/users/14132",
"pm_score": 1,
"selected": false,
"text": "$a"
},
{
"answer_id": 150485,
"author": "dsm",
"author_id": 7780,
"author_profile": "https://Stackoverf... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11289/"
] |
150,471 | <p>I have a DataGridView whose DataSource is a DataTable.
This DataTable has a boolean column, which is interpreted as a checkbox in the DataGridView.</p>
<pre><code>employeeSelectionTable.Columns.Add("IsSelected", typeof(bool));
...
employeeSelectionTable.RowChanged += selectionTableRowChanged;
dataGridViewSelectedEmployees.DataSource = employeeSelectionTable;
...
private void selectionTableRowChanged(object sender, DataRowChangeEventArgs e)
{
if ((bool)e.Row["IsSelected"])
{
Console.Writeline("Is Selected");
}
else
{
Console.Writeline("Is Not Selected");
}
break;
}
</code></pre>
<p>When the user single-clicks on a checkbox, it gets checked, and selectionTableRowChanged will output "Is Selected."</p>
<p>Similarly, when the user checks it again, the box gets cleared, and selectionTableRowChanged outputs "Is Not Selected."</p>
<p>Here's where I have the problem:</p>
<p>When the user double-clicks on the checkbox, the checkbox gets checked, the RowChanged event gets called ("Is Selected"), and then the checkbox is cleared, and no corresponding RowChanged event gets called. Now the subscriber to the the RowChanged event is out of sync.</p>
<p>My solution right now is to subclass DataGridView and override WndProc to eat WM_LBUTTONDBLCLICK, so any double-clicking on the control is ignored.
Is there a better solution?</p>
| [
{
"answer_id": 150549,
"author": "Vivek",
"author_id": 7418,
"author_profile": "https://Stackoverflow.com/users/7418",
"pm_score": 1,
"selected": false,
"text": "private void dgv_CellContentClick(object sender, DataGridViewCellEventArgs e)\n{\n if(e.ColumnIndex == <columnIndex of IsSele... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
150,479 | <p>Is there an official C# guideline for the order of items in terms of class structure?</p>
<p>Does it go:</p>
<ul>
<li>Public Fields</li>
<li>Private Fields</li>
<li>Properties</li>
<li>Constructors</li>
<li>Methods<br>
?</li>
</ul>
<p>I'm curious if there is a hard and fast rule about the order of items? I'm kind of all over the place. I want to stick with a particular standard so I can do it everywhere.</p>
<p>The real problem is my more complex properties end up looking a lot like methods and they feel out of place at the top before the constructor.</p>
<p>Any tips/suggestions?</p>
| [
{
"answer_id": 150516,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 3,
"selected": false,
"text": "public class myClass\n{\n#region Private Members\n\n#endregion\n#region Public Properties\n\n#endregion\n\n#region... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2635/"
] |
150,505 | <p>I am currently defining regular expressions in order to capture parameters in a URL, as described in the tutorial. How do I access parameters from the URL as part the <code>HttpRequest</code> object?</p>
<p>My <code>HttpRequest.GET</code> currently returns an empty <code>QueryDict</code> object.</p>
<p>I'd like to learn how to do this without a library, so I can get to know Django better.</p>
| [
{
"answer_id": 150518,
"author": "camflan",
"author_id": 22445,
"author_profile": "https://Stackoverflow.com/users/22445",
"pm_score": 11,
"selected": true,
"text": "domain/search/?q=haha"
},
{
"answer_id": 152349,
"author": "jamting",
"author_id": 2639,
"author_profi... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1227001/"
] |
150,509 | <p>I've got a C# program that's supposed to play audio files. I've figured out how to play any sound file for which Windows has a codec by using DirectShow, but now I want to properly fill in the file type filter box on the Open dialog. I'd like to automatically list any file format for which Windows has a codec. If some random user installs a codec for an obscure format, its associated extension(s) and file type description(s) need to show up in the list.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 216938,
"author": "Mark Heath",
"author_id": 7532,
"author_profile": "https://Stackoverflow.com/users/7532",
"pm_score": 0,
"selected": false,
"text": "AcmDriver"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9837/"
] |
150,513 | <p>I have a form in HTML where our users fill in the data and then print it. The data isn't saved anywhere. These forms come from outside our company and are built as html pages to resemble the original as closely as possible and then stuffed away and forgotten in a folder on the intranet. Normally another developer does them, but I have to do a few while he's out. Looking through his code, all his forms have a bunch of server-side code to take the inputs and re-write the page with only the contents. It seems like there should be a better way.</p>
<p>I want to just style the text inputs using a media selector so that when it prints you can see the text, but nothing of the box surrounding it. Any thoughts?</p>
| [
{
"answer_id": 150521,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 2,
"selected": false,
"text": "<input type=\"text\" style=\"border: 0; background-color: #fff;\" />\n"
},
{
"answer_id": 150530,
"author": "Chris... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3043/"
] |
150,514 | <p>In the database I have a field named 'body' that has an XML in it. The
method I created in the model looks like this:</p>
<pre><code>def self.get_personal_data_module(person_id)
person_module = find_by_person_id(person_id)
item_module = Hpricot(person_module.body)
personal_info = Array.new
personal_info = {:studies => (item_module/"studies").inner_html,
:birth_place => (item_module/"birth_place").inner_html,
:marrital_status => (item_module/"marrital_status").inner_html}
return personal_info
end
</code></pre>
<p>I want the function to return an object instead of an array. So I can
use Module.studies instead of Model[:studies].</p>
| [
{
"answer_id": 150587,
"author": "Atiaxi",
"author_id": 2555346,
"author_profile": "https://Stackoverflow.com/users/2555346",
"pm_score": 3,
"selected": true,
"text": "class PersonalData\n attr_accessor :studies\n attr_accessor :birth_place\n attr_accessor :marital_status\n\n def ini... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3718/"
] |
150,517 | <p>This is an almost-duplicate of <a href="https://stackoverflow.com/questions/68477/send-file-using-post-from-a-python-script">Send file using POST from a Python script</a>, but I'd like to add a caveat: I need something that properly handles the encoding of fields and attached files. The solutions I've been able to find blow up when you throw unicode strings containing non-ascii characters into the mix. Also, most of the solutions don't base64-encode data to keep things 7-bit clean.</p>
| [
{
"answer_id": 151642,
"author": "Dan Lenski",
"author_id": 20789,
"author_profile": "https://Stackoverflow.com/users/20789",
"pm_score": 3,
"selected": false,
"text": "from urllib2 import Request, urlopen\nfrom binascii import b2a_base64\n\ndef b64open(url, postdata):\n req = Request(u... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150517",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23582/"
] |
150,522 | <p>Using Restlet I needed to serve some simple static content in the same context as my web service. I've configured the component with a <code>Directory</code>, but in testing, I've found it will only serve 'index.html', everything else results in a 404.</p>
<pre><code>router.attach("/", new Directory(context, new Reference(baseRef, "./content"));
</code></pre>
<p>So... <a href="http://service" rel="nofollow noreferrer">http://service</a> and <a href="http://service/index.html" rel="nofollow noreferrer">http://service/index.html</a> both work, </p>
<p>but <a href="http://service/other.html" rel="nofollow noreferrer">http://service/other.html</a> gives me a 404</p>
<p>Can anyone shed some light on this? I want any file within the ./content directory to be available.</p>
<p>PS: I eventually plan to use a reverse proxy and serve all static content off another web server, but for now I need this to work as is.</p>
| [
{
"answer_id": 151642,
"author": "Dan Lenski",
"author_id": 20789,
"author_profile": "https://Stackoverflow.com/users/20789",
"pm_score": 3,
"selected": false,
"text": "from urllib2 import Request, urlopen\nfrom binascii import b2a_base64\n\ndef b64open(url, postdata):\n req = Request(u... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/758/"
] |
150,532 | <p>Similar to <a href="https://stackoverflow.com/questions/5415/convert-bytes-to-floating-point-numbers-in-python">this</a> question, I am trying to read in an ID3v2 tag header and am having trouble figuring out how to get individual bytes in python.</p>
<p>I first read all ten bytes into a string. I then want to parse out the individual pieces of information.</p>
<p>I can grab the two version number chars in the string, but then I have no idea how to take those two chars and get an integer out of them.</p>
<p>The struct package seems to be what I want, but I can't get it to work.</p>
<p>Here is my code so-far (I am very new to python btw...so take it easy on me):</p>
<pre><code>def __init__(self, ten_byte_string):
self.whole_string = ten_byte_string
self.file_identifier = self.whole_string[:3]
self.major_version = struct.pack('x', self.whole_string[3:4]) #this
self.minor_version = struct.pack('x', self.whole_string[4:5]) # and this
self.flags = self.whole_string[5:6]
self.len = self.whole_string[6:10]
</code></pre>
<p>Printing out any value except is obviously crap because they are not formatted correctly.</p>
| [
{
"answer_id": 150541,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "struct"
},
{
"answer_id": 150584,
"author": "Brian",
"author_id": 9493,
"author_profile": "https://St... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2598/"
] |
150,535 | <p>How do you remove the jagged edges from a wide button in internet explorer? For example:</p>
<p><img src="https://i.stack.imgur.com/em5K0.gif" alt="alt text"></p>
| [
{
"answer_id": 150545,
"author": "brad",
"author_id": 208,
"author_profile": "https://Stackoverflow.com/users/208",
"pm_score": 2,
"selected": false,
"text": "input.button {\n padding: 0 .25em;\n width: 0; /* for IE only */\n overflow: visible;\n}\n\ninput.button[class] { /* IE ign... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/208/"
] |
150,539 | <p>I've used asp.net profiles (using the AspNetSqlProfileProvider) for holding small bits of information about my users. I started to wonder how it would handle a robust profile for a large number of users. Does anyone have experience using this on a large website with large numbers of simultaneous users? What are the performance implications? How about maintenance?</p>
| [
{
"answer_id": 150545,
"author": "brad",
"author_id": 208,
"author_profile": "https://Stackoverflow.com/users/208",
"pm_score": 2,
"selected": false,
"text": "input.button {\n padding: 0 .25em;\n width: 0; /* for IE only */\n overflow: visible;\n}\n\ninput.button[class] { /* IE ign... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2757/"
] |
150,543 | <p>In C, is it possible to forward the invocation of a variadic function? As in,</p>
<pre><code>int my_printf(char *fmt, ...) {
fprintf(stderr, "Calling printf with fmt %s", fmt);
return SOMEHOW_INVOKE_LIBC_PRINTF;
}
</code></pre>
<p>Forwarding the invocation in the manner above obviously isn't strictly necessary in this case (since you could log invocations in other ways, or use vfprintf), but the codebase I'm working on requires the wrapper to do some actual work, and doesn't have (and can't have added) a helper function akin to vfprintf.</p>
<p>[Update: there seems to be some confusion based on the answers that have been supplied so far. To phrase the question another way: in general, can you wrap some arbitrary variadic function <i>without modifying that function's definition</i>.]</p>
| [
{
"answer_id": 150560,
"author": "Greg Rogers",
"author_id": 5963,
"author_profile": "https://Stackoverflow.com/users/5963",
"pm_score": 2,
"selected": false,
"text": "int my_printf(char *fmt, ...) {\n va_list va;\n int ret;\n\n va_start(va, fmt);\n ret = vfprintf(stderr, fmt... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23600/"
] |
150,544 | <p>In C# code can you catch a native exception thrown from deep in some unmanaged library? If so do you need to do anything differently to catch it or does a standard try...catch get it?</p>
| [
{
"answer_id": 150550,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": -1,
"selected": false,
"text": "try\n{\n\n}\ncatch(Exception ex)\n{\n\n}\n"
},
{
"answer_id": 150551,
"author": "Curt Hagenlocher",
... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17693/"
] |
150,548 | <p>Despite the rather clear <a href="http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary620.html" rel="noreferrer">documentation</a> which says that <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/package.html#parseFloat()" rel="noreferrer">parseFloat()</a> can return NaN as a value, when I write a block like:</p>
<pre><code>if ( NaN == parseFloat(input.text) ) {
errorMessage.text = "Please enter a number."
}
</code></pre>
<p>I am warned that the comparison will always be false. And testing shows the warning to be correct.</p>
<p>Where is the corrected documentation, and how can I write this to work with AS3?</p>
| [
{
"answer_id": 183596,
"author": "Matt W",
"author_id": 4969,
"author_profile": "https://Stackoverflow.com/users/4969",
"pm_score": 2,
"selected": false,
"text": "if( number != number )\n{\n //Is NaN \n}\n"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459/"
] |
150,552 | <p>I will preface this question by saying, I do not think it is solvable. I also have a workaround, I can create a stored procedure with an OUTPUT to accomplish this, it is just easier to code the sections where I need this checksum using a function.</p>
<p>This code will not work because of the <code>Exec SP_ExecuteSQL @SQL</code> calls. Anyone know how to execute dynamic SQL in a function? (and once again, I do not think it is possible. If it is though, I'd love to know how to get around it!)</p>
<pre><code>Create Function Get_Checksum
(
@DatabaseName varchar(100),
@TableName varchar(100)
)
RETURNS FLOAT
AS
BEGIN
Declare @SQL nvarchar(4000)
Declare @ColumnName varchar(100)
Declare @i int
Declare @Checksum float
Declare @intColumns table (idRecord int identity(1,1), ColumnName varchar(255))
Declare @CS table (MyCheckSum bigint)
Set @SQL =
'Insert Into @IntColumns(ColumnName)' + Char(13) +
'Select Column_Name' + Char(13) +
'From ' + @DatabaseName + '.Information_Schema.Columns (NOLOCK)' + Char(13) +
'Where Table_Name = ''' + @TableName + '''' + Char(13) +
' and Data_Type = ''int'''
-- print @SQL
exec sp_executeSql @SQL
Set @SQL =
'Insert Into @CS(MyChecksum)' + Char(13) +
'Select '
Set @i = 1
While Exists(
Select 1
From @IntColumns
Where IdRecord = @i)
begin
Select @ColumnName = ColumnName
From @IntColumns
Where IdRecord = @i
Set @SQL = @SQL + Char(13) +
CASE WHEN @i = 1 THEN
' Sum(Cast(IsNull(' + @ColumnName + ',0) as bigint))'
ELSE
' + Sum(Cast(IsNull(' + @ColumnName + ',0) as bigint))'
END
Set @i = @i + 1
end
Set @SQL = @SQL + Char(13) +
'From ' + @DatabaseName + '..' + @TableName + ' (NOLOCK)'
-- print @SQL
exec sp_executeSql @SQL
Set @Checksum = (Select Top 1 MyChecksum From @CS)
Return isnull(@Checksum,0)
END
GO
</code></pre>
| [
{
"answer_id": 154325,
"author": "AJD",
"author_id": 23601,
"author_profile": "https://Stackoverflow.com/users/23601",
"pm_score": 0,
"selected": false,
"text": "sum(cast(BINARY_CHECKSUM(*) as float))"
},
{
"answer_id": 12434613,
"author": "Praveen Kumar G",
"author_id": ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23601/"
] |
150,575 | <p>If I have an instance of a System.Timers.Timer that has a long interval - say 1 minute, how can I find out if it is started without waiting for the Tick?</p>
| [
{
"answer_id": 150597,
"author": "Ron Savage",
"author_id": 12476,
"author_profile": "https://Stackoverflow.com/users/12476",
"pm_score": 8,
"selected": true,
"text": "System.Timer.Timer.Enabled"
},
{
"answer_id": 150615,
"author": "Inisheer",
"author_id": 2982,
"auth... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] |
150,577 | <p>Where can I test HTML 5 functionality today - is there any test build of any rendering engines which would allow testing, or is it to early? I'm aware that much of the spec hasn't been finalised, but some has, and it would be good to try it out!</p>
| [
{
"answer_id": 1092034,
"author": "Rich Bradshaw",
"author_id": 16511,
"author_profile": "https://Stackoverflow.com/users/16511",
"pm_score": 1,
"selected": false,
"text": "<header>"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16511/"
] |
150,606 | <p>I have a website laid out in tables. (a long mortgage form)</p>
<p>in each table cell is one HTML object. (text box, radio buttons, etc)</p>
<p>What can I do so when each table cell is "tabbed" into it highlights the cell with a very light red (not to be obtrusive, but tell the user where they are)?</p>
| [
{
"answer_id": 150629,
"author": "roenving",
"author_id": 23142,
"author_profile": "https://Stackoverflow.com/users/23142",
"pm_score": 0,
"selected": false,
"text": "<script type=\"text/javascript\">\n//getParent(startElement,\"tagName\");\nfunction getParent(elm,tN){\n var parElm = el... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
150,610 | <p>The problem itself is simple, but I can't figure out a solution that does it in one query, and here's my "abstraction" of the problem to allow for a simpler explanation:</p>
<p><strong>I will let my original explenation stand, but here's a set of sample data and the result i expect:</strong></p>
<p>Ok, so here's some sample data, i separated pairs by a blank line</p>
<pre><code>-------------
| Key | Col | (Together they from a Unique Pair)
--------------
| 1 Foo |
| 1 Bar |
| |
| 2 Foo |
| |
| 3 Bar |
| |
| 4 Foo |
| 4 Bar |
--------------
</code></pre>
<p>And the result I would expect, <strong>after running the query once</strong>, it need to be able to select this result set in one query:</p>
<pre><code>1 - Foo
2 - Foo
3 - Bar
4 - Foo
</code></pre>
<p><em>Original explenation:</em></p>
<p>I have a table, call it <code>TABLE</code> where I have a two columns say <code>ID</code> and <code>NAME</code> which together form the primary key of the table. Now I want to select something where <code>ID=1</code> and then first checks if it can find a row where <code>NAME</code> has the value "John", if "John" does not exist it should look for a row where <code>NAME</code> is "Bruce" - but only return "John" if both "Bruce" and "John" exists or only "John" exists of course.</p>
<p>Also note that it should be able to return several rows per query that match the above criteria but with different ID/Name-combinations of course, and that the above explanation is just a simplification of the real problem.</p>
<p>I could be completely blinded by my own code and line of thought but I just can't figure this out. </p>
| [
{
"answer_id": 150624,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": -1,
"selected": false,
"text": "SELECT f1.id\n ,f1.col\nFROM foo f1 \nLEFT JOIN foo f2\n ON f1.id = f2.id\n AND f2.col = 'Foo'\nWHERE f1.col = 'Foo'... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/452521/"
] |
150,622 | <p>I'm trying to do this</p>
<pre><code>SELECT `Name`,`Value` FROM `Constants`
WHERE `Name` NOT IN ('Do not get this one'|'or this one');
</code></pre>
<p>But it doesn't seem to work.</p>
<p>How do I get all the values, except for a select few, without doing this:</p>
<pre><code>SELECT `Name`,`Value` FROM `Constants`
WHERE `Name` != 'Do not get this one'
AND `Name` != 'or this one'
</code></pre>
<p>The first one works with int values, but doesn't work with varchar, is there a syntax like the first one, that performs like the second query?</p>
| [
{
"answer_id": 150627,
"author": "jkramer",
"author_id": 12523,
"author_profile": "https://Stackoverflow.com/users/12523",
"pm_score": 2,
"selected": false,
"text": "IN('foo', 'bar')"
},
{
"answer_id": 150631,
"author": "skaffman",
"author_id": 21234,
"author_profile"... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/144/"
] |
150,638 | <p>Sometimes it feels that my company is the only company in the world using Ruby but not Ruby on Rails, to the point that Rails has almost become synonymous with Ruby.</p>
<p>I'm sure this isn't really true, but it'd be fun to hear some stories about non-Rails Ruby usage out there.</p>
| [
{
"answer_id": 7800691,
"author": "DigitalRoss",
"author_id": 140740,
"author_profile": "https://Stackoverflow.com/users/140740",
"pm_score": 3,
"selected": false,
"text": "sh(1),"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13051/"
] |
150,645 | <p>The MSDN states that the method returns</p>
<blockquote>
<p>true if the method is successfully
queued; NotSupportedException is
thrown if the work item is not queued.</p>
</blockquote>
<p>For testing purposes how to get the method to return <code>false</code>? Or it is just a "suboptimal" class design?</p>
| [
{
"answer_id": 150688,
"author": "herbrandson",
"author_id": 13181,
"author_profile": "https://Stackoverflow.com/users/13181",
"pm_score": 4,
"selected": true,
"text": "[MethodImpl(MethodImplOptions.InternalCall)]\nprivate static extern bool AdjustThreadsInPool(uint QueueLength);\n"
},... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23372/"
] |
150,646 | <p>I'm trying to create a new Excel file using jxl, but am having a hard time finding examples in their API documentation and online.</p>
| [
{
"answer_id": 150713,
"author": "Aaron",
"author_id": 2628,
"author_profile": "https://Stackoverflow.com/users/2628",
"pm_score": 5,
"selected": true,
"text": "try {\n String fileName = \"file.xls\";\n WritableWorkbook workbook = Workbook.createWorkbook(new File(fileName));\n w... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2628/"
] |
150,687 | <p>I would like to subscribe to the ItemCommand event of a Reorderlist I have on my page. The front end looks like this...</p>
<pre><code><cc1:ReorderList id="ReorderList1" runat="server" CssClass="Sortables" Width="400" OnItemReorder="ReorderList1_ItemReorder" OnItemCommand="ReorderList1_ItemCommand">
...
<asp:ImageButton ID="btnDelete" runat="server" ImageUrl="delete.jpg" CommandName="delete" CssClass="playClip" />
...
</cc1:ReorderList>
</code></pre>
<p>in the back-end I have this on Page_Load</p>
<pre><code>ReorderList1.ItemCommand += new EventHandler<AjaxControlToolkit.ReorderListCommandEventArgs>(ReorderList1_ItemCommand);
</code></pre>
<p>and this function defined</p>
<pre><code>protected void ReorderList1_ItemCommand(object sender, AjaxControlToolkit.ReorderListCommandEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (e.CommandName == "delete")
{
//do something here that deletes the list item
}
}
}
</code></pre>
<p>Despite my best efforts though, I can't seem to get this event to fire off. How do you properly subscribe to this events in a ReorderList control?</p>
| [
{
"answer_id": 151417,
"author": "Fung",
"author_id": 8280,
"author_profile": "https://Stackoverflow.com/users/8280",
"pm_score": 1,
"selected": false,
"text": "CommandName=\"delete\""
},
{
"answer_id": 467777,
"author": "roman m",
"author_id": 3661,
"author_profile":... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
150,690 | <p><strong>Problem:</strong></p>
<p>Given a list of strings, find the substring which, if subtracted from the beginning of all strings where it matches and replaced by an escape byte, gives the shortest total length.</p>
<p><strong>Example:</strong></p>
<p><code>"foo"</code>, <code>"fool"</code>, <code>"bar"</code></p>
<p>The result is: "foo" as the base string with the strings <code>"\0"</code>, <code>"\0l"</code>, <code>"bar"</code> and a total length of 9 bytes. <code>"\0"</code> is the escape byte. The sum of the length of the original strings is 10, so in this case we only saved one byte.</p>
<p><strong>A naive algorithm would look like:</strong></p>
<pre><code>for string in list
for i = 1, i < length of string
calculate total length based on prefix of string[0..i]
if better than last best, save it
return the best prefix
</code></pre>
<p>That will give us the answer, but it's something like O((n*m)^2), which is too expensive.</p>
| [
{
"answer_id": 150729,
"author": "nlucaroni",
"author_id": 157,
"author_profile": "https://Stackoverflow.com/users/157",
"pm_score": 4,
"selected": true,
"text": " f_2 b_1\n / |\n o_2 a_1\n | |\n o_2 r_1\n |\n l_1\n"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23423/"
] |
150,695 | <p>It seems like Sql Reporting Services Server logs information in several places including web server logs and logging tables in the database. Where are all the locations SSRS logs to, and what type of errors are logged in each place?</p>
| [
{
"answer_id": 150896,
"author": "Tomas",
"author_id": 23360,
"author_profile": "https://Stackoverflow.com/users/23360",
"pm_score": 5,
"selected": true,
"text": "select * from executionlog\n"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1644/"
] |
150,726 | <p>I was wondering how to use <code>cin</code> so that if the user does not enter in any value and just pushes <code>ENTER</code> that <code>cin</code> will recognize this as valid input.</p>
| [
{
"answer_id": 150761,
"author": "CB Bailey",
"author_id": 19563,
"author_profile": "https://Stackoverflow.com/users/19563",
"pm_score": 3,
"selected": false,
"text": "std::getline"
},
{
"answer_id": 150768,
"author": "Martin Cote",
"author_id": 9936,
"author_profile"... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
150,731 | <p>I would like to write some data to a file in Ruby. What is the best way to do that?</p>
| [
{
"answer_id": 150740,
"author": "thesmallprint",
"author_id": 12765,
"author_profile": "https://Stackoverflow.com/users/12765",
"pm_score": -1,
"selected": false,
"text": "filey = File.new(\"/path/to/the/file\", APPEND)\nfiley.puts \"stuff to write\"\n"
},
{
"answer_id": 150745,... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1681/"
] |
150,737 | <p>I'm working on a qnx device, and I want to be able to ssh into it. Does anyone have a primer on getting something like openSSH up and running?</p>
| [
{
"answer_id": 30245089,
"author": "Jim McAdams",
"author_id": 4721873,
"author_profile": "https://Stackoverflow.com/users/4721873",
"pm_score": 4,
"selected": false,
"text": "random -t\nssh-keygen -t rsa -f /etc/ssh/ssh_host_key -b 1024\nssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key\ns... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3575/"
] |
150,750 | <p>It's clear that a search performance of the generic <code>HashSet<T></code> class is higher than of the generic <code>List<T></code> class. Just compare the hash-based key with the linear approach in the <code>List<T></code> class.</p>
<p>However calculating a hash key may itself take some CPU cycles, so for a small amount of items the linear search can be a real alternative to the <code>HashSet<T></code>.</p>
<p>My question: where is the break-even?</p>
<p>To simplify the scenario (and to be fair) let's assume that the <code>List<T></code> class uses the element's <code>Equals()</code> method to identify an item.</p>
| [
{
"answer_id": 10762995,
"author": "innominate227",
"author_id": 1418484,
"author_profile": "https://Stackoverflow.com/users/1418484",
"pm_score": 11,
"selected": true,
"text": "HashSet<T>"
},
{
"answer_id": 13089134,
"author": "drzaus",
"author_id": 1037948,
"author_... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23372/"
] |
150,753 | <p>I'm currently working on a project for medical image processing, that needs a huge amount of memory. Is there anything I can do to avoid heap fragmentation and to speed up access of image data that has already been loaded into memory?</p>
<p>The application has been written in C++ and runs on Windows XP.</p>
<p><strong>EDIT:</strong> The application does some preprocessing with the image data, like reformatting, calculating look-up-tables, extracting sub images of interest ... The application needs about 2 GB RAM during processing, of which about 1,5 GB may be used for the image data.</p>
| [
{
"answer_id": 264620,
"author": "Suma",
"author_id": 16673,
"author_profile": "https://Stackoverflow.com/users/16673",
"pm_score": 2,
"selected": false,
"text": "LARGE_ADDRESS_AWARE"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2012356/"
] |
150,760 | <p>Let me first say that being able to take 17 million records from a flat file, pushing to a DB on a remote box and having it take 7 minutes is amazing. SSIS truly is fantastic. But now that I have that data up there, how do I remove duplicates?</p>
<p>Better yet, I want to take the flat file, remove the duplicates from the flat file and put them back into another flat file.</p>
<p>I am thinking about a:</p>
<p><strong><code>Data Flow Task</code></strong></p>
<ul>
<li>File source (with an associated file connection)</li>
<li>A for loop container</li>
<li>A script container that contains some logic to tell if another row exists</li>
</ul>
<p>Thak you, and everyone on this site is incredibly knowledgeable.</p>
<p><strong><code>Update:</code></strong> <a href="http://rafael-salas.blogspot.com/2007/04/remove-duplicates-using-t-sql-rank.html" rel="noreferrer">I have found this link, might help in answering this question</a></p>
| [
{
"answer_id": 150951,
"author": "Hector Sosa Jr",
"author_id": 12829,
"author_profile": "https://Stackoverflow.com/users/12829",
"pm_score": 2,
"selected": false,
"text": "SET NOCOUNT ON\n\nDECLARE @email varchar(100)\n\nSET @email = ''\n\nSET @emailid = (SELECT min(email) from StagingT... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7952/"
] |
150,762 | <p>I have a file that lists filenames, each on it's own line, and I want to test if each exists in a particular directory. For example, some sample lines of the file might be</p>
<pre><code>mshta.dll
foobar.dll
somethingelse.dll
</code></pre>
<p>The directory I'm interested in is <code>X:\Windows\System32\</code>, so I want to see if the following files exist:</p>
<pre><code>X:\Windows\System32\mshta.dll
X:\Windows\System32\foobar.dll
X:\Windows\System32\somethingelse.dll
</code></pre>
<p>How can I do this using the Windows command prompt? Also (out of curiosity) how would I do this using bash or another Unix shell?</p>
| [
{
"answer_id": 150807,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 1,
"selected": false,
"text": "\ntype file.txt >NUL 2>NUL\nif ERRORLEVEL 1 then echo \"file doesn't exist\"\n"
},
{
"answer_id": 150829,
... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5616/"
] |
150,764 | <p>Any code I've seen that uses Regexes tends to use them as a black box:</p>
<ol>
<li>Put in string</li>
<li>Magic Regex</li>
<li>Get out string</li>
</ol>
<p>This doesn't seem a particularly good idea to use in production code, as even a small change can often result in a completely different regex.</p>
<p>Apart from cases where the standard is permanent and unchanging, are regexes the way to do things, or is it better to try different methods?</p>
| [
{
"answer_id": 150812,
"author": "jkramer",
"author_id": 12523,
"author_profile": "https://Stackoverflow.com/users/12523",
"pm_score": 3,
"selected": false,
"text": "x"
},
{
"answer_id": 207446,
"author": "Brad Gilbert",
"author_id": 1337,
"author_profile": "https://S... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16511/"
] |
150,803 | <p>I'm working on a little test application at the minute and I have multiple window objects floating around and they each call RegisterWindowEx with the same WNDCLASSEX structure (mainly because they are all an instance of the same class).</p>
<p>The first one registers ok, then multiple ones fail, saying class already registered - as expected.</p>
<p>My question is - is this bad? I was thinking of using a hash table to store the ATOM results in, to look up before calling RegisterWindow, but it seems Windows does this already? </p>
| [
{
"answer_id": 150880,
"author": "paercebal",
"author_id": 14089,
"author_profile": "https://Stackoverflow.com/users/14089",
"pm_score": 3,
"selected": false,
"text": "RegisterClass()"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/986/"
] |
150,814 | <p>This is somewhat of a follow-up to an answer <a href="https://stackoverflow.com/questions/26536/active-x-control-javascript">here</a>.</p>
<p>I have a custom ActiveX control that is raising an event ("ReceiveMessage" with a "msg" parameter) that needs to be handled by Javascript in the web browser. Historically we've been able to use the following IE-only syntax to accomplish this on different projects:</p>
<pre><code>function MyControl::ReceiveMessage(msg)
{
alert(msg);
}
</code></pre>
<p>However, when inside a layout in which the control is buried, the Javascript cannot find the control. Specifically, if we put this into a plain HTML page it works fine, but if we put it into an ASPX page wrapped by the <code><Form></code> tag, we get a "MyControl is undefined" error. We've tried variations on the following:</p>
<pre><code>var GetControl = document.getElementById("MyControl");
function GetControl::ReceiveMessage(msg)
{
alert(msg);
}
</code></pre>
<p>... but it results in the Javascript error "GetControl is undefined."</p>
<p>What is the proper way to handle an event being sent from an ActiveX control? Right now we're only interested in getting this working in IE. This has to be a custom ActiveX control for what we're doing.</p>
<p>Thanks.</p>
| [
{
"answer_id": 152724,
"author": "Raelshark",
"author_id": 19678,
"author_profile": "https://Stackoverflow.com/users/19678",
"pm_score": 5,
"selected": true,
"text": "<script for=\"MyControl\" event=\"ReceiveMessage(msg)\">\n alert(msg);\n</script>\n"
},
{
"answer_id": 283053,... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19678/"
] |
150,845 | <p>I'm having issues creating an ActionLink using Preview 5. All the docs I can find describe the older generic version.</p>
<p>I'm constructing links on a list of jobs on the page /jobs. Each job has a guid, and I'd like to construct a link to /jobs/details/{guid} so I can show details about the job. My jobs controller has an Index controller and a Details controller. The Details controller takes a guid. I've tried this</p>
<pre><code><%= Html.ActionLink(job.Name, "Details", job.JobId); %>
</code></pre>
<p>However, that gives me the url "/jobs/details". What am I missing here?</p>
<hr>
<p>Solved, with your help.</p>
<p>Route (added before the catch-all route):</p>
<pre><code>routes.Add(new Route("Jobs/Details/{id}", new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(new
{
controller = "Jobs",
action = "Details",
id = new Guid()
}
});
</code></pre>
<p>Action link:</p>
<pre><code><%= Html.ActionLink(job.Name, "Details", new { id = job.JobId }) %>
</code></pre>
<p>Results in the html anchor:</p>
<blockquote>
<p><a href="http://localhost:3570/WebsiteAdministration/Details?id=2db8cee5-3c56-4861-aae9-a34546ee2113" rel="nofollow noreferrer">http://localhost:3570/WebsiteAdministration/Details?id=2db8cee5-3c56-4861-aae9-a34546ee2113</a></p>
</blockquote>
<p>So, its confusing routes. I moved my jobs route definition before the website admin and it works now. Obviously, my route definitions SUCK. I need to read more examples.</p>
<p>A side note, my links weren't showing, and quickwatches weren't working (can't quickwatch an expression with an anonymous type), which made it much harder to figure out what was going on here. It turned out the action links weren't showing because of a very minor typo:</p>
<pre><code><% Html.ActionLink(job.Name, "Details", new { id = job.JobId })%>
</code></pre>
<p>That's gonna get me again.</p>
| [
{
"answer_id": 150875,
"author": "Jonathan Carter",
"author_id": 6412,
"author_profile": "https://Stackoverflow.com/users/6412",
"pm_score": 3,
"selected": true,
"text": "<%= Html.ActionLink(job.Name, \"Details\", new { guid = job.JobId}); %>\n"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
150,891 | <p>I have a table with rowID, longitude, latitude, businessName, url, caption. This might look like:</p>
<pre><code>rowID | long | lat | businessName | url | caption
1 20 -20 Pizza Hut yum.com null
</code></pre>
<p>How do I delete all of the duplicates, but only keep the one that has a URL (first priority), or keep the one that has a caption if the other doesn't have a URL (second priority) and delete the rest?</p>
| [
{
"answer_id": 150967,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 3,
"selected": true,
"text": "DECLARE @LoopVar int\n\nDECLARE\n @long int,\n @lat int,\n @businessname varchar(30),\n @winner int\n\nSET @LoopVar = (SELE... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7952/"
] |
150,900 | <p>I am creating a Windows Forms control derived from UserControl to be embedded in a WPF app. I have generally followed the procedures given in <a href="http://www.codeproject.com/KB/WPF/WPFOpenGL.aspx?display=Print" rel="nofollow noreferrer">this link</a>.</p>
<pre><code>public ref class CTiledImgViewControl : public UserControl
{
...
virtual void OnPaint( PaintEventArgs^ e ) override;
...
};
</code></pre>
<p>And in my CPP file:</p>
<pre><code>void CTiledImgViewControl::OnPaint( PaintEventArgs^ e )
{
UserControl::OnPaint(e);
// do something interesting...
}
</code></pre>
<p>Everything compiles and runs, however the OnPaint method is never getting called.</p>
<p>Any ideas of things to look for? I've done a lot with C++, but am pretty new to WinForms and WPF, so it could well be something obvious...</p>
| [
{
"answer_id": 151143,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 3,
"selected": true,
"text": "OnPaint"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3114/"
] |
150,901 | <p>Anyone know a good Regex expression to drop in the ValidationExpression to be sure that my users are only entering ASCII characters? </p>
<pre><code><asp:RegularExpressionValidator id="myRegex" runat="server" ControlToValidate="txtName" ValidationExpression="???" ErrorMessage="Non-ASCII Characters" Display="Dynamic" />
</code></pre>
| [
{
"answer_id": 150925,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 0,
"selected": false,
"text": "^([\\x00-\\xff]*)$\n"
},
{
"answer_id": 153549,
"author": "Jon Biddle",
"author_id": 22895,
"auth... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13954/"
] |
150,902 | <p>How can an object be loaded via Hibernate based on a field value of a member object? For example, suppose the following classes existed, with a one-to-one relationship between bar and foo:</p>
<pre><code>Foo {
Long id;
}
Bar {
Long id;
Foo aMember;
}
</code></pre>
<p>How could one use Hibernate Criteria to load Bar if you only had the id of Foo?</p>
<p>The first thing that leapt into my head was to load the Foo object and set that as a Criterion to load the Bar object, but that seems wasteful. Is there an effective way to do this with Criteria, or is HQL the way this should be handled?</p>
| [
{
"answer_id": 150973,
"author": "laz",
"author_id": 8753,
"author_profile": "https://Stackoverflow.com/users/8753",
"pm_score": 3,
"selected": true,
"text": "session.createCriteria(Bar.class).\n createAlias(\"aMember\", \"a\").\n add(Restrictions.eq(\"a.id\", fooId));\n"
... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
150,953 | <p>I get the following error when attempting to install <a href="http://docs.rubygems.org/" rel="nofollow noreferrer">RubyGems</a>. I've tried Googling but have had no luck there. Has anybody encountered and resolved this issue before?</p>
<pre><code>
C:\rubygems-1.3.0> ruby setup.rb
.
.
install -c -m 0644 rubygems/validator.rb C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/validator.rb
install -c -m 0644 rubygems/version.rb C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/version.rb
install -c -m 0644 rubygems/version_option.rb C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/version_option.rb
install -c -m 0644 rubygems.rb C:/Ruby/lib/ruby/site_ruby/1.8/rubygems.rb
install -c -m 0644 ubygems.rb C:/Ruby/lib/ruby/site_ruby/1.8/ubygems.rb
cp gem C:/Users/brian/AppData/Local/Temp/gem
install -c -m 0755 C:/Users/brian/AppData/Local/Temp/gem C:/Ruby/bin/gem
rm C:/Users/brian/AppData/Local/Temp/gem
install -c -m 0755 C:/Users/brian/AppData/Local/Temp/gem.bat C:/Ruby/bin/gem.bat
rm C:/Users/brian/AppData/Local/Temp/gem.bat
Removing old RubyGems RDoc and ri
Installing rubygems-1.3.0 ri into C:/Ruby/lib/ruby/gems/1.8/doc/rubygems-1.3.0/ri
./lib/rubygems.rb:713:in `set_paths': undefined method `uid' for nil:NilClass (NoMethodError)
from ./lib/rubygems.rb:711:in `each'
from ./lib/rubygems.rb:711:in `set_paths'
from ./lib/rubygems.rb:518:in `path'
from ./lib/rubygems/source_index.rb:66:in `installed_spec_directories'
from ./lib/rubygems/source_index.rb:56:in `from_installed_gems'
from ./lib/rubygems.rb:726:in `source_index'
from ./lib/rubygems.rb:138:in `activate'
from ./lib/rubygems.rb:49:in `gem'
from setup.rb:279:in `run_rdoc'
from setup.rb:296
C:\rubygems-1.3.0></code></pre>
<p>I have Ruby 1.8.6 installed on my laptop running Windows Vista.</p>
| [
{
"answer_id": 150976,
"author": "JasonTrue",
"author_id": 13433,
"author_profile": "https://Stackoverflow.com/users/13433",
"pm_score": 3,
"selected": true,
"text": "require \"rubygems\""
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/150953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1969/"
] |
150,977 | <p>What is the best way to replace all '&lt' with <code>&lt;</code> in a given database column? Basically perform <code>s/&lt[^;]/&lt;/gi</code></p>
<p>Notes:</p>
<ul>
<li>must work in <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#SQL_Server_2005" rel="noreferrer">MS SQL Server</a> 2000</li>
<li>Must be repeatable (and not end up with <code>&lt;;;;;;;;;;</code>)</li>
</ul>
| [
{
"answer_id": 151072,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 5,
"selected": true,
"text": "create table test\n(\n id int identity(1, 1) not null,\n val varchar(25) not null\n)\n\ninsert into test values ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/80/"
] |
150,994 | <p>For technical reasons, I can't use ClickOnce to auto-update my .NET application and its assemblies. What is the best way to handle auto-updating in .NET?</p>
| [
{
"answer_id": 151325,
"author": "Timothy Carter",
"author_id": 4660,
"author_profile": "https://Stackoverflow.com/users/4660",
"pm_score": 1,
"selected": false,
"text": " static void Main()\n {\n Application.EnableVisualStyles();\n Application.SetCompatibleTextRender... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14606/"
] |
150,998 | <p>In my ActionScript3 class, can I have a property with a getter and setter?</p>
| [
{
"answer_id": 151108,
"author": "Max Stewart",
"author_id": 18338,
"author_profile": "https://Stackoverflow.com/users/18338",
"pm_score": 5,
"selected": true,
"text": "package {\n\n public class PropEG {\n\n private var _prop:String;\n\n public function get prop():Strin... | 2008/09/29 | [
"https://Stackoverflow.com/questions/150998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14131/"
] |
151,000 | <p>I've got a class named <code>BackgroundWorker</code> that has a thread constantly running. To turn this thread off, an instance variable named <code>stop</code> to needs to be <code>true</code>. </p>
<p>To make sure the thread is freed when the class is done being used, I've added <code>IDisposable</code> and a finalizer that invokes <code>Dispose()</code>. Assuming that <code>stop = true</code> does indeed cause this thread to exit, is this sippet correct? It's fine to invoke <code>Dispose</code> from a finalizer, right?</p>
<p>Finalizers should always call <code>Dispose</code> if the <code>object</code> inherits <code>IDisposable</code>, right?</p>
<pre><code>/// <summary>
/// Force the background thread to exit.
/// </summary>
public void Dispose()
{
lock (this.locker)
{
this.stop = true;
}
}
~BackgroundWorker()
{
this.Dispose();
}
</code></pre>
| [
{
"answer_id": 151207,
"author": "nedruod",
"author_id": 5504,
"author_profile": "https://Stackoverflow.com/users/5504",
"pm_score": 4,
"selected": false,
"text": "public void Dispose()\n{\n Dispose(true);\n GC.SuppressFinalize(this);\n}\n\n/// <summary>\n/// Force the background t... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11574/"
] |
151,005 | <p>How can I create an Excel spreadsheet with C# without requiring Excel to be installed on the machine that's running the code?</p>
| [
{
"answer_id": 151014,
"author": "GEOCHET",
"author_id": 5640,
"author_profile": "https://Stackoverflow.com/users/5640",
"pm_score": 6,
"selected": false,
"text": "Microsoft.Office.Interop.Excel"
},
{
"answer_id": 151048,
"author": "Panos",
"author_id": 8049,
"author_... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19242/"
] |
151,024 | <p>I'm sure this is a newbie question, but every time I've compiled/dl'ed a new version of vim for os x, running vim on the command-line opens up the gvim app. I just want to upgrade the console version (so I can, for example, have python compiled in to use omnicomplete).</p>
| [
{
"answer_id": 151169,
"author": "Dana the Sane",
"author_id": 2567,
"author_profile": "https://Stackoverflow.com/users/2567",
"pm_score": 4,
"selected": true,
"text": "/opt/local/bin/vim"
},
{
"answer_id": 14867094,
"author": "David West",
"author_id": 1222355,
"auth... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1367022/"
] |
151,026 | <pre><code>sqlite> DELETE FROM mails WHERE (`id` = 71);
SQL error: database is locked
</code></pre>
<p>How do I unlock the database so this will work?</p>
| [
{
"answer_id": 1226850,
"author": "Ben L",
"author_id": 22185,
"author_profile": "https://Stackoverflow.com/users/22185",
"pm_score": 4,
"selected": false,
"text": "mv mydata.db temp.db\ncp temp.db mydata.db\n"
},
{
"answer_id": 3083942,
"author": "Philip Clarke",
"author... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/823/"
] |
151,030 | <p>When I load <code>script/console</code>, sometimes I want to play with the output of a controller or a view helper method.</p>
<p>Are there ways to:</p>
<ul>
<li>simulate a request?</li>
<li>call methods from a controller instance on said request?</li>
<li>test helper methods, either via said controller instance or another way?</li>
</ul>
| [
{
"answer_id": 151285,
"author": "Gordon Wilson",
"author_id": 23071,
"author_profile": "https://Stackoverflow.com/users/23071",
"pm_score": 6,
"selected": false,
"text": ">> foo = ActionView::Base.new\n=> #<ActionView::Base:0x2aaab0ac2af8 @assigns_added=nil, @assigns={}, @helpers=#<Acti... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13989/"
] |
151,046 | <p>I'm trying to figure out the best way to determine whether I'm in the last iteration of a loop over a map in order to do something like the following:</p>
<pre><code>for (iter = someMap.begin(); iter != someMap.end(); ++iter) {
bool last_iteration;
// do something for all iterations
if (!last_iteration) {
// do something for all but the last iteration
}
}
</code></pre>
<p>There seem to be several ways of doing this: random access iterators, the <code>distance</code> function, etc. What's the canonical method?</p>
<p>Edit: no random access iterators for maps!</p>
| [
{
"answer_id": 151073,
"author": "Torlack",
"author_id": 5243,
"author_profile": "https://Stackoverflow.com/users/5243",
"pm_score": 4,
"selected": false,
"text": "bool last_iteration = iter == (--someMap.end());\n"
},
{
"answer_id": 151078,
"author": "Mark Ransom",
"auth... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] |
151,051 | <p>In .NET, under which circumstances should I use <code>GC.SuppressFinalize()</code>?</p>
<p>What advantage(s) does using this method give me?</p>
| [
{
"answer_id": 151058,
"author": "albertein",
"author_id": 23020,
"author_profile": "https://Stackoverflow.com/users/23020",
"pm_score": -1,
"selected": false,
"text": "Dispose"
},
{
"answer_id": 151059,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": ... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17174/"
] |
151,066 | <p>I have a Ruby/Rails app that has two or three main "sections". When a user visits that section, I wish to display some sub-navigation. All three sections use the same layout, so I can't "hard code" the navigation into the layout.</p>
<p>I can think of a few different methods to do this. I guess in order to help people vote I'll put them as answers.</p>
<p>Any other ideas? Or what do you vote for?</p>
| [
{
"answer_id": 151289,
"author": "webmat",
"author_id": 6349,
"author_profile": "https://Stackoverflow.com/users/6349",
"pm_score": 1,
"selected": false,
"text": "module RenderHelper\n #options: a nested array of menu names and their corresponding url\n def render_submenu(menu_items=[[... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2590/"
] |
151,079 | <p>My app generates PDFs for user consumption. The "Content-Disposition" http header is set as mentioned <a href="https://stackoverflow.com/questions/74019/specifying-filename-for-dynamic-pdf-in-aspnet">here</a>. This is set to "inline; filename=foo.pdf", which should be enough for Acrobat to give "foo.pdf" as the filename when saving the pdf.</p>
<p>However, upon clicking the "Save" button in the browser-embedded Acrobat, the default name to save is not that filename but instead the URL with slashes changed to underscores. Huge and ugly. Is there a way to affect this default filename in Adobe?</p>
<p>There IS a query string in the URLs, and this is non-negotiable. This may be significant, but adding a "&foo=/title.pdf" to the end of the URL doesn't affect the default filename.</p>
<p>Update 2: I've tried both</p>
<pre><code>content-disposition inline; filename=foo.pdf
Content-Type application/pdf; filename=foo.pdf
</code></pre>
<p>and</p>
<pre><code>content-disposition inline; filename=foo.pdf
Content-Type application/pdf; name=foo.pdf
</code></pre>
<p>(as verified through Firebug) Sadly, neither worked.</p>
<p>A sample url is</p>
<pre>/bar/sessions/958d8a22-0/views/1493881172/export?format=application/pdf&no-attachment=true</pre>
<p>which translates to a default Acrobat save as filename of</p>
<pre>http___localhost_bar_sessions_958d8a22-0_views_1493881172_export_format=application_pdf&no-attachment=true.pdf</pre>
<p>Update 3: Julian Reschke brings actual insight and rigor to this case. Please upvote his answer.
This seems to be broken in FF (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=433613" rel="nofollow noreferrer">https://bugzilla.mozilla.org/show_bug.cgi?id=433613</a>) and IE but work in Opera, Safari, and Chrome. <a href="http://greenbytes.de/tech/tc2231/#inlwithasciifilenamepdf" rel="nofollow noreferrer">http://greenbytes.de/tech/tc2231/#inlwithasciifilenamepdf</a></p>
| [
{
"answer_id": 151302,
"author": "Vivek",
"author_id": 7418,
"author_profile": "https://Stackoverflow.com/users/7418",
"pm_score": 4,
"selected": false,
"text": "context.Response.ContentType = \"application/pdf; name=\" + fileName;\n// the usual stuff\ncontext.Response.AddHeader(\"conten... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9365/"
] |
151,083 | <p>Having this route:</p>
<pre><code>map.foo 'foo/*path', :controller => 'foo', :action => 'index'
</code></pre>
<p>I have the following results for the <code>link_to</code> call</p>
<pre><code>link_to "Foo", :controller => 'foo', :path => 'bar/baz'
# <a href="/foo/bar%2Fbaz">Foo</a>
</code></pre>
<p>Calling <code>url_for</code> or <code>foo_url</code> directly, even with <code>:escape => false</code>, give me the same url:</p>
<pre><code>foo_url(:path => 'bar/baz', :escape => false, :only_path => true)
# /foo/bar%2Fbaz
</code></pre>
<p>I want the resulting url to be: <code>/foo/bar/baz</code></p>
<p>Is there a way around this without patching rails?</p>
| [
{
"answer_id": 151239,
"author": "Gordon Wilson",
"author_id": 23071,
"author_profile": "https://Stackoverflow.com/users/23071",
"pm_score": 3,
"selected": true,
"text": "link_to \"Foo\", :controller => 'foo', :path => %w(bar baz)\n# <a href=\"/foo/bar/baz\">Foo</a>\n"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/151083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13989/"
] |
151,099 | <p>I have two tables that are joined together. </p>
<p>A has many B</p>
<p>Normally you would do: </p>
<pre><code>select * from a,b where b.a_id = a.id
</code></pre>
<p>To get all of the records from a that has a record in b. </p>
<p>How do I get just the records in a that does not have anything in b?</p>
| [
{
"answer_id": 151102,
"author": "albertein",
"author_id": 23020,
"author_profile": "https://Stackoverflow.com/users/23020",
"pm_score": 8,
"selected": true,
"text": "select * from a where id not in (select a_id from b)\n"
},
{
"answer_id": 151103,
"author": "BlackWasp",
... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1681/"
] |
151,100 | <p>I am developing a web application using Struts 2.1.2 and Hibernate 3.2.6.GA. I have an entity, <code>User</code>, which I have mapped to a table <code>USERS</code> in the DB using Hibernate. I want to have an image associated with this entity, which I plan to store as a <code>BLOB</code> in the DB. I also want to display the image on a webpage along with other attributes of the <code>User</code>.</p>
<p>The solution I could think of was to have a table <code>IMAGES(ID, IMAGE)</code> where <code>IMAGE</code> is a <code>BLOB</code> column. <code>USERS</code> will have an <code>FK</code> column called <code>IMAGEID</code>, which points to the <code>IMAGES</code> table. I will then map a property on <code>User</code> entity, called <code>imageId</code> mapped to this <code>IMAGEID</code> as a Long. When rendering the page with a JSP, I would add images as <code><img src="images.action?id=1"/></code> etc, and have an Action which reads the image and streams the content to the browser, with the headers set to cache the image for a long time.</p>
<p>Will this work? Is there a better approach for rendering images stored in a DB? Is storing such images in the DB the right approach in the first place?</p>
| [
{
"answer_id": 151136,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 0,
"selected": false,
"text": "data:<mimetype>;base64,<data>\n"
},
{
"answer_id": 151194,
"author": "Craig Wohlfeil",
"author_id": 2... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3973/"
] |
151,124 | <p>Which one should I use?</p>
<pre><code>catch (_com_error e)
</code></pre>
<p>or </p>
<pre><code>catch (_com_error& e)
</code></pre>
| [
{
"answer_id": 151126,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 6,
"selected": true,
"text": "catch"
},
{
"answer_id": 151141,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "h... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9328/"
] |
151,152 | <p>I'm using spring 2.5, and am using annotations to configure my controllers. My controller works fine if I do not implement any additional interfaces, but the spring container doesn't recognize the controller/request mapping when I add interface implementations.</p>
<p>I can't figure out why adding an interface implementation messes up the configuration of the controller and the request mappings. Any ideas?</p>
<p>So, this works:</p>
<pre><code>package com.shaneleopard.web.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.providers.encoding.Md5PasswordEncoder;
import org.springframework.stereotype.Controller;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.shaneleopard.model.User;
import com.shaneleopard.service.UserService;
import com.shaneleopard.validator.RegistrationValidator;
import com.shaneleopard.web.command.RegisterCommand;
@Controller
public class RegistrationController {
@Autowired
private UserService userService;
@Autowired
private Md5PasswordEncoder passwordEncoder;
@Autowired
private RegistrationValidator registrationValidator;
@RequestMapping( method = RequestMethod.GET, value = "/register.html" )
public void registerForm(@ModelAttribute RegisterCommand registerCommand) {
// no op
}
@RequestMapping( method = RequestMethod.POST, value = "/register.html" )
public String registerNewUser( @ModelAttribute RegisterCommand command,
Errors errors ) {
String returnView = "redirect:index.html";
if ( errors.hasErrors() ) {
returnView = "register";
} else {
User newUser = new User();
newUser.setUsername( command.getUsername() );
newUser.setPassword( passwordEncoder.encodePassword( command
.getPassword(), null ) );
newUser.setEmailAddress( command.getEmailAddress() );
newUser.setFirstName( command.getFirstName() );
newUser.setLastName( command.getLastName() );
userService.registerNewUser( newUser );
}
return returnView;
}
public Validator getValidator() {
return registrationValidator;
}
}
</code></pre>
<p>but this doesn't:</p>
<pre><code>package com.shaneleopard.web.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.providers.encoding.Md5PasswordEncoder;
import org.springframework.stereotype.Controller;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.shaneleopard.model.User;
import com.shaneleopard.service.UserService;
import com.shaneleopard.validator.RegistrationValidator;
import com.shaneleopard.web.command.RegisterCommand;
@Controller
public class RegistrationController extends ValidatingController {
@Autowired
private UserService userService;
@Autowired
private Md5PasswordEncoder passwordEncoder;
@Autowired
private RegistrationValidator registrationValidator;
@RequestMapping( method = RequestMethod.GET, value = "/register.html" )
public void registerForm(@ModelAttribute RegisterCommand registerCommand) {
// no op
}
@RequestMapping( method = RequestMethod.POST, value = "/register.html" )
public String registerNewUser( @ModelAttribute RegisterCommand command,
Errors errors ) {
String returnView = "redirect:index.html";
if ( errors.hasErrors() ) {
returnView = "register";
} else {
User newUser = new User();
newUser.setUsername( command.getUsername() );
newUser.setPassword( passwordEncoder.encodePassword( command
.getPassword(), null ) );
newUser.setEmailAddress( command.getEmailAddress() );
newUser.setFirstName( command.getFirstName() );
newUser.setLastName( command.getLastName() );
userService.registerNewUser( newUser );
}
return returnView;
}
public Validator getValidator() {
return registrationValidator;
}
}
</code></pre>
| [
{
"answer_id": 196647,
"author": "Dov Wasserman",
"author_id": 26010,
"author_profile": "https://Stackoverflow.com/users/26010",
"pm_score": 2,
"selected": false,
"text": "ValidatingController"
},
{
"answer_id": 16970812,
"author": "user979051",
"author_id": 979051,
"... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9955/"
] |
151,190 | <p>I encountered the following ddl in a pl/sql script this morning:</p>
<p>create index genuser.idx$$_0bdd0011
...</p>
<p>My initial thought was that the index name was generated by a tool...but I'm also not a pl/sql superstar so I could very well be incorrect. Does the double dollar sign have any special significance in this statement? </p>
| [
{
"answer_id": 151222,
"author": "Eddie Awad",
"author_id": 17273,
"author_profile": "https://Stackoverflow.com/users/17273",
"pm_score": 2,
"selected": false,
"text": "SQL> create table t (col number)\n 2 /\n\nTable created.\n\nSQL> create index idx$$_0bdd0011 on t(col)\n 2 /\n\nInd... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2376109/"
] |
151,195 | <p>I have a bunch of tasks in a MySQL database, and one of the fields is "deadline date". Not every task has to have to a deadline date.</p>
<p>I'd like to use SQL to sort the tasks by deadline date, but put the ones without a deadline date in the back of the result set. As it is now, the null dates show up first, then the rest are sorted by deadline date earliest to latest.</p>
<p>Any ideas on how to do this with SQL alone? (I can do it with PHP if needed, but an SQL-only solution would be great.)</p>
<p>Thanks!</p>
| [
{
"answer_id": 151202,
"author": "Danimal",
"author_id": 2757,
"author_profile": "https://Stackoverflow.com/users/2757",
"pm_score": 2,
"selected": false,
"text": "SELECT foo, bar, due_date FROM tablename\nORDER BY CASE ISNULL(due_date, 0)\nWHEN 0 THEN 1 ELSE 0 END, due_date\n"
},
{
... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
151,199 | <p>If I have two dates (ex. <code>'8/18/2008'</code> and <code>'9/26/2008'</code>), what is the best way to get the number of days between these two dates?</p>
| [
{
"answer_id": 151211,
"author": "Dana",
"author_id": 7856,
"author_profile": "https://Stackoverflow.com/users/7856",
"pm_score": 11,
"selected": true,
"text": "timedelta"
},
{
"answer_id": 151212,
"author": "dguaraglia",
"author_id": 2384,
"author_profile": "https://... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] |
151,204 | <p>I have a folder, '/var/unity/conf' with some properties files in it, and I'd like the Caucho's Resin JVM to have that directory on the classpath.</p>
<p>What is the best way to modifiy resin.conf so that Resin knows to add this directory to the classpath?</p>
| [
{
"answer_id": 1176542,
"author": "Mike",
"author_id": 54376,
"author_profile": "https://Stackoverflow.com/users/54376",
"pm_score": 2,
"selected": false,
"text": "<server-default>\n ...\n <jvm-classpath>/var/unity/conf/...</jvm-classpath>\n ...\n</server-default>\n"
}
] | 2008/09/29 | [
"https://Stackoverflow.com/questions/151204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18320/"
] |
151,210 | <p>So I just interviewed two people today, and gave them "tests" to see what their skills were like. Both are entry level applicants, one of which is actually still in college. Neither applicant saw anything wrong with the following code.</p>
<p>I do, obviously or I wouldn't have picked those examples. <strong>Do you think these questions are too harsh for newbie programmers?</strong></p>
<p>I guess I should also note neither of them had much experience with C#... but I don't think the issues with these are language dependent. </p>
<pre><code>//For the following functions, evaluate the code for quality and discuss. E.g.
//E.g. could it be done more efficiently? could it cause bugs?
public void Question1()
{
int active = 0;
CheckBox chkactive = (CheckBox)item.FindControl("chkactive");
if (chkactive.Checked == true)
{
active = 1;
}
dmxdevice.Active = Convert.ToBoolean(active);
}
public void Question2(bool IsPostBack)
{
if (!IsPostBack)
{
BindlistviewNotification();
}
if (lsvnotificationList.Items.Count == 0)
{
BindlistviewNotification();
}
}
//Question 3
protected void lsvnotificationList_ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
ListViewDataItem item = lsvnotificationList.Items[e.ItemIndex];
string Email = ((TextBox)item.FindControl("txtEmailAddress")).Text;
int id = Convert.ToInt32(((HiddenField)item.FindControl("hfID")).Value);
ESLinq.ESLinqDataContext db = new ESLinq.ESLinqDataContext();
var compare = from N in db.NotificationLists
where N.ID == id
select N;
if (compare.Count() > 0)
{
lblmessage.Text = "Record Already Exists";
}
else
{
ESLinq.NotificationList Notice = db.NotificationLists.Where(N => N.ID == id).Single();
Notice.EmailAddress = Email;
db.SubmitChanges();
}
lsvnotificationList.EditIndex = -1;
BindlistviewNotification();
}
</code></pre>
| [
{
"answer_id": 151221,
"author": "jussij",
"author_id": 14738,
"author_profile": "https://Stackoverflow.com/users/14738",
"pm_score": 0,
"selected": false,
"text": " boolean active = true;\n"
},
{
"answer_id": 151232,
"author": "Ed S.",
"author_id": 1053,
"author_pro... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17145/"
] |
151,231 | <p>I need to get the actual local network IP address of the computer (e.g. 192.168.0.220) from my program using C# and .NET 3.5. I can't just use 127.0.0.1 in this case.</p>
<p>How can I accomplish this?</p>
| [
{
"answer_id": 151237,
"author": "PostMan",
"author_id": 18405,
"author_profile": "https://Stackoverflow.com/users/18405",
"pm_score": 6,
"selected": true,
"text": "System.Net"
},
{
"answer_id": 151313,
"author": "GBegen",
"author_id": 10223,
"author_profile": "https:... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] |
151,238 | <p>It seems that I've never got this to work in the past. Currently, I KNOW it doesn't work.</p>
<p>But we start up our Java process:</p>
<pre><code>-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=6002
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
</code></pre>
<p>I can telnet to the port, and "something is there" (that is, if I don't start the process, nothing answers, but if I do, it does), but I can not get JConsole to work filling in the IP and port.</p>
<p>Seems like it should be so simple, but no errors, no noise, no nothing. Just doesn't work.</p>
<p>Anyone know the hot tip for this?</p>
| [
{
"answer_id": 900006,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": false,
"text": "-Djava.rmi.server.hostname='<host ip>'"
},
{
"answer_id": 3256207,
"author": "kishore",
"author_id": 392775,
... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13663/"
] |
151,250 | <p>I have a setup project for my C# program, and this setup project has a Version in its properties. I'd like for the MSI file that is generated to have this Version embedded in it, so I can mouse over it in explorer and see what version the file is.</p>
<p>I'm using VS2008. How can I do this?</p>
| [
{
"answer_id": 6750147,
"author": "Clay Didier",
"author_id": 852371,
"author_profile": "https://Stackoverflow.com/users/852371",
"pm_score": 1,
"selected": false,
"text": " \"Product\"\n {\n \"Name\" = \"8:Microsoft Visual Studio\"\n \"ProductName\" = \"8:tidAxCleanupScript\"\n... | 2008/09/29 | [
"https://Stackoverflow.com/questions/151250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/369/"
] |
151,268 | <p>In Linux environment, when getting "glibc detected *** free(): invalid pointer" errors, how do I identify which line of code is causing it?</p>
<p>Is there a way to force an abort? I recall there being an ENV var to control this?</p>
<p>How to set a breakpoint in gdb for the glibc error?</p>
| [
{
"answer_id": 151286,
"author": "Adrian",
"author_id": 23624,
"author_profile": "https://Stackoverflow.com/users/23624",
"pm_score": 2,
"selected": false,
"text": "MallocErrorAbort If set, causes abort(3) to be called if an\n error was encountere... | 2008/09/30 | [
"https://Stackoverflow.com/questions/151268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23630/"
] |
151,272 | <p>movie id tt0438097 can be found at <a href="http://www.imdb.com/title/tt0438097/" rel="noreferrer">http://www.imdb.com/title/tt0438097/</a></p>
<p>What's the url for its poster image?</p>
| [
{
"answer_id": 151281,
"author": "Vincent McNabb",
"author_id": 16299,
"author_profile": "https://Stackoverflow.com/users/16299",
"pm_score": 3,
"selected": false,
"text": "img"
},
{
"answer_id": 5630721,
"author": "Kamyar",
"author_id": 337294,
"author_profile": "htt... | 2008/09/30 | [
"https://Stackoverflow.com/questions/151272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2033811/"
] |
151,291 | <p>Is it possible to use system.currency. It says system.currency is inaccessible due to its protection level. what is the alternative of currency.</p>
| [
{
"answer_id": 151314,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 2,
"selected": false,
"text": "FromOACurrency()"
}
] | 2008/09/30 | [
"https://Stackoverflow.com/questions/151291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14752/"
] |
151,299 | <p>I'd like my .exe to have access to a resource string with my svn version. I can type this in by hand, but I'd prefer an automated way to embed this at compile time. Is there any such capability in Visual Studio 2008?</p>
| [
{
"answer_id": 151445,
"author": "antik",
"author_id": 1625,
"author_profile": "https://Stackoverflow.com/users/1625",
"pm_score": 5,
"selected": true,
"text": "svnversion -n"
}
] | 2008/09/30 | [
"https://Stackoverflow.com/questions/151299",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23071/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.