qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
273,313 | <p>What is the best way to randomize the order of a generic list in C#? I've got a finite set of 75 numbers in a list I would like to assign a random order to, in order to draw them for a lottery type application.</p>
| [
{
"answer_id": 273352,
"author": "albertein",
"author_id": 23020,
"author_profile": "https://Stackoverflow.com/users/23020",
"pm_score": 2,
"selected": false,
"text": "var list = new List<T> ();\nfillList (list);\nvar randomizedList = new List<T> ();\nvar rnd = new Random ();\nwhile (lis... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35286/"
] |
273,314 | <p>For example, in <a href="http://homepages.cwi.nl/~paulv/papers/algorithmicstatistics.pdf" rel="noreferrer">http://homepages.cwi.nl/~paulv/papers/algorithmicstatistics.pdf</a> at the bottom of page 5 and top of page 6, he uses a plus/equal symbol and a similar plus/lessthan symbol. I can't figure out how to make that symbol, and I'd like to quote him.</p>
<p>Any help?</p>
| [
{
"answer_id": 273402,
"author": "Noah",
"author_id": 28035,
"author_profile": "https://Stackoverflow.com/users/28035",
"pm_score": 6,
"selected": true,
"text": "$\\stackrel{top}{bottom}$"
}
] | 2008/11/07 | [
"https://Stackoverflow.com/questions/273314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35600/"
] |
273,353 | <p>Note: The examples below are C# but this problem should not be specific to any language in particular.</p>
<p>So I am building an object domain using a variant of the <a href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx" rel="nofollow noreferrer">S# Architecture</a>. For those unfamiliar with it, and to save you some reading time the idea is simply that you have a Data Access Object Interface for each of your domain objects that is responsible for loading to/from the persistence layer. Everything that might ever need to load/save a given object then accepts that object's data access interface as a dependency. So for example we can have the following where a product will lazy load the customer that purchased it as needed:</p>
<pre><code>public class Product {
private ICustomerDao _customerDao;
private Customer _customer;
public Product(ICustomerDao customerDao) {_customerDao = customerDao;}
public int ProductId {get; set;}
public int CustomerId {get; set;}
public Customer Customer {
get{
if(_customer == null) _customer = _customerDao.GetById(CustomerId);
return _customer;
}
}
public interface ICustomerDao {
public Customer GetById(int id);
}
</code></pre>
<p>This is all well and good until you reach a situation where two objects need to be able to load each other. For example a many-to-one relationship where, as above, a product needs to be able to lazy load its customer, but also customer needs to be able to get a list of his products.</p>
<pre><code>public class Customer {
private IProductDao _productDao;
private Product[] _products;
public Customer(IProductDao productDao) {_productDao = productDao;}
public int CustomerId {get; set;}
public Product[] Products {
get{
if(_products == null) _products = _productDao. GetAllForCustomer(this);
return _products;
}
}
public interface IProductDao {
public Product[] GetAllForCustomer(Customer customer);
}
</code></pre>
<p>I know that this is a really common situation but I am relatively new at this. My stumbling block is what to do when implementing the Data Access Objects. Because a Customer has a dependency on IProductDao, the CustomerDao implementation must also, however the vice versa is also true and ProductDao must take a dependency on ICustomerDao.</p>
<pre><code>public class CustomerDao : ICustomerDao {
private IProductDao _productDao;
public CustomerDao(IProductDao productDao) {_productDao = productDao;}
public Customer GetById(int id) {
Customer c = new Customer(_customerDao);
// Query the database and fill out CustomerId
return c;
}
}
public class ProductDao : IProductDao {
private ICustomerDao _customerDao;
public ProductDao (ICustomerDao customerDao) {_customerDao = customerDao;}
public Product[] GetAllForCustomer(Customer customer) {
// you get the idea
}
}
</code></pre>
<p>And here we have the problem. You cannot instantiate CustomerDao without an IProductDao and vice versa. My inversion of control container (Castle Windsor) hits the circular dependency and chokes.</p>
<p>I have come up with a for-the-time-being solution which involves lazy loading the DAO objects themselves (I will post this as an answer) but I don't like it. What are the time-tested solutions to this problem?</p>
<p><strong>EDIT:</strong> The above is a simplification of the architecture I'm actually using and I am not recommending someone actually pass DAOs to an object. A better implementation closer to what I am actually doing is similar to the way NHibernate works where the actual objects are very simple and the above are actually proxy objects which inherit and override the appropriate fields.</p>
| [
{
"answer_id": 273395,
"author": "George Mauer",
"author_id": 5056,
"author_profile": "https://Stackoverflow.com/users/5056",
"pm_score": 0,
"selected": false,
"text": "public abstract class BaseDao() {\n private ICustomerDao _customerDao;\n protected ICustomerDao _CustomerDao {\n g... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] |
273,354 | <p>I am a big time user of using double quotes in PHP so that I can interpolate variables rather than concatenating strings. As a result, when I am generating HTML I often use single quotes for setting tag fields. For example:</p>
<pre><code>$html = "<input type='text' name='address' value='$address'>";
</code></pre>
<p>Now this is far more readable to me than either</p>
<pre><code>$html = "<input type=\"text\" name=\"address\" value=\"$address\">";
</code></pre>
<p>or</p>
<pre><code>$html = '<input type="text" name="address" values="' . $address . '">' ;
</code></pre>
<p>From brief searches I have heard people saying that single quotes for HTML fields is not recognized by EVERY browser. Thus I am wondering what browsers would have problems recognizing single quote HTML?</p>
| [
{
"answer_id": 9718124,
"author": "inteblio",
"author_id": 371983,
"author_profile": "https://Stackoverflow.com/users/371983",
"pm_score": 3,
"selected": false,
"text": "<input value='it's gonna break'/>\n"
},
{
"answer_id": 16198937,
"author": "mcandre",
"author_id": 350... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
273,356 | <p>I have some pages on my site that are plain HTML pages, but I want to add some ASP .NET type functionality to these pages. My concern is that if I simple rename the .html page to .aspx that I will break links, and lose SEO, and so on.</p>
<p>I would think there is a "best practice" for how to handle this situation.</p>
| [
{
"answer_id": 273411,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 4,
"selected": true,
"text": "<html>\n<head>\n<title>Moved to new URL: http://example.com/newurl</title>\n<meta http-equiv=\"refresh\" content=\"0; url=htt... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23294/"
] |
273,374 | <p>So, if i have:</p>
<pre><code>public class Sedan : Car
{
/// ...
}
public class Car : Vehicle, ITurn
{
[MyCustomAttribute(1)]
public int TurningRadius { get; set; }
}
public abstract class Vehicle : ITurn
{
[MyCustomAttribute(2)]
public int TurningRadius { get; set; }
}
public interface ITurn
{
[MyCustomAttribute(3)]
int TurningRadius { get; set; }
}
</code></pre>
<p>What magic can I use to do something like:</p>
<pre><code>[Test]
public void Should_Use_Magic_To_Get_CustomAttributes_From_Ancestry()
{
var property = typeof(Sedan).GetProperty("TurningRadius");
var attributes = SomeMagic(property);
Assert.AreEqual(attributes.Count, 3);
}
</code></pre>
<hr>
<p>Both </p>
<pre><code>property.GetCustomAttributes(true);
</code></pre>
<p>And</p>
<pre><code>Attribute.GetCustomAttributes(property, true);
</code></pre>
<p>Only return 1 attribute. The instance is the one built with MyCustomAttribute(1). This doesn't seem to work as expected.</p>
| [
{
"answer_id": 273414,
"author": "albertein",
"author_id": 23020,
"author_profile": "https://Stackoverflow.com/users/23020",
"pm_score": 2,
"selected": false,
"text": "object[] SomeMagic (PropertyInfo property)\n{\n return property.GetCustomAttributes(true);\n}\n"
}
] | 2008/11/07 | [
"https://Stackoverflow.com/questions/273374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1946/"
] |
273,410 | <p>How can I find out the number of dimensions in an array in Classic ASP ( VBScript ) .</p>
<p>I am being passed an Array with multiple dimensions but I only want to look at the last. Seems easy in other languages.</p>
| [
{
"answer_id": 273454,
"author": "Bullines",
"author_id": 27870,
"author_profile": "https://Stackoverflow.com/users/27870",
"pm_score": 4,
"selected": true,
"text": "Ubound(MySingleDimensionalArray, 2) ' Number of Array Elements\n\nUbound(MyMultiDimensionalArray, 1) ' Number of Columns\... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] |
273,433 | <p>I've been Googling around for .htaccess redirection information, but nothing I find is quite what I'm looking for.</p>
<p>Basically, I want a solution that will take a site example.com and allow you to enter URL's like:</p>
<pre><code> 123.example.com
ksdfkjds.example.com
dsf38jif348.example.com
</code></pre>
<p>and this would redirect them to:</p>
<pre><code> example.com/123
example.com/ksdfkjds
example.com/dsf38jif348
</code></pre>
<p>So basically accept any subdomain and automatically redirect to a folder on the root of the domain with the name of that subdomain.</p>
| [
{
"answer_id": 273456,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 2,
"selected": false,
"text": "# If we're not on http://example.com\nRewriteCond %{HTTP_HOST} .+\\.example.com\n\n# Add the host to the front of the URL and... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
273,437 | <p>My current process for debugging stored procedures is very simple. I create a table called "debug" where I insert variable values from the stored procedure as it runs. This allows me to see the value of any variable at a given point in the script, but is there a better way to debug MySQL stored procedures?</p>
| [
{
"answer_id": 11137574,
"author": "Jeremy S.",
"author_id": 231982,
"author_profile": "https://Stackoverflow.com/users/231982",
"pm_score": 3,
"selected": false,
"text": "SELECT 'Message Text' AS `Title`; \n"
},
{
"answer_id": 15687954,
"author": "Brad Parks",
"author_id... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26180/"
] |
273,447 | <p>I am using the .NET 3.5 SP1 framework and I've implemented URL routing in my application. I was getting javascript errors: </p>
<p><code>
Error: ASP.NET Ajax client-side framework failed to load.<br>
Resource interpreted as script but transferred with MIME type text/html.<br>
ReferenceError: Can't find variable: Sys
</code></p>
<p>Which I believe is because my routing is picking up the microsoft axd files and not properly sending down the javascript. I did some research and found that I could use <code>Routes.IgnoreRoute</code>, which should allow me to ignore the axd like below:</p>
<pre><code>Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
</code></pre>
<p>But, when I add that line to my Global.asax I get this error:</p>
<p><code>
CS1061: 'System.Web.Routing.RouteCollection' does not contain a definition for 'IgnoreRoute' and no extension method 'IgnoreRoute' accepting a first argument of type 'System.Web.Routing.RouteCollection' could be found (are you missing a using directive or an assembly reference?)
</code></p>
<p>I've got the <code>System.Web.Routing</code> namespace imported, any ideas?</p>
| [
{
"answer_id": 276036,
"author": "Haacked",
"author_id": 598,
"author_profile": "https://Stackoverflow.com/users/598",
"pm_score": 6,
"selected": true,
"text": "routes.Add(new Route(\"{resource}.axd/{*pathInfo}\", new StopRoutingHandler()));\n"
},
{
"answer_id": 7889659,
"aut... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32854/"
] |
273,450 | <p>Has anybody implemented a feature where if the user has not touched the screen for a certain time period, you take a certain action? I'm trying to figure out the best way to do that.</p>
<p>There's this somewhat-related method in UIApplication:</p>
<pre><code>[UIApplication sharedApplication].idleTimerDisabled;
</code></pre>
<p>It'd be nice if you instead had something like this:</p>
<pre><code>NSTimeInterval timeElapsed = [UIApplication sharedApplication].idleTimeElapsed;
</code></pre>
<p>Then I could set up a timer and periodically check this value, and take some action when it exceeds a threshold.</p>
<p>Hopefully that explains what I'm looking for. Has anyone tackled this issue already, or have any thoughts on how you would do it? Thanks.</p>
| [
{
"answer_id": 309535,
"author": "Mike McMaster",
"author_id": 544,
"author_profile": "https://Stackoverflow.com/users/544",
"pm_score": 8,
"selected": true,
"text": "- (void)sendEvent:(UIEvent *)event {\n [super sendEvent:event];\n\n // Only want to reset the timer on a Began touc... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/544/"
] |
273,452 | <p>I can't seem to find a nice clean example of using AES 128 bit encryption.</p>
<p>Does anyone have some sample code?</p>
| [
{
"answer_id": 273499,
"author": "Dan Esparza",
"author_id": 19020,
"author_profile": "https://Stackoverflow.com/users/19020",
"pm_score": 7,
"selected": false,
"text": "using System;\nusing System.IO;\nusing System.Security.Cryptography;\n\nnamespace RijndaelManaged_Example\n{\n clas... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
273,461 | <p>In Microsoft Access I have a table called Time Sheet and in this I have Time sheet no. , waiter no. , date and hours worked. I have 10 waiters. </p>
<p>I have another table called Service Charge Distribution. In this table I have Service Charge No. , waiter no. , week no. and distribution amount. </p>
<p>There is a Bill table where the Service charge distribution is worked out from the bill. </p>
<p>i need to calculate the distribution amount in the service charge distribution table but I do not know how to do this. I would like to do this in Forms. I do know how to work out the total for a week. </p>
<p>Could anyone help?</p>
| [
{
"answer_id": 273611,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 0,
"selected": false,
"text": "Answer=DSum(\"NameOfField\",\"NameOfTable\", _\n \"SomeDate Between #2008/1/20# And #2008/1/27#\")\n"
}
] | 2008/11/07 | [
"https://Stackoverflow.com/questions/273461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
273,485 | <p>Seems likes it might be useful to have the assert display a message when an assertion fails.</p>
<p>Currently an <code>AssertionError</code> gets thrown, can you specify a custom message for it?</p>
<p>Can you show an example mechanism for doing this (other than creating your own exception type and throwing it)?</p>
| [
{
"answer_id": 273488,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 8,
"selected": true,
"text": "assert x > 0 : \"x must be greater than zero, but x = \" + x;\n"
},
{
"answer_id": 273492,
"author": "Jason Co... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] |
273,489 | <p>I am looking at the pricing of various cloud computing platforms, particularly Amazon's EC2, and a lot of the quotes are based on a unit called an Instance-Hour. </p>
<p>I am trying to get a handle on the exact definition of an instance-hour to better compare the costs of continuing to host a web-application versus putting it out on the cloud. </p>
<p>(1) Does it correspond to any of the Windows performance counters in such a way that I could benchmark our current implmentation and use it in their pricing calculators?</p>
<p>(2) How does a multi-processor instance figure into the instance-hour calculation?</p>
| [
{
"answer_id": 23718002,
"author": "Mike S",
"author_id": 1941995,
"author_profile": "https://Stackoverflow.com/users/1941995",
"pm_score": 1,
"selected": false,
"text": "--alive"
}
] | 2008/11/07 | [
"https://Stackoverflow.com/questions/273489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30018/"
] |
273,508 | <p>How do I make an activeX control in a C# library project and then reference it in another ASP.NET wet site project?</p>
| [
{
"answer_id": 273521,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<object...>...</object>"
}
] | 2008/11/07 | [
"https://Stackoverflow.com/questions/273508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22769/"
] |
273,516 | <p>Many of us need to deal with user input, search queries, and situations where the input text can potentially contain profanity or undesirable language. Oftentimes this needs to be filtered out.</p>
<p>Where can one find a good list of swear words in various languages and dialects? </p>
<p>Are there APIs available to sources that contain good lists? Or maybe an API that simply says "yes this is clean" or "no this is dirty" with some parameters?</p>
<p>What are some good methods for catching folks trying to trick the system, like a$$, azz, or a55?</p>
<p>Bonus points if you offer solutions for PHP. :)</p>
<h2><em>Edit: Response to answers that say simply avoid the programmatic issue:</em></h2>
<p>I think there is a place for this kind of filter when, for instance, a user can use public image search to find pictures that get added to a sensitive community pool. If they can search for "penis", then they will likely get many pictures of, yep. If we don't want pictures of that, then preventing the word as a search term is a good gatekeeper, though admittedly not a foolproof method. Getting the list of words in the first place is the real question.</p>
<p>So I'm really referring to a way to figure out of a single token is dirty or not and then simply disallow it. I'd not bother preventing a sentiment like the totally hilarious "long necked giraffe" reference. Nothing you can do there. :)</p>
| [
{
"answer_id": 273520,
"author": "HanClinto",
"author_id": 26933,
"author_profile": "https://Stackoverflow.com/users/26933",
"pm_score": 9,
"selected": true,
"text": "$filterRegex = \"(boogers|snot|poop|shucks|argh)\"\n"
},
{
"answer_id": 273532,
"author": "Robert K",
"au... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27899/"
] |
273,530 | <p>Does anybody have a suggestion for a java library that performs automatic cropping and deskewing of images (like those retrieved from a flatbed scanner)?</p>
| [
{
"answer_id": 36248013,
"author": "delkant",
"author_id": 1250805,
"author_profile": "https://Stackoverflow.com/users/1250805",
"pm_score": 3,
"selected": false,
"text": "public void testDoOCR_SkewedImage() throws Exception {\n logger.info(\"doOCR on a skewed PNG image\");\n File ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25939/"
] |
273,534 | <p>Hey all, I need some advice on this...</p>
<p>We have certain permissions setup in the database for certain levels of control a user can have over the application. Disabled, ReadOnly and Edit. </p>
<p>My question is: Are there more generic/better ways to handle permissions applied to a form element on the page than writing a security method/check per page to enable/disable/hide/show proper controls depending on the permissions allowed?</p>
<p>Anyone have any experience handling this in different ways?</p>
<p>Edit:</p>
<p>I just thought about the possibility of adding constants for each layer that needs security and then adding an IsAuthorized function in the user class that would accept a constant from the form that the control is on, and return boolean to enable/disable controls, this would really reduce the amount of places I'd have to hit when/if I ever need to modify the security for all forms.</p>
<p>Cheers!</p>
| [
{
"answer_id": 1743792,
"author": "Julian Bromwich",
"author_id": 212262,
"author_profile": "https://Stackoverflow.com/users/212262",
"pm_score": 1,
"selected": false,
"text": "/** NO permissions.\n * Presentation: \"hidden\"\n * Database: \"no access\"\n */\nNONE(0),\n\n/** VIEW... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14045/"
] |
273,546 | <p>I'm trying to get a user control working asynchronously, yet no matter what I do it continues to work synchronously. I've stripped it down to its bare minimum as a test web application. This would be the user control:</p>
<pre><code><%@ Control Language="C#" %>
<script runat="server">
SqlConnection m_oConnection;
SqlCommand m_oCommand;
void Page_Load(object sender, EventArgs e)
{
Trace.Warn("Page_Load");
string strDSN = ConfigurationManager.ConnectionStrings["DSN"].ConnectionString + ";async=true";
string strSQL = "waitfor delay '00:00:10'; select * from MyTable";
m_oConnection = new SqlConnection(strDSN);
m_oCommand = new SqlCommand(strSQL, m_oConnection);
m_oConnection.Open();
Page.RegisterAsyncTask(new PageAsyncTask(new BeginEventHandler(BeginHandler), new EndEventHandler(EndHandler), new EndEventHandler(TimeoutHandler), null, true));
Page.ExecuteRegisteredAsyncTasks();
}
IAsyncResult BeginHandler(object src, EventArgs e, AsyncCallback cb, object state)
{
Trace.Warn("BeginHandler");
return m_oCommand.BeginExecuteReader(cb, state);
}
void EndHandler(IAsyncResult ar)
{
Trace.Warn("EndHandler");
GridView1.DataSource = m_oCommand.EndExecuteReader(ar);
GridView1.DataBind();
m_oConnection.Close();
}
void TimeoutHandler(IAsyncResult ar)
{
Trace.Warn("TimeoutHandler");
}
</script>
<asp:gridview id="GridView1" runat="server" />
</code></pre>
<p>And this would be the page in which I host the control three times:</p>
<pre><code><%@ page language="C#" trace="true" async="true" asynctimeout="60" %>
<%@ register tagprefix="uc" tagname="mycontrol" src="~/MyControl.ascx" %>
<html>
<body>
<form id="form1" runat="server">
<uc:mycontrol id="MyControl1" runat="server" />
<uc:mycontrol id="MyControl2" runat="server" />
<uc:mycontrol id="MyControl3" runat="server" />
</form>
</body>
</html>
</code></pre>
<p>The page gets displayed without errors, but the trace at the bottom of the page shows each control instance is processed synchronously. What am I doing wrong? Is there a configuration setting somewhere I'm missing?</p>
| [
{
"answer_id": 273717,
"author": "Charles",
"author_id": 24898,
"author_profile": "https://Stackoverflow.com/users/24898",
"pm_score": 4,
"selected": true,
"text": "Page.ExecuteRegisteredAsyncTasks"
},
{
"answer_id": 5229916,
"author": "Nandun",
"author_id": 649470,
"... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24898/"
] |
273,567 | <p>Every Christmas we draw names for gift exchanges in my family. This usually involves mulitple redraws until no one has pulled their spouse. So this year I coded up my own name drawing app that takes in a bunch of names, a bunch of disallowed pairings, and sends off an email to everyone with their chosen giftee.</p>
<p>Right now, the algorithm works like this (in pseudocode):</p>
<pre><code>function DrawNames(list allPeople, map disallowedPairs) returns map
// Make a list of potential candidates
foreach person in allPeople
person.potentialGiftees = People
person.potentialGiftees.Remove(person)
foreach pair in disallowedPairs
if pair.first = person
person.Remove(pair.second)
// Loop through everyone and draw names
while allPeople.count > 0
currentPerson = allPeople.findPersonWithLeastPotentialGiftees
giftee = pickRandomPersonFrom(currentPerson.potentialGiftees)
matches[currentPerson] = giftee
allPeople.Remove(currentPerson)
foreach person in allPeople
person.RemoveIfExists(giftee)
return matches
</code></pre>
<p>Does anyone who knows more about graph theory know some kind of algorithm that would work better here? For my purposes, this works, but I'm curious.</p>
<p>EDIT: Since the emails went out a while ago, and I'm just hoping to learn something I'll rephrase this as a graph theory question. I'm not so interested in the special cases where the exclusions are all pairs (as in spouses not getting each other). I'm more interested in the cases where there are enough exclusions that finding any solution becomes the hard part. My algorithm above is just a simple greedy algorithm that I'm not sure would succeed in all cases.</p>
<p>Starting with a complete directed graph and a list of vertex pairs. For each vertex pair, remove the edge from the first vertex to the second.</p>
<p>The goal is to get a graph where each vertex has one edge coming in, and one edge leaving.</p>
| [
{
"answer_id": 303476,
"author": "wxs",
"author_id": 12981,
"author_profile": "https://Stackoverflow.com/users/12981",
"pm_score": 3,
"selected": false,
"text": "import random\nfrom collections import deque\ndef pairup(people):\n \"\"\" Given a list of people, assign each one a secret... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8701/"
] |
273,578 | <p><a href="https://web.archive.org/web/20210126032647/http://geekswithblogs.net/michelotti/archive/2007/12/17/117791.aspx" rel="nofollow noreferrer">Link</a></p>
<p>I'm using ASP.NET with C# and trying to use linq to sql to update a data context as exhibited on the blog linked above. I created the timestamp field in the table just as stated and am using the following method:</p>
<pre><code>private void updateRecord(TableName updatedRecord)
{
context db = new context();
db.TableName.Attach(updatedRecord,true);
db.SubmitChanges();
}
</code></pre>
<p>My question is, are you supposed to assign the timeStamp field to anything in your updatedRecord before trying to call the Attach method on your data context?</p>
<p>When I run this code I get the following exception: <code>System.Data.Linq.ChangeConflictException: Row not found or changed. </code> I update all of the fields, including the primary key of the record that I'm updating before passing the object to this update method. During debugging the TimeStamp attribute of the object shows as null. I'm not sure if it's supposed to be that way or not.</p>
<p>Every book and resource I have says that this is the way to do it, but none of them go into great detail about this TimeStamp attribute.</p>
<p>I know this is quick and easy, so if anybody knows, please let me know.</p>
| [
{
"answer_id": 273740,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "AutoGenerated = true\nAuto-Sync = Always\nTime Stamp = True\nUpdate Check = Never\n"
}
] | 2008/11/07 | [
"https://Stackoverflow.com/questions/273578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35617/"
] |
273,606 | <p>I am designing a WCF service which a client will call to get a list of GUID's from a server.</p>
<p>How should I define my endpoint contract?</p>
<p>Should I just return an Array? </p>
<p>If so, will the array just be serialized by WCF?</p>
| [
{
"answer_id": 273616,
"author": "Adron",
"author_id": 29345,
"author_profile": "https://Stackoverflow.com/users/29345",
"pm_score": 2,
"selected": false,
"text": "[DataMember] List<Guid> SomeGuidsGoInHere {get;set;}\n"
},
{
"answer_id": 1354324,
"author": "Blue Toque",
"... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
273,612 | <p>It's a really basic question but i can't think at the second. How do i set up a loop that asks each time the function inside runs whether to do it again. So it runs it then says something like;</p>
<p>"loop again? y/n"</p>
| [
{
"answer_id": 273618,
"author": "Martin Cote",
"author_id": 9936,
"author_profile": "https://Stackoverflow.com/users/9936",
"pm_score": 5,
"selected": true,
"text": "while True:\n func()\n answer = raw_input( \"Loop again? \" )\n if answer != 'y':\n break\n"
},
{
... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33061/"
] |
273,623 | <p>I have a list of numbers, say {2,4,5,6,7}
I have a table, foos, with foos.ID, including say, {1,2,3,4,8,9}</p>
<p>Id like to take my list of numbers, and find those without a counterpart in the ID field of my table.</p>
<p>One way to achieve this would be to create a table bars, loaded with {2,4,5,6,7} in the ID field.
Then, I would do </p>
<pre>
SELECT bars.* FROM bars LEFT JOIN foos ON bars.ID = foos.ID WHERE foos.ID IS NULL
</pre>
<p>However, I'd like to accomplish this sans temp table. </p>
<p>Anyone have any input on how it might happen?</p>
| [
{
"answer_id": 273649,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 4,
"selected": false,
"text": "SELECT bars.* FROM bars WHERE bars.ID NOT IN (SELECT ID FROM foos)\n"
},
{
"answer_id": 273703,
"author": "Bill ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26001/"
] |
273,624 | <p>How do you create a 1 bit per pixel mask from an image using GDI in C#? The image I am trying to create the mask from is held in a System.Drawing.Graphics object.</p>
<p>I have seen examples that use Get/SetPixel in a loop, which are too slow. The method that interests me is one that uses only BitBlits, like <a href="http://www.vbaccelerator.com/home/VB/Tips/Mask_Images/article.asp" rel="nofollow noreferrer">this</a>. I just can't get it to work in C#, any help is much appreciated.</p>
| [
{
"answer_id": 273686,
"author": "Hans Passant",
"author_id": 17034,
"author_profile": "https://Stackoverflow.com/users/17034",
"pm_score": 3,
"selected": false,
"text": "using System.Drawing;\nusing System.Drawing.Imaging;\nusing System.Runtime.InteropServices;\n"
}
] | 2008/11/07 | [
"https://Stackoverflow.com/questions/273624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24201/"
] |
273,630 | <p>Actually my question is all in the title.<br>
Anyway:<br>
I have a class and I use explicit constructor:
<br>.h<br></p>
<pre><code>class MyClass
{
public:
explicit MyClass(const string& s): query(s) {}
private:
string query;
}
</code></pre>
<p>Is it obligatory or not to put <b>explicit</b> keyword in implementation(.cpp) file?</p>
| [
{
"answer_id": 273633,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 6,
"selected": true,
"text": "explicit"
}
] | 2008/11/07 | [
"https://Stackoverflow.com/questions/273630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28298/"
] |
273,639 | <p>I have a windows form application that uses a Shared class to house all of the common objects for the application. The settings class has a collection of objects that do things periodically, and then there's something of interest, they need to alert the main form and have it update.</p>
<p>I'm currently doing this through Events on the objects, and when each object is created, I add an EventHandler to maps the event back to the form. However, I'm running into some trouble that suggests that these requests aren't always ending up on the main copy of my form. For example, my form has a notification tray icon, but when the form captures and event and attempts to display a bubble, no bubble appears. However, if I modify that code to make the icon visible (though it already is), and then display the bubble, a second icon appears and displays the bubble properly.</p>
<p>Has anybody run into this before? Is there a way that I can force all of my events to be captured by the single instance of the form, or is there a completely different way to handle this? I can post code samples if necessary, but I'm thinking it's a common threading problem.</p>
<p><strong>MORE INFORMATION:</strong> I'm currently using Me.InvokeRequired in the event handler on my form, and it always returns FALSE in this case. Also, the second tray icon created when I make it visible from this form doesn't have a context menu on it, whereas the "real" icon does - does that clue anybody in?</p>
<p>I'm going to pull my hair out! This can't be that hard!</p>
<p><strong>SOLUTION</strong>: Thanks to nobugz for the clue, and it lead me to the code I'm now using (which works beautifully, though I can't help thinking there's a better way to do this). I added a private boolean variable to the form called "IsPrimary", and added the following code to the form constructor:</p>
<pre><code> Public Sub New()
If My.Application.OpenForms(0).Equals(Me) Then
Me.IsFirstForm = True
End If
End Sub
</code></pre>
<p>Once this variable is set and the constructor finishes, it heads right to the event handler, and I deal with it this way (CAVEAT: Since the form I'm looking for is the primary form for the application, My.Application.OpenForms(0) gets what I need. If I was looking for the first instance of a non-startup form, I'd have to iterate through until I found it):</p>
<pre><code> Public Sub EventHandler()
If Not IsFirstForm Then
Dim f As Form1 = My.Application.OpenForms(0)
f.EventHandler()
Me.Close()
ElseIf InvokeRequired Then
Me.Invoke(New HandlerDelegate(AddressOf EventHandler))
Else
' Do your event handling code '
End If
End Sub
</code></pre>
<p>First, it checks to see if it's running on the correct form - if it's not, then call the right form. Then it checks to see if the thread is correct, and calls the UI thread if it's not. Then it runs the event code. I don't like that it's potentially three calls, but I can't think of another way to do it. It seems to work well, though it's a little cumbersome. If anybody has a better way to do it, I'd love to hear it!</p>
<p>Again, thanks for all the help - this was going to drive me nuts!</p>
| [
{
"answer_id": 273653,
"author": "Hans Passant",
"author_id": 17034,
"author_profile": "https://Stackoverflow.com/users/17034",
"pm_score": 3,
"selected": true,
"text": " Dim main As Form1 = CType(Application.OpenForms(0), Form1)\n if (main.InvokeRequired)\n ' etc...\n"
},
{
... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8114/"
] |
273,641 | <p>This question has been discussed in two blog posts (<a href="http://dow.ngra.de/2008/10/27/when-systemcurrenttimemillis-is-too-slow/" rel="nofollow noreferrer">http://dow.ngra.de/2008/10/27/when-systemcurrenttimemillis-is-too-slow/</a>, <a href="http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/" rel="nofollow noreferrer">http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/</a>), but I haven't heard a definitive answer yet. If we have one thread that does this:</p>
<pre><code>public class HeartBeatThread extends Thread {
public static int counter = 0;
public static volatile int cacheFlush = 0;
public HeartBeatThread() {
setDaemon(true);
}
static {
new HeartBeatThread().start();
}
public void run() {
while (true) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
counter++;
cacheFlush++;
}
}
}
</code></pre>
<p>And many clients that run the following:</p>
<pre><code>if (counter == HeartBeatThread.counter) return;
counter = HeartBeatThread.cacheFlush;
</code></pre>
<p>is it threadsafe or not?</p>
| [
{
"answer_id": 273690,
"author": "jiriki",
"author_id": 19907,
"author_profile": "https://Stackoverflow.com/users/19907",
"pm_score": 1,
"selected": false,
"text": "if (counter == HeartBeatThread.counter) \n return;\n"
}
] | 2008/11/07 | [
"https://Stackoverflow.com/questions/273641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20022/"
] |
273,662 | <p>With multiple developers working on the same Tomcat application, I'd like to tell the application to install to a different path, based on the current user and revision control client/view.</p>
<p>So, if Bob is building, the app should be installed in Bob's test environment, maybe /bob1 or something like that. Bob might have several revision control clients/views/workspaces he works with so he could have /bob1, /bob2, /bob3, etc.</p>
<p>The install location is specified in the build.properties file. Is there a way to avoid checking that file out and changing it for each specific user and revision control view?</p>
<p>Can "ant install" take arguments or be configured to consider environment variables for the install target?</p>
| [
{
"answer_id": 275622,
"author": "flicken",
"author_id": 12880,
"author_profile": "https://Stackoverflow.com/users/12880",
"pm_score": 2,
"selected": false,
"text": "ant -Dinstall.location=/bob1 install\n"
},
{
"answer_id": 275794,
"author": "SAL9000",
"author_id": 11609,... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22917/"
] |
273,664 | <p>I find AWK really useful. Here is a one liner I put together to manipulate data.</p>
<pre><code>ls | awk '{ print "awk " "'"'"'" " {print $1,$2,$3} " "'"'"'" " " $1 ".old_ext > " $1 ".new_ext" }' > file.csh
</code></pre>
<p>I used this AWK to make a script file that would rename some files and only print out selective columns. Anyone know a better way to do this? What are you best AWK one liners or clever manipulations?</p>
| [
{
"answer_id": 273737,
"author": "Niniki",
"author_id": 4155,
"author_profile": "https://Stackoverflow.com/users/4155",
"pm_score": 1,
"selected": false,
"text": "ls -1 *.mp3 | awk '{printf(\"mv %s newDir/%s\\n\",$1,$1)}' | /bin/sh\n"
},
{
"answer_id": 274539,
"author": "Jona... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30181/"
] |
273,668 | <p>I'm working on a Java based project that has a client program which needs to connect to a MySQL database on a remote server. This was implemented is as follows:</p>
<p>Use JDBC to write the SQL queries to be executed which are then hosted as a servlet using Apache Tomcat and made accessible via XML-RPC. The client code uses XML-RPC to remotely execute these JDBC based functions. This allows us to keep our MySQL database non-public, restricts use to the pre-defined functions, and allows Tomcat to manage the database transactions (which I've been told is better than letting MySQL do it alone, but I really don't understand why). However, this approach requires a lot of boiler-plate code, and Tomcat is a huge memory hog on our server.</p>
<p>I'm looking for a better way to do this. One way I'm considering is to make the MySQL database publicly accessible, re-writing the JDBC based code as stored procedures, and restricting public use to these procedures only. The problem I see with this are that translating all the JDBC code to stored procedures will be difficult and time consuming. I'm also not too familiar with MySQL's permissions. Can one grant access to a stored procedure which performs select statements on a table, but also deny arbitrary select statements on that same table?</p>
<p>Any other ideas are welcome, as are thoughts and or sugguestions on the stored procedure solution.</p>
<p>Thank you! </p>
| [
{
"answer_id": 273737,
"author": "Niniki",
"author_id": 4155,
"author_profile": "https://Stackoverflow.com/users/4155",
"pm_score": 1,
"selected": false,
"text": "ls -1 *.mp3 | awk '{printf(\"mv %s newDir/%s\\n\",$1,$1)}' | /bin/sh\n"
},
{
"answer_id": 274539,
"author": "Jona... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
273,671 | <p>In an attempt to hide the Safari UI components for an web-app bookmarked as a Homescreen Icon. I am using this meta tag </p>
<pre><code><meta name="apple-mobile-web-app-capable" content="yes" />
</code></pre>
<p>as specified on <a href="https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html#//apple_ref/doc/uid/TP40002051-CH3-SW2" rel="nofollow noreferrer">iPhone Dev Center</a> but the address bar and toolbar are still there when launched from the home screen icon. What do I need to do different? Does anyone have an example?</p>
| [
{
"answer_id": 2002558,
"author": "Benoit",
"author_id": 222769,
"author_profile": "https://Stackoverflow.com/users/222769",
"pm_score": 3,
"selected": false,
"text": "<meta name=\"apple-touch-fullscreen\" content=\"yes\" />\n"
},
{
"answer_id": 3049787,
"author": "mbxtr",
... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
273,675 | <p>From an application I'm building I need to print existing PDFs (created by another app).
How can I do this in C# and provide a mechanism so the user can select a different printer or other properties. </p>
<p>I've looked at the PrintDialog but not sure what file it is attempting to print, if any, b/c the output is always a blank page. Maybe I'm just missing something there.</p>
<p>Do I need to use "iTextSharp" (as suggested else where)? That seems odd to me since I can "send the the file to the printer" I just don't have any nice dialog before hand to set the printer etc. and I don't really want to write a printing dialog from the ground up but it seems like a lot of examples I found by searching did just that.</p>
<p>Any advice, examples or sample code would be great!</p>
<p>Also if PDF is the issue the files could be created by the other app in a diff format such as bitmap or png if that makes things easier.</p>
| [
{
"answer_id": 273729,
"author": "Nicholas Piasecki",
"author_id": 32187,
"author_profile": "https://Stackoverflow.com/users/32187",
"pm_score": 5,
"selected": false,
"text": "PrinterSettings.InstalledPrinters"
},
{
"answer_id": 273822,
"author": "Community",
"author_id":... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
273,691 | <p>In the C / Unix environment I work in, I see some developers using <code>__progname</code> instead of <code>argv[0]</code> for usage messages. Is there some advantage to this? What's the difference between <code>__progname</code> and <code>argv[0]</code>. Is it portable?</p>
| [
{
"answer_id": 273701,
"author": "Evan Teran",
"author_id": 13430,
"author_profile": "https://Stackoverflow.com/users/13430",
"pm_score": 5,
"selected": true,
"text": "__progname"
},
{
"answer_id": 273706,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10888/"
] |
273,695 | <p>I've been using a local git repository interacting with my group's CVS repository for several months, now. I've made an almost neurotic number of branches, most of which have thankfully merged back into my trunk. But naming is starting to become an issue. If I have a task easily named with a simple label, but I accomplish it in three stages which each include their own branch and merge situation, then I can repeat the branch name each time, but that makes the history a little confusing. If I get more specific in the names, with a separate description for each stage, then the branch names start to get long and unwieldy.</p>
<p>I did learn looking through old threads here that I could start naming branches with a / in the name, i.e., topic/task, or something like that. I may start doing that and seeing if it helps keep things better organized.</p>
<p>What are some best practices for naming git branches?</p>
<p>Edit:
Nobody has actually suggested any naming conventions.
I do delete branches when I'm done with them. I just happen to have several around due to management constantly adjusting my priorities. :)
As an example of why I might need more than one branch on a task, suppose I need to commit the first discrete milestone in the task to the group's CVS repository. At that point, due to my imperfect interaction with CVS, I would perform that commit and then kill that branch. (I've seen too much weirdness interacting with CVS if I try to continue to use the same branch at that point.)</p>
| [
{
"answer_id": 273760,
"author": "Aristotle Pagaltzis",
"author_id": 9410,
"author_profile": "https://Stackoverflow.com/users/9410",
"pm_score": 6,
"selected": false,
"text": "git branch"
},
{
"answer_id": 280157,
"author": "farktronix",
"author_id": 677,
"author_prof... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18103/"
] |
273,711 | <p>I have an Eclipse RCP application that displays a lot (10k+) of small images next to each other, like a film strip. For each image, I am using a SWT <code>Image</code> object. This uses an excessive amount of memory and resources. I am looking for a more efficient way. I thought of taking all of these images and concatenating them by creating an <code>ImageData</code> object of the proper total, concatenated width (with a constant height) and using <code>setPixel()</code> for the rest of the pixels. However, the <code>Palette</code> used in the <code>ImageData</code> constructor I can't figure out.</p>
<p>I also searched for SWT tiling or mosaic functionality to create one image from a group of images, but found nothing.</p>
<p>Any ideas how I can display thousands of small images next to each other efficiently? Please note that once the images are displayed, they are not manipulated, so this is a one-time cost.</p>
| [
{
"answer_id": 290904,
"author": "Herman Lintvelt",
"author_id": 27602,
"author_profile": "https://Stackoverflow.com/users/27602",
"pm_score": 3,
"selected": true,
"text": " final List<Image> images;\n final Image bigImage = new Image(Display.getCurrent(), combinedWidth, he... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/725/"
] |
273,720 | <p>Should Singleton objects that don't use instance/reference counters be considered memory leaks in C++?</p>
<p>Without a counter that calls for explicit deletion of the singleton instance when the count is zero, how does the object get deleted? Is it cleaned up by the OS when the application is terminated? What if that Singleton had allocated memory on the heap?</p>
<p>In a nutshell, do I have to call a Singelton's destructor or can I rely on it getting cleaned up when the application terminates?</p>
| [
{
"answer_id": 273749,
"author": "Nicola Bonelli",
"author_id": 19630,
"author_profile": "https://Stackoverflow.com/users/19630",
"pm_score": 2,
"selected": false,
"text": "signal(SIGTERM,exit);"
},
{
"answer_id": 273826,
"author": "Don Wakefield",
"author_id": 3778,
... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34731/"
] |
273,721 | <p>I wonder if there is an example which html files and java files are resides in different folders. </p>
| [
{
"answer_id": 273818,
"author": "Loren_",
"author_id": 13703,
"author_profile": "https://Stackoverflow.com/users/13703",
"pm_score": 3,
"selected": false,
"text": "IResourceSettings resourceSettings = getResourceSettings();\nresourceSettings.addResourceFolder(\"pages\"); //the full path... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34367/"
] |
273,732 | <p>I have an application where, in the course of using the application, a user might click from</p>
<pre><code>virginia.usa.com
</code></pre>
<p>to</p>
<pre><code>newyork.usa.com
</code></pre>
<p>Since I'd rather not create a new session each time a user crosses from one subdomain to another, what's a good way to share session info across multiple subdomains?</p>
| [
{
"answer_id": 273775,
"author": "Matthew Scharley",
"author_id": 15537,
"author_profile": "https://Stackoverflow.com/users/15537",
"pm_score": 2,
"selected": false,
"text": ".usa.com"
},
{
"answer_id": 2088853,
"author": "Matt Connolly",
"author_id": 2845,
"author_pr... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28118/"
] |
273,743 | <p>I have a web directory where I store some config files. I'd like to use wget to pull those files down and maintain their current structure. For instance, the remote directory looks like:</p>
<pre><code>http://mysite.com/configs/.vim/
</code></pre>
<p>.vim holds multiple files and directories. I want to replicate that on the client using wget. Can't seem to find the right combo of wget flags to get this done. Any ideas?</p>
| [
{
"answer_id": 273755,
"author": "Conor McDermottroe",
"author_id": 63985,
"author_profile": "https://Stackoverflow.com/users/63985",
"pm_score": 3,
"selected": false,
"text": "wget -r http://mysite.com/configs/.vim/\n"
},
{
"answer_id": 273757,
"author": "kasperjj",
"aut... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2476/"
] |
273,751 | <p>I have a SSIS package that eventually I would like to pass parameters too, these parameters will come from a .NET application (VB or C#) so I was curious if anyone knows of how to do this, or better yet a website with helpful hints on how to do it. </p>
<p>So basically I want to execute a SSIS package from .NET passing the SSIS package parameters that it can use within it. </p>
<p>For instance, the SSIS package will use flat file importing into a SQL db however the Path and name of the file could be the parameter that is passed from the .Net application.</p>
| [
{
"answer_id": 1920083,
"author": "Craig Schwarze",
"author_id": 226235,
"author_profile": "https://Stackoverflow.com/users/226235",
"pm_score": 6,
"selected": false,
"text": "using Microsoft.SqlServer.Dts.Runtime;\n\nprivate void Execute_Package()\n { \n string pkgLo... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
273,789 | <p>In javascript, is there an equivalent of String.indexOf() that takes a regular expression instead of a string for the first first parameter while still allowing a second parameter ?</p>
<p>I need to do something like </p>
<pre><code>str.indexOf(/[abc]/ , i);
</code></pre>
<p>and</p>
<pre><code>str.lastIndexOf(/[abc]/ , i);
</code></pre>
<p>While String.search() takes a regexp as a parameter it does not allow me to specify a second argument!</p>
<p>Edit:<br>
This turned out to be harder than I originally thought so I wrote a small test function to test all the provided solutions... it assumes regexIndexOf and regexLastIndexOf have been added to the String object.</p>
<pre><code>function test (str) {
var i = str.length +2;
while (i--) {
if (str.indexOf('a',i) != str.regexIndexOf(/a/,i))
alert (['failed regexIndexOf ' , str,i , str.indexOf('a',i) , str.regexIndexOf(/a/,i)]) ;
if (str.lastIndexOf('a',i) != str.regexLastIndexOf(/a/,i) )
alert (['failed regexLastIndexOf ' , str,i,str.lastIndexOf('a',i) , str.regexLastIndexOf(/a/,i)]) ;
}
}
</code></pre>
<p>and I am testing as follow to make sure that at least for one character regexp, the result is the same as if we used indexOf</p>
<p>//Look for the a among the xes<br>
test('xxx');<br>
test('axx');<br>
test('xax');<br>
test('xxa');<br>
test('axa');<br>
test('xaa');<br>
test('aax');<br>
test('aaa'); </p>
| [
{
"answer_id": 273797,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 3,
"selected": false,
"text": "str.substr(i).match(/[abc]/);\n"
},
{
"answer_id": 273810,
"author": "Glenn",
"author_id": 25191,
"... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/238/"
] |
273,794 | <p>Similar to <a href="https://stackoverflow.com/questions/85978/query-a-tables-foreign-key-relationships">this question</a> but for MySQL....</p>
<p>How can I programmatically determine foreign key references in MySQL (assuming InnoDB)? I can almost get them with:</p>
<pre><code>SHOW TABLE STATUS WHERE Name = 'MyTableName';
</code></pre>
<p>...but alas, the comment column which seems to contain some of this info gets truncated so I can't rely on it. There must be some other way...</p>
<p>I'd be happy with a C API call, a SQL statement, anything--I just need something that consistently works.</p>
<p>Note: I've also considered parsing the results of a "SHOW CREATE TABLE MyTableName" statement, but I'm really hoping there's something simpler.</p>
| [
{
"answer_id": 273812,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 2,
"selected": false,
"text": "INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS"
},
{
"answer_id": 273907,
"author": "Bill Karwin",
"author_i... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23934/"
] |
273,809 | <p>I have a bunch of controls on my window. One of them is a refresh button that performs a cumbersome task on a background thread.</p>
<p>When the user clicks the refresh button, I put the cursor in a wait (hourglass) status and disable the whole window -- <code>Me.IsEnabled = False</code>.</p>
<p>I'd like to support cancellation of the refresh action by letting the user click a cancel button, but I can't facilitate this while the whole window is disabled.</p>
<p>Is there a way to do this besides disabling each control (except for the cancel button) one by one and then re-enabling them one by one when the user clicks cancel?</p>
| [
{
"answer_id": 273852,
"author": "Abe Heidebrecht",
"author_id": 9268,
"author_profile": "https://Stackoverflow.com/users/9268",
"pm_score": 6,
"selected": true,
"text": "<StackPanel Orientation=\"Horizontal\">\n <StackPanel x:Name=\"controlContainer\" Orientation=\"Horizontal\">\n ... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/132931/"
] |
273,847 | <p>I'm developing multi-language support for our web app. We're using <a href="http://docs.djangoproject.com/en/dev/topics/i18n/" rel="noreferrer">Django's helpers</a> around the <a href="http://en.wikipedia.org/wiki/Gettext" rel="noreferrer">gettext</a> library. Everything has been surprisingly easy, except for the question of how to handle sentences that include significant HTML markup. Here's a simple example:</p>
<pre><code>Please <a href="/login/">log in</a> to continue.
</code></pre>
<p>Here are the approaches I can think of:</p>
<ol>
<li><p>Change the link to include the whole sentence. Regardless of whether the change is a good idea in this case, the problem with this solution is that UI becomes dependent on the needs of i18n when the two are ideally independent.</p></li>
<li><p>Mark the whole string above for translation (formatting included). The translation strings would then also include the HTML directly. The problem with this is that changing the HTML formatting requires changing all the translation.</p></li>
<li><p>Tightly couple multiple translations, then use string interpolation to combine them. For the example, the phrase "Please %s to continue" and "log in" could be marked separately for translation, then combined. The "log in" is localized, then wrapped in the HREF, then inserted into the translated phrase, which keeps the %s in translation to mark where the link should go. This approach complicates the code and breaks the independence of translation strings.</p></li>
</ol>
<p>Are there any other options? How have others solved this problem?</p>
| [
{
"answer_id": 273914,
"author": "hangy",
"author_id": 11963,
"author_profile": "https://Stackoverflow.com/users/11963",
"pm_score": 3,
"selected": false,
"text": "<strong />"
},
{
"answer_id": 274037,
"author": "Niniki",
"author_id": 4155,
"author_profile": "https://... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
273,848 | <p>I am developing a HTML form designer that needs to generate static HTML and show this to the user. I keep writing ugly code like this:</p>
<pre><code>public string GetCheckboxHtml()
{
return ("&lt;input type="checkbox" name="somename" /&gt;");
}
</code></pre>
<p>Isn't there a set of strongly typed classes that describe html elements and allow me to write code like this instead:</p>
<pre><code>var checkbox = new HtmlCheckbox(attributes);
return checkbox.Html();
</code></pre>
<p>I just can't think of the correct namespace to look for this or the correct search term to use in Google.</p>
| [
{
"answer_id": 273866,
"author": "Jacob Carpenter",
"author_id": 26627,
"author_profile": "https://Stackoverflow.com/users/26627",
"pm_score": 2,
"selected": false,
"text": "var input = new XElement(\"input\",\n new XAttribute(\"type\", \"checkbox\"),\n new XAttribute(\"name\", \"s... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
273,854 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/26094/most-efficient-implementation-of-a-large-number-class">Most efficient implementation of a large number class</a> </p>
</blockquote>
<p>Suppose I needed to calculate 2^150000. Obviously that number is going to exceed the size of an int, float, or double. How can I make a data type that allows normal math functions but exceeds the basic number types?</p>
<p>If this is a "depends which language you use" kind of deal. I will say C#.</p>
| [
{
"answer_id": 273861,
"author": "John D. Cook",
"author_id": 25188,
"author_profile": "https://Stackoverflow.com/users/25188",
"pm_score": 1,
"selected": false,
"text": "bc"
},
{
"answer_id": 273893,
"author": "Bjarke Ebert",
"author_id": 31890,
"author_profile": "ht... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3800/"
] |
273,869 | <p>The topic generically says it all. Basically in a situation like this:</p>
<pre><code>boost::scoped_array<int> p(new int[10]);
</code></pre>
<p>Is there any appreciable difference in performance between doing: <code>&p[0]</code> and <code>p.get()</code>?</p>
<p>I ask because I prefer the first one, it has a more natural pointer like syntax. In fact, it makes it so you could replace p with a native pointer or array and not have to change anything else.</p>
<p>I am guessing since get is a one liner "<code>return ptr;</code>" that the compiler will inline that, and I hope that it is smart enough to to inline <code>operator[]</code> in such a way that it is able to not dereference and then immediately reference.</p>
<p>Anyone know?</p>
| [
{
"answer_id": 273900,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 2,
"selected": false,
"text": "T * scoped_array::get() const // never throws\n{\n return ptr;\n}\n\nT & scoped_array::operator[](std::ptrdiff_t i)... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13430/"
] |
273,898 | <p>I have two forms in microsoft access, one called Bill and the other one called Payment. They both have Total amount as a field in both of the forms. I am trying to reference the Bill total amount to the Payment total amount. </p>
<p>I have tried in the Payment total amount control source : =Forms!Bill![Total Amount]</p>
<p>but this doesnt seem to work. In Design view it says '#Name?' in the text box. </p>
<p>How would you do this? </p>
| [
{
"answer_id": 273950,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 2,
"selected": false,
"text": "Me.Parent.[Total order]\nMe.[Subform Control name Here].form.[Total order]\n"
},
{
"answer_id": 274059,
"autho... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
273,908 | <p>Problem: I have an integer; this integer needs to be converted to a stl::string type. </p>
<p>In the past, I've used <code>stringstream</code> to do a conversion, and that's just kind of cumbersome. I know the C way is to do a <code>sprintf</code>, but I'd much rather do a C++ method that is typesafe(er).</p>
<p>Is there a better way to do this? </p>
<p>Here is the stringstream approach I have used in the past:</p>
<pre><code>std::string intToString(int i)
{
std::stringstream ss;
std::string s;
ss << i;
s = ss.str();
return s;
}
</code></pre>
<p>Of course, this could be rewritten as so:</p>
<pre><code>template<class T>
std::string t_to_string(T i)
{
std::stringstream ss;
std::string s;
ss << i;
s = ss.str();
return s;
}
</code></pre>
<p>However, I have the notion that this is a fairly 'heavy-weight' implementation.</p>
<p>Zan noted that the invocation is pretty nice, however:</p>
<pre><code>std::string s = t_to_string(my_integer);
</code></pre>
<p>At any rate, a nicer way would be... nice. </p>
<blockquote>
<h3>Related:</h3>
<p><a href="https://stackoverflow.com/questions/228005/alternative-to-itoa-for-converting-integer-to-string-c">Alternative to itoa() for converting integer to string C++?</a> </p>
</blockquote>
| [
{
"answer_id": 273961,
"author": "Mic",
"author_id": 35656,
"author_profile": "https://Stackoverflow.com/users/35656",
"pm_score": 5,
"selected": false,
"text": "#include <boost/lexical_cast.hpp>\nstd::string s = boost::lexical_cast<std::string>(i);\n"
},
{
"answer_id": 8362045,
... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26227/"
] |
273,909 | <p>Is there a idiomatic way of removing elements from PATH-like shell variables?</p>
<p>That is I want to take</p>
<pre><code>PATH=/home/joe/bin:/usr/local/bin:/usr/bin:/bin:/path/to/app/bin:.
</code></pre>
<p>and <strong>remove</strong> or <strong>replace</strong> the <code>/path/to/app/bin</code> without clobbering the rest of the variable. Extra points for allowing me <em>put</em> new elements in arbitrary positions. The target will be recognizable by a well defined string, and may occur at any point in the list.</p>
<p>I know I've seen this done, and can probably cobble something together on my own, but I'm looking for a nice approach. Portability and standardization a plus.</p>
<p>I use bash, but example are welcome in your favorite shell as well.</p>
<hr>
<p>The context here is one of needing to switch conveniently between multiple versions (one for doing analysis, another for working on the framework) of a large scientific analysis package which produces a couple dozen executables, has data stashed around the filesystem, and uses environment variable to help find all this stuff. I would like to write a script that selects a version, and need to be able to remove the <code>$PATH</code> elements relating to the currently active version and replace them with the same elements relating to the new version.</p>
<hr>
<p>This is related to the problem of preventing repeated <code>$PATH</code> elements when re-running login scripts and the like.</p>
<hr>
<ul>
<li>Previous similar question: <a href="https://stackoverflow.com/questions/135754/how-to-keep-from-duplicating-path-variable-in-csh">How to keep from duplicating path variable in csh</a></li>
<li>Subsequent similar question: <a href="https://stackoverflow.com/questions/370047/what-is-the-most-elegant-way-to-remove-a-path-from-the-path-variable-in-bash">What is the most elegant way to remove a path from the $PATH variable in Bash?</a></li>
</ul>
| [
{
"answer_id": 273998,
"author": "florin",
"author_id": 18308,
"author_profile": "https://Stackoverflow.com/users/18308",
"pm_score": 2,
"selected": false,
"text": "#!/bin/bash\nNEW_PATH=$(echo -n $PATH | tr \":\" \"\\n\" | sed \"/foo/d\" | tr \"\\n\" \":\")\nexport PATH=$NEW_PATH\n"
}... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2509/"
] |
273,929 | <p><strong>In Oracle I can declare a reference cursor...</strong></p>
<pre><code>TYPE t_spool IS REF CURSOR RETURN spool%ROWTYPE;
</code></pre>
<p><strong>...and use it to pass a cursor as the return value...</strong></p>
<pre><code>FUNCTION end_spool
RETURN t_spool
AS
v_spool t_spool;
BEGIN
COMMIT;
OPEN v_spool FOR
SELECT
*
FROM
spool
WHERE
key = g_spool_key
ORDER BY
seq;
RETURN v_spool;
END end_spool;
</code></pre>
<p><strong>...and then capture it as a result set using JDBC...</strong></p>
<pre><code>private Connection conn;
private CallableStatement stmt;
private OracleResultSet rset;
[...clip...]
stmt = conn.prepareCall("{ ? = call " + call + "}");
stmt.registerOutParameter(1, OracleTypes.CURSOR);
stmt.execute();
rset = (OracleResultSet)stmt.getObject(1);
</code></pre>
<p><strong>What is the equivalent in MySQL?</strong></p>
| [
{
"answer_id": 445434,
"author": "Yoni",
"author_id": 36071,
"author_profile": "https://Stackoverflow.com/users/36071",
"pm_score": 3,
"selected": false,
"text": "CREATE PROCEDURE `TEST`()\nMODIFIES SQL DATA\nBEGIN\n SELECT * FROM test_table;\nEND;\n"
}
] | 2008/11/07 | [
"https://Stackoverflow.com/questions/273929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13930/"
] |
273,937 | <p>I am trying to learn Python and WxPython. I have been a SAS programmer for years. This OOP stuff is slowly coming together but I am still fuzzy on a lot of the concepts. Below is a section of code. I am trying to use a button click to create an instance of another class. Specifically-I have my main panel in one class and I wanted to instance a secondary panel when a user clicked on one of the menu items on the main panel. I made all of this work when the secondary panel was just a function. I can't seem to get ti to work as a class. </p>
<p>Here is the code</p>
<pre><code>import wx
class mainPanel(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, 'directEDGAR Supplemental Tools', size=(450, 450))
wx.Panel(self,-1)
wx.StaticText(self,-1, "This is where I will describe\n the purpose of these tools",(100,10))
menubar = wx.MenuBar()
parser = wx.Menu()
one =wx.MenuItem(parser,1,'&Extract Tables with One Heading or Label')
two =wx.MenuItem(parser,1,'&Extract Tables with Two Headings or Labels')
three =wx.MenuItem(parser,1,'&Extract Tables with Three Headings or Labels')
four =wx.MenuItem(parser,1,'&Extract Tables with Four Headings or Labels')
quit = wx.MenuItem(parser, 2, '&Quit\tCtrl+Q')
parser.AppendItem(one)
parser.AppendItem(two)
parser.AppendItem(three)
parser.AppendItem(four)
parser.AppendItem(quit)
menubar.Append(parser, '&Table Parsers')
textRip = wx.Menu()
section =wx.MenuItem(parser,1,'&Extract Text With Section Headings')
textRip.AppendItem(section)
menubar.Append(textRip, '&Text Rippers')
dataHandling = wx.Menu()
deHydrate =wx.MenuItem(dataHandling,1,'&Extract Data from Tables')
dataHandling.AppendItem(deHydrate)
menubar.Append(dataHandling, '&Data Extraction')
self.Bind(wx.EVT_MENU, self.OnQuit, id=2)
</code></pre>
<h1>this is where I think I am being clever by using a button click to create an instance</h1>
<h1>of subPanel.</h1>
<pre><code> self.Bind(wx.EVT_MENU, self.subPanel(None, -1, 'TEST'),id=1)
self.SetMenuBar(menubar)
self.Centre()
self.Show(True)
def OnQuit(self, event):
self.Close()
class subPanel(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, 'directEDGAR Supplemental Tools', size=(450, 450))
wx.Panel(self,-1)
wx.StaticText(self,-1, "This is where I will describe\n the purpose of these tools",(100,10))
getDirectory = wx.Button(panel, -1, "Get Directory Path", pos=(20,350))
getDirectory.SetDefault()
getTerm1 = wx.Button(panel, -1, "Get Search Term", pos=(20,400))
getTerm1.SetDefault()
#getDirectory.Bind(wx.EVT_BUTTON, getDirectory.OnClick, getDirectory.button)
self.Centre()
self.Show(True)
app = wx.App()
mainPanel(None, -1, '')
app.MainLoop()
</code></pre>
| [
{
"answer_id": 274004,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 1,
"selected": false,
"text": "self.Bind(wx.EVT_MENU, self.subPanel(None, -1, 'TEST'),id=1)\n"
},
{
"answer_id": 274145,
"author": "Ryan G... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30105/"
] |
273,941 | <p>I am trying to write a function that will pull the name of a property and the type using syntax like below:</p>
<pre><code>private class SomeClass
{
Public string Col1;
}
PropertyMapper<Somewhere> propertyMapper = new PropertyMapper<Somewhere>();
propertyMapper.MapProperty(x => x.Col1)
</code></pre>
<p>Is there any way to pass the property through to the function without any major changes to this syntax?</p>
<p>I would like to get the property name and the property type.</p>
<p>So in the example below i would want to retrieve </p>
<p><code>Name = "Col1"</code> and <code>Type = "System.String"</code></p>
<p>Can anyone help?</p>
| [
{
"answer_id": 273971,
"author": "Jacob Carpenter",
"author_id": 26627,
"author_profile": "https://Stackoverflow.com/users/26627",
"pm_score": 7,
"selected": true,
"text": "public static MemberInfo GetMemberInfo<T, U>(Expression<Func<T, U>> expression)\n{\n var member = expression.Bod... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1213936/"
] |
273,943 | <p>Presuming I have a class named <code>A</code>, and I want to use the decorator design pattern. Correct me if I'm wrong, but for that to work , we'll need to create a decorator class, say <code>ADecorator</code>, which will hold a reference to an <code>A</code> instance, and all the other decorators will extend this to add functionality.</p>
<p>I don't understand why do we have to create a decorator class, instead of using an <code>A</code> instance?</p>
| [
{
"answer_id": 274234,
"author": "Vincent Ramdhanie",
"author_id": 27439,
"author_profile": "https://Stackoverflow.com/users/27439",
"pm_score": 6,
"selected": true,
"text": "public double cost(){\n return 3.45;\n}\n"
}
] | 2008/11/07 | [
"https://Stackoverflow.com/questions/273943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31610/"
] |
273,946 | <p>Is there an obvious way to do this that I'm missing? I'm just trying to make thumbnails.</p>
| [
{
"answer_id": 273962,
"author": "gnud",
"author_id": 27204,
"author_profile": "https://Stackoverflow.com/users/27204",
"pm_score": 10,
"selected": true,
"text": "min(maxwidth/width, maxheight/height)"
},
{
"answer_id": 364789,
"author": "Community",
"author_id": -1,
... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3912/"
] |
273,949 | <p>For some reason I'm not getting this. (Example model below) If I write: </p>
<pre><code>var property = typeof(sedan).GetProperty("TurningRadius");
Attribute.GetCustomAttributes(property,typeof(MyAttribute), false)
</code></pre>
<p>the call will return MyAttribute(2) despite indicating I don't want to search the inheritance chain. Does anyone know what code I can write so that calling</p>
<pre><code>MagicAttributeSearcher(typeof(Sedan).GetProperty("TurningRadius"))
</code></pre>
<p>returns nothing while calling</p>
<pre><code>MagicAttributeSearcher(typeof(Vehicle).GetProperty("TurningRadius"))
</code></pre>
<p>returns MyAttribute(1)?</p>
<hr>
<p>Example Model:</p>
<pre><code>public class Sedan : Car
{
// ...
}
public class Car : Vehicle
{
[MyAttribute(2)]
public override int TurningRadius { get; set; }
}
public abstract class Vehicle
{
[MyAttribute(1)]
public virtual int TurningRadius { get; set; }
}
</code></pre>
| [
{
"answer_id": 274005,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "using System;\nusing System.Reflection;\n\npublic class MyAttribute : Attribute\n{\n public MyAttribute(int x) {}\n}\... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1946/"
] |
273,964 | <p>I have a CSS rule like this:</p>
<pre><code>a:hover { background-color: #fff; }
</code></pre>
<p>But this results in a bad-looking gap at the bottom on image links, and what's even worse, if I have transparent images, the link's background color can be seen through the image.</p>
<p>I have stumbled upon this problem many times before, but I always solved it using the quick-and-dirty approach of assigning a class to image links:</p>
<pre><code>a.imagelink:hover { background-color: transparent; }
</code></pre>
<p>Today I was looking for a more elegant solution to this problem when I stumbled upon <a href="https://developer.mozilla.org/en/Images%2c_Tables%2c_and_Mysterious_Gaps" rel="noreferrer">this</a>.</p>
<p>Basically what it suggests is using <code>display: block</code>, and this really solves the problem for non-transparent images. However, it results in another problem: now the link is as wide as the paragraph, although the image is not.</p>
<p>Is there a nice way to solve this problem, or do I have to use the dirty approach again?</p>
<p>Thanks,</p>
| [
{
"answer_id": 273973,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 1,
"selected": false,
"text": "a:hover {background-color: #fff;}\nimg:hover { background-color: transparent;}\n"
},
{
"answer_id": 273993,
"aut... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2119/"
] |
273,969 | <p>I'm having a little bit of trouble making a sticky form that will remember what is entered in it on form submission if the value has double quotes. The problem is that the HTML is supposed to read something like:</p>
<pre><code><input type="text" name="something" value="Whatever value you entered" />
</code></pre>
<p>However, if the phrase: "How do I do this?" is typed in with quotes, the resulting HTML is similar to:</p>
<pre><code><input type="text" this?="" do="" i="" how="" value="" name="something"/>
</code></pre>
<p>How would I have to filter the double quotes? I've tried it with magic quotes on and off, I've used stripslashes and addslashes, but so far I haven't come across the right solution. What's the best way to get around this problem for PHP?</p>
| [
{
"answer_id": 273976,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 5,
"selected": true,
"text": "<input type=\"text\" value=\"<?php echo htmlentities($myValue); ?>\">"
},
{
"answer_id": 274002,
"author": "thesma... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13281/"
] |
273,970 | <p>Right now we've got web pages that show UI elements, and web pages that just process form submissions, and then redirect back to the UI pages. They do this using PHP's header() function:</p>
<pre><code>header("Location: /other_page.php");
</code></pre>
<p>This causes a 302 Found response to be sent; according to the HTTP 1.1 spec, 302 is for cases where "The requested resource resides temporarily under a different URI." <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.3" rel="nofollow noreferrer">[HTTP 1.1 spec]</a></p>
<p>Functionally, this is fine, but it doens't seem like this is the proper status code for what we're doing. It looks like 303 ("See Other") is the appropriate status here, so I'm wondering if there's any reason not to use it. We'd have to be more explicit in our use of header(), since we'd have to specify that status line rather than just a Location: field. Thoughts?</p>
| [
{
"answer_id": 273989,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 2,
"selected": false,
"text": "header('Location: /foo.php', true, 303);"
},
{
"answer_id": 274036,
"author": "troelskn",
"author_id": 18180,... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20903/"
] |
273,978 | <p>What makes all the words of a programming language actually do anything? I mean, what's actually happening to make the computer know what all of those words mean? If I verbally tell my my computer to do something, it doesn't do it, because it doesn't understand. So how exactly can these human words written into a language actually cause the computer to do some desirable activity? </p>
| [
{
"answer_id": 273984,
"author": "kasperjj",
"author_id": 34240,
"author_profile": "https://Stackoverflow.com/users/34240",
"pm_score": -1,
"selected": false,
"text": "print(\"Hello World\");\n"
},
{
"answer_id": 273988,
"author": "FlySwat",
"author_id": 1965,
"author... | 2008/11/07 | [
"https://Stackoverflow.com/questions/273978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35661/"
] |
273,995 | <p>How does one prevent an inclusion cycle in C? ie. You shouldn't have a.h #include "b.h", which #include's "c.h" which #include's "a.h". I'm looking for a way of preventing this from happening using some sort of C directive.</p>
<p>I had originally thought this would've prevented this from happening:</p>
<p>Contents of a.h:</p>
<pre><code>#ifndef __A_H
#define __A_H
#include "b.h"
#endif // __A_H
</code></pre>
<p>Contents of b.h:</p>
<pre><code>#ifndef __B_H
#define __B_H
#include "c.h"
#endif // __B_H
</code></pre>
<p>Contents of c.h:</p>
<pre><code>#ifndef __C_H
#define __C_H
#include "a.h"
#endif // __C_H
</code></pre>
<p>But it doesn't seem to work.</p>
| [
{
"answer_id": 274008,
"author": "florin",
"author_id": 18308,
"author_profile": "https://Stackoverflow.com/users/18308",
"pm_score": 4,
"selected": true,
"text": "gcc -E $(CFLAGS) -o foo.i foo.cpp\n"
}
] | 2008/11/07 | [
"https://Stackoverflow.com/questions/273995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19026/"
] |
274,009 | <p>I have a "username" TEdit on a Delphi 2006 login form. When the application starts up the user is asked to enter the username. The TEdit gets focus and the caret is placed in its horizontal center for some reason. As soon as anything is typed the caret is left aligned again and everything looks normal. </p>
<p>It is also strange that it wasn't always like this. This behaviour suddenly started a few years ago (I believe we still used Delphi 6 at that time). Any idea what might be causing this?</p>
<p>Additional info (has been asked for):
<li>The problem is widespread: D2006 and D6 (I believe), 5 or 6 Delphi instances on as much computers, all applications using that login form. The effect is limited to the form however, it does not occur on other TEdits.</li>
<li>The TEdit is not filled with spaces (that would be strange to do in the first place).</li>
<br>
More info (Nov 13):
<li>The caret is not centered exactly, it is <i>almost</i> centered.</li>
<li>Currently it seems to occur in a DLL only. The same login dialog is used in regular executables and does not show the problem there (although I believe it did at some time).</li>
<li>The edit field is a password edit, the OnChange handler sets an integer field of that form only, there are no other event handlers on that edit field.</li>
<li>I added another plain TEdit, which is also the ActiveControl so that it has focus when the form shows (as it was with the password edit). I also removed the default text "Edit1". Now the issue is present in that TEdit in the same way.</li>
<li>The "centered" caret goes back to normal if either a character is entered or if I tab through the controls - when I come back to the TEdit it looks normal. This was the same with the password edit.</li></p>
| [
{
"answer_id": 2103150,
"author": "DamienD",
"author_id": 254839,
"author_profile": "https://Stackoverflow.com/users/254839",
"pm_score": 2,
"selected": false,
"text": " ../..\n Focused := IsActiveControl;\n if Focused and (CurRow = Row) and (CurCol = Col) then\n beg... | 2008/11/07 | [
"https://Stackoverflow.com/questions/274009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35657/"
] |
274,011 | <p>I would like to know if there is software that, given a regex and of course some other constraints like length, produces random text that always matches the given regex.
Thanks</p>
| [
{
"answer_id": 274035,
"author": "HanClinto",
"author_id": 26933,
"author_profile": "https://Stackoverflow.com/users/26933",
"pm_score": 1,
"selected": false,
"text": "def generate_problem(level):\n keep_trying = True\n while(keep_trying):\n regex = gen_regex(level)\n # print 're... | 2008/11/07 | [
"https://Stackoverflow.com/questions/274011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11906/"
] |
274,022 | <p>I very rarely meet any other programmers!</p>
<p>My thought when I first saw the token was "implies that" since that's what it would read it as in a mathematical proof but that clearly isn't its sense.</p>
<p>So how do I say or read "=>" as in:-</p>
<pre><code>IEnumerable<Person> Adults = people.Where(p => p.Age > 16)
</code></pre>
<p>Or is there even an agreed way of saying it?</p>
| [
{
"answer_id": 274025,
"author": "Erik Forbes",
"author_id": 16942,
"author_profile": "https://Stackoverflow.com/users/16942",
"pm_score": 8,
"selected": true,
"text": "x => x * 2;\n"
},
{
"answer_id": 274247,
"author": "Mark Brackett",
"author_id": 2199,
"author_prof... | 2008/11/07 | [
"https://Stackoverflow.com/questions/274022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29411/"
] |
274,024 | <p>I'm increasingly becoming aware that there must be major differences in the ways that regular expressions will be interpreted by browsers.<br />
As an example, a co-worker had written this regular expression, to validate that a file being uploaded would have a PDF extension:</p>
<pre><code>^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.pdf)$
</code></pre>
<p>This works in Internet Explorer, and in Google Chrome, but does NOT work in Firefox. The test always fails, even for an actual PDF. So I decided that the extra stuff was irrelevant and simplified it to:</p>
<pre><code>^.+\.pdf$
</code></pre>
<p>and now it works fine in Firefox, as well as continuing to work in IE and Chrome.<br />
Is this a quirk specific to asp:FileUpload and RegularExpressionValidator controls in ASP.NET, or is it simply due to different browsers supporting regex in different ways? Either way, what are some of the latter that you've encountered?</p>
| [
{
"answer_id": 274052,
"author": "Mauricio",
"author_id": 33913,
"author_profile": "https://Stackoverflow.com/users/33913",
"pm_score": 1,
"selected": false,
"text": "var regex = /^(([a-zA-Z]:)|(\\\\{2}\\w+)\\$?)(\\\\(\\w[\\w].*))(.pdf)$/;"
}
] | 2008/11/07 | [
"https://Stackoverflow.com/questions/274024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12975/"
] |
274,039 | <p>I would like to do this:</p>
<pre><code>[RequiresAuthentication(CompanyType.Client)]
public class FooController
{
public ActionResult OnlyClientUsersCanDoThis()
public ActionResult OnlyClientUsersCanDoThisToo()
[RequiresAuthentication]
public ActionResult AnyTypeOfUserCanDoThis()
</code></pre>
<p>You can see why this won't work. On the third action the controller-level filter will block non-clients. I would like instead to "resolve" conflicting filters. I would like for the more specific filter (action filter) to always win. This seems natural and intuitive.</p>
<p>Once upon a time filterContext exposed MethodInfo for the executing action. That would have made this pretty easy. I considered doing some reflection myself using route info. That won't work because the action it might be overloaded and I cannot tell which one is the current executing one.</p>
<p>The alternative is to scope filters either at the controller level or the action level, but no mix, which will create a lot of extra attribute noise.</p>
| [
{
"answer_id": 2060147,
"author": "Thomas",
"author_id": 250207,
"author_profile": "https://Stackoverflow.com/users/250207",
"pm_score": 0,
"selected": false,
"text": "public override void OnActionExecuting(ActionExecutingContext filterContext) {\n base.OnActionExecuting(filterContext... | 2008/11/07 | [
"https://Stackoverflow.com/questions/274039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29493/"
] |
274,051 | <p>Is keeping JMS connections / sessions / consumer always open a bad practice?</p>
<p>Code draft example:</p>
<pre><code>// app startup code
ConnectionFactory cf = (ConnectionFactory)jndiContext.lookup(CF_JNDI_NAME);
Connection connection = cf.createConnection(user,pass);
Session session = connection.createSession(true,Session.TRANSACTIONAL);
MessageConsumer consumer = session.createConsumer(new Queue(queueName));
consumer.setMessageListener(new MyListener());
connection.start();
connection.setExceptionListener(new MyExceptionHandler()); // handle connection error
// ... Message are processed on MyListener asynchronously ...
// app shutdown code
consumer.close();
session.close();
connection.close();
</code></pre>
<p>Any suggestions to improve this pattern of JMS usage? </p>
| [
{
"answer_id": 40217347,
"author": "eparvan",
"author_id": 5202500,
"author_profile": "https://Stackoverflow.com/users/5202500",
"pm_score": 2,
"selected": false,
"text": "try { \n this.connection.close();\n } catch (JMSException e) {\n //\n }\n"
}
] | 2008/11/07 | [
"https://Stackoverflow.com/questions/274051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35323/"
] |
274,056 | <p>I'm setting up a User Control driven by a XML configuration. It is easier to explain by example. Take a look at the following configuration snippet:</p>
<pre><code><node>
<text lbl="Text:"/>
<checkbox lbl="Check me:" checked="true"/>
</node>
</code></pre>
<p>What I'm trying to achieve to translate that snippet into a single text box and a checkbox control. Of course, had the snippet contained more nodes more controls would be generated automatically.</p>
<p>Give the iterative nature of the task, I have chosen to use Repeater. Within it I have placed two (well more, see bellow) Controls, one CheckBox and one Editbox. In order to choose which control get activate, I used an inline switch command, checking the name of the current configuration node.</p>
<p>Sadly, that doesn't work. The problem lies in the fact that the switch is being run during rendering time, long after data binding had happened. That alone would not be a problem, was not for the fact that a configuration node might offer the needed info to data bind. Consider what would happen if the check box control will try to bind to the text node in the snippet above, desperately looking for it's "checked" attribute.</p>
<p>Any ideas how to make this possible?</p>
<p>Thanks,
Boaz</p>
<p>Here is my current code:</p>
<p>Here is my code (which runs on a more complex syntax than the one above):</p>
<pre><code><asp:Repeater ID="settingRepeater" runat="server">
<ItemTemplate>
<%
switch (((XmlNode)Page.GetDataItem()).LocalName)
{
case "text":
%>
<asp:Label ID="settingsLabel" CssClass="editlabel" Text='<%# XPath("@lbl") %>' runat="server" />
<asp:TextBox ID="settingsLabelText" Text='<%# SettingsNode.SelectSingleNode(XPath("@xpath").ToString()).InnerText %>'
runat="server" AutoPostBack="true" Columns='<%# XmlUtils.OptReadInt((XmlNode)Page.GetDataItem(),"@width",20) %>'
/>
<% break;
case "checkbox":
%>
<asp:CheckBox ID="settingsCheckBox" Text='<%# XPath("@lbl") %>' runat="server"
Checked='<%# ((XmlElement)SettingsNode.SelectSingleNode(XPath("@xpath").ToString())).HasAttribute(XPath("@att").ToString()) %>'
/>
<% break;
} %>
&nbsp;&nbsp;
</ItemTemplate>
</asp:Repeater>
</code></pre>
| [
{
"answer_id": 274249,
"author": "Keltex",
"author_id": 28260,
"author_profile": "https://Stackoverflow.com/users/28260",
"pm_score": 1,
"selected": false,
"text": "<ItemTemplate>\n <%# GetContent(Page.GetDataItem()) %>\n</ItemTemplate>\n"
},
{
"answer_id": 276591,
"author... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2892/"
] |
274,066 | <p>I have a large existing c++ codebase. Typically the users of the codebase edit the source with gvim, but we'd like to start using the nifty IDE features in Eclipse. The codebase has an extensive directory hierarchy, but the source files use include directives without paths due to some voodoo we use in our build process. When I link the source to my project in Eclipse, the indexer complains that it can't find any header files (because we don't specify paths in our includes.) If I manually add the directories from the workspace to the include path then everything works wonderfully, but obviously adding hundreds of directories manually isn't feasible. Would there be a simple method to tell Eclipse to look anywhere in the project for the include files without having to add them one by one? If not, then can anyone suggest a good starting place, like what classes to extend, for writing a plugin to just scan the project at creation/modification and programatically add all directories to the include path?</p>
| [
{
"answer_id": 274194,
"author": "luke",
"author_id": 25920,
"author_profile": "https://Stackoverflow.com/users/25920",
"pm_score": 3,
"selected": false,
"text": "<option id=\"gnu.c.compiler.option.include.paths....>\n<listoptionValue builtIn=\"false\" value=\""${workspace_loc:/some... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/152/"
] |
274,149 | <p>Is it possible in CSS using a property inside an @page to say that table headers (th) should be repeated on every page if the table spreads over multiple pages?</p>
| [
{
"answer_id": 274186,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 6,
"selected": false,
"text": "thead"
},
{
"answer_id": 2633761,
"author": "Eero",
"author_id": 4505,
"author_profile": "https://Stackove... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5295/"
] |
274,157 | <p>Wordpress provides a function called "the_permalink()" that returns, you guessed it!, the permalink to a given post while in a loop of posts.</p>
<p>I am trying to URL encode that permalink and when I execute this code:</p>
<pre><code><?php
print(the_permalink());
$permalink = the_permalink();
print($permalink);
print(urlencode(the_permalink()));
print(urlencode($permalink));
$url = 'http://wpmu.local/graphjam/2008/11/06/test4/';
print($url);
print(urlencode($url));
?>
</code></pre>
<p>it produces these results in HTML:</p>
<pre><code>http://wpmu.local/graphjam/2008/11/06/test4/
http://wpmu.local/graphjam/2008/11/06/test4/
http://wpmu.local/graphjam/2008/11/06/test4/
http://wpmu.local/graphjam/2008/11/06/test4/
http%3A%2F%2Fwpmu.local%2Fgraphjam%2F2008%2F11%2F06%2Ftest4%2F
</code></pre>
<p>I would expect lines 2, 3 and 5 of the output to be URL encoded, but only line 5 is so. Thoughts?</p>
| [
{
"answer_id": 274163,
"author": "Jonathan Lonowski",
"author_id": 15031,
"author_profile": "https://Stackoverflow.com/users/15031",
"pm_score": 4,
"selected": false,
"text": "the_permalink"
},
{
"answer_id": 274304,
"author": "Matthew Scharley",
"author_id": 15537,
"... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33754/"
] |
274,158 | <p>I have a very painful library which, at the moment, is accepting a C# string as a way to get arrays of data; apparently, this makes marshalling for pinvokes easier. </p>
<p>So how do I make a ushort array into a string by bytes? I've tried:</p>
<pre><code>int i;
String theOutData = "";
ushort[] theImageData = inImageData.DataArray;
//this is as slow like molasses in January
for (i = 0; i < theImageData.Length; i++) {
byte[] theBytes = System.BitConverter.GetBytes(theImageData[i]);
theOutData += String.Format("{0:d}{1:d}", theBytes[0], theBytes[1]);
}
</code></pre>
<p>I can do it this way, but it doesn't finish in anything remotely close to a sane amount of time.</p>
<p>What should I do here? Go unsafe? Go through some kind of IntPtr intermediate?</p>
<p>If it were a char* in C++, this would be significantly easier...</p>
<p>edit: the function call is</p>
<pre><code>DataElement.SetByteValue(string inArray, VL Length);
</code></pre>
<p>where VL is a 'Value Length', a DICOM type, and the function itself is generated as a wrapper to a C++ library by SWIG. It seems that the representation chosen is string, because that can cross managed/unmanaged boundaries relatively easily, but throughout the C++ code in the project (this is GDCM), the char* is simply used as a byte buffer. So, when you want to set your image buffer pointer, in C++ it's fairly simple, but in C#, I'm stuck with this weird problem.</p>
<p>This is hackeration, and I know that probably the best thing is to make the SWIG library work right. I really don't know how to do that, and would rather a quick workaround on the C# side, if such exists.</p>
| [
{
"answer_id": 274207,
"author": "Barry Kelly",
"author_id": 3712,
"author_profile": "https://Stackoverflow.com/users/3712",
"pm_score": 4,
"selected": true,
"text": "ushort[] data = new ushort[10];\nfor (int i = 0; i < data.Length; ++i)\n data[i] = (char) ('A' + i);\n\nstring asStrin... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21981/"
] |
274,162 | <p>Is there a specific reason why I should be using the <code>Html.CheckBox</code>, <code>Html.TextBox</code>, etc methods instead of just manually writing the HTML?</p>
<pre><code><%= Html.TextBox("uri") %>
</code></pre>
<p>renders the following HTML</p>
<pre><code><input type="text" value="" name="uri" id="uri"/>
</code></pre>
<p>It guess it saves you a few key strokes but other than that. Is there a specific reason why I should go out of my way to use the HtmlHelpers whenever possible or is it just a preference thing?</p>
| [
{
"answer_id": 274272,
"author": "user17060",
"author_id": 17060,
"author_profile": "https://Stackoverflow.com/users/17060",
"pm_score": 3,
"selected": false,
"text": "ViewData[\"FirstName\"] = \"Joe Bloggs\"; \n\n<%=Html.TextBox(\"FirstName\") %>\n"
},
{
"answer_id": 274273,
... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] |
274,172 | <p>VB.Net2005</p>
<p>Simplified Code:</p>
<pre><code> MustInherit Class InnerBase(Of Inheritor)
End Class
MustInherit Class OuterBase(Of Inheritor)
Class Inner
Inherits InnerBase(Of Inner)
End Class
End Class
Class ChildClass
Inherits OuterBase(Of ChildClass)
End Class
Class ChildClassTwo
Inherits OuterBase(Of ChildClassTwo)
End Class
MustInherit Class CollectionClass(Of _
Inheritor As CollectionClass(Of Inheritor, Member), _
Member As OuterBase(Of Member))
Dim fails As Member.Inner ' Type parameter cannot be used as qualifier
Dim works As New ChildClass.Inner
Dim failsAsExpected As ChildClassTwo.Inner = works ' type conversion failure
End Class
</code></pre>
<p>The error message on the "fails" line is in the subject, and "Member.Inner" is highlighted. Incidentally, the same error occurs with trying to call a shared method of OuterBase.</p>
<p>The "works" line works, but there are a dozen (and counting) ChildClass classes in real life.</p>
<p>The "failsAsExpected" line is there to show that, with generics, each ChildClass has its own distinct Inner class.</p>
<p>My question: is there a way to get a variable, in class CollectionClass, defined as type Member.Inner? what's the critical difference that the compiler can't follow?</p>
<p>(I was eventually able to generate an object by creating a dummy object of type param and calling a method defined in OuterBase. Not the cleanest approach.)</p>
<p>Edit 2008/12/2 altered code to make the two "base" classes generic.</p>
| [
{
"answer_id": 274272,
"author": "user17060",
"author_id": 17060,
"author_profile": "https://Stackoverflow.com/users/17060",
"pm_score": 3,
"selected": false,
"text": "ViewData[\"FirstName\"] = \"Joe Bloggs\"; \n\n<%=Html.TextBox(\"FirstName\") %>\n"
},
{
"answer_id": 274273,
... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
274,179 | <p>I have followed the instructions to setup rxtx on windows from <a href="http://www.jcontrol.org/download/readme_rxtx_en.html" rel="nofollow noreferrer">http://www.jcontrol.org/download/readme_rxtx_en.html</a>.</p>
<p>What I did exactly was copy rxtxSerial.dll to "C:\Program Files\Java\jdk1.6.0_07\jre\bin"
and copied RXTXcomm.jar to "C:\Program Files\Java\jdk1.6.0_07\jre\lib\ext"
(my JAVA_HOME variable is set to C:\Program Files\Java\jdk1.6.0_07\jre)</p>
<p>I also added RXTXcomm.jar to my eclipse project.</p>
<p>But when I run it, it still says "NoSuchPortException"</p>
<pre>
Devel Library
=========================================
Native lib Version = RXTX-2.0-7pre1
Java lib Version = RXTX-2.0-7pre1
java.lang.ClassCastException: gnu.io.RXTXCommDriver cannot be cast to gnu.io.CommDriver thrown while loading gnu.io.RXTXCommDriver
gnu.io.NoSuchPortException
at gnu.io.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:218)
at TwoWaySerialComm.connect(TwoWaySerialComm.java:20)
at TwoWaySerialComm.main(TwoWaySerialComm.java:107)
</pre>
<p>In my java file, I tell it:</p>
<pre>
try
{
(new TwoWaySerialComm()).connect("COM4");
}
</pre>
<p>and I've also tried the Java Comm API. Both cannot recognize my serial port but I am sure I followed the instruction correctly. There files are there.</p>
<p>Does anybody have any idea what it could be?</p>
| [
{
"answer_id": 274257,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 1,
"selected": false,
"text": "rxtxSerial.dll"
},
{
"answer_id": 274464,
"author": "Lawrence Dol",
"author_id": 8946,
"author_profil... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28462/"
] |
274,185 | <p>Let's say there's a.gz, and b.gz.</p>
<p>$ gzip_merge a.gz b.gz -output c.gz</p>
<p>I'd like to have this program. Of course,</p>
<p>$ cat a.gz b.gz > c.gz</p>
<p>doesn't work. Because the final DEFLATE block of a.gz has BFINAL, and the GZIP header of b.gz. (Refer to RFC1951, RFC1952) But if you unset BFINAL, throw away the second GZIP header and walk through the byte boundaries of the second gzip file, you can merge it.</p>
<p>In fact, I thought of writing an open source program for this matter, but didn't know how to publish it. So I asked the Joel to be my program manager, and I walked him through my explanation and defense, he finally understood what I wanted to do, but said he was too busy. :(</p>
<p>Of course, I could write one myself and try my way to publish it. But I can't do this alone because my day work belongs to the property of my employer.</p>
<p>Is there any volunteers? We could work as programmer(me), publisher(you) or programmer(you), publisher(me). All I need is some credit. I once implemented a Universal Decompressor Virtual Machine described in RFC3320. So I know this is feasible. </p>
<p>OR, you could point me to THAT program. It would be very useful for managing log files like merging 365 (day) gzipped log files to one. ;)</p>
<p>Thanks.</p>
| [
{
"answer_id": 274190,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 6,
"selected": true,
"text": " Multiple compressed files can be concatenated. In this case, gunzip\n will extract all members at once. For exa... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24349/"
] |
274,196 | <p>I've got a large number of integer arrays. Each one has a few thousand integers in it, and each integer is generally the same as the one before it or is different by only a single bit or two. I'd like to shrink each array down as small as possible to reduce my disk IO. </p>
<p>Zlib shrinks it to about 25% of its original size. That's nice, but I don't think its algorithm is particularly well suited for the problem. Does anyone know a compression library or simple algorithm that might perform better for this type of information?</p>
<p>Update: zlib after converting it to an array of xor deltas shrinks it to about 20% of the original size. </p>
| [
{
"answer_id": 274278,
"author": "Jay Kominek",
"author_id": 32878,
"author_profile": "https://Stackoverflow.com/users/32878",
"pm_score": 4,
"selected": true,
"text": "1101\n1101\n1110\n1110\n0110\n"
}
] | 2008/11/08 | [
"https://Stackoverflow.com/questions/274196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23524/"
] |
274,213 | <p>All paint programs, independent of how simple or complex they are, come with a fill tool. This basically replaces the color of a closed region with another color. I know that there are different APIs to do this, but I am interested in the algorithm. What would be an efficient algorithm to implement this tool?</p>
<p>A couple of things I can think of quickly are:</p>
<ol>
<li>Convert image into a binary map, where pixels in the color to be replaced are <code>1</code> and all other colors are <code>0</code>.</li>
<li>Find a closed region around the point you want to change such that all the pixels inside are 1 and all the neighbouring pixels are 0.</li>
</ol>
<p><a href="http://img206.imageshack.us/my.php?image=toolfillsv5.jpg" rel="nofollow noreferrer">Sample Image</a></p>
| [
{
"answer_id": 274227,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "Vis[]"
},
{
"answer_id": 274353,
"author": "Cybis",
"author_id": 32998,
"author_profile": "https://Stackov... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33885/"
] |
274,265 | <p>I can't for the life of me find a way to make this work.</p>
<p>If I have 3 divs (a left sidebar, a main body, and a footer), how can I have the sidebar and main body sit next to each other without setting their positions as "absolute" or floating them? Doing either of these options result in the footer div not being pushed down by one or the other.</p>
<p>How might I accomplish this regardless of what comes before these elements (say another header div or something)?</p>
<p>In case it helps, here's an illustration of the two cases I'm trying to allow for:</p>
<p><img src="https://i.stack.imgur.com/zjEzC.jpg" alt="alt text"></p>
<p>Here's a simplified version of the HTML I currently have set up:</p>
<pre><code><div id="sidebar"></div>
<div id="content"></div>
<div id="footer"></div>
</code></pre>
| [
{
"answer_id": 274269,
"author": "Vincent Ramdhanie",
"author_id": 27439,
"author_profile": "https://Stackoverflow.com/users/27439",
"pm_score": 5,
"selected": true,
"text": "#footer{\n clear: both;\n}\n"
}
] | 2008/11/08 | [
"https://Stackoverflow.com/questions/274265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] |
274,286 | <p>I have a new VPS server, and I'm trying to get it to connect to another server at the same ISP. When I connect via mysql's command line tool, the connection is very fast.</p>
<p>When I use PHP to connect to the remote DB, the connection time may take up to 5 seconds. Queries after this are executed quickly.</p>
<p>This is not limited to mysql, using file_get_contents() to download a file from nearly any other server gives the same lag. Using wget to get the file does not have this lag.</p>
<p>I timed DNS queries from within PHP using dns_get_record(), and these are fast (1-2 milliseconds).</p>
<p>Any thoughts on what in the php config may be causing this? </p>
<p>Thanks.</p>
| [
{
"answer_id": 275204,
"author": "Jay",
"author_id": 31479,
"author_profile": "https://Stackoverflow.com/users/31479",
"pm_score": 2,
"selected": true,
"text": "gethostbyname('example.com')\n"
}
] | 2008/11/08 | [
"https://Stackoverflow.com/questions/274286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31479/"
] |
274,296 | <p>Does anyone know of an already implemented money type for the .NET framework that supports i18n (currencies, formatting, etc)? I have been looking for a well implemented type and can't seem to find one.</p>
| [
{
"answer_id": 274316,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 3,
"selected": false,
"text": "CultureInfo current = CultureInfo.CurrentCulture;\ndecimal myMoney = 99.99m;\n\n//formats as money in current cultu... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2220/"
] |
274,307 | <p>Just as an example, if I have a <code>Book</code> model and a <code>BooksController</code>, autotest, part of the ZenTest suite will pick up the association between the two and load <code>test/unit/book_test.rb</code> and <code>test/functional/books_controller_test.rb</code> into the test suite. On the other hand, if I have a <code>Story</code> model and a <code>StoriesController</code>, autotest refuse to "notice" the <code>test/functional/stories_controller_test.rb</code></p>
| [
{
"answer_id": 274316,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 3,
"selected": false,
"text": "CultureInfo current = CultureInfo.CurrentCulture;\ndecimal myMoney = 99.99m;\n\n//formats as money in current cultu... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31891/"
] |
274,308 | <p>Is which IPs are assigned to which ISPs public information? How do geo IP services obtain this information and maintain this information?</p>
<p>How can I personally figure out where a certain IP belongs without using one of these services?</p>
| [
{
"answer_id": 277537,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 7,
"selected": true,
"text": "whois"
}
] | 2008/11/08 | [
"https://Stackoverflow.com/questions/274308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] |
274,309 | <p>Is there any benefit on Windows to use the WSA winsock functions compared to the BSD-style ones?</p>
| [
{
"answer_id": 276688,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 3,
"selected": true,
"text": "read"
}
] | 2008/11/08 | [
"https://Stackoverflow.com/questions/274309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] |
274,315 | <p>I'm writing a C# app using the WebBrowser control, and I want all content I display to come from embedded resources - not static local files, and not remote files.</p>
<p>Setting the initial text of the control to an embedded HTML file works great with this code inspired by <a href="http://blog.topholt.com/2008/03/18/c-trick-load-embedded-resources-in-a-class-library/" rel="nofollow noreferrer">this post</a>:</p>
<pre><code>browser.DocumentText=loadResourceText("myapp.index.html");
private string loadResourceText(string name)
{
Assembly assembly = Assembly.GetExecutingAssembly();
Stream stream = assembly.GetManifestResourceStream(name);
StreamReader streamReader = new StreamReader(stream);
String myText = streamReader.ReadToEnd();
return myText;
}
</code></pre>
<p>As good as that is, files referred to in the HTML - javascript, images like <code><img src="whatever.png"/></code> etc, don't work. I found similar questions <a href="https://stackoverflow.com/questions/72103/how-do-i-reference-a-local-resource-in-generated-html-in-winforms-webbrowser-co#273840">here</a> and <a href="https://stackoverflow.com/questions/153748/webbrowser-control-from-net-how-to-inject-javascript">here</a>, but neither is asking <em>exactly</em> what I mean, namely referring to <em>embedded</em> resources in the exe, not files. </p>
<p>I tried <code>res://...</code> and using a <code><base href='..."</code> but neither seemed to work (though I may have not got it right).</p>
<p>Perhaps (following my own suggestion on <a href="https://stackoverflow.com/questions/72103/how-do-i-reference-a-local-resource-in-generated-html-in-winforms-webbrowser-co#273840">this question</a>), using a little embedded C# webserver is the only way... but I would have thought there is some trick to get this going?</p>
<p>Thanks!</p>
| [
{
"answer_id": 274530,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "WebBrowser"
},
{
"answer_id": 1471460,
"author": "Community",
"author_id": -1,
"author_profile": ... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25362/"
] |
274,319 | <p>I know that I need to tell my UITextField to resign first responder when I want to dismis the keyboard, but I'm not sure how to know when the user has pressed the "Done" key on the keyboard. Is there a notification I can watch for?</p>
| [
{
"answer_id": 274325,
"author": "Jason Coco",
"author_id": 34218,
"author_profile": "https://Stackoverflow.com/users/34218",
"pm_score": 6,
"selected": false,
"text": "-(IBAction)userDoneEnteringText:(id)sender\n{\n UITextField theField = (UITextField*)sender;\n // do whatever you... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28422/"
] |
274,344 | <p>When you lock an object is that object locked throughout the whole application?</p>
<p>For Example, this snippet from C# 3.0 in a Nutshell Section 19.6.1 "Thread Safety and .NET Framework Types":</p>
<pre><code>static void AddItems( )
{
for (int i = 0; i < 100; i++)
lock (list)
list.Add ("Item " + list.Count);
string[] items;
lock (list) items = list.ToArray( );
foreach (string s in items) Console.WriteLine (s);
}
</code></pre>
<p>Does the first lock:</p>
<pre><code>lock (list)
list.Add ("Item " + list.Count);
</code></pre>
<p>prevent another thread from accessing:</p>
<pre><code>lock (list) items = list.ToArray( );
</code></pre>
<p>or can both be executed at the same time?</p>
<p>And does the CLR automatically make your static methods thread safe? Or is that up to the developer?</p>
<p>Thanks,
John</p>
| [
{
"answer_id": 274357,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 3,
"selected": true,
"text": "class UsefulStuff {\n object _TheLock = new object { };\n public void UsefulThingNumberOne() {\n lock(_TheLo... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19490/"
] |
274,348 | <p>In my small WPF project, I have a <code>TabControl</code> with three tabs. On each tab is a <code>ListBox</code>. This project keeps track of groceries we need to buy. (No, it's not homework, it's for my wife.) So I have a list of <code>ShoppingListItem</code>s, each of which has a <code>Name</code> and a <code>Needed</code> property: <code>true</code> when we need the item, and <code>false</code> after we buy it.</p>
<p>So the three tabs are All, Bought, and Needed. They should all point to the same <code>ShoppingListItemCollection</code> (which inherits from <code>ObservableCollection<ShoppingListItem></code>). But Bought should only show the items where Needed is false, and Needed should only show items where Needed is true. (The All tab has checkboxes on the items.)</p>
<p>This doesn't seem <em>that</em> hard, but after a couple hours, I'm no closer to figuring this out. It seems like a CollectionView or CollectionViewSource is what I need, but I can't get anything to happen; I check and uncheck the boxes on the All tab, and the items on the other two tabs just sit there staring at me.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 274458,
"author": "Todd White",
"author_id": 30833,
"author_profile": "https://Stackoverflow.com/users/30833",
"pm_score": 2,
"selected": false,
"text": "<Window.Resources>\n <CollectionViewSource x:Key=\"NeededItems\" Source=\"{Binding Items}\" Filter=\"NeededCollectio... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5486/"
] |
274,349 | <p>As title. </p>
<p>ruby test/functionals/whatevertest.rb doesn't work, that requires me to replace all <code>require 'test_helper'</code> to <code>require File.dirname(__FILE__) + '/../test_helper'</code>. For some reason most of those test templates have such issue, so I rather to see if there is a hack I could get around it.</p>
| [
{
"answer_id": 274507,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": true,
"text": "(cd test && ruby functionals/whatevertest.rb)"
},
{
"answer_id": 3577710,
"author": "Szymon Jeż",
"autho... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16371/"
] |
274,360 | <p>Given a class instance, is it possible to determine if it implements a particular interface? As far as I know, there isn't a built-in function to do this directly. What options do I have (if any)?</p>
| [
{
"answer_id": 274363,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 9,
"selected": true,
"text": "interface IInterface\n{\n}\n\nclass TheClass implements IInterface\n{\n}\n\n$cls = new TheClass();\nif ($cls instanceof IInterf... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] |
274,361 | <p>ok so my issue is i have the string '\222\222\223\225' which is stored as latin-1 in the db. What I get from django (by printing it) is the following string, 'ââââ¢' which I assume is the UTF conversion of it. Now I need to pass the string into a function that
does this operation: </p>
<pre><code>strdecryptedPassword + chr(ord(c) - 3 - intCounter - 30)
</code></pre>
<p>I get this error: </p>
<blockquote>
<p>chr() arg not in range(256)</p>
</blockquote>
<p>If I try to encode the string as latin-1 first I get this error:</p>
<blockquote>
<p>'latin-1' codec can't encode characters in position 0-3: ordinal not
in range(256)</p>
</blockquote>
<p>I have read a bunch on how character encoding works, and there is something I am missing because I just don't get it!</p>
| [
{
"answer_id": 274403,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 3,
"selected": true,
"text": ">>> a = '\\222\\222\\223\\225'\n>>> u = unicode(a,'latin-1')\n>>> u\nu'\\x92\\x92\\x93\\x95'\n>>> print u.encode('utf... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35697/"
] |
274,375 | <p>I want to setup a statistics monitoring platform to watch a specific service, but I'm not quiet sure how to go about it. Processing the intercepted data isn't my concern, just how to go about it. One idea was to setup a proxy between the client application and the service so that all TCP traffic went first to my proxy, the proxy would then delegate the intercepted messages to an awaiting thread/fork to pass the message on and recieve the results. The other was to try and sniff the traffic between client & service.</p>
<p>My primary goal is to avoid any serious loss in transmission speed between client & application but get 100% complete communications between client & service.</p>
<p>Environment: UBuntu 8.04</p>
<p>Language: c/c++</p>
<p>In the background I was thinking of using a sqlite DB running completely in memory or a 20-25MB memcache dameon slaved to my process.</p>
<p>Update:
Specifically I am trying to track the usage of keys for a memcache daemon, storing the # of sets/gets success/fails on the key. The idea is that most keys have some sort of separating character [`|_-#] to create a sort of namespace. The idea is to step in between the daemon and the client, split the keys apart by a configured separator and record statistics on them. </p>
| [
{
"answer_id": 274393,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "https://Stackoverflow.com/users/29157",
"pm_score": 1,
"selected": false,
"text": "iptables"
},
{
"answer_id": 274481,
"author": "derobert",
"author_id": 27727,
"author_profile": "htt... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9908/"
] |
274,384 | <p>Is anyone aware of any gems, tutorials, or solutions enabling a user to sign in to a website at one domain and automatically given access to other partner domains in the same session? </p>
<p>I have two rails apps running, let's call them App-A and App-B. App-A has a database associated with it, powering the registration and login at App-A.com. I'd now like to give all of those users with App-A.com accounts access to App-B.com, without making them reregister or manually login to App-B.com separately.</p>
<p>Thanks in advance for any help!
--Mark</p>
| [
{
"answer_id": 274640,
"author": "Ricardo Acras",
"author_id": 19224,
"author_profile": "https://Stackoverflow.com/users/19224",
"pm_score": 4,
"selected": true,
"text": "Rails::Initializer.run do |config|\n ... \n config.action_controller.session = {\n :session_key => '_portal_sess... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
274,404 | <p>How can I know in a C#-Application, in which direction the screen of the mobile device is orientated? (i.e. horizontal or vertical).</p>
| [
{
"answer_id": 274456,
"author": "Jason Stangroome",
"author_id": 20819,
"author_profile": "https://Stackoverflow.com/users/20819",
"pm_score": 0,
"selected": false,
"text": "var rect = System.Windows.Forms.Screen.PrimaryScreen.Bounds;\n// or var rect = System.Windows.Forms.Screen.Primar... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26070/"
] |
274,408 | <p>I'm trying to create a database scripter tool for a local database I'm using.</p>
<p>I've been able to generate create scripts for the tables, primary keys, indexes, and foreign keys, but I can't find any way to generate create scripts for the table defaults.</p>
<p>For indexes, it's as easy as </p>
<pre><code>foreach (Index index in table.Indexes)
{
ScriptingOptions drop = new ScriptingOptions();
drop.ScriptDrops = true;
drop.IncludeIfNotExists = true;
foreach (string dropstring in index.Script(drop))
{
createScript.Append(dropstring);
}
ScriptingOptions create = new ScriptingOptions();
create.IncludeIfNotExists = true;
foreach (string createstring in index.Script(create))
{
createScript.Append(createstring);
}
}
</code></pre>
<p>But the Table object doesn't have a Defaults property. Is there some other way to generate scripts for the table defaults?</p>
| [
{
"answer_id": 274578,
"author": "Pavel Chuchuva",
"author_id": 14131,
"author_profile": "https://Stackoverflow.com/users/14131",
"pm_score": 3,
"selected": false,
"text": "Server server = new Server(@\".\\SQLEXPRESS\");\nDatabase db = server.Databases[\"AdventureWorks\"];\nList<Urn> lis... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108/"
] |
274,411 | <p>Jeff Atwood wrote about this <a href="https://blog.codinghorror.com/who-needs-stored-procedures-anyways/" rel="noreferrer">here</a>, and while I understand the theoretical performance boost a stored procedure could offer, it does seem like a tremendous pain.</p>
<p>What types of queries would you see the most performance increase using stored procedures, and what types of queries would you rather just build on the fly?</p>
<p>Any documentation one way or another would be greatly appreciated.</p>
| [
{
"answer_id": 275010,
"author": "HTTP 410",
"author_id": 13118,
"author_profile": "https://Stackoverflow.com/users/13118",
"pm_score": 4,
"selected": false,
"text": "-- First, clear the cache\nDBCC FREEPROCCACHE\n\n-- Look at what executable plans are in cache\nSELECT sc.*\nFROM master.... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25538/"
] |
274,439 | <p>How to, in C# round any value to 10 interval? For example, if I have 11, I want it to return 10, if I have 136, then I want it to return 140. </p>
<p>I can easily do it by hand</p>
<pre><code>return ((int)(number / 10)) * 10;
</code></pre>
<p>But I am looking for an builtin algorithm to do this job, something like Math.Round(). The reason why I won't want to do by hand is that I don't want to write same or similar piece of code all over my projects, even for something as simple as the above. </p>
| [
{
"answer_id": 274453,
"author": "Armstrongest",
"author_id": 26931,
"author_profile": "https://Stackoverflow.com/users/26931",
"pm_score": 5,
"selected": false,
"text": "int number = 236;\nnumber = (int)(Math.Ceiling(number / 10.0d) * 10);\n"
},
{
"answer_id": 274487,
"autho... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] |
274,457 | <p>I created a project using the default tab-controller project. I am using interface builder to edit the .xib file and add images and buttons. I hook them up to the FirstViewController object in interface builder (that I created and set it's class to the same as the code file). I hooked everything up using <code>IBoutlets</code> and <code>IBActions</code>. </p>
<p>Everything was working fine, but then I made some changes in interface builder (added a <code>UILabel</code>) and now a method that is run when clicked (I ran through it with the debugger) has a line that adds a subview to the view controller, and it acts as if it wasn't executed. The method (and code is run through) is executed with no errors (per the debugger) but the view is simply not being added. This happened after I made some change via interface builder. </p>
<p>Now, if I hook-up my button to "Selected First View Controller" by clicking on the appropriate tab and dragging the <code>IBOutlet</code> to the <code>UILabel</code>, that label now has multiple referencing outlets. Now, if I do the same thing for the button, the method (the <code>IBAction</code>) is executed twice but the subview is actually added and displayed. But, I get a memory access error because my <code>IBAction</code> (button) method access a property that stores something. I am guessing this has to do with somehow creating the memory in the First View Controller but trying to access it in the Selected First View Controller? If that makes any sense?</p>
<p>I have no idea why this is happening and why it just the button suddenly stopped working. I tried to explain this problem the best I could, it is sort of confusing. But if anyone has any tips or ideas I would love to hear what you guys think about this problem and how to solve it.</p>
| [
{
"answer_id": 274453,
"author": "Armstrongest",
"author_id": 26931,
"author_profile": "https://Stackoverflow.com/users/26931",
"pm_score": 5,
"selected": false,
"text": "int number = 236;\nnumber = (int)(Math.Ceiling(number / 10.0d) * 10);\n"
},
{
"answer_id": 274487,
"autho... | 2008/11/08 | [
"https://Stackoverflow.com/questions/274457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23695/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.