qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
422,951
<p>I'm looking for a way to set up (via SQL) a log table containing everything that had been done to my sqlite database (preferably in terms of the insert, create table etc. statements as issued to the database). I'm sure there are way to do it via setting trigger on each table, but that is just WAY too much work and does not bode well if I change the database's schema later. Is there a catch-all global thing that work on the database (like trigger on database itself)?</p> <p>I'm also open for other suggestions for keeping records of changes done to sqlite database so that I can look back months later on the changes.</p> <p>(Programatically of course there are ways but I can't be sure that my program is the only program writing to the database).</p>
[ { "answer_id": 423332, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "void *sqlite3_update_hook(\n sqlite3*, \n void(*)(void *,int ,char const *,char const *,sqlite3_int64),\n void*\n);\n\nvoid...
2009/01/08
[ "https://Stackoverflow.com/questions/422951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45383/" ]
422,958
<p>There are 4 overloaded signatures for Enumerable.SelectMany. To make it simple, we ignore the two signatures with <em>int</em> argument. So we have 2 signatures for SelectMany:</p> <pre><code>public static IEnumerable&lt;TResult&gt; SelectMany&lt;TSource, TResult&gt;( this IEnumerable&lt;TSource&gt; source, Func&lt;TSource, IEnumerable&lt;TResult&gt;&gt; selector ) public static IEnumerable&lt;TResult&gt; SelectMany&lt;TSource, TCollection, TResult&gt;( this IEnumerable&lt;TSource&gt; source, Func&lt;TSource, IEnumerable&lt;TCollection&gt;&gt; collectionSelector, Func&lt;TSource, TCollection, TResult&gt; resultSelector ) </code></pre> <p>My question is: how C# compiler choose SelectMany when translating LINQ expression to extension method invocation?</p> <p>Basically, if there are multiple <strong>from</strong> in LINQ expression, there will be SelectMany. But, it seems that C# compiler only choose the second signature. The first signature is never used.</p> <pre><code> IEnumerable&lt;int&gt; en1 = Enumerable.Range(1, 3); IEnumerable&lt;double&gt; en2 = new double[] { 1.0, 3.14 }; IEnumerable&lt;string&gt; en3 = from i1 in en1 from i2 in en2 select (i1 * i2).ToString(); foreach (var i in en3) { Console.WriteLine(i); } </code></pre> <p>With the help of Reflector, I can see that above LINQ expression is translated into </p> <pre><code>en1.SelectMany&lt;int, double, string&gt;(delegate (int i1) { return en2; }, delegate (int i1, double i2) { double CS$0$0000 = i1 * i2return CS$0$0000.ToString(); }) </code></pre> <p>Above example involves 3 types. So, it is reasonable to select the second SelectMany signature. However, for below example, only one type is involved, it still selects the second signature.</p> <pre><code> IEnumerable&lt;int&gt; en4 = from i1 in en1 from i2 in Enumerable.Range(0, i1) select i2; </code></pre> <p>It is translated into:</p> <pre><code>en1.SelectMany&lt;int, int, int&gt;(delegate (int i1) { return Enumerable.Range(0, i1); }, delegate (int i1, int i2) { return i2; }) </code></pre> <p>So, I cannot find a case that LINQ expression is translated into the first SelectMany signature. Is there such case?</p> <p>If the first SelectMany signature is not used, then it exists just because it is BIND of monad in functional programming?</p> <p>Perhaps the question can be: why do we have 2 signatures of SelectMany?</p> <p>Thanks.</p>
[ { "answer_id": 423332, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "void *sqlite3_update_hook(\n sqlite3*, \n void(*)(void *,int ,char const *,char const *,sqlite3_int64),\n void*\n);\n\nvoid...
2009/01/08
[ "https://Stackoverflow.com/questions/422958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26349/" ]
422,963
<p>I'm using the following command to remove every ".dummy" directories in a folder named "Test Folder":</p> <pre><code>rm -rf `find "Test Folder" -type d -name .dummy` </code></pre> <p>However, this doesn't work since it expands to, say:</p> <pre><code>rm -rf Test Folder/.dummy </code></pre> <p>Since the whitespace is not escaped, this fails.</p> <p>I also tried something like this:</p> <pre><code>find "Test Folder" -type d -name .dummy -exec rm -rf {} \; </code></pre> <p>It works, but it gives an annoying error like this:</p> <pre><code>find: Test Folder/.dummy: No such file or directory </code></pre> <p>Is there a way to make either solution to succeed?</p>
[ { "answer_id": 422974, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 2, "selected": false, "text": "find \"Test Folder\" -type d -name .dummy -exec rm -rf \\\"{}\\\" \\;\n rm -rf \"{}\" -exec Test Folder/.dummy" }, { ...
2009/01/08
[ "https://Stackoverflow.com/questions/422963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9936/" ]
422,969
<p>I am building stats for my users and dont wish the visits from bots to be counted.</p> <p>Now I have a basic php with mysql increasing 1 each time the page is called.</p> <p>But bots are also added to the count.</p> <p>Does anyone can think of a way?</p> <p>Mainly is just the major ones that mess things up. Google, Yahoo, Msn, etc.</p>
[ { "answer_id": 422987, "author": "Rob", "author_id": 3542, "author_profile": "https://Stackoverflow.com/users/3542", "pm_score": 2, "selected": false, "text": "$_SERVER['HTTP_USER_AGENT'] $_SERVER" }, { "answer_id": 422993, "author": "Rob", "author_id": 41908, "author...
2009/01/08
[ "https://Stackoverflow.com/questions/422969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52730/" ]
422,970
<p>I would like to use java to get the source of a website (secure) and then parse that website for links that are in it. I have found how to connect to that url, but then how can i easily get just the source, preferraby as the DOM Document oso that I could easily get the info I want.</p> <p>Or is there a better way to connect to https site, get the source (which I neet to do to get a table of data...its pretty simple) then those links are files i am going to download.</p> <p>I wish it was FTP but these are files stored on my tivo (i want to programmatically download them to my computer(</p>
[ { "answer_id": 422986, "author": "Peter Hilton", "author_id": 2670, "author_profile": "https://Stackoverflow.com/users/2670", "pm_score": 2, "selected": false, "text": "WebConversation wc = new WebConversation();\nWebResponse resp = wc.getResponse(\"http://stackoverflow.com/questions/422...
2009/01/08
[ "https://Stackoverflow.com/questions/422970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/673/" ]
422,984
<p>Today I was looking at some code atually from Nikhil Kothari's Facebook.NET API. I just wanted to check out how he was doing some things in there for ideas.</p> <p>One of the things I came across was a Property that just seemed really weird to me.</p> <p>check this out:</p> <p>FacebookRequest.cs defines a property and sets it in the constructor to a new instance of a custom Class:</p> <pre><code> public FacebookRequest(FacebookSession session) { .... _parameters = new FacebookRequestParameterList(); } </code></pre> <p>private field:</p> <p>private FacebookRequestParameterList _parameters;</p> <p>and the property:</p> <pre><code> public FacebookRequestParameterList Parameters { get { return _parameters; } } </code></pre> <p>now the FacebookRequestParameterList is actually a Generic Dictionary because it inherits &amp; extends Dictionary:</p> <pre><code>public sealed class FacebookRequestParameterList : Dictionary&lt;string, string&gt; { ... } </code></pre> <p>Ok so essentially when you instantiate FacebookRequest, it therefore automatically comes with an auto-instantiated instance of the FacebookRequestParameterList class. So the Property is essentially returning an instance of FacebookRequestParameterList.</p> <p>Is that normal? I don't think I've seen that a lot. Seems sneaky to me or is this standard stuff here? It just seemed like an odd way to do it. I'm not posting this to bring him down but to understand if this is something standard or sneaky/evil.</p> <p>It seems to me it would be better to require developers to pass in an instance of FacebookRequestParameterList through the constructor of FacebookRequest instead. And then work with that by setting the private field _parameters after you initialize it through the constructor. Why do I think this is better? Because then developers know exactly what's going on. They know that the class expects a parameter list up front. And just exposing an instance like that through a properly to me just seems odd.</p> <p>Am I off base here?</p>
[ { "answer_id": 423010, "author": "Mike Hofer", "author_id": 47580, "author_profile": "https://Stackoverflow.com/users/47580", "pm_score": 3, "selected": true, "text": "FacebookRequestParameterList FacebookRequest _parameters FacebookRequestParameterList null" }, { "answer_id": 42...
2009/01/08
[ "https://Stackoverflow.com/questions/422984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
422,989
<p>I have inherited a project that uses the following pattern for passing parameters from the code behind to the aspx page. I know this is wrong, but I am on the fence on the best way to refactor it.</p> <p>Code Behind:</p> <pre><code>using System; using System.Web; namespace BadPassing { public partial class _Default : System.Web.UI.Page { private Random rnd = new Random(); //Is this bad? protected int numberOne; //this is bad protected int numberTwo; //this is bad protected void Page_Load(object sender, EventArgs e) { numberOne = rnd.Next(100); numberTwo = rnd.Next(100); } } } </code></pre> <p>ASPX Page:</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BadPassing._Default" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head runat="server"&gt; &lt;title&gt;Bad Page&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;a href="http://www.google.com/search?q=&lt;%=this.numberOne %&gt;%2B&lt;%=this.numberTwo %&gt;"&gt; Add &lt;%=this.numberOne %&gt; and &lt;%=this.numberTwo %&gt; using google. &lt;/a&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>My understanding is that the numberOne and numberTwo are not thread-safe, and could cause incorrect behavior if two people loaded the page at the same time. Furthermore, if the page relied on numberOne and numberTwo to store values between postbacks, multiple simultaneous users would cause unexpected results.</p> <p>Is my understanding of why this the above technique is so bad correct, and if so, how would you best refactor this code?</p> <p>On a side note, is it incorrect to store stateless page-level services (like Random) as member variables of the page class?</p>
[ { "answer_id": 423112, "author": "lomaxx", "author_id": 493, "author_profile": "https://Stackoverflow.com/users/493", "pm_score": 0, "selected": false, "text": "namespace BadPassing\n{\n public partial class _Default : System.Web.UI.Page\n {\n private Random rnd = new Random...
2009/01/08
[ "https://Stackoverflow.com/questions/422989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17715/" ]
422,991
<p>Basically, I want to have a std::list but with std::map properties such as find(), do I really need to loop through every single list entry to find what I need? </p>
[ { "answer_id": 423205, "author": "wilhelmtell", "author_id": 456, "author_profile": "https://Stackoverflow.com/users/456", "pm_score": 1, "selected": false, "text": "std::set<T> std::map<T,void> find() std::set<T> std::priority_queue<T,C> C std::vector<T> std::priority_queue<T> make_heap...
2009/01/08
[ "https://Stackoverflow.com/questions/422991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
422,999
<p>I have a fixed-length data file need to persistence into database. I use a XML file to define the length for the fields and use a list of FieldItem class to store the data.</p> <pre><code> class FieldItem { public string ObjectName {get; set;} public string ObjectProperty {get; set;} public string ObjectValue {get; set;} public FieldItem() { } } </code></pre> <p>So the FieldItem will look like</p> <pre><code>var fieldItem = new FieldItem { ObjectName = "Company", ObjectProperty = "Name", ObjectValue = "ABC Corp." } </code></pre> <p>After get the list of FieldItem, I will do refection to create Company and other domain objects to save them into database. </p> <p>But before they are saved into database, I have some business rules needed to be applied to validate the data line. My data line will look like:</p> <pre><code>var fieldItemList = new List&lt;FieldItem&gt;(){ new FieldItem { ObjectName="Company", ObjectProperty = "Name", ObjectValue = "ABC" } new FieldItem{ ObjectName = "Product", ObjectProperty = "ProductCode", ObjectValue ="XYZ0123" new FieldItem{ ObjectName = "Product", ObjectProperty = "ProductName", ObjectValue ="Christmas Tree" } // other FieldItem objects... } </code></pre> <p>For example, my rule is to check if the company == "ABC" and ProductCode == "XYZ0123". Those rules are created by users and stored as a string in the database. What I am doing right now is to use Microsoft's System.Linq.Dynamic to evaluate the rule, such as </p> <pre><code>string validationRule = " (ObjectName == \"Company\" And ObjectProperty=\"CompanyName\" And ObjectValue = \"ABC Corp.\") And (ObjectName == \"Product\" And ObjectProperty=\"ProductCode\" And ObjectValue = \"XYZ0123\") "; var query = fieldItemList.AsQuerable().Where(validationRule); </code></pre> <p>then check if it has one row return to tell if that data row has passed the rule or not. Obviously, it is too verbose. Do you have any better suggestion? What should I do if I only like my rule expression like: "Company.CompanyName = 'ABC Corp.' and Product.ProductCode = 'XYZ001'"?</p>
[ { "answer_id": 423096, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 0, "selected": false, "text": "FieldItem class FieldItem\n{\n public string ObjectName {get; set;}\n public string ObjectProperty {get; set;}\n p...
2009/01/08
[ "https://Stackoverflow.com/questions/422999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31689/" ]
423,006
<p>I am working on a simulation system. I will soon have experimental data (histograms) for the real-world distribution of values for several simulation inputs. </p> <p>When the simulation runs, I would like to be able to produce random values that match the measured distribution. I'd prefer to do this without storing the original histograms. What are some good ways of </p> <ol> <li>Mapping a histogram to a set of parameters representing the distribution? </li> <li>Generating values that based on those parameters at runtime?</li> </ol> <p>EDIT: The input data are event durations for several different types of events. I expect that different types will have different distribution functions.</p>
[ { "answer_id": 423037, "author": "dmckee --- ex-moderator kitten", "author_id": 2509, "author_profile": "https://Stackoverflow.com/users/2509", "pm_score": 5, "selected": true, "text": "[0-1) x" }, { "answer_id": 425293, "author": "AShelly", "author_id": 10396, "autho...
2009/01/08
[ "https://Stackoverflow.com/questions/423006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10396/" ]
423,007
<p>I'm really new to ASP.Net Mvc, but not new to Asp.Net. I was aware of all of the HtmlHelper class, but I was having problems with ecoding issues using Html.ActionLink. I asked a question <a href="https://stackoverflow.com/questions/422929/how-do-i-bypass-the-html-encoding-when-using-html-actionlink-in-mvc">here</a> and got an answer right away about using the UrlHelper class, which I had no idea even existed.</p> <p>My question is, are there other classes like this that I should be aware of? </p>
[ { "answer_id": 423037, "author": "dmckee --- ex-moderator kitten", "author_id": 2509, "author_profile": "https://Stackoverflow.com/users/2509", "pm_score": 5, "selected": true, "text": "[0-1) x" }, { "answer_id": 425293, "author": "AShelly", "author_id": 10396, "autho...
2009/01/08
[ "https://Stackoverflow.com/questions/423007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
423,032
<p>I know that an interface must be public. However, I don't want that.</p> <p>I want my implemented methods to only be accessible from their own package, so I want my implemented methods to be protected.</p> <p>The problem is I can't make the interface or the implemented methods protected. </p> <p>What is a work around? Is there a design pattern that pertains to this problem?</p> <p>From the Java guide, an abstract class wouldn't do the job either.</p>
[ { "answer_id": 423046, "author": "kdgregory", "author_id": 42126, "author_profile": "https://Stackoverflow.com/users/42126", "pm_score": 4, "selected": false, "text": "class Foo implements Runnable \n{\n public void run()\n {\n }\n}\n" }, { "answer_id": 423047, "auth...
2009/01/08
[ "https://Stackoverflow.com/questions/423032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38663/" ]
423,035
<p>I have an application for Windows XP. This application is deployed with the hardware. The application is the only application that ever runs on these machines. These machines are never connected to the internet. I'm interested in instant-on (or quick-on) options that bypass the Windows XP startup for these machines.</p> <p>This is similar to Windows XP "hibernation", but not exactly. With hibernation, the memory state is only read from disk once - the very next time the system is turned on. I want a memory state permanently stored to disk, so the system always starts from that same spot every time, regardless of how it was shut down. How can I achieve this?</p>
[ { "answer_id": 424290, "author": "George Stocker", "author_id": 16587, "author_profile": "https://Stackoverflow.com/users/16587", "pm_score": 0, "selected": false, "text": "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\n" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/423035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25640/" ]
423,062
<p>I want to let the user adjust the Mic volume. Rather than reinventing the wheel, we (in XP) would just launch the Volume control panel (by running sndvol32.exe). </p> <p>You can bring up the <em>Speaker</em> Volume control in Win <strong>Vista</strong> by shelling out to : SndVol.exe</p> <p><em>In XP you could specify a command line parameter -R to show Microphone volume.</em></p> <p>Anyone know what the command line parameter is for SndVol.exe to show Mic volume for <strong>Windows Vista</strong>?</p> <p>Or some other way to display the Mic volume control panel?</p>
[ { "answer_id": 423090, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 2, "selected": false, "text": "sndvol32 -record\n" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/423062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4906/" ]
423,070
<p>Let us say that I have a Flex 3 mxml component, call it A. A has a get/set attribute called 'b'. Within A I have another internal component C, which is specified using mxml. When "instantiating" component A within mxml, I can specify the value of b at declaration, and everything works fine. However, when I initialize the component using Actionscript, I must first add the component to a rendered container before I can set the attribute (in this case 'b') of said component. This happens when the setter for attribute 'b' somehow accesses C within A.</p> <p>So, this fails at runtime (it says that C is null)...</p> <pre><code>var a:A = new A(); a.b = "woopy"; //Sets the Label (declared in mxml) withn A to "woopy" this.addChild(a); </code></pre> <p>On the other hand, either of the following will work</p> <pre><code>&lt;customNamespace:A b="woopy"/&gt; </code></pre> <p>or</p> <pre><code>var a:A = new A(); this.addChild(a); a.b = "woopy"; //Sets the Label (declared in mxml) withn A to "woopy" </code></pre> <p>As shown, no runtime error message is thrown when a attribute is set after a component is added to a container. Ok, this makes sense, I suppose the internals of the component are not actually created until the component is added to a container. Still, this is kind of annoying. Is there any way to guarantee that the component internals are fully rendered without adding it to a container? I don't like the way it feels different when I am using actionscript vs mxml. I want a solution so that basically declaring A in mxml with no attribute "arguments" is equivalent to declaring A using the new operator in AS. At least, in terms of the internal state of A.</p>
[ { "answer_id": 423990, "author": "inferis", "author_id": 51998, "author_profile": "https://Stackoverflow.com/users/51998", "pm_score": 4, "selected": true, "text": "var a:A = new A();\na.initialize();\na.b = \"woopy\";\nthis.addChild(a);\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n<mx:...
2009/01/08
[ "https://Stackoverflow.com/questions/423070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21317/" ]
423,081
<p>i have added an icon to a WPF app in the project properties.</p> <p>How do I refer to that icon so I can add it to a NotifyIcon that I am creating for system tray.</p> <p>In code that is??</p> <pre><code> System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon(); ni.Icon = new System.Drawing.Icon("MyIcon.ico"); </code></pre> <p>Does not work. Malcolm</p>
[ { "answer_id": 430909, "author": "Stanislav Kniazev", "author_id": 10757, "author_profile": "https://Stackoverflow.com/users/10757", "pm_score": 3, "selected": false, "text": "System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon();\nni.Icon = System.Drawing.Icon.Extra...
2009/01/08
[ "https://Stackoverflow.com/questions/423081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40568/" ]
423,107
<p>I've been trying to find a way to match a number in a Javascript string that is surrounded by parenthesis at the end of the string, then increment it.</p> <p>Say I have a string:</p> <pre><code>var name = "Item Name (4)"; </code></pre> <p>I need a RegExp to match the (4) part, and then I need to increment the 4 then put it back into the string.</p> <p>This is the regex I have so far:</p> <pre><code>\b([0-9]+)$\b </code></pre> <p>This regex does not work. Furthermore, I do not know how to extract the integer retrieved and put it back in the same location in the string.</p> <p>Thanks.</p>
[ { "answer_id": 423150, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 0, "selected": false, "text": "// Tested on rhino\nvar name = \"Item Name (4)\";\nvar re = /\\((\\d+)\\)/;\n\nmatch = re.exec(name);\nnumber = parseI...
2009/01/08
[ "https://Stackoverflow.com/questions/423107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52749/" ]
423,110
<p>I have a command line program in C# that I've wrapped with a try-catch block to keep it from crashing the console. However, while I am debugging it, if an exception is thrown somewhere in the DoStuff() method, Visual Studio will break on the "catch" statement. I want Visual Studio to break where the exception occurred. What's the best way to do this? </p> <p>Comment out the try?<br> A setting in Visual Sudio?<br> An #if DEBUG statement?</p> <pre><code>static void Main(string[] args) { try { DoStuff(); } catch (Exception e) { //right now I have a breakpoint here Console.WriteLine(e.Message); } } private void DoStuff() { //I'd like VS to break here if an exception is thrown here. } </code></pre>
[ { "answer_id": 423351, "author": "Rinat Abdullin", "author_id": 47366, "author_profile": "https://Stackoverflow.com/users/47366", "pm_score": 1, "selected": false, "text": "private static void Main(string[] args)\n{\n var parameters = CommandLineUtil.ParseCommandString(args);\n\n#if DEB...
2009/01/08
[ "https://Stackoverflow.com/questions/423110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571/" ]
423,111
<p>It's probably the tenth time I'm implementing something like this, and I've never been 100% happy about solutions I came up with.</p> <p>The reason using mysql table instead of a "proper" messaging system is attractive is primarily because most application already use some relational database for other stuff (which tends to be mysql for most of the stuff I've been doing), while very few applications use a messaging system. Also - relational databases have very strong ACID properties, while messaging systems often don't.</p> <p>The first idea is to use:</p> <pre> create table jobs( id auto_increment not null primary key, message text not null, process_id varbinary(255) null default null, key jobs_key(process_id) ); </pre> <p>And then enqueue looks like this:</p> <pre> insert into jobs(message) values('blah blah'); </pre> <p>And dequeue looks like this:</p> <pre> begin; select * from jobs where process_id is null order by id asc limit 1; update jobs set process_id = ? where id = ?; -- whatever i just got commit; -- return (id, message) to application, cleanup after done </pre> <p>Table and enqueue look nice, but dequeue kinda bothers me. How likely is it to rollback? Or to get blocked? What keys I should use to make it O(1)-ish?</p> <p>Or is there any better solution that what I'm doing?</p>
[ { "answer_id": 423276, "author": "Gary Richardson", "author_id": 2506, "author_profile": "https://Stackoverflow.com/users/2506", "pm_score": 3, "selected": false, "text": "SELECT table FROM DELETE SELECT GET_LOCK('READQUEUE');\nSELECT * FROM jobs;\nDELETE FROM JOBS WHERE ID = ?;\nSELECT ...
2009/01/08
[ "https://Stackoverflow.com/questions/423111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52751/" ]
423,114
<p>I need to keep program variable values in an iPhone application when the application is exited. Does the SDK give the programmer any non volitile memory to use? How much is available? Will it be kept thru a power cycle? Through sleep mode? Through a hard reset?</p>
[ { "answer_id": 1214618, "author": "angelfilm entertainment", "author_id": 53175, "author_profile": "https://Stackoverflow.com/users/53175", "pm_score": 2, "selected": false, "text": "-(void)saveToUserDefaults:(NSString*)myString\n{\n NSUserDefaults *standardUserDefaults = [NSUserDefau...
2009/01/08
[ "https://Stackoverflow.com/questions/423114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
423,127
<p>So I'm new to rhino mocks and I'm trying to get it going in a MVP patterned project I'm on. So I've got an interface representing my View and a class for my Presenter like so:</p> <pre><code>public interface IView { string SomeData { get; set; } } public class Presenter { public IView View { get; set; } public void Init(IView view) { this.View = view; } public virtual string DoStuff(){ return "Done stuff with " + this.View.SomeData; } } </code></pre> <p>And I'm trying to set up a test to mock the <code>DoStuff</code> method, so I've got a basic fixture like this:</p> <pre><code>[TestMethod] public void Test(){ var mocks = new MockRepository(); var view = mocks.Stub&lt;IView&gt;(); var presenter = mocks.StrictMock&lt;Presenter&gt;(); presenter.Init(view); using(mocks.Record()){ presenter.Expect(p =&gt; p.DoStuff()).Return("Mocked result"); } string result = string.Empty; using(mocks.Playback()){ result = presenter.DoStuff(); } Assert.AreEqual(result, "Mocked result"); } </code></pre> <p>But I keep getting a <strong>null reference exception</strong> from within the <code>DoStuff</code> method (during the expectation setup), because the View object is null. And this is where I'm stuck. I've called the <code>Init</code> method, which assigns the value of the <code>View</code> property, and I thought that the point of an expectation setup was that the method itself wasn't ever called?</p>
[ { "answer_id": 423145, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "presenter.Expect( p => p.View ).Return( view );\n string expectedResult = \"Done stuff with Mocked Result\";\n\nvar view...
2009/01/08
[ "https://Stackoverflow.com/questions/423127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11388/" ]
423,128
<p>Simple question: do I have to <code>delete</code> or <code>delete []</code> <code>c</code>? Does the language matter?</p> <pre><code>char c[] = "hello" </code></pre>
[ { "answer_id": 423130, "author": "Gordon Wilson", "author_id": 23071, "author_profile": "https://Stackoverflow.com/users/23071", "pm_score": 5, "selected": true, "text": "delete[] char c[6]={'h','e','l','l','o','\\0'};\n" }, { "answer_id": 423144, "author": "Greg Hewgill", ...
2009/01/08
[ "https://Stackoverflow.com/questions/423128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
423,132
<p>Does it make sense to use interfaces for your domain object factories by default, or should interfaces be reserved for the factory classes only when you need them?</p> <pre><code>public IUserFactory { User CreateNewUser(); } public UserFactory : IUserFactory { public User CreateNewUser() { return new User(); } } </code></pre>
[ { "answer_id": 423224, "author": "Alan", "author_id": 17205, "author_profile": "https://Stackoverflow.com/users/17205", "pm_score": 3, "selected": true, "text": "public interface UserFactoryIF\n{\n User createNewUser();\n}\n public class UserFactory implements UserFactoryIF\n{\n pu...
2009/01/08
[ "https://Stackoverflow.com/questions/423132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25847/" ]
423,135
<p>An idea I had to solve this, is to make up an buffer of size 8x8, fill it up with pointers to my checkers (all 20 of them), and the rest leave 0 (null), then run a shuffling algorithm on the buffer, and thats it (just read it as a 8x8 array)</p> <ol> <li>I was wondering if there's a better way to do this.</li> <li>I need to write it in C#, and my proposal wouldn't work in the way I described it</li> </ol> <p>anyone ? </p>
[ { "answer_id": 423152, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 0, "selected": false, "text": "using System;\nusing System.Linq;\n\nPiece[] board = whatever();\n\n// New random number generator.\nRandom random = ne...
2009/01/08
[ "https://Stackoverflow.com/questions/423135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
423,157
<p>I have the following classes:</p> <pre><code>public class Person { public String FirstName { set; get; } public String LastName { set; get; } public Role Role { set; get; } } public class Role { public String Description { set; get; } public Double Salary { set; get; } public Boolean HasBonus { set; get; } } </code></pre> <p>I want to be able to automatically extract the property value diferences between Person1 and Person2, example as below:</p> <pre><code>public static List&lt;String&gt; DiffObjectsProperties(T a, T b) { List&lt;String&gt; differences = new List&lt;String&gt;(); foreach (var p in a.GetType().GetProperties()) { var v1 = p.GetValue(a, null); var v2 = b.GetType().GetProperty(p.Name).GetValue(b, null); /* What happens if property type is a class e.g. Role??? * How do we extract property values of Role? * Need to come up a better way than using .Namespace != "System" */ if (!v1.GetType() .Namespace .Equals("System", StringComparison.OrdinalIgnoreCase)) continue; //add values to differences List } return differences; } </code></pre> <p>How can I extract property values of Role in Person???</p>
[ { "answer_id": 423188, "author": "Jeff", "author_id": 52752, "author_profile": "https://Stackoverflow.com/users/52752", "pm_score": 0, "selected": false, "text": "var v1 = p.GetValue(a, null);\n" }, { "answer_id": 423210, "author": "Diadistis", "author_id": 47401, "au...
2009/01/08
[ "https://Stackoverflow.com/questions/423157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52752/" ]
423,160
<p>I have a rails model that validates uniqueness of 2 form values. If these 2 values aren't unique the validation errors are shows and the "submit" button is changed to "resubmit". I want to allow a user to click the "resubmit" button and bypass the model validation. I want to do something like this from the rails validation documentation:</p> <blockquote> <p><code>validates_uniqueness_of :value, :unless =&gt; Proc.new { |user| user.signup_step &lt;= 2 }</code></p> </blockquote> <p>but I don't have a a value in my model that I can check for...just the params that have the "Resubmit" value.</p> <p>Any ideas on how to do this?</p>
[ { "answer_id": 423173, "author": "zenazn", "author_id": 46848, "author_profile": "https://Stackoverflow.com/users/46848", "pm_score": 3, "selected": false, "text": "Model.save(false) Model.save(:validate => false)" }, { "answer_id": 423207, "author": "PJ Davis", "author_i...
2009/01/08
[ "https://Stackoverflow.com/questions/423160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50029/" ]
423,166
<p>I'm embedding a Flash ActiveX control in my C++ app (Flash.ocx, Flash10a.ocx, etc depending on your Flash version). </p> <p>I can load an SWF file by calling LoadMovie(0, filename), but the file needs to physically reside in the disk. How to load the SWF from memory (or resource, or stream)? I'm sure there must be a way, because commercial solutions like <strong>f-in-box</strong>'s feature <a href="http://www.f-in-box.org/dll/#feature_load_movie" rel="nofollow noreferrer">Load flash movies from memory directly</a> also uses Flash ActiveX control.</p>
[ { "answer_id": 423254, "author": "fenomas", "author_id": 10651, "author_profile": "https://Stackoverflow.com/users/10651", "pm_score": 0, "selected": false, "text": "var mc:MovieClip = createEmptyMovieClip( \"mc\", 0 );\nmc.loadMovie( \"fakeprotocol://\"+filename )\n" }, { "answe...
2009/01/08
[ "https://Stackoverflow.com/questions/423166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11238/" ]
423,172
<p>Is it possible to have two background images? For instance, I'd like to have one image repeat across the top (repeat-x), and another repeat across the entire page (repeat), where the one across the entire page is behind the one which repeats across the top.</p> <p>I've found that I can achieve the desired effect for two background images by setting the background of html and body:</p> <pre class="lang-css prettyprint-override"><code>html { background: url(images/bg.png); } body { background: url(images/bgtop.png) repeat-x; } </code></pre> <p>Is this "good" CSS? Is there a better method? And what if I wanted three or more background images?</p>
[ { "answer_id": 423190, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 10, "selected": true, "text": "body {\n background-image: url(images/bgtop.png), url(images/bg.png);\n background-repeat: repeat-x, repeat;\n}\n <body>...
2009/01/08
[ "https://Stackoverflow.com/questions/423172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/219/" ]
423,182
<p>As the code shown below, I want to get value from the OracleParameter object. Its datatype is datetime.</p> <pre><code>... Dim cmd As New OracleCommand("stored_proc_name", cnObject) cmd.Parameters.Add("tran_date_out", OracleDbType.Date, ParameterDirection.Output) ... cmd.ExecuteNonQuery() ... Dim tranDate As Date tranDate = cmd.Parameters("tran_date_out").Value </code></pre> <p>When I assign value to tranDate variable, I get an error. But if I code as below, I get only the date.</p> <pre><code>tranDate = CDate(cmd.Parameters("tran_date_out").Value.ToString) </code></pre> <p>So how can I get the value both date and time to tranDate variable? </p>
[ { "answer_id": 423216, "author": "CodingWithSpike", "author_id": 28278, "author_profile": "https://Stackoverflow.com/users/28278", "pm_score": 3, "selected": false, "text": "/// <summary>\n/// The need for this method is highly annoying.\n/// When Oracle sets its output parameters, the O...
2009/01/08
[ "https://Stackoverflow.com/questions/423182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1602746/" ]
423,186
<p>As a follow-up to <a href="https://stackoverflow.com/questions/423128/is-this-dynamic-memory-allocation">this question</a>:</p> <p>From what I've seen, this should work as expected:</p> <pre><code>void greet(){ char c[] = "Hello"; greetWith(c); return; } </code></pre> <p>but this will cause undefined behavior:</p> <pre><code>char *greet(){ char c[] = "Hello"; return c; } </code></pre> <p>If I'm right, what's the best way to fix the second greet function? In an embedded environment? On a desktop?</p>
[ { "answer_id": 423197, "author": "dmckee --- ex-moderator kitten", "author_id": 2509, "author_profile": "https://Stackoverflow.com/users/2509", "pm_score": 0, "selected": false, "text": "malloc" }, { "answer_id": 423198, "author": "Greg Hewgill", "author_id": 893, "au...
2009/01/08
[ "https://Stackoverflow.com/questions/423186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
423,212
<p>I'm trying to make a graph in Rails, for example the avg sales amount per day for each day in a given date range</p> <p>Say I have a products_sold model which has a "sales_price" float attribute. But if a specific day has no sales (e.g none in the model/db), I want to return simply 0.</p> <p>What's the best way in MySQL/Rails to get this done? I know I can do something like this:</p> <p>(<em>This SQL query might be the completely wrong way to get what I'm wanting too</em>)</p> <pre><code>SELECT avg(sales_price) AS avg, DATE_FORMAT(created_at, '%m-%d-%Y') AS date FROM products_sold WHERE merchant_id = 1 GROUP BY date; </code></pre> <p>And get results like this:</p> <pre> | avg | date | 23 01-03-2009 50 01-05-2009 34 01-07-2009 ... ... </pre> <p>What I'd like to get is this:</p> <pre> | avg | date | 23 01-03-2009 0 01-04-2009 50 01-05-2009 0 01-06-2009 34 01-07-2009 0 01-08-2009 ... ... </pre> <p>Can I do this with SQL or will I have to post-process the results to find what dates in the daterange aren't in the SQL result set? Perhaps I need some sub-selects or IF statements?</p> <p>Thanks for any help everyone.</p>
[ { "answer_id": 423426, "author": "j_random_hacker", "author_id": 47984, "author_profile": "https://Stackoverflow.com/users/47984", "pm_score": 0, "selected": false, "text": "select 'foo', generate_series(3, 5);\n generate_series() LEFT OUTER JOIN SELECT\n avg(sales_price) as avg,\n ...
2009/01/08
[ "https://Stackoverflow.com/questions/423212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1609611/" ]
423,228
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/5938802/are-function-and-function-functionally-equal-i">Are &ldquo;(function ( ) { } ) ( )&rdquo; and &ldquo;(function ( ) { } ( ) )&rdquo; functionally equal in JavaScript?</a> </p> </blockquote> <p>This is something I haven't quite figured out yet, but I have been using function(){}() just because my VIM syntax highlight screws up if I add the parenthesis, although I've seen (function(){})() around many times, maybe its an IE thing?</p> <p><strong>edit:</strong></p> <pre><code>var singleton = function() { // code }(); var singleton = (function() { // code })(); </code></pre>
[ { "answer_id": 423268, "author": "x-yuri", "author_id": 52499, "author_profile": "https://Stackoverflow.com/users/52499", "pm_score": 2, "selected": false, "text": "function(){}();\n (function(){})();\n function(){}\n function() {\n alert(1);\n}();\n" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/423228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50394/" ]
423,247
<p>I would like to be able to do somthing like the following:</p> <pre><code>//non-generic var MyTable = new Table(); string name = MyTable.Name; IEnumerable&lt;String&gt; rows = MyTable.Rows; //generic var MyTableGeneric = new Table&lt;MyType&gt;(); string name = MyTableGeneric.Name; IEnumerable&lt;MyType&gt; rows = MyTableGeneric .Rows; </code></pre> <p>Would something like this be to much:</p> <p><a href="http://img81.imageshack.us/img81/427/diagramcm3.jpg" rel="nofollow noreferrer">http://img81.imageshack.us/img81/427/diagramcm3.jpg</a></p> <p>or would this be better:</p> <p><a href="http://img301.imageshack.us/img301/4136/presentation1nh9.jpg" rel="nofollow noreferrer">http://img301.imageshack.us/img301/4136/presentation1nh9.jpg</a></p> <p>Sorry if this hard to understand what I am trying to get at, basically I have two objects will share comman properties except for there row collections which will be generic. I would like to do this in cleanest way.</p> <p>Sorry for my crappy diagrams, made in powerpoint :)</p>
[ { "answer_id": 423432, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "Table Table<string> Table<string> Rows Table" }, { "answer_id": 423448, "author": "Øyvind Skaar", "autho...
2009/01/08
[ "https://Stackoverflow.com/questions/423247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
423,248
<p>The OpenGroup POSIX.1-2001 defines <a href="http://www.opengroup.org/onlinepubs/000095399/functions/strerror.html" rel="noreferrer">strerror_r</a>, as does <a href="http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/baselib-strerror-r.html" rel="noreferrer">The Linux Standard Base Core Specification 3.1</a>. But I can find no reference to the maximum size that could be reasonably expected for an error message. I expected some define somewhere that I could put in my code but there is none that I can find.</p> <p><em>The code must be thread safe.</em> Which is why strerror_r is used and not strerror.</p> <p>Does any one know the symbol I can use? I should I create my own?</p> <hr> <h2>Example</h2> <pre><code>int result = gethostname(p_buffy, size_buffy); int errsv = errno; if (result &lt; 0) { char buf[256]; char const * str = strerror_r(errsv, buf, 256); syslog(LOG_ERR, "gethostname failed; errno=%d(%s), buf='%s'", errsv, str, p_buffy); return errsv; } </code></pre> <hr> <p><strong>From the documents:</strong></p> <p>The Open Group Base Specifications Issue 6:</p> <blockquote> <p><strong>ERRORS</strong></p> <p>The strerror_r() function may fail if:</p> <ul> <li><strong>[ERANGE]</strong> Insufficient storage was supplied via strerrbuf and buflen to contain the generated message string.</li> </ul> </blockquote> <hr> <p><strong>From the source:</strong></p> <p>glibc-2.7/glibc-2.7/string/strerror.c:41:</p> <pre><code> char * strerror (errnum) int errnum; { ... buf = malloc (1024); </code></pre>
[ { "answer_id": 423301, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 4, "selected": false, "text": "strerror() strerror_r() strdup() strerror_r() strerror() glibc-2.7" }, { "answer_id": 427437, "author": ...
2009/01/08
[ "https://Stackoverflow.com/questions/423248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11032/" ]
423,298
<p>Instruction on accessing a interface to an application, in <b>plain</b> C/C++ <b>without</b>:</p> <ul> <li>MFC</li> <li>ATL</li> <li>WTL</li> </ul> <p>Basically, I would like to make use of a COM object.</p> <p>Working sample source code or guidance - to <b>using</b> (functionality) a COM object, <b>not</b> creating a COM server.</p> <p>Regards</p>
[ { "answer_id": 423594, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 4, "selected": true, "text": "CoInitialize(NULL); // absolutely essential: initialize the COM subsystem\nIMyInterface* pIFace;\n// create the obje...
2009/01/08
[ "https://Stackoverflow.com/questions/423298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51078/" ]
423,320
<p>I have a feeling that I already know the answer to this one, but I thought I'd check.</p> <p>I have a number of different folders:</p> <pre><code>images_a/ images_b/ images_c/ </code></pre> <p>Can I create some sort of symlink such that this new directory has the contents of all those directories? That is this new "<code>images_all</code>" would contain all the files in <code>images_a</code>, <code>images_b</code> and <code>images_c</code>?</p>
[ { "answer_id": 423326, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 5, "selected": true, "text": "images_all rm -f images_all/*\nfor i in images_[abc]/* ; do; ln -s $i images_all/$(basename $i) ; done\n mv mkdir images_...
2009/01/08
[ "https://Stackoverflow.com/questions/423320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
423,330
<p>I have Perl v5.10. I am trying to install Net::SSLeay 1.30 and Crypt::SSLeay 0.57. I have already installed OpenSSL 0.9.8e.</p> <p>For Net::SSLeay 1.30 I followed these steps:</p> <pre> perl Makefile.PL -windows C:\openssl nmake nmake test -- test fails nmake install perl test.pl </pre> <p>but I got an fatal error as:</p> <pre> D:\perl\Net_SSLeay.pm-1.30>perl -w test.pl 1..20 Can't load 'D:/perl/site/lib/auto/Net/SSLeay/SSLeay.dll' for module Net::SSLeay: load_file:The specified module could not be found at D:/perl/lib/DynaLoader.pm line 203. at test.pl line 25 Compilation failed in require at test.pl line 25. BEGIN failed--compilation aborted at test.pl line 25. </pre> <p>I got the same results for Crypt::SSLeay 0.57.</p>
[ { "answer_id": 45736430, "author": "rurban", "author_id": 414279, "author_profile": "https://Stackoverflow.com/users/414279", "pm_score": 1, "selected": false, "text": "SSLeay.dll ldd set PERL_DL_DEBUG=5 depends.exe" }, { "answer_id": 62648902, "author": "Nathan", "author...
2009/01/08
[ "https://Stackoverflow.com/questions/423330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
423,373
<p>It is obvious what I am trying to do below, but I get the following exception:</p> <blockquote> <p>Unable to return a TimeSpan property value for a Duration value of 'Automatic'.</p> </blockquote> <p>I was discouraged to read that</p> <blockquote> <p>NaturalDuration cannot be determined until after MediaOpened has occurred. (<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.mediaplayer.naturalduration(VS.85).aspx" rel="nofollow noreferrer">link</a>)</p> </blockquote> <p>Does this mean that I have to come up with a contrived method to open the file, wait for the media opened event in a separate thread, then return the duration only after the event has fired?</p> <pre><code> public static int PlayAudio(string fileName) { try { myMediaPlayer.Stop(); myMediaPlayer.Close(); myMediaPlayer.Open(new Uri(filename)); myMediaPlayer.Play(); return myMediaPlayer.NaturalDuration.TimeSpan.Milliseconds; } catch (Exception e) { MessageBox.Show(e.Message); return -1; } } </code></pre>
[ { "answer_id": 928113, "author": "Tim Erickson", "author_id": 8787, "author_profile": "https://Stackoverflow.com/users/8787", "pm_score": 4, "selected": true, "text": "using System;\nusing System.Threading;\nusing System.Windows.Media;\nusing System.Windows.Threading;\n\nclass Program\n{...
2009/01/08
[ "https://Stackoverflow.com/questions/423373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50859/" ]
423,376
<p>Is there a way that I can get the last value (based on the '\' symbol) from a full path?</p> <p>Example:</p> <p><code>C:\Documents and Settings\img\recycled log.jpg</code></p> <p>With this case, I just want to get <code>recycled log.jpg</code> from the full path in JavaScript.</p>
[ { "answer_id": 423385, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 11, "selected": true, "text": "var filename = fullPath.replace(/^.*[\\\\\\/]/, '')\n" }, { "answer_id": 424006, "author": "bobince", "author_...
2009/01/08
[ "https://Stackoverflow.com/questions/423376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52745/" ]
423,379
<p>How do I create or use a global variable inside a function?</p> <p>How do I use a global variable that was defined in one function inside other functions?</p> <hr /> <p><sub>Failing to use the <code>global</code> keyword where appropriate often causes <code>UnboundLocalError</code>. The precise rules for this are explained at <a href="https://stackoverflow.com/questions/370357">UnboundLocalError on local variable when reassigned after first use</a>. Generally, please close other questions as a duplicate of <em>that</em> question when an explanation is sought, and <em>this</em> question when someone simply needs to know the <code>global</code> keyword.</sub></p>
[ { "answer_id": 423401, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 8, "selected": false, "text": "modname.itemname x = 0 # Default value of the 'x' configuration setting\n import config\nconfig.x = 1\n import config\nimpor...
2009/01/08
[ "https://Stackoverflow.com/questions/423379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46646/" ]
423,393
<p>What do you find to provide the best menu for an ASP.Net 2.0 - 3.5 web application? Suggestions do not have to particularly be ASP.Net controls, but could be other menu's that work well within an ASP.Net web application.</p> <p>I would like for the suggestions to be options that do not require purchasing or royalty fees. OpenSource suggestions would be even better.</p>
[ { "answer_id": 424126, "author": "Trevor de Koekkoek", "author_id": 41783, "author_profile": "https://Stackoverflow.com/users/41783", "pm_score": 2, "selected": false, "text": "<div id=\"nav_main\" >\n<ul>\n <li id=\"current\">Button 1</li>\n <li><a href=\"#\">Button 2</a></li>\n <li>...
2009/01/08
[ "https://Stackoverflow.com/questions/423393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28919/" ]
423,404
<p>i have a c function which returns a <code>long double</code>. i'd like to call this function from python using ctypes, and it mostly works. setting <code>so.func.restype = c_longdouble</code> does the trick -- except that python's float type is a <code>c_double</code> so if the returned value is larger than a double, but well within the bounds of a long double, python still gets inf as the return value. i'm on a 64 bit processor and <code>sizeof(long double)</code> is 16.</p> <p>any ideas on getting around this (e.g. using the decimal class or numpy) without modifying the c code?</p>
[ { "answer_id": 423479, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 2, "selected": true, "text": "long double float c_longdouble %eax" }, { "answer_id": 423491, "author": "gimel", "author_id": 6491, ...
2009/01/08
[ "https://Stackoverflow.com/questions/423404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49994/" ]
423,434
<p>I would like to know how to change the schema of DataSet at Runtime</p>
[ { "answer_id": 423537, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "DataSet Columns DataSet" }, { "answer_id": 1435242, "author": "Community", "author_id": -1, "auth...
2009/01/08
[ "https://Stackoverflow.com/questions/423434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
423,467
<p>While working with ASP.Net Forms Authentication I came across the .ASPXAUTH cookie. I have a couple questions:</p> <ul> <li>What is the purpose of this cookie?</li> <li>What is the location of this cookie?</li> </ul>
[ { "answer_id": 424061, "author": "Todd", "author_id": 2572, "author_profile": "https://Stackoverflow.com/users/2572", "pm_score": 7, "selected": true, "text": "HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];//.ASPXAUTH\nFormsAuthenticationTicket authTicket =...
2009/01/08
[ "https://Stackoverflow.com/questions/423467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
423,469
<p>I have encountered odd behavior when using document.getElementById tonight. Duplicated in Firefox 3 and Safari.</p> <p>Basically, it finds the div with id "divid" in Example1. However, in Example2 it always returns null. What's going on here?</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;script type="text/javascript"&gt; addelement = function(){ alert( document.getElementById('divid') ); } //Example1 window.onload = function(){ alert( document.getElementById('divid') ); } //Example2 window.onload = addelement(); &lt;/script&gt; &lt;body&gt; &lt;div id="divid" class="divclass"&gt; &lt;p&gt;Test&lt;/p&gt; &lt;/div&gt; &lt;body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 423478, "author": "cbp", "author_id": 21966, "author_profile": "https://Stackoverflow.com/users/21966", "pm_score": 5, "selected": true, "text": "window.onload = addelement();\n window.onload = addelement;\n" }, { "answer_id": 423487, "author": "Chris Burgess",...
2009/01/08
[ "https://Stackoverflow.com/questions/423469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/68788/" ]
423,483
<p>My test file is basically:</p> <pre><code>class Test(unittest.TestCase): def testOk(): pass if __name__ == "__main__": expensiveSetup() try: unittest.main() finally: cleanUp() </code></pre> <p>However, I do wish to run my test through Netbeans testing tools, and to do that I need unittests that don't rely on an environment setup done in <strong>main</strong>. Looking at <a href="https://stackoverflow.com/questions/402483/caching-result-of-setup-using-python-unittest">Caching result of setUp() using Python unittest</a> - it recommends using Nose. However, I don't think Netbeans supports this. I didn't find any information indicating that it does. Additionally, I am the only one here actually writing tests, so I don't want to introduce additional dependencies for the other 2 developers unless they are needed.</p> <p>How can I do the setup and cleanup once for all the tests in my TestSuite?</p> <p>The expensive setup here is creating some files with dummy data, as well as setting up and tearing down a simple xml-rpc server. I also have 2 test classes, one testing locally and one testing all methods over xml-rpc.</p>
[ { "answer_id": 423569, "author": "muhuk", "author_id": 42188, "author_profile": "https://Stackoverflow.com/users/42188", "pm_score": 2, "selected": false, "text": "expensiveSetup() __expensiveSetup_has_run = False\n\nclass ExpensiveSetupMixin(unittest.TestCase):\n def setUp(self):\n ...
2009/01/08
[ "https://Stackoverflow.com/questions/423483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3355/" ]
423,503
<p>The first time I call <code>Update</code> on my DataWindow it returns 1 (success) and <code>SQLCA.SQLNRows</code> is 1. When I do a second update on the same screen without closing it in between, <code>Update</code> returns 1 and <code>SQLCA.SQLNRows</code> is 0. Any suggestions why this is happening?</p>
[ { "answer_id": 2426496, "author": "Hugh Brackett", "author_id": 207337, "author_profile": "https://Stackoverflow.com/users/207337", "pm_score": 0, "selected": false, "text": "Update UpdateEnd rowsinserted, rowsupdated, rowsdeleted beep(1) sqlpreview" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/423503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
423,504
<p>I am trying to run a .Net 2.0 application from a network share without using the FullTrust permission set. I want to create a new permission set that has just the permissions my assemblies require, and then assign that to the exe on the shared path. Is it possible to do this? From my limited experiments, I find that I am unable to do get any application working from a network share without FullTrust. I tried creating a new perm set, and also tried the Everything and other perm sets, but none seem to work. Has anyone had any experience with this?</p>
[ { "answer_id": 423583, "author": "Oliver Friedrich", "author_id": 44532, "author_profile": "https://Stackoverflow.com/users/44532", "pm_score": 2, "selected": false, "text": "caspol.exe -q -m -ag MyZone -strong -hex [HexCodeOfYourStrongName] -noname -noversion FullTrust -name MyCode -des...
2009/01/08
[ "https://Stackoverflow.com/questions/423504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52795/" ]
423,524
<p>What I want to do is when user finish editing of data in table cell to move focus onto another cell depending of what user entered, and to turn that cell into editing mode so user can start typing immediately with no additional action. This way user can focus on his work and software will do the 'thinking' about which cell should be edited next. </p> <p>Simple task which does not look so simple in real life ... anyone some idea? </p>
[ { "answer_id": 423582, "author": "Markus Lausberg", "author_id": 39062, "author_profile": "https://Stackoverflow.com/users/39062", "pm_score": 0, "selected": false, "text": "FocusTraversalPolicy table.setFocusTraversalPolicy(policy)\n FocusTraversalPolicy FocusManager.getCurrentManager()...
2009/01/08
[ "https://Stackoverflow.com/questions/423524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
423,536
<p>I want to save an audio file to the Documents folder of my application while one of the classes in my app is streaming it. How can I do this?</p> <p>Is it possible to save the streamed audio directly to an mp3? (if the audio file being streamed is an mp3 or I have to use caf?)</p> <p>Thanks.</p> <p><i> Edit: What if I am running the save in another thread and the user exits the application? I know an app cannot run in the background in an iPhone, but is there any way I can stop the download and remove the partially saved file when the user exits the app? Can I get an exit signal inside a class or in a delegate for NSURLConnection? </i></p>
[ { "answer_id": 872292, "author": "Rhythmic Fistman", "author_id": 22147, "author_profile": "https://Stackoverflow.com/users/22147", "pm_score": 0, "selected": false, "text": "- (void)applicationWillTerminate:(UIApplication *)application" }, { "answer_id": 6260802, "author": "...
2009/01/08
[ "https://Stackoverflow.com/questions/423536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46297/" ]
423,547
<p>HI, I am doing ERP solution in C#(2.0) windows application and SQL2005 Database.The network application communicate through Database.I used normal technique for user login and logout, keeping a status bit.My problem is that when my application interrupted with any other reason user status might not change.That will cause the user can't login at next time.How can I solve this problem? Could you give any new technique for user manipulation?</p>
[ { "answer_id": 423754, "author": "Michael Buen", "author_id": 11432, "author_profile": "https://Stackoverflow.com/users/11432", "pm_score": 2, "selected": true, "text": "Logging In:\n\nif (select count(*) from staff where staff_name = @staff_name and password = 'correct' and (last_logged...
2009/01/08
[ "https://Stackoverflow.com/questions/423547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49001/" ]
423,554
<p>I am currently trying to learn C and I have come to a problem that I've been unable to solve.</p> <p>Consider:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #define ELEMENTS 5 void make(char **array, int *array_size) { int i; char *t = "Hello, World!"; array = malloc(ELEMENTS * sizeof(char *)); for (i = 0; i &lt; ELEMENTS; ++i) { array[i] = malloc(strlen(t) + 1 * sizeof(char)); array[i] = strdup(t); } } int main(int argc, char **argv) { char **array; int size; int i; make(array, &amp;size); for (i = 0; i &lt; size; ++i) { printf("%s\n", array[i]); } return 0; } </code></pre> <p>I have no idea why the above fails to read back the contents of the array after creating it. I have literally spent an hour trying to understand why it fails but have come up empty handed. No doubt it's something trivial.</p> <p>Cheers,</p>
[ { "answer_id": 423560, "author": "PolyThinker", "author_id": 47707, "author_profile": "https://Stackoverflow.com/users/47707", "pm_score": 3, "selected": false, "text": "void make(char ***array, int *array_size)\n make(&array, &size);\n *array = malloc(ELEMENTS * sizeof(char *));\n" },...
2009/01/08
[ "https://Stackoverflow.com/questions/423554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
423,591
<p>I wish to use a modelbinder I've made directly on an action method parameter. Such as:</p> <pre><code>public ActionResult MyAction([ModelBinder(typeof(MyBinder))] string param1) </code></pre> <p>However, I need to pass a string into the binder itself, so I was wondering if you could do something along the lines of:</p> <pre><code>public ActionResult MyAction([MyBinder("mystring")] string param1) </code></pre> <p>Is it possible?</p>
[ { "answer_id": 51046531, "author": "Chayim Friedman", "author_id": 7884305, "author_profile": "https://Stackoverflow.com/users/7884305", "pm_score": 0, "selected": false, "text": "System.Web.Mvc.CustomModelBinder GetBinder Type public sealed class MyModelBinderAttribute : CustomModelBind...
2009/01/08
[ "https://Stackoverflow.com/questions/423591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13148/" ]
423,598
<p>var result = from с in dal.context.Funds select new { Name = c.CODE Price = c.Price };</p>
[ { "answer_id": 423608, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "Dim result = From c In dal.context.Funds _\n Select c.CODE, c.Price\n With Select New With {.Name = c...
2009/01/08
[ "https://Stackoverflow.com/questions/423598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
423,600
<p>I am new to programming and am trying to follow an example which uses #! comment in ruby.</p> <p>I am consistently get the message: bash: matz.rb: command not found</p> <p>I am using this comment: #! /usr/bin/env ruby</p> <p>I have tried it with and without the space after ! as well as with and without the env. </p> <p>when I use the $ which ruby </p> <p>ruby is in: /usr/bin/ruby</p> <p>I have also gone into the operating system and changed the permissions on the file matz.rb to rwx for all users w/ no effect. Am I doing something wrong or do I have my system set up incorrectly?</p>
[ { "answer_id": 423603, "author": "Oliver Friedrich", "author_id": 44532, "author_profile": "https://Stackoverflow.com/users/44532", "pm_score": 0, "selected": false, "text": "#! /usr/bin/ruby\n ./matz.rb\n" }, { "answer_id": 423610, "author": "Gareth", "author_id": 31582,...
2009/01/08
[ "https://Stackoverflow.com/questions/423600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
423,605
<p>I'm sure I've done this before, but can't find any example of it! Grrr...</p> <p>For example, I want to convert an <code>IList&lt;T&gt;</code> into a <code>BindingList&lt;T&gt;</code>:</p> <pre><code>public class ListHelper { public static BindingList&lt;T&gt; ToBindingList(IList&lt;T&gt; data) { BindingList&lt;T&gt; output = new BindingList&lt;T&gt;(); foreach (T item in data) output.Add(item); return output; } } </code></pre>
[ { "answer_id": 423620, "author": "Sander", "author_id": 2928, "author_profile": "https://Stackoverflow.com/users/2928", "pm_score": 6, "selected": true, "text": "ToBindingList <T> (...)\n public class ListHelper\n{\n public static BindingList<T> ToBindingList<T>(IList<T> data)\n {\...
2009/01/08
[ "https://Stackoverflow.com/questions/423605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5461/" ]
423,606
<p>I have this scenario where I need data integrity in the physical database. For example, I have a variable of <code>@email_address VARCHAR(200)</code> and I want to check if the value of <code>@email_address</code> is of email format. Anyone has any idea how to check format in T-SQL? </p> <p>Many thanks!</p>
[ { "answer_id": 423642, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 5, "selected": true, "text": "IF (\n CHARINDEX(' ',LTRIM(RTRIM(@email_address))) = 0 \nAND LEFT(LTRIM(@email_address),1) <> '@' \nAND RIGHT(RTRIM(@e...
2009/01/08
[ "https://Stackoverflow.com/questions/423606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47610/" ]
423,623
<p>I am developing a flvplayer with cocoa. I want to drag a flv file from the finder and drop it to the webview window (I use it to view the flv). But I didn't have the path of this file from finder. This is my code:</p> <pre><code> _ (void)showflv(nsstring*)aa { .......... //Register to accept flv drag/drop NSString *pboardType = NSCreateFileContentsPboardType(@"flv"); NSArray *dragTypes = [NSArray arrayWithObject:pboardType]; [self registerForDraggedTypes:dragTypes]; } _ (BOOL)performDragOperation:(id &lt;NSDraggingInfo&gt;)sender { NSPasteboard *pboard = [sender draggingPasteboard]; if ( [[pboard types] containsObject:NSFileContentsPboardType] ) { } return YES; } </code></pre> <p>I read the document about this.I find that the function of PerformDragOperation can be written like this:</p> <pre><code>_ (BOOL)performDragOperation:(id &lt;NSDraggingInfo&gt;)sender { NSPasteboard *pboard = [sender draggingPasteboard]; if ( [[pboard types] containsObject:NSFileContentsPboardType] ) { NSFileWrapper *fileContents = [pboard readFileWrapper]; // Perform operation using the file’s contents } return YES; } </code></pre> <p>I can get the filecontents of this dragging file.but how to get the path? </p> <pre><code>NSString *fileName = [fileContents filename]; </code></pre> <p>I did a test, it wasn't correct. </p> <hr> <p>I did a test ,but The draggedFilePaths didn't work.I found that the code:</p> <pre><code>NSPasteboard *pboard = [sender draggingPasteboard]; if ( [[pboard types] containsObject:NSFileContentsPboardType] ) { //NSFileWrapper *fileContents = [pboard readFileWrapper]; // Perform operation using the file’s contents nslog(@"aa"); } </code></pre> <p>when the app run ,the string "aa" didn't appear,why?</p>
[ { "answer_id": 423702, "author": "Chuck", "author_id": 50742, "author_profile": "https://Stackoverflow.com/users/50742", "pm_score": 4, "selected": true, "text": "NSArray *draggedFilePaths = [pboard propertyListForType:NSFilenamesPboardType];\n" }, { "answer_id": 16290724, "a...
2009/01/08
[ "https://Stackoverflow.com/questions/423623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51958/" ]
423,626
<p>I want to get the MIME type from a filename using C. Is there a way to do this without using a textfile containing MIME types and file extensions (i.e. Apache's file <code>mime.types</code>)?</p> <p>Maybe there is a function to get the MIME type using the filename? I rather not use the file extension if I don't have to.</p>
[ { "answer_id": 423630, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 4, "selected": true, "text": "mime.types file(1) mod_mime_magic" }, { "answer_id": 423758, "author": "lImbus", "author_id": 32490, "aut...
2009/01/08
[ "https://Stackoverflow.com/questions/423626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52355/" ]
423,627
<p>I'm using JUnit 4.4 and Maven and I have a large number of long-running integration tests.</p> <p>When it comes to parallelizing test suites there are a few solutions that allow me to run each test method in a single test-class in parallel. But all of these require that I change the tests in one way or another.</p> <p>I really think it would be a much cleaner solution to run X different test classes in X threads in parallel. I have hundreds of tests so I don't really care about threading individual test-classes.</p> <p>Is there any way to do this?</p>
[ { "answer_id": 1991457, "author": "Toby", "author_id": 233266, "author_profile": "https://Stackoverflow.com/users/233266", "pm_score": 3, "selected": false, "text": "@RunWith(ConcurrentTestRunner)" }, { "answer_id": 9498315, "author": "Oleksandr", "author_id": 1240114, ...
2009/01/08
[ "https://Stackoverflow.com/questions/423627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23691/" ]
423,650
<p>Do you know how to access textboxes added to a radgrid that are not bound but are used to trap any row related input a user typed in to the textbox for that column. I need to access this data server side when a postback occurs. Your thoughts are greatly appreciated Thanking you</p> <p>Tony</p>
[ { "answer_id": 436080, "author": "Corey Downie", "author_id": 44861, "author_profile": "https://Stackoverflow.com/users/44861", "pm_score": 2, "selected": true, "text": "Private Sub radGrid_ItemCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles R...
2009/01/08
[ "https://Stackoverflow.com/questions/423650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51630/" ]
423,663
<p>I'm rendering a certain scene into a texture and then I need to process that image in some simple way. How I'm doing this now is to read the texture using <code>glReadPixels()</code> and then process it on the CPU. This is however too slow so I was thinking about moving the processing to the GPU. </p> <p>The simplest setup to do this I could think of is to display a simple white quad that takes up the entire viewport in an orthogonal projection and then write the image processing bit as a fragment shader. This will allow many instances of the processing to run in parallel as well as to access any pixel of the texture it requires for the processing.</p> <p>Is this a viable course of action? is it common to do things this way? Is there maybe a better way to do it?</p>
[ { "answer_id": 436080, "author": "Corey Downie", "author_id": 44861, "author_profile": "https://Stackoverflow.com/users/44861", "pm_score": 2, "selected": true, "text": "Private Sub radGrid_ItemCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles R...
2009/01/08
[ "https://Stackoverflow.com/questions/423663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9611/" ]
423,673
<p>I've got m2eclipse plugin installed and there's no problem syncing compile time dependencies that appear in pom.xml.</p> <p>Now, I add JPA + Hibernate(or whatever) dependency that maven catches up just fine when doing <code>mvn jetty:run</code>.</p> <p>The problem is, Eclipse doesn't. So I don't get those extra .jars deployed on the referenced tomcat when I launch the web app from eclipse.</p> <p>Is there a way to add this kind of web runtime dependencies to Eclipse? Don't really like the idea of manually editing org.eclipse.wst.common.component.</p>
[ { "answer_id": 423683, "author": "Beau Simensen", "author_id": 50453, "author_profile": "https://Stackoverflow.com/users/50453", "pm_score": 4, "selected": true, "text": "mvn clean install eclipse:clean eclipse:eclipse eclipse:m2eclipse\n <build>\n <plugins>\n <plugin>\n <groupI...
2009/01/08
[ "https://Stackoverflow.com/questions/423673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15187/" ]
423,677
<p>I am using the following code </p> <p><strong>--- EDIT @annakata :</strong> Adding the complete code</p> <pre><code>&lt;HTML&gt; &lt;HEAD&gt; &lt;TITLE&gt; New Document &lt;/TITLE&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;table id="additionalContactsTable" name="additionalContactsTable" width="100%" &gt; &lt;thead&gt; &lt;tr&gt; &lt;th style="text-align: center" class="Ntablerow1RightDark" width="25%"&gt;&lt;b&gt;Last&lt;/b&gt; &lt;/th&gt; &lt;th style="text-align: center" class="Ntablerow1RightDark" width="25%"&gt;&lt;b&gt;First&lt;/b&gt; &lt;/th&gt; &lt;th style="text-align: center" class="Ntablerow1RightDark" width="25%"&gt;&lt;b&gt;Middle&lt;/b&gt; &lt;/th&gt; &lt;th style="text-align: center" class="Ntablerow1RightDark" width="25%"&gt;&lt;b&gt;Email&lt;/b&gt; &lt;/th&gt; &lt;tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="NcontextlabelboldNormal" height="24"&gt; &lt;input maxlength="256" type="text" name="additionalContact" style="width: 90%;" value="aaaaaaaaaaa aaaaaaaaaaaaaaaaaaa aaaaaaaa aaaaaaaaaaaa aaaaa aaaaaaaaaaaaaaa" &gt; &lt;/td&gt; &lt;td class="NcontextlabelboldNormal" height="24"&gt; &lt;input maxlength="256" type="text" name="additionalContact" style="width: 90%;" value="aaaaaaaaaaaaaaaaaaaaaaaaaa" &gt; &lt;/td&gt; &lt;td class="NcontextlabelboldNormal" height="24"&gt; &lt;input maxlength="256" type="text" name="additionalContact" style="width: 90%;" value="aaaaaaaaaaaa aaaaaaaa aaaaaaaaaab bbbbbbbb bbbbbbbbbbbbbbbb" &gt; &lt;/td&gt; &lt;td class="NcontextlabelboldNormal" height="24"&gt; &lt;input maxlength="256" type="text" name="additionalContact" style="width: 90%;" value="aaaaaaaa aaaaaa aaaaaaa aaaaa" &gt; &lt;/td&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre> <p>The problem arises when the user enters a large text, the text box expands and table is distorted. If I put size="30" in there the expansion problem is fixed but on different resolutions, the structure behaves diffferently.</p> <p>Any fixes or wok around to achieve the desired gracefully ?</p>
[ { "answer_id": 423700, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 2, "selected": true, "text": "<div> em px width: expression(this.parentNode.offsetWidth*0.9); <style>\n/* table method */\ntable {width: 100%;}\nth {wid...
2009/01/08
[ "https://Stackoverflow.com/questions/423677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11614/" ]
423,678
<p>I'm just starting out using Ruby and I've written a bit of code to do basic parsing of a CSV file (Line is a basic class, omitted for brevity):</p> <pre><code>class File def each_csv each do |line| yield line.split(",") end end end lines = Array.new File.open("some.csv") do |file| file.each_csv do |csv| lines &lt;&lt; Line.new(:field1 =&gt; csv[0], :field2 =&gt; csv[1]) end end </code></pre> <p>I have a feeling I would be better off using <code>collect</code> somehow rather than pushing each <code>Line</code> onto the array but I can't work out how to do it.</p> <p>Can anyone show me how to do it or is it perfectly fine as it is?</p> <p><strong>Edit:</strong> I should have made it clear that I'm not actually going to use this code in production, it's more to get used to the constructs of the language. It is still useful to know there are libraries to do this properly though.</p>
[ { "answer_id": 423748, "author": "georg", "author_id": 3748, "author_profile": "https://Stackoverflow.com/users/3748", "pm_score": 2, "selected": false, "text": "def csv_to_array(file_location)\n csv = CSV::parse(File.open(file_location, 'r') {|f| f.read })\n fields = csv.shift\n csv....
2009/01/08
[ "https://Stackoverflow.com/questions/423678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6369/" ]
423,679
<p>I am using Kohana and just found this piece of code in their autoloading method</p> <pre><code> // Class extension to be evaluated $extension = 'class '.$class.' extends '.$class.'_Core { }'; // Start class analysis $core = new ReflectionClass($class.'_Core'); if ($core-&gt;isAbstract()) { // Make the extension abstract $extension = 'abstract '.$extension; } // Transparent class extensions are handled using eval. This is // a disgusting hack, but it gets the job done. eval($extension); </code></pre> <p>basically what it does is when I am referring to a class that doesn't exist (through object instantiation, calling class_exists() etc.), Kohana will create a class (eg. Foo) that extends a library class that follows certain naming convention (eg. Foo_Core). just being curious, is there any way to do something similar but without the use of eval?</p>
[ { "answer_id": 423695, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 1, "selected": false, "text": "eval()" }, { "answer_id": 423708, "author": "Beau Simensen", "author_id": 50453, "author_profile": "https...
2009/01/08
[ "https://Stackoverflow.com/questions/423679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5742/" ]
423,693
<p>My pages contain German characters and I have typed the text in between the HTML tag, but the browser views some characters differently. Do I need to include anything in HTML to properly display German characters?</p> <pre><code>&lt;label&gt; ausgefüllt &lt;/label&gt; </code></pre>
[ { "answer_id": 423709, "author": "Karsten", "author_id": 28144, "author_profile": "https://Stackoverflow.com/users/28144", "pm_score": 5, "selected": false, "text": "<META HTTP-EQUIV=\"content-type\" CONTENT=\"text/html; charset=utf-8\">\n <?php header('Content-Type: text/html; charset=u...
2009/01/08
[ "https://Stackoverflow.com/questions/423693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44984/" ]
423,704
<p>I need to create a data transfer object, which I will use for storing the records retrieved from database. In this data transfer object, I need to declare a numeric field. For that which one is better - <strong>int</strong> or <strong>Integer</strong></p> <p>If I am defining the field as Integer, will there be any performance impact because of 'Integer' type if I am going to retrieve more than 2000 records from DB!?</p> <p>Thanks in advance.</p>
[ { "answer_id": 423716, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": false, "text": "Integer int" }, { "answer_id": 423718, "author": "Adeel Ansari", "author_id": 42769, "author_profile": "ht...
2009/01/08
[ "https://Stackoverflow.com/questions/423704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42372/" ]
423,710
<p>How to return more than one variable from a function in Python?</p>
[ { "answer_id": 423712, "author": "ConcernedOfTunbridgeWells", "author_id": 15401, "author_profile": "https://Stackoverflow.com/users/15401", "pm_score": 3, "selected": false, "text": "def foo (a):\n x=a\n y=a*2\n return (x,y)\n" }, { "answer_id": 423722, "author": "C...
2009/01/08
[ "https://Stackoverflow.com/questions/423710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46646/" ]
423,728
<p>I am struggling with something that I think should be easily (ish). I have a windows form and a flowgridlayout panel at the bottom of the form. Inside this form I dynamically populate it with X number of User Controls. The controls are all the same type.</p> <p>The goal is when the user hoovers the mouse over the user control it opens another form and positions it where the mouse is. When mouse leaves the form the opened form disappears.</p> <p>This almost works great. The problem is when the User Control has anything like a label or text box inside it. It is considered to have left the UC so the form disappears.</p> <p>My thought was then to use the X and Y to tell if it is inside the UC but I can not figure this out.</p> <p>Can I ask:</p> <p>1) What is the best approach to this? 2) How can I code it, as the UC's are dynamic I can not know exactly where they will be.</p> <p>Thanks</p> <p><strong>EDIT</strong></p> <p>I am trying to figure out the mouse pointers but not getting there. The code below is within the UC SmallTagBox_MouseLeave event:</p> <pre><code> Point loc = this.Location; Point p = this.PointToScreen(this.Location); Point p2 = this.PointToScreen(this.Parent.Location); Point ms = MousePosition; Rectangle screenBounds = new Rectangle(this.PointToScreen(this.Location), this.Size); if (!screenBounds.Contains(ms)) { thw.Close(); thw = null; } </code></pre> <ul> <li>loc {X = 275 Y = 3} System.Drawing.Point</li> <li>p {X = 808 Y = 908} System.Drawing.Point</li> <li>p {X = 808 Y = 908} System.Drawing.Point</li> <li>p2 {X = 545 Y = 1542} System.Drawing.Point</li> <li>ms {X = 574 Y = 914} System.Drawing.Point</li> <li>screenBounds {X = 808 Y = 908 Width = 62 Height = 29} System.Drawing.Rectangle</li> </ul> <p>I do not understand how p2 (its parent) can have a greater Y value relative to the screen.</p>
[ { "answer_id": 423734, "author": "lc.", "author_id": 44853, "author_profile": "https://Stackoverflow.com/users/44853", "pm_score": 0, "selected": false, "text": "MouseLeave MouseEnter MouseLeave MouseLeave MouseEnter" }, { "answer_id": 423747, "author": "Grzenio", "author...
2009/01/08
[ "https://Stackoverflow.com/questions/423728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6486/" ]
423,730
<p>I would like to pass a COM method as a function argument but I get this error (Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86):</p> <p>error C3867: 'IDispatch::GetTypeInfoCount': function call missing argument list; use '&amp;IDispatch::GetTypeInfoCount' to create a pointer to member</p> <p>What am I missing?</p> <p>Thank you very much.</p> <pre><code>#include &lt;atlbase.h&gt; void update( HRESULT(*com_uint_getter)(UINT*), UINT&amp; u ) { UINT tmp; if ( S_OK == com_uint_getter( &amp;tmp ) ) { u = tmp; } } // only for compile purpose, it will not work at runtime int main(int, char*[]) { // I choose IDispatch::GetTypeInfoCount just for the sake of exemplification CComPtr&lt; IDispatch &gt; ptr; UINT u; update( ptr-&gt;GetTypeInfoCount, u ); return 0; } </code></pre>
[ { "answer_id": 425595, "author": "Joel", "author_id": 46852, "author_profile": "https://Stackoverflow.com/users/46852", "pm_score": 1, "selected": false, "text": "#include <atlbase.h>\n#include <boost/function.hpp>\n#include <boost/bind.hpp>\n\nvoid update( boost::function<HRESULT (UINT*...
2009/01/08
[ "https://Stackoverflow.com/questions/423730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15485/" ]
423,739
<p>Been playing a lot with Boost.Asio of late. I like the library a lot since it offers a fantastic way to squeeze performance out of today's multicore systems.</p> <p>A question I have asked myself a few times, and I thought worth throwing out there regards object lifespan / ownership when making async calls with Asio.</p> <p>The problem I've come accross repeatedly is that you quite often have to "expire" an object that still has async callbacks pending against it. If that object goes out of scope before the callback is invoked things inevitably go bang.</p> <p>To combat this I've taken to using the <code>boost::enable_shared_from_this</code> template as a base class for most asio based classes. This works OK but it's a little burdensome: usually this also means protecting the constructor and adding a factory method to the class to ensure that all instances are created inside a shared_ptr.</p> <p>I just wanted to know how other people had tackled this problem. Am I going about this the best way? Or have I got my Asio.Foo all wrong?</p> <p>Discuss... :)</p>
[ { "answer_id": 425611, "author": "Head Geek", "author_id": 12193, "author_profile": "https://Stackoverflow.com/users/12193", "pm_score": 1, "selected": false, "text": "interrupt" }, { "answer_id": 988030, "author": "user121826", "author_id": 121826, "author_profile": ...
2009/01/08
[ "https://Stackoverflow.com/questions/423739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/912/" ]
423,753
<p>RIM has released a new Blackberry JDE4.7 after releasing the Blackberry Storm. Does the Blackberry storm support programs created using the previous versions? I've heard there have been a lot of changes in this version compared to the old ones. And there have been complaints about Storm having many bugs.</p> <p>Should I use 4.7 or keep using the older JDE?</p> <p>Thanks.</p>
[ { "answer_id": 433155, "author": "Ed Marty", "author_id": 36007, "author_profile": "https://Stackoverflow.com/users/36007", "pm_score": 1, "selected": false, "text": "moveFocus(int x, int y)" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/423753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46297/" ]
423,761
<p>On a dual quad-core <a href="http://msdn.microsoft.com/en-us/library/ms683213%28VS.85%29.aspx" rel="nofollow noreferrer">GetProcessAffinityMask</a> (or the dialog from "Set affinity" in taskman.exe) will report eight logical processors. How do I find out which logical processor is on which physical processor? Especially: which logical processors are on the same physical processor?</p> <p><strong>EDIT:</strong> If it is not possible to do this programmatically, do anyone just know what the normal mapping is? Are the first four on the first processor and the second four on the second or are the odd numbered on the first and the even numbered on the second?</p>
[ { "answer_id": 423785, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 4, "selected": true, "text": "Win32_Processor" }, { "answer_id": 7324224, "author": "Sandy Soil", "author_id": 448442, "author_profile": ...
2009/01/08
[ "https://Stackoverflow.com/questions/423761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5542/" ]
423,790
<p>I need C# string search algorithm which can match multiple occurance of pattern. For example, if pattern is 'AA' and string is 'BAAABBB' Regex produce match result Index = 1, but I need result Index = 1,2. Can I force Regex to give such result? </p>
[ { "answer_id": 423851, "author": "Sani Singh Huttunen", "author_id": 26742, "author_profile": "https://Stackoverflow.com/users/26742", "pm_score": 2, "selected": false, "text": "Dim rx As Regex = New Regex(\"(?=AA)\")\nDim mc As MatchCollection = rx.Matches(\"BAAABBB\")\n Regex rx = new ...
2009/01/08
[ "https://Stackoverflow.com/questions/423790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
423,792
<p>I am developing a cocoa application which downloads firmware to the device. The progress of downloading is showed using NSProgressIndicator. I call the <code>-incrementBy:</code> method of NSProgressIndicator after DeviceRequestTO method in a while loop. But the progress indicator gets updated only after the entire firmware is written to the device. It shows 100% completion at one go itself. So I added the <code>-displayIfNeeded</code> method of NSView class. Now it shows progress smoothly but this too occurs after the firmware download is complete. How can I achieve the progress indication and write operation simultaneously?</p> <p>Following is the code:</p> <pre><code>while(1) { int result = (*dev)-&gt;DeviceRequestTO(dev, &amp;request); printf("\nBlocks Written Successfully: %d",DfuBlockCnt); [refToSelf performSelectorOnMainThread:@selector(notifyContent) withObject:nil waitUntilDone:NO]; } //In main thread - (void)notifyContent{ [dnldIndicator incrementBy:1]; [self displayIfNeeded]; } </code></pre>
[ { "answer_id": 423964, "author": "Peter Hosey", "author_id": 30461, "author_profile": "https://Stackoverflow.com/users/30461", "pm_score": 3, "selected": false, "text": "setNeedsDisplay: displayIfNeeded display setNeedsDisplay:YES displayIfNeeded setNeedsDisplay: displayIfNeeded" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/423792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39270/" ]
423,797
<p>I need to know how much physical memory a windows machine has, using Perl.</p> <p>I've tried using <a href="http://search.cpan.org/dist/Win32-SystemInfo" rel="nofollow noreferrer">Win32::SystemInfo</a>. However this module states the following caveat:</p> <blockquote> <p>On Intel x86 computers with more than 2 GB and less than 4 GB of memory, the MemoryStatus function will always return 2 GB for TotalPhys. Similarly, if the total available memory is between 2 and 4 GB, AvailPhys will be rounded down to 2 GB.</p> </blockquote> <p>So on a machine which has 2-4 GB of physical memory, I get a false answer.</p> <p>Is there a way to get the correct amount of physical memory? Perhaps another module? Or directly using <a href="http://search.cpan.org/dist/Win32-API" rel="nofollow noreferrer">Win32::API</a>?</p> <p>Edit: From the comments people gave here, it looks like the limitation is in the Win32 API , and not specific to <a href="http://search.cpan.org/dist/Win32-SystemInfo" rel="nofollow noreferrer">Win32::SystemInfo</a>. However, the OS <strong>does</strong> know <strong><em>exactly</em></strong> how much physical ram is available, so there must be a way to extract that information. If not in Perl then maybe in another language?</p>
[ { "answer_id": 427435, "author": "j_random_hacker", "author_id": 47984, "author_profile": "https://Stackoverflow.com/users/47984", "pm_score": 1, "selected": false, "text": "Win32::SystemInfo" }, { "answer_id": 431668, "author": "Jay", "author_id": 20840, "author_prof...
2009/01/08
[ "https://Stackoverflow.com/questions/423797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13523/" ]
423,808
<p>I need to create a Firebird Database programmatically using DBExpress. I have done this for SQL server, by first connecting to Master, then passing in the script for Create to a query, but with Firebird I have a little chicken and egg problem.</p>
[ { "answer_id": 423877, "author": "Birger", "author_id": 11485, "author_profile": "https://Stackoverflow.com/users/11485", "pm_score": 3, "selected": true, "text": "procedure TIBConnection.CreateDB;\n\nvar ASQLDatabaseHandle,\n ASQLTransactionHandle : pointer;\n CreateSQL : String;\...
2009/01/08
[ "https://Stackoverflow.com/questions/423808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22712/" ]
423,820
<p>Basically, I have been using both <code>Integer.Parse</code> and <a href="https://msdn.microsoft.com/en-us/library/s2dy91zy.aspx" rel="noreferrer">CInt</a> in most of my daily programming tasks, but I'm a little bit confused of what the difference is between the two.</p> <p>What is the difference between <code>Integer.Parse</code> and <code>CInt</code> in VB.NET?</p>
[ { "answer_id": 423910, "author": "Binary Worrier", "author_id": 18797, "author_profile": "https://Stackoverflow.com/users/18797", "pm_score": 6, "selected": true, "text": "CInt Integer.Parse CInt CInt Integer.Parse Integer.TryParse variant object CInt" }, { "answer_id": 423982, ...
2009/01/08
[ "https://Stackoverflow.com/questions/423820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48581/" ]
423,840
<p>Is there an equivalent of a SQL IN statement in LINQ to objects?</p>
[ { "answer_id": 423875, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "var desiredNames = new[] { \"Jon\", \"Marc\" };\n\nvar people = new[]\n{\n new { FirstName=\"Jon\", Surname=\"Skeet\" ...
2009/01/08
[ "https://Stackoverflow.com/questions/423840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5461/" ]
423,841
<p>I am generating some text to be shown on a web-site, and use <a href="http://msdn.microsoft.com/en-us/library/system.web.httputility.htmlencode.aspx" rel="nofollow noreferrer">HttpUtility.HtmlEncode</a> to ensure it will look correct. However, this method does not appear to encode the <a href="http://en.wikipedia.org/wiki/Mdash#Em_dash" rel="nofollow noreferrer">Em Dash</a> (it should convert it to "&mdash;"). </p> <p>I have come up with a solution, but I'm sure there is a better way of doing it - some library function or something.</p> <pre><code>sWebsiteText = _ "&lt;![CDATA[" &amp; _ HttpUtility.HtmlEncode(sSomeText) &amp; _ "]]&gt;" 'This is the bit which seems "hacky"' sWebsiteText = _ sWebsiteText.Replace(HttpUtility.HtmlDecode("&amp;#8211;"), "&amp;#8211;") </code></pre> <p>So my question is - how would you implement the "hacky" part?</p> <p>Many thanks,</p> <p>RB.</p>
[ { "answer_id": 423867, "author": "mouviciel", "author_id": 45249, "author_profile": "https://Stackoverflow.com/users/45249", "pm_score": 0, "selected": false, "text": "&#8212;" }, { "answer_id": 969159, "author": "Community", "author_id": -1, "author_profile": "https:...
2009/01/08
[ "https://Stackoverflow.com/questions/423841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15393/" ]
423,860
<pre><code>include('header.php'); $name = $_POST['name']; $score = $_POST['score']; $dept = $_POST['dept']; $MyDB-&gt;prep("INSERT INTO demo (`id`,`name`,`score`,`dept`, `date`) VALUES ('','$name','$score','$dept','$date')"); // Bind a value to our :id hook // Produces: SELECT * FROM demo_table WHERE id = '23' $MyDB-&gt;bind(':date', $date); // Run the query $MyDB-&gt;run(); header('Location:index.php'); exit; </code></pre> <p>The above code keeps giving me an issue with the redirect. The error is the following: </p> <blockquote> <p>Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/testygubbins/OO/test/header.php:15) in /Applications/MAMP/htdocs/testygubbins/OO/test/form.php on line 16.</p> </blockquote> <p>I am totally flummoxed by this. Does anyone know what I should be doing to make it work?</p> <p>EDIT</p> <p>header.php code:</p> <pre><code>&lt;?php include('class.user.php'); include('class.Connection.php'); $date = date('Y-m-j'); ?&gt; &lt;html&gt; &lt;head&gt; &lt;link rel=StyleSheet href="css/style.css" type="text/css" media=screen&gt; &lt;title&gt;Test&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="page"&gt; </code></pre>
[ { "answer_id": 423883, "author": "Gant", "author_id": 12460, "author_profile": "https://Stackoverflow.com/users/12460", "pm_score": 2, "selected": false, "text": "include('class.user.php');\ninclude('class.Connection.php');\n\n $date = date('Y-m-j');\n" }, { "answer_id": 4...
2009/01/08
[ "https://Stackoverflow.com/questions/423860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31677/" ]
423,865
<p>The data that I am sending to convertStringToDataSet function is </p> <pre><code> &lt;NewDataSet&gt;\r\n &lt;Table ID="Table1"&gt; \r\n &lt;PATNAME&gt;Doe,JaneN&lt;/PATNAME&gt;\r\n &lt;LEVEL&gt;175&lt;/LEVEL&gt;\r\n &lt;WHEN&gt;2007-09-13T23:00:00.0000000-05:00&lt;/WHEN&gt;\r\n &lt;NOTE&gt;New 180-day low -- ALERT: loss of 11.6 % in 123 days&lt;/NOTE&gt;\r\n &lt;IS_BAD&gt;32&lt;/IS_BAD&gt;\r\n &lt;NAME&gt;202a&lt;/NAME&gt;\r\n &lt;ID&gt;2459&lt;/ID&gt;\r\n &lt;LASTNAME&gt;Doe&lt;/LASTNAME&gt;\r\n &lt;FIRSTNAME&gt;Jane&lt;/FIRSTNAME&gt;\r\n &lt;MIDDLENAME&gt;N&lt;/MIDDLENAME&gt;\r\n &lt;/Table&gt;\r\n &lt;Table ID="Table2"&gt; \r\n &lt;PATNAME&gt;Face,SmileyE&lt;/PATNAME&gt;\r\n &lt;LEVEL&gt;124&lt;/LEVEL&gt;\r\n &lt;WHEN&gt;2007-10-16T23:00:00.0000000-05:00&lt;/WHEN&gt;\r\n &lt;NOTE&gt;New 180-day low -- ALERT: loss of 14.5 % in 86 days&lt;/NOTE&gt;\r\n &lt;IS_BAD&gt;32&lt;/IS_BAD&gt;\r\n &lt;NAME&gt;101b&lt;/NAME&gt;\r\n &lt;ID&gt;2736&lt;/ID&gt;\r\n &lt;LASTNAME&gt;Face&lt;/LASTNAME&gt;\r\n &lt;FIRSTNAME&gt;Smiley&lt;/FIRSTNAME&gt;\r\n &lt;MIDDLENAME&gt;E&lt;/MIDDLENAME&gt;\r\n &lt;/Table&gt;\r\n&lt;/NewDataSet&gt; </code></pre> <pre><code> private DataSet convertStringToDataSet(string xmlString) { // Search for datetime values of the format // --> 2004-08-22T00:00:00.0000000-05:00 string rp = @"(?\d{4}-\d{2}-\d{2})(?T\d{2}:\d{2}:\d{2}.\d{7}-)(?\d{2})(?:\d{2})"; // Replace UTC offset value string fixedString = Regex.Replace( xmlString, rp, new MatchEvaluator( getHourOffset ) ); DataSet dataSet = new DataSet(); StringReader stringReader = new StringReader( fixedString ); dataSet.ReadXml( stringReader ); return dataSet; } private static string getHourOffset( Match m ) { // Need to also account for Daylights Savings // Time when calculating UTC offset value string Date=m.Result( "${date}" ); DateTime dtLocal = DateTime.Parse( m.Result( "${date}" ) ); DateTime dtUTC = dtLocal.ToUniversalTime(); int hourLocalOffset = dtUTC.Hour - dtLocal.Hour; int hourServer = int.Parse( m.Result( "${hour}" ) ); string newHour = ( hourServer + ( hourLocalOffset - hourServer ) ).ToString( "0#" ); string retString = m.Result( "${date}" + "${time}" + newHour + "${last}" ); return retString; } </code></pre> <p>The Exception That I am getting The string was not recognized as a valid DateTime. There is a unknown word starting at index 2.</p>
[ { "answer_id": 423890, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 0, "selected": false, "text": "m.Result( \"${date}\" )\n" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/423865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
423,896
<p>I am getting to grips with Windows Azure. I usually use NInject as my IoC container in web apps. However, when trying to use it within an Azure web role I get a security exception (something to do with reflection permission).</p> <p>Has anyone used other IoC with Azure and had succcess?</p>
[ { "answer_id": 469133, "author": "Andrew Davey", "author_id": 7011, "author_profile": "https://Stackoverflow.com/users/7011", "pm_score": 2, "selected": false, "text": "var options = new KernelOptions\n{ \n UseReflectionBasedInjection = true\n}; \nvar kernel = new StandardKernel(optio...
2009/01/08
[ "https://Stackoverflow.com/questions/423896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7011/" ]
423,898
<p>There are enough resources on how to convert an expression tree into postfix notation, and it's not that hard.</p> <p>But I have to parse a postfix expression into an expression tree.</p> <p>The expression is:</p> <blockquote> <p>A 2 ^ 2 A * B * - B 2 ^ + A B - /</p> </blockquote> <p>I don't really have a clue on how to interpret the expression. Does someone has a clue on how to proces this?</p>
[ { "answer_id": 423905, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 7, "selected": true, "text": "// Add the following two using-directives to LINQPad:\n// System.Drawing\n// System.Drawing.Imaging\n\nstatic Bitmap _...
2009/01/08
[ "https://Stackoverflow.com/questions/423898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20261/" ]
423,921
<p>I have an xml template document that I need to load into an XmlDocument. eg</p> <pre><code>myXMLDocument.Load(myXMLFile); </code></pre> <p>However this is very slow as it loads in the dtd. I have tried both <code>"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"</code> and a local copy of the dtd. Both take more or less the same time. If I turn of loading the dtd by setting the resolver to null (for example), I then get errors such as <code>"Reference to undeclared entity 'nbsp'"</code> if the document contains these.</p> <p>I need to use an XmlDocument as I need to manipulate the DOM before outputting the document. How can I get round these problems?</p>
[ { "answer_id": 423946, "author": "Wolfwyrd", "author_id": 15570, "author_profile": "https://Stackoverflow.com/users/15570", "pm_score": -1, "selected": false, "text": "class DummyResolver : XmlUrlResolver \n{\n public override Uri ResolveUri (Uri baseUri, String relativeUri) \n {\n...
2009/01/08
[ "https://Stackoverflow.com/questions/423921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15233/" ]
423,924
<p>How to get Hibernate session inside a Hibernate Interceptor?</p> <p>I'm trying to use Hibernate to enforce data access by organization id transparently. I have set a global Filter to filter all queries by organization id. Now, I need to use an Entity interceptor to set Organizational Id on all Entities before Save/Update.</p> <p>The organization id comes from HttpSession</p> <p>I've set Organizational Id as a Filter property in Hibernate session which i want to retrieve inside my interceptor and use for all Inserts and Updates as well. The problem is i dont seem to have access to Session inside the Interceptor. Any workarounds for this?</p>
[ { "answer_id": 425660, "author": "Nicholas", "author_id": 43786, "author_profile": "https://Stackoverflow.com/users/43786", "pm_score": 2, "selected": false, "text": "org.hibernate.event.FlushEntityEventListener FlushEntityEventListener.onFlushEntity(FlushEntityEvent event)\nEntityEvent ...
2009/01/08
[ "https://Stackoverflow.com/questions/423924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51402/" ]
423,925
<p>Does anyone know why, using SQLServer 2005</p> <pre><code>SELECT CONVERT(DECIMAL(30,15),146804871.212533)/CONVERT(DECIMAL (38,9),12499999.9999) </code></pre> <p>gives me 11.74438969709659,</p> <p>but when I increase the decimal places on the denominator to 15, I get a less accurate answer:</p> <pre><code>SELECT CONVERT(DECIMAL(30,15),146804871.212533)/CONVERT(DECIMAL (38,15),12499999.9999) </code></pre> <p>give me 11.74438969</p>
[ { "answer_id": 424015, "author": "cmsjr", "author_id": 23114, "author_profile": "https://Stackoverflow.com/users/23114", "pm_score": 2, "selected": false, "text": "select CONVERT(DECIMAL(38,36),146804871.212533 / 12499999.9999)\n" }, { "answer_id": 424052, "author": "gbn", ...
2009/01/08
[ "https://Stackoverflow.com/questions/423925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52881/" ]
423,950
<p>Well, I have an image that I would like to put as a background to a button (or something clicable). The problem is that this image is round, so I need to show this image, without any borders, etc.</p> <p>The JComponent that holds this button has a custom background, so the button really needs to only show the image.</p> <p>After searching Google, I couldn't manage to do so. I have tried all the following, but with no luck:</p> <pre><code>button.setBorderPainted(false); button.setContentAreaFilled(false); button.setOpaque(true); </code></pre> <p>And after I paint the icon at the background, the button paints it, but holds an ugly gray background with borders, etc. I have also tried to use a JLabel and a JButton. And to paint an ImageIcon at it, but if the user resizes or minimizes the window, the icons disappear!</p> <p>How can I fix this?</p> <p>I just need to paint and round an image to a JComponent and listen for clicks at it...</p>
[ { "answer_id": 423960, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 0, "selected": false, "text": "button.setOpaque(false);\n" }, { "answer_id": 424081, "author": "VonC", "author_id": 6309, "author_profi...
2009/01/08
[ "https://Stackoverflow.com/questions/423950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37190/" ]
423,961
<p>I have some code that uses the Oracle function add_months to increment a Date by X number of months.</p> <p>I now need to re-implement the same logic in a C / C++ function. For reasons I don't want/need to go into I can't simply issue a query to oracle to get the new date.</p> <p>Does anyone know of a simple and reliable way of adding X number of months to a time_t? Some examples of the types of calculations are shown below.</p> <p>30/01/2009 + 1 month = 28/02/2009<br> 31/01/2009 + 1 month = 28/02/2009<br> 27/02/2009 + 1 month = 27/03/2009<br> 28/02/2009 + 1 month = 31/03/2009<br> 31/01/2009 + 50 months = 31/03/2013</p>
[ { "answer_id": 423977, "author": "MSalters", "author_id": 15416, "author_profile": "https://Stackoverflow.com/users/15416", "pm_score": 3, "selected": false, "text": "time_t struct tm" }, { "answer_id": 423995, "author": "Pieter", "author_id": 5822, "author_profile": ...
2009/01/08
[ "https://Stackoverflow.com/questions/423961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52888/" ]
423,994
<p>Is there any tricky way to use Java reserved words as variable, method, class, interface, package, or enum constant names?</p>
[ { "answer_id": 423999, "author": "Miserable Variable", "author_id": 18573, "author_profile": "https://Stackoverflow.com/users/18573", "pm_score": 2, "selected": false, "text": "class cl4ss {\n String r3turn() {\n return \"but why?\";\n }\n}\n" }, { "answer_id": 424014, "...
2009/01/08
[ "https://Stackoverflow.com/questions/423994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
424,010
<p>I've created a user scoped setting with the type "System.Collections.Specialized.StringDictionary". Whenever I open the local settings, I can see it in the config, but it's empty.</p> <p>I have other user settings that save correctly, but this dictionary doesn't seem to be saving at all.</p> <p>Is there something I need to do in order to get a dictionary to save?</p>
[ { "answer_id": 424030, "author": "lc.", "author_id": 44853, "author_profile": "https://Stackoverflow.com/users/44853", "pm_score": 4, "selected": false, "text": "Dictionary [SettingSerializeAs(SettingsSerializeAs.Binary)]" }, { "answer_id": 424120, "author": "Marc Gravell", ...
2009/01/08
[ "https://Stackoverflow.com/questions/424010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
424,013
<p>I'm interested in knowing what is "best" free/OSS compiler for MIPS code, GCC or LLVM, or is there anything even better than those?</p> <p>I'm interested in knowing more about fast and memory constrained generated Assembly code than code size.</p> <p>In other words, does llvm-opt do the job better than gcc -O3?</p>
[ { "answer_id": 1161250, "author": "old_timer", "author_id": 16007, "author_profile": "https://Stackoverflow.com/users/16007", "pm_score": 1, "selected": false, "text": "void dummy ( unsigned int );\nvoid dowait ( void )\n{\n unsigned int ra;\n for(ra=0x80000;ra;ra--) dummy(ra);\n}\...
2009/01/08
[ "https://Stackoverflow.com/questions/424013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51560/" ]
424,016
<p>I have a WPF App which is grinding to a halt after running out of memory...<br> It is basically a TreeView displaying nodes, which are instances of Linq To Sql OR Generated class ICTemplates.Segment. There around 20 tables indirectly linked via associations to this class in the OR designer. </p> <pre><code>&lt;TreeView Grid.Column="0" x:Name="tvwSegments" ItemsSource="{Binding}" SelectedItemChanged="OnNewSegmentSelected"/&gt; &lt;HierarchicalDataTemplate DataType="{x:Type local:Segment}" ItemsSource="{Binding Path=Children}"&gt; ... // code behind, set the data context based on user-input (Site, Id) KeeperOfControls.DataContext = from segment in tblSegments where segment.site == iTemplateSite &amp;&amp; segment.id == iTemplateSid select segment; </code></pre> <p>I've added an explicit property called Children to the segment class which looks up another table with parent-child records.</p> <pre><code>public IEnumerable&lt;Segment&gt; Children { get { System1ConfigDataContext dc = new System1ConfigDataContext(); return from link in this.ChildLinks join segment in dc.Segments on new { Site = link.ChildSite, ID = link.ChildSID } equals new { Site = segment.site, ID = segment.id } select segment; } } </code></pre> <p>The rest of it is data binding coupled with data templates to display each Segment as a set of UI Controls. </p> <p>I'm pretty certain that the children are being loaded on-demand (when I expand the parent) going by the response time. When I expand a node with around <strong>70</strong> children, it takes a while before the children are loaded (Task manager shows Mem Usage as 1000000K!). If I expand the next node with around 50 children, BOOM! OutOfMemoryException</p> <p>I ran the VS Profiler to dig deeper and here are the results</p> <p><a href="http://picasaweb.google.com/lh/photo/mfh-GTeeAcOAJOqOfHQ9eg?feat=directlink" rel="nofollow noreferrer">Summary Page</a> <a href="http://picasaweb.google.com/lh/photo/YRT7jirnf7LRP1OLG1y3uA?feat=directlink" rel="nofollow noreferrer">Object Lifetimes</a> <a href="http://picasaweb.google.com/lh/photo/s20N3uYqwV6Qmp6oLFUccA?feat=directlink" rel="nofollow noreferrer">Allocation</a></p> <p>The top 3 are Action, DeferredSourceFactory.DeferredSource and EntitySet (all .Net/LINQ classes). The only user-classes are Segment[] and Segment come in at #9 an #10.</p> <p>I can't think of a lead to pursue.. What could be the reason ? </p>
[ { "answer_id": 427331, "author": "Ali Ersöz", "author_id": 4215, "author_profile": "https://Stackoverflow.com/users/4215", "pm_score": 0, "selected": false, "text": "public IEnumerable<Segment> Children\n{\n get\n {\n System1ConfigDataContext dc = new System1ConfigDataContext();\n ...
2009/01/08
[ "https://Stackoverflow.com/questions/424016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
424,018
<p>I'm trying to add a custom property which is a guid, but it gives me this error:</p> <blockquote> <p>System.InvalidCastException: Failed to convert parameter value from a String to a Guid. ---> System.InvalidCastException: Invalid cast from 'System.String' to 'System.Guid'.</p> </blockquote> <p>I specify this in the config:</p> <pre><code>&lt;parameter&gt; &lt;parameterName value="@id" /&gt; &lt;dbType value="Guid" /&gt; &lt;layout type="log4net.Layout.PatternLayout"&gt; &lt;conversionPattern value="%X{id}" /&gt; &lt;/layout&gt; &lt;/parameter&gt; </code></pre> <p>The actual code (snippet) i use is this:</p> <pre><code> Guid guid = Guid.NewGuid(); if (defaultLogger.IsEnabledFor(level)) { var loggingEvent = new LoggingEvent(ThisDeclaringType, defaultLogger.Repository, defaultLogger.Name, level, message, exception); loggingEvent.Properties["Id"] = guid; </code></pre> <p>Any help please? :) The id field in the database is defined as a uniqueidentifier NOT NULL, but it does not have the primary key contraint.</p>
[ { "answer_id": 424171, "author": "Claus Thomsen", "author_id": 15555, "author_profile": "https://Stackoverflow.com/users/15555", "pm_score": 6, "selected": true, "text": "<parameter>\n<parameterName value=\"@Oid\" />\n<dbType value=\"Guid\" />\n<layout type=\"log4net.Layout.RawPropertyLa...
2009/01/08
[ "https://Stackoverflow.com/questions/424018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11619/" ]
424,020
<p>I have the following RegEx</p> <pre><code>id=(.*?) | id="(.*?)" </code></pre> <p>The reason for this is I am trying to replace Ids from the browsers DOM using JavaScript. IE, however strips quotes from element atributes as it appears not to require them in the DOM</p> <p>The problem I have is that the backrefererences from each alternate statement are in separate groups ($1 and $2) as the match is only one OR the other can I return both the backreference as a single backreference?</p> <p>EDIT:</p> <pre><code>&lt;div id="test1" /&gt;&lt;div id=test2 /&gt; </code></pre> <p>will match as follows</p> <pre><code> match | $1 | $2 -------------------------------- id="test1" | test1 | id=test2 | | test2 </code></pre> <p>I just want both backreferences to be added to $1</p>
[ { "answer_id": 424171, "author": "Claus Thomsen", "author_id": 15555, "author_profile": "https://Stackoverflow.com/users/15555", "pm_score": 6, "selected": true, "text": "<parameter>\n<parameterName value=\"@Oid\" />\n<dbType value=\"Guid\" />\n<layout type=\"log4net.Layout.RawPropertyLa...
2009/01/08
[ "https://Stackoverflow.com/questions/424020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32021/" ]
424,025
<p>In my struts 2.0.12 application I'm trying to use s:datetimepicker but it does not render.</p> <p>Firebug error: dojo is not defined on dojo.require("dojo.widget.DatePicker");</p> <p>My jsp page </p> <pre><code> &lt;%@taglib prefix="s" uri="/struts-tags" %&gt; . . &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;s:head theme="ajax" debug="true"/&gt; . . &lt;/head&gt; &lt;body&gt; . . &lt;s:datetimepicker name="dataInizioRicerca" label="data inizio ricerca (yyyy-MM-dd)" displayFormat="yyyy-MM-dd"/&gt; . . &lt;/body&gt; </code></pre> <p>What's wrong? Did I miss something?</p>
[ { "answer_id": 495638, "author": "kazanaki", "author_id": 60593, "author_profile": "https://Stackoverflow.com/users/60593", "pm_score": 1, "selected": false, "text": "<head>\n[..other stuff]\n<s:head/> <!-- Struts 2 Ajax/Dojo needed for calendar -->\n</head>" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/424025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
424,032
<p>We have a (pure native C++) .DLL that is build by VS. As clients we have some native C++ applications and a .Net-Wrapper around this DLL written in C++/CLI. Finally there are some client applications for the .Net-Wrapper written in C#.</p> <p>My problem is that the native.dll must be distributed in a different way than the .Net world works and the VS does not keeps track of that DLL. So to let all my C# Apps work correctly I have to copy it to each executable directory or put it somwhere in %PATH% (which I would avoid on developer computers since they may want to start different apps with different versions of the DLL). Even bigger problems occur if there are UserControls that reference the Wrapper-DLL: You have to copy the DLL to VS's directory or again to %PATH%. But the worst case occurs with our Translator tool. This tool keeps track of .Net-Assemblies and packs them into Translator-packages that can be send to an external translator. As far as I know there is no way to put the native .DLL into that package!</p> <p>So I plan to link the native DLL statically into the .Net-Wrapper which would solve my problems. But for our Native applications this native DLL must still be a DLL.</p> <p>So I have two options:</p> <ul> <li>Make two projects of that (one that generates a static library; and one that creates a dynamic one => I try to avoid this)</li> <li>Find a solution to link DLLs statically</li> <li>Find a way to let VS generate two outputs from one project</li> </ul>
[ { "answer_id": 26936274, "author": "kiriloff", "author_id": 1141493, "author_profile": "https://Stackoverflow.com/users/1141493", "pm_score": 1, "selected": false, "text": "dllexport" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/424032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44086/" ]
424,037
<p>I wanted to set <code>.htaccess</code> to rewrite:</p> <pre><code>example.com/bla/info/ </code></pre> <p>to</p> <pre><code>example.com/info/index.php?q=bla example.com/bla/info/txt/ </code></pre> <p>to</p> <pre><code>example.com/info/index.php?q=bla&amp;t=txt </code></pre> <p>I wanted the browser still to display:</p> <pre><code>example.com/bla/info/txt/ </code></pre> <p>I didn't want rewrite in the level 2 rewrites, like:</p> <pre><code>example.com/bla/xxx/ </code></pre> <p>or</p> <pre><code>example.com/ccc/zzz/aaa/ </code></pre> <p>but</p> <pre><code>example.com/silly/info/ </code></pre> <p>would work as well as</p> <pre><code>example.com/strange/info/mytxt/ </code></pre> <p>Did this make sense?</p> <p>Any help?</p>
[ { "answer_id": 26936274, "author": "kiriloff", "author_id": 1141493, "author_profile": "https://Stackoverflow.com/users/1141493", "pm_score": 1, "selected": false, "text": "dllexport" } ]
2009/01/08
[ "https://Stackoverflow.com/questions/424037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52730/" ]
424,071
<p>How can I print a plain list of all files that were part of a given commit?</p> <p>Although the following lists the files, it also includes unwanted diff information for each:</p> <pre><code>git show a303aa90779efdd2f6b9d90693e2cbbbe4613c1d </code></pre>
[ { "answer_id": 424084, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 8, "selected": false, "text": "gitk git show --name-only <sha>" }, { "answer_id": 424142, "author": "Ryan McGeary", "author_id": 8985, ...
2009/01/08
[ "https://Stackoverflow.com/questions/424071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11123/" ]