qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
411,572
<p>Given a method <code>DoSomething</code> that takes a (parameterless) function and handles it in some way. Is there a better way to create the "overloads" for functions with parameters than the snippet below?</p> <pre><code>public static TResult DoSomething&lt;TResult&gt;(Func&lt;TResult&gt; func) { //call func() and do something else } public static TResult DoSomething&lt;T0, TResult&gt;( Func&lt;T0, TResult&gt; func, T0 arg0) { return DoSomething(() =&gt; func(arg0)); } public static TResult DoSomething&lt;T0, T1, TResult&gt;( Func&lt;T0, T1, TResult&gt; func, T0 arg0, T1 arg1) { return DoSomething(arg =&gt; func(arg, arg1), arg0); } public static TResult DoSomething&lt;T0, T1, T2, TResult&gt;( Func&lt;T0, T1, T2, TResult&gt; func, T0 arg0, T1 arg1, T2 arg2) { return DoSomething(arg =&gt; func(arg, arg1, arg2), arg0); } </code></pre>
[ { "answer_id": 411586, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": true, "text": "public static Func<TResult> Apply<TResult, TArg> (Func<TArg, TResult> func, TArg arg)\n{\n return () => func(arg);\n}\...
2009/01/04
[ "https://Stackoverflow.com/questions/411572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48722/" ]
411,575
<p>Given a table such as:</p> <pre><code>CREATE TABLE dbo.MyTestData (testdata varchar(50) NOT NULL) ALTER TABLE dbo.MyTestData WITH NOCHECK ADD CONSTRAINT [PK_MyTestData] PRIMARY KEY CLUSTERED (testdata) </code></pre> <p>And given that we want a unique list of 'testdata' when we are done gathering items to be added from a list of external data with known duplicates... When performing an insert stored procedure should the procedure be written to test for existence or should it just allow for error? What's the most common practice? I've always performed the test for existence but was debating this last night... </p> <pre><code>CREATE PROCEDURE dbo.dmsInsertTestData @ptestdata VarChar(50) AS SET NOCOUNT ON IF NOT EXISTS(SELECT testdata FROM dbo.MyTestData WHERE testdata=@ptestdata) BEGIN INSERT INTO dbo.MyTestData (testdata ) VALUES (@ptestdata) END RETURN 0 </code></pre> <p>or just capture/ignore PK violation errors when executing this one?</p> <pre><code>CREATE PROCEDURE dbo.dmsInsertTestData @ptestdata VarChar(50) AS SET NOCOUNT ON INSERT INTO dbo.MyTestData (testdata ) VALUES (@ptestdata) RETURN 0 </code></pre>
[ { "answer_id": 411643, "author": "D'Arcy Rittich", "author_id": 39430, "author_profile": "https://Stackoverflow.com/users/39430", "pm_score": 3, "selected": true, "text": "INSERT INTO dbo.MyTestData (testdata ) VALUES (@ptestdata)\nWHERE NOT EXISTS(SELECT 1 FROM dbo.MyTestData WHERE test...
2009/01/04
[ "https://Stackoverflow.com/questions/411575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35696/" ]
411,579
<p>Take the method System.Windows.Forms.Control.Invoke(Delegate method)</p> <p>Why does this give a compile time error:</p> <pre><code>string str = "woop"; Invoke(() =&gt; this.Text = str); // Error: Cannot convert lambda expression to type 'System.Delegate' // because it is not a delegate type </code></pre> <p>Yet this works fine:</p> <pre><code>string str = "woop"; Invoke((Action)(() =&gt; this.Text = str)); </code></pre> <p>When the method expects a plain Delegate?</p>
[ { "answer_id": 411597, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 8, "selected": true, "text": "public delegate void Action1();\npublic delegate void Action2();\n\n...\n\nDelegate x = () => Console.WriteLine(\"hi\");\...
2009/01/04
[ "https://Stackoverflow.com/questions/411579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/82/" ]
411,592
<p>I have a <code>StreamReader</code> object that I initialized with a stream, now I want to save this stream to disk (the stream may be a <code>.gif</code> or <code>.jpg</code> or <code>.pdf</code>).</p> <p>Existing Code:</p> <pre><code>StreamReader sr = new StreamReader(myOtherObject.InputStream); </code></pre> <ol> <li>I need to save this to disk (I have the filename).</li> <li>In the future I may want to store this to SQL Server.</li> </ol> <p>I have the encoding type also, which I will need if I store it to SQL Server, correct?</p>
[ { "answer_id": 411605, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 9, "selected": false, "text": "StreamReader StreamReader StreamReader /// <summary>\n/// Copies the contents of input to output. Doesn't close either s...
2009/01/04
[ "https://Stackoverflow.com/questions/411592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50700/" ]
411,628
<p>I am trying to learn ASP.NET MVC and I hit this problem: I have a "view product details" form that I want to reuse as an add/edit form. (When you look at the product details, if you have the rights to do it an Edit link should appear; it should redisplay the same form, but with the textbox fields enabled this time.)</p> <p>Right now the Details view looks something like this:</p> <pre><code>&lt;% var product = ViewData.Model; %&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Name&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;%= Html.TextBox("Name", product.Name, new { size = "50", disabled = "disabled"})%&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>Is there a way I could reuse it without putting too much logic in the view? For example, I will need to remove the <code>disabled = "disabled"</code> part (but the <code>size</code> part needs to stay there), to put everything inside a form and so on.</p> <p>If it can't be done, that's fine, I'm just trying not to repeat the same thing several times in case I need to change it (and I will).</p>
[ { "answer_id": 411665, "author": "Todd Smith", "author_id": 31624, "author_profile": "https://Stackoverflow.com/users/31624", "pm_score": 4, "selected": true, "text": "ViewData.Model.CanEdit\n public class ProductViewData\n{\n public Product Product {get; set;}\n public bool CanEdi...
2009/01/04
[ "https://Stackoverflow.com/questions/411628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31793/" ]
411,631
<p>I've got a bunch of <a href="http://www.unicode.org/charts/PDF/U1F000.pdf" rel="nofollow noreferrer">unicode characters</a> from U1F000 and upwards, and I'm wondering how to represent them in Java. A Java unicode escape is on the form "\uXXXX" and the Java language specification says that "Representing supplementary characters requires two consecutive Unicode escapes". How does that apply to U1F000?</p> <pre><code>String mahjongTile = "\u0001\uf000"; </code></pre> <p>Does not <strong>seem</strong> to work (I only get two blank squares), but that may be a font-glitch, I presume.</p>
[ { "answer_id": 411638, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "String foo = new String(new int[]{0x1f000}, 0, 1);\n" }, { "answer_id": 412606, "author": "Alan Moore", ...
2009/01/04
[ "https://Stackoverflow.com/questions/411631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13051/" ]
411,632
<p>OS X 10.5.6.</p> <p>My Eclipse 3.4 is going crazy lately. </p> <p>After innocent operations like typing text or moving some files in Navigator view or saving, it sometimes starts "waiting on background operation", and eats one CPU core, shuffling back and forth tens of megabytes of memory.</p> <p>I suspect some of plug-ins went rogue.</p> <p>How can I find which one it is (except for binary search)?</p>
[ { "answer_id": 411638, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "String foo = new String(new int[]{0x1f000}, 0, 1);\n" }, { "answer_id": 412606, "author": "Alan Moore", ...
2009/01/04
[ "https://Stackoverflow.com/questions/411632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6236/" ]
411,646
<p>I've been reading a lot lately about how joins in DB queries slow things down. Evidently Google App Engine doesn't even allow them.</p> <p>I'm wondering how people design an app with no joins though. For example I'm working on an app that has <code>contacts</code> and <code>organizations</code>. A contact can be in many organizations and an organization can have many contacts. How would it be possible to have that relationship without a third table that connects the two entities...</p> <pre><code>contacts --&lt; contacts_organizations &gt;-- organizations </code></pre> <p>Does it mean that in GAE you can't have a many-to-many relationship? You just leave out functionality that would require a join?</p> <p>I guess you could have a TEXT <code>organizations</code> column in the <code>contacts</code> table containing a space-separated list of the organization IDs for each contact. That seems a little weird though.</p>
[ { "answer_id": 411655, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 2, "selected": false, "text": "db.ReferenceProperty" }, { "answer_id": 1174751, "author": "Community", "author_id": -1, "author...
2009/01/04
[ "https://Stackoverflow.com/questions/411646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42595/" ]
411,660
<p>What's pros and cons of using Enterprise Library Unity vs other IoC containers (Windsor, Spring.Net, Autofac ..)?</p>
[ { "answer_id": 423168, "author": "Chris Brandsma", "author_id": 9443, "author_profile": "https://Stackoverflow.com/users/9443", "pm_score": 9, "selected": true, "text": " IKernel kernel = new StandardKernel(\n new InlineModule(\n x => x.Bind<ICustomerRep...
2009/01/04
[ "https://Stackoverflow.com/questions/411660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50974/" ]
411,669
<p>I did some HTTP monitoring with WireShark. Are there more tools like this that allow you to create your own HTTP messsages? Telnet comes to mind</p> <p>Could be handy to get see how hacker-proof your site is...</p>
[ { "answer_id": 411719, "author": "Parand", "author_id": 13055, "author_profile": "https://Stackoverflow.com/users/13055", "pm_score": 1, "selected": false, "text": "nc www.mywebsite.com 80\nGET / HTTP/1.0\n(hit return twice)\n" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
411,688
<p>I am looking to extend jQuery so I can easily retrieve the tagName of the first element in a jQuery object. This is what I have come up with, but it doesn't seem to work:</p> <pre><code>$.fn.tagName = function() { return this.each(function() { return this.tagName; }); } alert($('#testElement').tagName()); </code></pre> <p>Any ideas what's wrong?</p> <p>BTW, I'm looking to use this more for testing than in production.</p>
[ { "answer_id": 411692, "author": "Dan Herbert", "author_id": 392, "author_profile": "https://Stackoverflow.com/users/392", "pm_score": 6, "selected": true, "text": "$.fn.tagName = function() {\n return this.get(0).tagName;\n}\nalert($('#testElement').tagName());\n each() each() functi...
2009/01/04
[ "https://Stackoverflow.com/questions/411688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
411,709
<p>How do you replicate this in F#?</p> <pre><code>interface IMarker { // No members here } class MyClass : IMarker { // can contain code } </code></pre> <p>Update: The following code does define marker interface, but none of the answers so far manages to producde class that implements this marker interface (see MyClass above)</p> <pre><code>type IMarker = interface end </code></pre>
[ { "answer_id": 411731, "author": "Pete OHanlon", "author_id": 43635, "author_profile": "https://Stackoverflow.com/users/43635", "pm_score": -1, "selected": false, "text": "type IMarker ;\n\ntype MyClass =\n interface IMarker\n" }, { "answer_id": 411802, "author": "Codingday"...
2009/01/04
[ "https://Stackoverflow.com/questions/411709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28912/" ]
411,724
<p>I have a parts database that I am going to be constantly querying for a quoting system. The parts database has 1,400,000+ records in it. The users are just going to start typing part numbers, which they expect the system to be able to find after only a few characters, so I need to be able to do a wildcard search, something like:</p> <pre><code>SELECT NeededFields FROM Parts WHERE PartNumber LIKE 'ML%' </code></pre> <p>Is there any kind of optimization that I can perform to try to wring the most performance out of this type of query? I have the PartNumber field indexed, but I'm not sure if that is the best that I can get. I'd be willing to consider alternate indexing structures built into the database separate from SQL indexes too. The primary key is a Guid, but I need this for replication and because of specific data structures that I use.</p>
[ { "answer_id": 411739, "author": "Henning", "author_id": 7034, "author_profile": "https://Stackoverflow.com/users/7034", "pm_score": 1, "selected": false, "text": "LIKE 'term%'" }, { "answer_id": 411824, "author": "Sam Saffron", "author_id": 17174, "author_profile": "...
2009/01/04
[ "https://Stackoverflow.com/questions/411724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50356/" ]
411,726
<p>On a program of me, the <a href="http://www.splint.org/" rel="nofollow noreferrer">splint</a> checker warns:</p> <pre><code>expat-test.c:23:1: Function exported but not used outside expat-test: start A declaration is exported, but not used outside this module. Declaration can use static qualifier. (Use -exportlocal to inhibit warning) expat-test.c:38:1: Definition of start </code></pre> <p>The start() function <strong>is</strong> used. The program uses the <a href="http://expat.sourceforge.net/" rel="nofollow noreferrer">expat</a> XML parser which works with callbacks. You give the parser a function:</p> <pre><code>XML_SetElementHandler(parser, start, end); </code></pre> <p>and the parser calls it back at some points. This is a very common idiom in C and I wonder why splint complains. I find nothing in the <a href="http://www.splint.org/faq.html" rel="nofollow noreferrer">FAQ</a> or in the <a href="http://www.splint.org/manual/html/sec8.html" rel="nofollow noreferrer">manual</a>.</p>
[ { "answer_id": 411742, "author": "Christoph", "author_id": 48015, "author_profile": "https://Stackoverflow.com/users/48015", "pm_score": 3, "selected": true, "text": "XML_SetElementHandler() start() static" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15625/" ]
411,738
<p>I am trying to write a static function to Or two expressions, but recieve the following error:</p> <blockquote> <p>The parameter 'item' is not in scope.</p> <p>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p> <p>Exception Details: System.InvalidOperationException: The parameter 'item' is not in scope.</p> </blockquote> <p>the method:</p> <pre><code>public static Expression&lt;Func&lt;T, bool&gt;&gt; OrExpressions(Expression&lt;Func&lt;T, bool&gt;&gt; left, Expression&lt;Func&lt;T, bool&gt;&gt; right) { // Define the parameter to use var param = Expression.Parameter(typeof(T), "item"); var filterExpression = Expression.Lambda&lt;Func&lt;T, bool&gt;&gt; (Expression.Or( left.Body, right.Body ), param); // Build the expression and return it return (filterExpression); } </code></pre> <p><strong>edit</strong>: adding more info</p> <p>The expressions being or'd are coming from the method below, which execute just fine. if there is a better way to or the results I am all ears. Also, I do not know how many are being or'd in advance.</p> <pre><code>public static Expression&lt;Func&lt;T, bool&gt;&gt; FilterExpression(string filterBy, object Value, FilterBinaryExpression binaryExpression) { // Define the parameter to use var param = Expression.Parameter(typeof(T), "item"); // Filter expression on the value switch (binaryExpression) { case FilterBinaryExpression.Equal: { // Build an expression for "Is the parameter equal to the value" by employing reflection var filterExpression = Expression.Lambda&lt;Func&lt;T, bool&gt;&gt; (Expression.Equal( Expression.Convert(Expression.Property(param, filterBy), typeof(TVal)), Expression.Constant(Value) ), param); // Build the expression and return it return (filterExpression); } </code></pre> <p><strong>edit</strong>: adding even more info</p> <p>Alternatively, is there a better way to do an or? Currently the .Where(constraint) works just fine where constraint is of type Expression>. How can i do where(constraint1 or constraint2) (to the constraint n'th)</p> <p>Thanks in advance!</p>
[ { "answer_id": 411804, "author": "Cameron MacFarland", "author_id": 3820, "author_profile": "https://Stackoverflow.com/users/3820", "pm_score": 2, "selected": false, "text": "var param1 = Expression.Parameter(typeof(T), \"item\");\nvar param2 = Expression.Parameter(typeof(T), \"item\");\...
2009/01/04
[ "https://Stackoverflow.com/questions/411738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51275/" ]
411,740
<p>I've used the <a href="http://perldoc.perl.org/functions/localtime.html" rel="noreferrer">localtime</a> function in Perl to get the current date and time but need to parse in existing dates. I have a GMT date in the following format: "20090103 12:00" I'd like to parse it into a date object I can work with and then convert the GMT time/date into my current time zone which is currently Eastern Standard Time. So I'd like to convert "20090103 12:00" to "20090103 7:00" any info on how to do this would be greatly appreciated.</p>
[ { "answer_id": 411795, "author": "Schwern", "author_id": 14660, "author_profile": "https://Stackoverflow.com/users/14660", "pm_score": 7, "selected": true, "text": "#!/usr/bin/perl\n\nuse 5.10.0;\n\nuse strict;\nuse warnings;\n\nuse Time::Piece;\n\n# Read the date from the command line.\...
2009/01/04
[ "https://Stackoverflow.com/questions/411740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14744/" ]
411,746
<p>In a Rails 2.2 project, I'm having users put together a list of projects into a portfolio object (i.e.: <code>PortfolioHasManyProjects</code>). On the page is a Rails form for regular text, titles etc., as well as 2 sortable lists; the lists are used for dragging projects from the global-project-list into your portfolio-project-list.</p> <p>It is similar to what's done here: <a href="http://ui.jquery.com/latest/demos/functional/#ui.sortable" rel="nofollow noreferrer">http://ui.jquery.com/latest/demos/functional/#ui.sortable</a>.</p> <p>I have the portfolio list (#drag_list) updating on change and submitting its serialized data through an AJAX call. <strong>This is done in the application.js file:</strong></p> <pre><code>jQuery.ajaxSetup({ 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} }) jQuery.fn.submitDragWithAjax = function() { this.submit(function() { $.post(this.action, $("#drag_list").sortable('serialize'), null, "script"); return false; }) return this; }; $(document).ajaxSend(function(event, request, settings) { if (typeof(AUTH_TOKEN) == "undefined") return; // settings.data is a serialized string like "foo=bar&amp;baz=boink" (or null) settings.data = settings.data || ""; settings.data += (settings.data ? "&amp;" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN); }); /-------------------------------------------/ $(document).ready(function(){ $(".ajax_drag").submitDragWithAjax(); $("#drag_list").sortable({ placeholder: "ui-selected", revert: true, connectWith:["#add_list"], update : function () { $("#drag_list").submit(); } }); $("#add_list").sortable({ placeholder: "ui-selected", revert: true, connectWith:["#drag_list"] }); </code></pre> <p>Here is where things got tricky. I wasn't sure how to deal with the serialized data and have it submit with the form to the controller in the <code>new.html.erb</code> file. So what I did was have the <code>new.js.erb</code> insert hidden form fields into <code>new.html.erb</code> with the data that I would extract in the controller.</p> <p><strong>here's the new.js.erb:</strong></p> <pre><code>$("#projects").html(""); &lt;% r = params[:proj] %&gt; &lt;% order=1 %&gt; &lt;% for i in r %&gt; $("#projects").append("&lt;input type=hidden name=proj[&lt;%=order%&gt;] value=&lt;%=i%&gt; /&gt;"); &lt;% order=order+1 %&gt; &lt;% end %&gt; </code></pre> <p><strong>which edits new.html.erb:</strong></p> <pre><code>&lt;h1&gt;New portfolio&lt;/h1&gt; &lt;h2&gt;The List&lt;/h2&gt; &lt;div class="list_box"&gt; &lt;h3&gt;All Available Projects&lt;/h3&gt; &lt;%= render :partial =&gt; "projects/add_list" %&gt; &lt;/div&gt; &lt;div class="list_box"&gt; &lt;h3&gt;Projects currently in your new portfolio&lt;/h3&gt; &lt;%= render :partial =&gt; "projects/drag_list" %&gt; &lt;/div&gt; &lt;div style="clear:both"&gt;&lt;/div&gt; &lt;br/&gt; &lt;br/&gt; &lt;h2&gt;Portfolio details&lt;/h2&gt; &lt;% form_for(@portfolio) do |f| %&gt; &lt;%= f.error_messages %&gt; &lt;h3&gt;Portfolio Name&lt;/h3&gt; &lt;p&gt; &lt;%= f.text_field :name %&gt; &lt;/p&gt; &lt;h3&gt;URL&lt;/h3&gt; &lt;p&gt; &lt;%= f.text_field :url %&gt; &lt;/p&gt; &lt;h3&gt;Details&lt;/h3&gt; &lt;p&gt; &lt;%= f.text_area :details %&gt; &lt;/p&gt; &lt;p&gt; &lt;div id="projects"&gt; &lt;input type="hidden" name="proj" value="" /&gt; &lt;/div&gt; &lt;%= f.submit "Create" %&gt; &lt;/p&gt; &lt;% end %&gt; </code></pre> <p>The form then submits to the create method in the portfolio controller:</p> <pre><code> def new @projects = Project.find(:all) @portfolio = Portfolio.new respond_to do |format| format.html # new.html.erb format.xml { render :xml =&gt; @portfolio } format.js end end def create @portfolio = Portfolio.new(params[:portfolio]) proj_ids = params[:proj] @portfolio.projects = [] @portfolio.save proj_ids.each {|key, value| puts "Key:#{key} , Value:#{value} " } proj_ids.each_value {|value| @portfolio.projects &lt;&lt; Project.find_by_id(value) } respond_to do |format| if @portfolio.save flash[:notice] = 'Portfolio was successfully created.' format.html { render :action =&gt; "index" } format.xml { render :xml =&gt; @portfolio, :status =&gt; :created, :location =&gt; @portfolio } else format.html { render :action =&gt; "new" } format.xml { render :xml =&gt; @portfolio.errors, :status =&gt; :unprocessable_entity } end end end </code></pre> <hr> <p><strong>So finally my question:</strong></p> <ol> <li><p>Is this a proper way of doing this? For some reason I feel it isn't, mostly because doing everything else in Rails seemed so much easier and intuitive. This works, but it was hell to get it to. There has to be a more <em>elegant</em> way of sending serialized data to the controller through AJAX calls.</p></li> <li><p>How would I call for different AJAX actions on the same page? Let's say I had a sortable and an autocomplete AJAX call, could I have a <code>sortable.js.erb</code> and <code>autocomplete.js.erb</code> and call them from any file? I'm not sure how to setup the controllers to respond to this.</p></li> </ol>
[ { "answer_id": 463920, "author": "Martin Stannard", "author_id": 38463, "author_profile": "https://Stackoverflow.com/users/38463", "pm_score": 0, "selected": false, "text": "#sorter\n- @lesson.parts.each do |part|\n %div[part] <- HAML rocks - this constructs a div <div id=\"the_part_id\...
2009/01/04
[ "https://Stackoverflow.com/questions/411746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51446/" ]
411,752
<p>What is the best way to generate a string of <code>\t</code>'s in C#</p> <p>I am learning C# and experimenting with different ways of saying the same thing.</p> <p><code>Tabs(uint t)</code> is a function that returns a <code>string</code> with <code>t</code> amount of <code>\t</code>'s</p> <p>For example <code>Tabs(3)</code> returns <code>&quot;\t\t\t&quot;</code></p> <p>Which of these three ways of implementing <code>Tabs(uint numTabs)</code> is best?</p> <p>Of course that depends on what &quot;best&quot; means.</p> <ol> <li><p>The LINQ version is only two lines, which is nice. But are the calls to Repeat and Aggregate unnecessarily time/resource consuming?</p> </li> <li><p>The <code>StringBuilder</code> version is very clear but is the <code>StringBuilder</code> class somehow slower?</p> </li> <li><p>The <code>string</code> version is basic, which means it is easy to understand.</p> </li> <li><p>Does it not matter at all? Are they all equal?</p> </li> </ol> <p>These are all questions to help me get a better feel for C#.</p> <pre><code>private string Tabs(uint numTabs) { IEnumerable&lt;string&gt; tabs = Enumerable.Repeat(&quot;\t&quot;, (int) numTabs); return (numTabs &gt; 0) ? tabs.Aggregate((sum, next) =&gt; sum + next) : &quot;&quot;; } private string Tabs(uint numTabs) { StringBuilder sb = new StringBuilder(); for (uint i = 0; i &lt; numTabs; i++) sb.Append(&quot;\t&quot;); return sb.ToString(); } private string Tabs(uint numTabs) { string output = &quot;&quot;; for (uint i = 0; i &lt; numTabs; i++) { output += '\t'; } return output; } </code></pre>
[ { "answer_id": 411762, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 12, "selected": true, "text": "string tabs = new string('\\t', n);\n n static string Tabs(int n)\n{\n return new string('\\t', n);\n}\n" ...
2009/01/04
[ "https://Stackoverflow.com/questions/411752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47630/" ]
411,756
<p>i'm trying to debug a program, that i don't have the source code for: explorer.exe</p> <p>It's a native Win32 application from Microsoft, and symbols are avilable.</p> <p>All i need now is a (graphical) debugger that supports symbols.</p> <ul> <li>OllyDbg is a graphical debugger, but doesn't support symbols.</li> <li>Delphi is a graphical debugger, but doesn't support symbols.</li> <li>WinDbg is not a graphical debugger, which supports symbols.</li> <li>Visual C# Express Edition is not Win32 a debugger.</li> <li>Process Explorer supports symbols, but isn't a debugger</li> <li>Process Monitor supports symbols, but isn't a debugger</li> </ul> <p>Have any new graphical debuggers that support Microsoft's symbols server, been written in the last 6 months that i don't know about?</p> <hr> <p>A graphical debugger is one where you can see the disassembly, and can Step Into and Stop Over instructions, e.g.:</p> <p>Delphi</p> <p><a href="https://i.stack.imgur.com/HoQ6g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HoQ6g.png" alt="alt text"></a> </p> <p>OllyDebug:</p> <p><a href="https://i.stack.imgur.com/oPmhJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oPmhJ.png" alt="alt text"></a> </p> <p>IDA Pro </p> <p><a href="http://www.hex-rays.com/idapro/linux/remotedebugger2.gif" rel="nofollow noreferrer">alt text http://www.hex-rays.com/idapro/linux/remotedebugger2.gif</a></p> <p>WinDbg does not show you a series of instructions:</p> <p><a href="http://windowsitpro.com/Files/11/21217/Figure_01.gif" rel="nofollow noreferrer">alt text http://windowsitpro.com/Files/11/21217/Figure_01.gif</a></p>
[ { "answer_id": 1567446, "author": "ericj", "author_id": 189997, "author_profile": "https://Stackoverflow.com/users/189997", "pm_score": 2, "selected": false, "text": "l+t l-t srv*c:\\Symbols*http://msdl.microsoft.com/download/symbols;srv*c:\\Symbols*http://symbols.mozilla.org/firefox\n" ...
2009/01/04
[ "https://Stackoverflow.com/questions/411756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
411,758
<p>I'm not sure if this is the right place to post these kind of questions, if it's not so, please (politely) let me know... :-)</p> <p>I need to save files greater than 16MB on a mysql database from a php site...</p> <p>I've already changed the c:\xampp\mysql\bin\my.cnf</p> <p>and set max_allowed_packet to 16 MB, and everything worked fine</p> <p>then I set it to 32 MB but there´s no way I can handle a file bigger than 16 MB</p> <p>I get the following error:</p> <p>'MySQL server has gone away'</p> <p>(the same error I had when max_allowed_packet was set to 1MB)</p> <p>there must be some other setting that doesn´t allow me to handle files bigger than 16MB</p> <p>maybe the php client, I guess, but I don't know where to edit it</p> <p>this is the code I'm running</p> <p>when file.txt is smaller than 16.776.192 bytes long, it works fine, but</p> <p>if file.txt has 16.777.216 bytes i get the aforementioned error</p> <p>oh, and the field download.content is a longblob...</p> <pre><code> $file = 'file.txt'; $file_handle = fopen( $file, 'r' ); $content = fread( $file_handle, filesize( $file ) ); fclose( $file_handle ); db_execute( 'truncate table download', true ); $sql = "insert into download( code, title, name, description, original_name, mime_type, size, content, user_insert_id, date_insert, user_update_id, date_update ) values ( 'new file', 'new file', 'sas.jpg', 'new file', '$file', 'mime', " . filesize( $file ) . ", '" . addslashes( $content ) . "', 0, " . db_char_to_sql( now_char(), 'datetime' ) . ", 0, " . db_char_to_sql( now_char(), 'datetime' ) . " )"; db_execute( $sql, true ); </code></pre> <p>(the db_execute funcion just opens the connections and executes the sql stuff)</p> <p>running on windows XP sp2 server version: 5.0.67-community PHP Version 4.4.9 mysql client API version: 3.23.49 </p> <p>using: ApacheFriends XAMPP (Basispaket) version 1.6.8 that comes with + Apache 2.2.9 + MySQL 5.0.67 (Community Server) + PHP 5.2.6 + PHP 4.4.9 + PEAR + phpMyAdmin 2.11.9.2 ...</p> <p>this is part of the content of c:\xampp\mysql\bin\my.cnf</p> <pre> # The MySQL server [mysqld] port= 3306 socket= "C:/xampp/mysql/mysql.sock" basedir="C:/xampp/mysql" tmpdir="C:/xampp/tmp" datadir="C:/xampp/mysql/data" skip-locking key_buffer = 16M # max_allowed_packet = 1M max_allowed_packet = 32M table_cache = 128 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M </pre>
[ { "answer_id": 412446, "author": "esmajic", "author_id": 31906, "author_profile": "https://Stackoverflow.com/users/31906", "pm_score": -1, "selected": false, "text": "; Maximum allowed size for uploaded files.\nupload_max_filesize = 16M\n\n; Maximum size of POST data that PHP will accept...
2009/01/04
[ "https://Stackoverflow.com/questions/411758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
411,761
<p>Is it possible to have a variable number of fields using django forms?</p> <p>The specific application is this:</p> <p>A user can upload as many pictures as they want on the image upload form. Once the pictures are uploaded they are taken to a page where they can give the pictures a name and description. The number of pictures will depend on how many the user has chosen to upload.</p> <p>So <strong>how do I get django to generate a form using a variable number of input fields</strong> (which could be passed as an argument if necessary)?</p> <p><strong>edit:</strong> a few things have changed since the <a href="http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/" rel="noreferrer">article mentioned in jeff bauer's answer</a> was written. </p> <p>Namely this line of code which doesn't seem to work:</p> <pre><code># BAD CODE DO NOT USE!!! return type('ContactForm', [forms.BaseForm], { 'base_fields': fields }) </code></pre> <p>So here is what I came up with...</p> <h1>The Answer I used:</h1> <pre><code> from tagging.forms import TagField from django import forms def make_tagPhotos_form(photoIdList): "Expects a LIST of photo objects (ie. photo_sharing.models.photo)" fields = {} for id in photoIdList: id = str(id) fields[id+'_name'] = forms.CharField() fields[id+'_tags'] = TagField() fields[id+'_description'] = forms.CharField(widget=forms.Textarea) return type('tagPhotos', (forms.BaseForm,), { 'base_fields': fields }) </code></pre> <p>note tagging is not part of django, but it is free and very useful. check it out: <a href="http://code.google.com/p/django-tagging/" rel="noreferrer">django-tagging</a></p>
[ { "answer_id": 411852, "author": "Alcides", "author_id": 28516, "author_profile": "https://Stackoverflow.com/users/28516", "pm_score": 3, "selected": false, "text": "python manage.py shell\n from app.forms import PictureForm\np = PictureForm()\np.fields\ntype(p.fields)\n p.fields.insert(...
2009/01/04
[ "https://Stackoverflow.com/questions/411761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2908/" ]
411,771
<p>When using TortoiseCVS, as I checkout a module, dialog (see <a href="http://img.skitch.com/20090104-b2pne85gp2xn9bhcgwjfsfbkcr.png" rel="nofollow noreferrer">screenshot</a>) telling me "Trouble launching CVS process", "The handle is invalid". Any idea on how this would be happening?</p>
[ { "answer_id": 61380755, "author": "hkbharath", "author_id": 1761743, "author_profile": "https://Stackoverflow.com/users/1761743", "pm_score": 0, "selected": false, "text": "cvs.exe CVSNT" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5295/" ]
411,777
<p>I'd like to know how one would create an application that starts in the background. I'm currently creating a webserver in C as a little project, both to learn some old C and Linux Socket Programming. But my current concern is:</p> <ul> <li>How do I get the current process number?</li> </ul> <p>I want to get this because when I start the process, I want to display the process number for the user who starts the service.</p> <ul> <li>My second problem is, how do I start my application as a Daemon to run in the background?</li> </ul> <p>Any references, tutorials and/or videos on how I'd do this is appreciated!</p> <hr> <p>Maybe I was a little bit unclear; I want to get the Process ID from within C. So, do I need to create a shell script for my application or can I do this from C?</p>
[ { "answer_id": 411787, "author": "opyate", "author_id": 51280, "author_profile": "https://Stackoverflow.com/users/51280", "pm_score": 1, "selected": false, "text": "ps aux | grep processname\n" }, { "answer_id": 411792, "author": "JesperE", "author_id": 13051, "author...
2009/01/04
[ "https://Stackoverflow.com/questions/411777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39106/" ]
411,798
<p>I am presently working on converting a 32-bit application into a 64-bit application in C. This application is currently working on x86 architecture (Windows, osx, Unix, Linux). So, before starting coding, I wanted to know what do I need to consider while converting the application.</p>
[ { "answer_id": 411807, "author": "Christoph", "author_id": 48015, "author_profile": "https://Stackoverflow.com/users/48015", "pm_score": 3, "selected": false, "text": "size_t ptrdiff_t uintptr_t stdint.h" }, { "answer_id": 411816, "author": "geocar", "author_id": 37507, ...
2009/01/04
[ "https://Stackoverflow.com/questions/411798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51451/" ]
411,810
<p>Without having the full module path of a Django model, is it possible to do something like:</p> <pre><code>model = 'User' [in Django namespace] model.objects.all() </code></pre> <p>...as opposed to:</p> <pre><code>User.objects.all(). </code></pre> <p>EDIT: I am trying to make this call based on command-line input. Is it possible to avoid the import statement, e.g., </p> <pre><code>model = django.authx.models.User </code></pre> <p>Without Django returning the error:</p> <pre><code>"global name django is not defined." </code></pre>
[ { "answer_id": 411814, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "from django.authx.models import User\nmodel = User\nmodel.objects.all()\n" }, { "answer_id": 411822, "author": "Ha...
2009/01/04
[ "https://Stackoverflow.com/questions/411810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44440/" ]
411,823
<p>I'm just learning Qt with C++. I have successfully implemented signals and slots to trap standard events like <code>ButtonPushed()</code>, etc. However, I want to have a function called when I mouse over and mouse out of a <code>QLabel</code>. It looks like <a href="http://doc.qt.io/qt-4.8/qhoverevent.html" rel="nofollow noreferrer">QHoverEvent</a> will do what I need, but I can't seem to find any tutorials or examples on how to implement this. Is it done the same way as signals and slots?. I tried:</p> <pre><code>connect(ui.lbl_test, SIGNAL(QHoverEvent), this, SLOT(TestFunc(QEvent::Type type, const QPoint &amp; pos, const QPoint &amp; oldPos))); </code></pre> <p>.. but the function didn't get called when I hovered over the label.</p> <p>Here is the function, listed in the header file as a public slot:</p> <pre><code>void MyDialog::TestFunc(QEvent::Type type, const QPoint &amp; pos, const QPoint &amp; oldPos) { QMessageBox::information(this, tr("Hey"), tr("Listen!")); } </code></pre> <p>Can anyone help me figure this out or point me to a good example?</p> <p>EDIT:</p> <p>After reading a post below, I found no <code>setFlag()</code> member to call for my label widget, but I did try:</p> <pre><code> ui.lbl_test-&gt;setMouseTracking(true); connect(ui.lbl_test, SIGNAL(ui.lbl_test-&gt;mouseMoveEvent()), this, SLOT(TestFunc(QMouseEvent *event))); </code></pre> <p>And updated <code>TestFunc()</code> accordingly. But still nothing happens when I mouse over.</p> <p>After looking I am not sure <code>QLabel</code> even inherits the mouseMoveEvent() even from <code>QWidget</code>. If this is true, is there a widget that does, or a list of objects that inherit it somewhere?. All I can tell from the documentation on their site is how many inherited functions an object has..</p>
[ { "answer_id": 411849, "author": "shoosh", "author_id": 9611, "author_profile": "https://Stackoverflow.com/users/9611", "pm_score": 4, "selected": false, "text": "Qt::WA_Hover widget->setAttribute(Qt::WA_Hover);\n mouseMoveEvent() widget->setMouseTracking(true);\n" }, { "answer_i...
2009/01/04
[ "https://Stackoverflow.com/questions/411823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48923/" ]
411,825
<p>I've have just been stumped with this problem for an hour and I annoyingly found the problem eventually.</p> <p><strong>THE CIRCUMSTANCES</strong></p> <p>I have a table which users a string as a primary key, this table has various many to one and many to many relationships all off this primary key.</p> <p>When searching for multiple items from the table all relationships were brought back. However whenever I tried to get the object by the primary key (string) it was not bringing back any relationships, they were always set to 0. </p> <p><strong>THE PARTIAL SOLUTION</strong></p> <p>So I looked into my logs to see what the SQL was doing and that was returning the correct results. So I tried various things in all sorts of random ways and eventually worked out it was. The case of the string being passed into the get method was not EXACTLY the same case as it was in the database, so when it tried to match up the relationship items with the main entity it was finding nothing <strong>(Or at least NHIbernate wasn't because as I stated above the SQL was actually returning the correct results)</strong></p> <p><strong>THE REAL SOLUTION</strong></p> <p>Has anyone else come across this? If so how do you tell NHibernate to ignore case when matching SQL results to the entity? It is silly because it worked perfectly well before now all of a sudden it has started to pay attention to the case of the string.</p>
[ { "answer_id": 447145, "author": "Mark Struzinski", "author_id": 1284, "author_profile": "https://Stackoverflow.com/users/1284", "pm_score": 2, "selected": false, "text": "return session.Get<T>(id);\n <class name=\"Merchant\" table=\"T__MERCHANT\">\n <id name=\"MerchantId\" co...
2009/01/04
[ "https://Stackoverflow.com/questions/411825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26081/" ]
411,829
<p>can anybody please, explain that what does SET IDENTITY INSERT ON AND OFF do. </p> <p>Thanks, Chris</p>
[ { "answer_id": 411885, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 3, "selected": false, "text": "SET IDENTITY_INSERT YourTable ON" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47957/" ]
411,837
<p>This is in continuation with the question posted here: <a href="https://stackoverflow.com/questions/408358/finding-the-center-of-mass-on-a-2d-bitmap">Finding the center of mass on a 2D bitmap</a> which talked about finding the center of mass in a boolean matrix, as the example was given.</p> <p>Suppose now we expand the matrix to this form:</p> <pre><code>0 1 2 3 4 5 6 7 8 9 1 . X X . . . . . . 2 . X X X . . X . . 3 . . . . . X X X . 4 . . . . . . X . . 5 . X X . . . . . . 6 . X . . . . . . . 7 . X . . . . . . . 8 . . . . X X . . . 9 . . . . X X . . . </code></pre> <p>As you can see we now have 4 centers of mass, for 4 different clusters.</p> <p>We already know how to find a center of mass given that only one exists, if we run that algorithm on this matrix we'll get some point in the middle of the matrix which does not help us.</p> <p>What can be a good, correct and fast algorithm to find these clusters of mass?</p>
[ { "answer_id": 411855, "author": "PEZ", "author_id": 44639, "author_profile": "https://Stackoverflow.com/users/44639", "pm_score": 3, "selected": true, "text": "matrix = [[1.0 if x == \"X\" else 0.0 for x in y] for y in \"\"\".XX......\n.XXX..X..\n.....XXX.\n......X..\n.XX......\n.X........
2009/01/04
[ "https://Stackoverflow.com/questions/411837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24545/" ]
411,841
<p>Adding source files more than one directory away (e.g. ../../source.cpp or ../../../somewhere_else/source.cpp, vs. just source.cpp or ../source.cpp) to the SOURCES= declaration in a WDK/DDK build yields the following error:</p> <pre><code>Ignoring invalid directory prefix in SOURCES= entry </code></pre> <p>Is it possible to include remote source files in a build?</p>
[ { "answer_id": 411854, "author": "jrk", "author_id": 3815, "author_profile": "https://Stackoverflow.com/users/3815", "pm_score": 4, "selected": true, "text": "build sources build #include \"../../remote_source.cpp SOURCES= build nmake remote_source.cpp remote_source.cpp touch build -cZ" ...
2009/01/04
[ "https://Stackoverflow.com/questions/411841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3815/" ]
411,843
<p>I am currently writing a simple password generator (C#). For that I need some random numbers.</p> <p>Is it OK to simply use the <a href="http://msdn.microsoft.com/en-us/library/system.random.aspx" rel="nofollow noreferrer">Random</a> class that ships with .NET or are there any known problems with that? </p>
[ { "answer_id": 411850, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 4, "selected": false, "text": "Random RandomClass = new Random();\nint RandomNumber = RandomClass.Next(); // Random number between 1 and 2147483647\ndoub...
2009/01/04
[ "https://Stackoverflow.com/questions/411843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
411,857
<p>This is an erlang problem, it seems. I have this code to test the client sending data, written in Actionscript 3:</p> <pre><code>var socket:Socket=new Socket("localhost", 2345); socket.addEventListener(Event.CONNECT, connected); private function connected(event:Event):void { socket.writeInt(12); //packet length, should be correct? 4 bytes each? socket.writeInt(3); socket.writeInt(6); socket.writeInt(9); socket.flush(); } </code></pre> <p>Then I have this small server, written in Erlang:</p> <pre><code>start_nano_server() -&gt; {ok, Listen} = gen_tcp:listen(2345, [binary, {packet, 0}, {reuseaddr, true}, {active, true}, {packet_size, 128}]), {ok, Socket} = gen_tcp:accept(Listen), gen_tcp:close(Listen), receive_data(Socket, []). receive_data(Socket, SoFar) -&gt; receive {tcp,Socket,Bin} -&gt; receive_data(Socket, [Bin|SoFar]); {tcp_closed,Socket} -&gt; Bytes=list_to_binary(reverse(SoFar)), io:format("~p~n",[Bytes]) end. </code></pre> <p>Now, no matter what I send from the client, I ALWAYS get <code>[&lt;&lt;0,0,0,4,0,0,0,32&gt;&gt;]</code> as the response. I can try writing bytes to the socket directly instead of ints, and I get the same thing. I can write more or less data, same result. UTF strings same result. Even when specifying "4" as the packet header length, I just get the same consistent result of <code>[&lt;&lt;0,0,0,32&gt;&gt;]</code> instead. I don't understand what I'm doing wrong here.</p>
[ { "answer_id": 413197, "author": "Alexey Romanov", "author_id": 9204, "author_profile": "https://Stackoverflow.com/users/9204", "pm_score": 2, "selected": false, "text": "Listen" }, { "answer_id": 413565, "author": "Community", "author_id": -1, "author_profile": "http...
2009/01/04
[ "https://Stackoverflow.com/questions/411857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49018/" ]
411,864
<p>What does <code>SET ANSI_NULLS OFF</code> do?</p>
[ { "answer_id": 411868, "author": "dkretz", "author_id": 31641, "author_profile": "https://Stackoverflow.com/users/31641", "pm_score": 4, "selected": false, "text": "SET ANSI_NULLS WHERE column_name = NULL WHERE column_name <> NULL SET ANSI_NULLS WHERE column_name = NULL WHERE column_name...
2009/01/04
[ "https://Stackoverflow.com/questions/411864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47957/" ]
411,876
<p>I'm converting an algorithm I wrote in Java to Objective-C. In java the BigDecimal class handles base-10 numbers and can take the primitive double as a constructor arg. In Cocoa's NSDecimalNumber class, however, there is no direct way to construct an instance using a primitive double.</p> <p>Currently I'm using this (smelly) hack:</p> <pre><code> [NSDecimalNumber decimalNumberWithString:[NSString stringWithFormat:@"%1.38f", number]]; </code></pre> <p>Is there a better way?</p>
[ { "answer_id": 411893, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 2, "selected": false, "text": "[NSDecimalNumber numberWithDouble:myDouble]\n" }, { "answer_id": 1988093, "author": "Futurist", "aut...
2009/01/04
[ "https://Stackoverflow.com/questions/411876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4897/" ]
411,877
<p>I'm trying to implement a "Popular Products" feature. Basically, every time a Product is viewed, I want to log to the database the number of views of that product. Where do I put the hooks for something like this? I have seen things that are based on building some sort of traffic analytics, but I am looking for ideas that would keep this feature more coupled to the RoR app.</p>
[ { "answer_id": 411920, "author": "eelco", "author_id": 8293, "author_profile": "https://Stackoverflow.com/users/8293", "pm_score": 2, "selected": false, "text": "@product = Product.find(params[:id])\n @product.views = @product.views + 1\n@product.save\n" }, { "answer_id": 412574,...
2009/01/04
[ "https://Stackoverflow.com/questions/411877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
411,896
<p>I'm trying to solve the problem of passing a 2-dimensional table into JavaScript AJAX application through SOAP web services. I'm trying to pass data into JavaScript web page through ASP.NET web service declared with following attributes:</p> <pre><code>[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.Web.Script.Services.ScriptService] </code></pre> <p>I need a complex type to be passed into the JavaScript:</p> <pre><code>[Serializable] public class PayRateSummary { public string[] EmployeeId; public Dictionary&lt;string, string&gt; EmployeeName; public string[] PaycodeId; public Dictionary&lt;string, Dictionary&lt;string, double?&gt;&gt; EmployeePaycodeRate; } [WebMethod(EnableSession = true)] public DataElements.PayRateSummary EnumPayRates(Guid companyId) { } </code></pre> <p>And web service declared in a pretty standard way:</p> <pre><code> &lt;asp:ScriptManager runat="server" ID="ScriptManager1"&gt; &lt;Services&gt;&lt;asp:ServiceReference Path="~/WebService.asmx" /&gt;&lt;/Services&gt; &lt;/asp:ScriptManager&gt; </code></pre> <p>... function RefreshPayRates() { WebService.EnumPayRates(CompanyCurrent, OnPayRatesLoaded, OnFailure); }</p> <p>For some reason, Dictionary[string,string] is getting passed allright, but not the Dictionary[string,Dictionary[string,string]]:</p> <p>--> <a href="http://vvcap.net/db/8rveoL-FMP6EUikCaqiz.htp" rel="nofollow noreferrer"><a href="http://vvcap.net/db/8rveoL-FMP6EUikCaqiz.htp" rel="nofollow noreferrer">http://vvcap.net/db/8rveoL-FMP6EUikCaqiz.htp</a></a></p> <p>I remember beating my head against the wall in the past to understand, what could be done to pass such objects and never found any solution.</p>
[ { "answer_id": 411920, "author": "eelco", "author_id": 8293, "author_profile": "https://Stackoverflow.com/users/8293", "pm_score": 2, "selected": false, "text": "@product = Product.find(params[:id])\n @product.views = @product.views + 1\n@product.save\n" }, { "answer_id": 412574,...
2009/01/04
[ "https://Stackoverflow.com/questions/411896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14395/" ]
411,902
<p>I am trying to port my first Django 1.0.2 application to run on OSX/Leopard with Apache + mod_python 3.3.1 + python 2.6.1 (all running in 64-bit mode) and I am experiencing an occasional error when uploading a file that was not present when testing with the Django development server. </p> <p>The code for the upload is similar to what described in the Django documentation:</p> <pre><code>class UploadFileForm(forms.Form): file = forms.FileField() description = forms.CharField(max_length=100) notifygroup = forms.BooleanField(label='Notify Group?', required=False) def upload_file(request, date, meetingid ): print date, meetingid if request.method == 'POST': print 'before reloading the form...' form = UploadFileForm(request.POST, request.FILES) print 'after reloading the form' if form.is_valid(): try: handle_uploaded_file(request.FILES['file'], request.REQUEST['date'], request.REQUEST['description'], form.cleaned_data['notifygroup'], meetingid ) except: return render_to_response('uploaded.html', { 'message': 'Error! File not uploaded!' }) return HttpResponseRedirect('/myapp/uploaded/') else: form = UploadFileForm() return render_to_response('upload.html', {'form': form, 'date':date, 'meetingid':meetingid}) </code></pre> <p>This code normally works correctly, but sometimes (say, once every 10 uploads) and after a fairly long waiting time, it fails with the following error:</p> <pre><code>IOError at /myapp/upload/2009-01-03/1 Client read error (Timeout?) Request Method: POST Request URL: http://192.168.0.164/myapp/upload/2009-01-03/1 Exception Type: IOError Exception Value: Client read error (Timeout?) Exception Location: /Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/django/http/multipartparser.py in read, line 406 Python Executable: /usr/sbin/httpd Python Version: 2.6.1 Python Path: ['/djangoapps/myapp/', '/djangoapps/', '/Library/Frameworks/Python64.framework/Versions/2.6/lib/python26.zip', '/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6', '/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/plat-darwin', '/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/plat-mac', '/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/lib-tk', '/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/lib-old', '/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/lib-dynload', '/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages'] Server time: Sun, 4 Jan 2009 22:42:04 +0100 Environment: Request Method: POST Request URL: http://192.168.0.164/myapp/upload/2009-01-03/1 Django Version: 1.0.2 final Python Version: 2.6.1 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'myapp.application1'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware') Traceback: File "/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "/djangoapps/myapp/../myapp/application1/views.py" in upload_file 137. form = UploadFileForm(request.POST, request.FILES) File "/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/django/core/handlers/modpython.py" in _get_post 113. self._load_post_and_files() File "/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/django/core/handlers/modpython.py" in _load_post_and_files 87. self._post, self._files = self.parse_file_upload(self.META, self._req) File "/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/django/http/__init__.py" in parse_file_upload 124. return parser.parse() File "/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/django/http/multipartparser.py" in parse 134. for item_type, meta_data, field_stream in Parser(stream, self._boundary): File "/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/django/http/multipartparser.py" in __iter__ 607. for sub_stream in boundarystream: File "/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/django/http/multipartparser.py" in next 421. return LazyStream(BoundaryIter(self._stream, self._boundary)) File "/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/django/http/multipartparser.py" in __init__ 447. unused_char = self._stream.read(1) File "/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/django/http/multipartparser.py" in read 300. out = ''.join(parts()) File "/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/django/http/multipartparser.py" in parts 293. chunk = self.next() File "/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/django/http/multipartparser.py" in next 315. output = self._producer.next() File "/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/django/http/multipartparser.py" in next 376. data = self.flo.read(self.chunk_size) File "/Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/django/http/multipartparser.py" in read 406. return self._file.read(num_bytes) Exception Type: IOError at /myapp/upload/2009-01-03/1 Exception Value: Client read error (Timeout?) </code></pre> <p>I tried to run everything using mod_wsgi and no difference.</p> <p>Does anybody know what am I doing wrong?</p> <p>Thanks in advance for your help!</p> <p>ppdo</p> <p>=====</p> <p>Updated:</p> <p>Though I succeeded uploading large files (60+ MB), when it fails it fails with no evident relationship with the size of the upload, i.e. it fails also with 10kB files that have successfully been uploaded before. </p>
[ { "answer_id": 413089, "author": "Bartosz Radaczyński", "author_id": 985, "author_profile": "https://Stackoverflow.com/users/985", "pm_score": 1, "selected": false, "text": "Client read error (Timeout?)\n" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
411,905
<p>My iphone app has several text fields. The "Did End on Exit" event on each text field calls a single action. How can I tell which text field called the action? Can I detect this from the sender object which is passed to the action?</p>
[ { "answer_id": 411930, "author": "Lily Ballard", "author_id": 582, "author_profile": "https://Stackoverflow.com/users/582", "pm_score": 3, "selected": false, "text": "sender sender == aField" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51472/" ]
411,906
<p>What are some of the biggest design flaws in C# or the .NET Framework in general?</p> <p>Example: there is no non-nullable string type and you have to check for DBNull when fetching values from an IDataReader.</p>
[ { "answer_id": 411919, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 6, "selected": false, "text": "Reset() IEnumerator<T> IEnumerable<out T> Func<in T, out TResult> List<T> ApplicationException Contains Add System.Co...
2009/01/04
[ "https://Stackoverflow.com/questions/411906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48722/" ]
411,921
<p>This is probably one of the most common tasks / problems when programming; You need to store the configuration of your application somewhere.</p> <p>While I'm trying to create a webserver or other applications, I'd like to keep the code as clean as possible since my main interest in programming is architecture. This results in me wanting to store configurations in a file which can be changed without having to re-compile the software.</p> <p>I'm not here to re-invent the wheel or anything like that, so what I'd like to do is creating a Configuration reader in C on *nix. The configuration might look a lot like any other software's configuration; Apache, vsftpd, MySQL, etc.</p> <p>The basic question is: How do you read from a textfile and process each line efficiently (in pure C)? Do I need to use <code>fgetc()</code> and process each char?</p>
[ { "answer_id": 411958, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 3, "selected": false, "text": "#include <stdio.h>\n\nFILE * fp ;\nchar bufr[MAXLINE];\n\nif((fp = fopen(filename, \"r\") != NULL){\n while(! fe...
2009/01/04
[ "https://Stackoverflow.com/questions/411921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39106/" ]
411,945
<p>I'm new to java but I would have thought this was pretty straight foward. I display a JDialog for user input when importing data from a text file but the dialog isn't being painted properly on other computers.</p> <p>On my computer if I run the program from within NetBeans or from the command prompt then the dialog displays properly. If I run the program on the computer it's supposed to be running on then the inside of the dialog isn't painted - all I see is the border of the dialog then the screen behind it where the controls should be. This computer is running XPSP2 and jre6 update 11.</p> <p>Does anyone know what could be going wrong?</p> <p>TIA</p>
[ { "answer_id": 412685, "author": "Nick Fortescue", "author_id": 5346, "author_profile": "https://Stackoverflow.com/users/5346", "pm_score": 0, "selected": false, "text": "UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());\n" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
411,954
<p>Over the years most web developers will have built an arsenal of tools or "tools of the trade". Recently I discovered rsync and I am surprised how I managed to live without it all these years. What tools do you consider to be the most compelling? Please stick to the ones you use on a regular basis and swear by. They can also be frameworks, platforms, editors and whatever else you think web developers ought to be using (jquery, joomla, xdebug, vi, notepad++, etc).</p> <p>I'll start off with a couple:</p> <ol> <li><a href="http://samba.anu.edu.au/ftp/rsync/rsync.html" rel="noreferrer">rsync</a> - 'One click' sync to live servers or vice-versa</li> <li><a href="http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html" rel="noreferrer">mysqldump</a> - used alongside rsync to sync the databases</li> <li><a href="https://www.squarefree.com/bookmarklets/webdevel.html" rel="noreferrer">test styles bookmarklet</a> - live css editor bookmarklet which beats the heck out of the 'edit > save > reload' cycle by allowing live editing.</li> <li><a href="https://www.squarefree.com/bookmarklets/webdevel.html" rel="noreferrer">javascript shell</a> - javascript shell window attached to a window</li> <li><a href="http://www.getfirebug.com/" rel="noreferrer">firebug</a> - advanced javascript/css/dom debugger</li> <li><a href="http://pear.php.net/package/PHP_Shell/" rel="noreferrer">php-shell</a> - I use this regularly for quickly testing statements, functions, classes or scripts</li> <li><a href="http://css-discuss.incutio.com/" rel="noreferrer">CSS-Discuss Wiki</a> - I'd be surprised if you couldn't find a solution to your CSS problem on this wiki (in which case you should add it)</li> <li><a href="http://media.24ways.org/2007/17/fontmatrix.html" rel="noreferrer">Font Matrix</a> - Helps me choose font stacks</li> <li><a href="http://www.phpmyadmin.net/" rel="noreferrer">PHPMyAdmin</a> - I'm certain everyone uses this for managing their MySQL databases but thought I'd add it to the list for good measure</li> </ol> <p>Even though I have highlighted tools in the LAMP environment, you may mention tools you use in your environment.</p>
[ { "answer_id": 485811, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "echo 'foo=1&bar=2' | lynx -post\\_data -mime\\_header http://localhost/my/app" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/411954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50475/" ]
411,974
<p>My objective is to retry an asynchronous HttpWebRequest when it fails.</p> <p>When I <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.abort.aspx" rel="nofollow noreferrer">Abort()</a> an HttpWebRequest, I cannot BeginGetResponse() again. So the only way to request again probably is recreate the HttpWebRequest object. It seems to require a lot of work since I would have to copy all properties from the old object. Is there any shortcut? </p> <p>Note: I think that serialization it would solve my problem, but this class won't serialize, as discussed in a <a href="https://stackoverflow.com/questions/351265/httpwebrequest-wont-serialize">previous question</a>.</p> <p><strong>Update</strong> Removed example source code because it was unnecessary</p> <p><strong>Current view on this matter</strong> There is no shortcut, the only way to redo the request is creating another HttpWebRequest object the same way you created the original one.</p>
[ { "answer_id": 34860910, "author": "Elad Nava", "author_id": 1123355, "author_profile": "https://Stackoverflow.com/users/1123355", "pm_score": 3, "selected": true, "text": "HttpWebRequest /// <summary>\n/// Clones a HttpWebRequest for retrying a failed HTTP request.\n/// </summary>\n/// ...
2009/01/05
[ "https://Stackoverflow.com/questions/411974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48465/" ]
411,976
<p>I am in the early stages of planning and designing a custom accounting application for my firm. My goal is to utilize an open source relational database for the data storage portion and I'm aware of two solid databases that are widely supported: MySQL and PostgreSQL.</p> <p>For a system that will require transactions, stored procedures, functions, and security, are there any opinions on which of these two databases would be best suited for an accounting application or is there another database I'm missing?</p> <p>I'm more familiar with MySQL and MS SQLServer 2005, but I'm trying to move away from the latter due to license costs.</p> <p><em>Let me add: This is not an accounting need like Quickbooks or Peachtree. This is basically a system that handles accounting for a specific business service we provide. There are maybe two or three systems that cater to this need, are priced in the six figure range before any customization, and would require my small firm to be married to a vendor for the long-term. Thus, we are building the application in-house.</em></p> <p><em>Also, while I appreciate the <strong>Buy vs. Build</strong> argument, I'd like to move away from that particular religious question because the Buy road was already taken and the vendor failed miserably. Sometimes you just need to do the job yourself and this particular project and budget warrants it.</em></p> <p>Thanks for everyone's replies thus far.</p>
[ { "answer_id": 412015, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 3, "selected": false, "text": "FLOAT DOUBLE PRECISION" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/411976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51482/" ]
411,982
<p>For my Swing project, I need to support both <strong>Java 5</strong> and <strong>Java 6</strong>. I have defined a custom <code>JComponent</code> (call it <code>Picture</code>) and, after embedding it in a <code>JScrollPane</code>, I put it in a <code>JPanel</code> that uses DesignGridLayout manager. </p> <p>DesignGridLayout supports baseline alignment thanks to <strong>swing-layout</strong> open source library (implements baseline support for Java 5 and provides compatibility with the new Java 6 baseline support).</p> <p>My <code>Picture</code> class <em>overrides</em> <code>public int getBaseline(int width, int height)</code> so that I can define a correct baseline for it. Note that "<em>override</em>" is not completely correct: it overrides the method on Java6 but defines it in Java5.</p> <p>When I run my sample app <strong>on Java5, everything is fine</strong>: the <code>Picture</code> baseline I have defined is correctly used.</p> <p>However, <strong>when I use Java6</strong>, my <code>Picture#getBaseline()</code> method does not get called! And of course <strong>the baseline alignment of my picture is terrible</strong> (centered).</p> <p>After checking in Java6 source, I have seen that, in <code>BasicScrollPaneUI</code>, <code>getBaseline()</code> calls first <code>getBaselineResizeBehavior()</code> on the viewport component (my <code>Picture</code> instance). And it will call <code>getBaseline()</code> only if <code>getBaselineResizeBehavior()</code> returns <code>Component.BaselineResizeBehavior.CONSTANT_ASCENT</code>.</p> <p>Now my problem is that <code>getBaselineResizeBehavior()</code> is a Java6 method of <code>JComponent</code> that I cannot implement in Java5 because it returns an enum <code>Component.BaselineResizeBehavior</code> which does not exist in Java5.</p> <p>So my question (finally) is: how can I implement (or simulate?) <code>getBaselineResizeBehavior()</code> so that my class can still compile and run in a Java5 environment?</p>
[ { "answer_id": 412002, "author": "Lawrence Dol", "author_id": 8946, "author_profile": "https://Stackoverflow.com/users/8946", "pm_score": 0, "selected": false, "text": "try {\n Field fld=Class.forName(\"java.awt.Dialog$ModalExclusionType\").getField(\"TOOLKIT_EXCLUDE\");\n Method ...
2009/01/05
[ "https://Stackoverflow.com/questions/411982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1440720/" ]
412,011
<p>I have been working on a WCF service library where hopefully all the business logic will end up living. The problem that I am running into is that sometimes I have to make quick fixes to a service and in order to apply those fixes I have to stop the Windows Service, replace the service dll and then restart the Windows service. This is going to start to cause additional headaches as we start migrating more and more of our logic to this layer and have to shutdown the entire service in order to make any changes.</p> <p>What I would like to do is create an empty shell of a Windows service and dynamically load and unload the services. What is the best way to load and unload .Net DLLs on demand? Or is it better to rely on IIS for this kind of service?</p>
[ { "answer_id": 412072, "author": "Sailing Judo", "author_id": 42620, "author_profile": "https://Stackoverflow.com/users/42620", "pm_score": 2, "selected": false, "text": "Assembly a = GetAssembly();\nType t = ExportModule.GetExportType(a);\nif (t == null) throw new Exception(\"No proper ...
2009/01/05
[ "https://Stackoverflow.com/questions/412011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48832/" ]
412,014
<p>I'm trying to make a form invisible for x amount of time in c#. Any ideas?</p> <p>Thanks, Jon</p>
[ { "answer_id": 412029, "author": "BFree", "author_id": 15861, "author_profile": "https://Stackoverflow.com/users/15861", "pm_score": 2, "selected": false, "text": "Timer timer = new Timer();\nprivate int counter = 0;\n public Form1()\n {\n InitializeComponent();...
2009/01/05
[ "https://Stackoverflow.com/questions/412014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40399/" ]
412,019
<p>I've been profiling an application all day long and, having optimized a couple bits of code, I'm left with this on my todo list. It's the activation function for a neural network, which gets called over a 100 million times. According to dotTrace, it amounts to about 60% of the overall function time.</p> <p>How would you optimize this?</p> <pre><code>public static float Sigmoid(double value) { return (float) (1.0 / (1.0 + Math.Pow(Math.E, -value))); } </code></pre>
[ { "answer_id": 412027, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 7, "selected": true, "text": "public static float Sigmoid(double value) {\n return 1.0f / (1.0f + (float) Math.Exp(-value));\n}\n public static ...
2009/01/05
[ "https://Stackoverflow.com/questions/412019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40164/" ]
412,022
<p>I have a stored procedure in my database that calculates the distance between two lat/long pairs. This stored procedure is called "DistanceBetween". I have a SQL statement allows a user to search for all items in the Items table ordered by the distance to a supplied lat/long coordinate. The SQL statement is as follows:</p> <pre><code>SELECT Items.*, dbo.DistanceBetween(@lat1, @lat2, Latitude, Longitude) AS Distance FROM Items ORDER BY Distance </code></pre> <p>How do I go about using this query in NHibernate? The Item class in my domain doesn't have a "Distance" property since there isn't a "Distance" column in my Items table. The "Distance" property really only comes into play when the user is performing this search.</p>
[ { "answer_id": 423176, "author": "Sam", "author_id": 47636, "author_profile": "https://Stackoverflow.com/users/47636", "pm_score": 1, "selected": false, "text": "session.CreateSqlQuery(@\"SELECT {item.*}, dbo.DistanceBetween(:lat1, :lat2, {item}.Latitude, {item}.Longitude) AS Distance\n ...
2009/01/05
[ "https://Stackoverflow.com/questions/412022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
412,070
<p>Is there a good way, in a javascript onfocus() handler, to trampoline the focus to the next item in the tab order, without having to manually enter the ID of the item that should be next?</p> <p>I built an HTML date picker in Django/jQuery. It's a line edit followed by a calendar icon that pops up a calendar. I want to be able to tab from the line edit to the next input, skipping the link for the calendar icon. I mean for it to be a generalized widget, so I can't hardcode the id of whatever is next and call .focus(). I know I could set tabindex attributes on everything, but that's more manual than I'd like. Also, iirc, that wouldn't prevent it from taking the focus, it would just put it at the end of the tab order.</p>
[ { "answer_id": 412074, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 2, "selected": false, "text": "$(\"#your-calendar-icon\").focus(function() {\n $(this).trigger(\"blur\");\n);\n" }, { "answer_id": 412144,...
2009/01/05
[ "https://Stackoverflow.com/questions/412070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
412,101
<p>Let's say I have a table <em>tbl</em> with columns <em>id</em> and <em>title</em>. I need to change all values of title column:</p> <ol> <li>from 'a-1' to 'a1',</li> <li>from 'a.1' to 'a1',</li> <li>from 'b-1' to 'b1',</li> <li>from 'b.1' to 'b1'.</li> </ol> <p>Right now, I'm performing two UPDATE statements:</p> <pre><code>UPDATE tbl SET title='a1' WHERE title IN ('a-1', 'a.1') UPDATE tbl SET title='b1' WHERE title IN ('b-1', 'b.1') </code></pre> <p>This isn't at all a problem, if the table is small, and the single statement completes in less than a second and you only need a few statements to execute.</p> <p>You probably guested it - I have a huge table to deal with (one statement completes in about 90 seconds), and I have a huge number of updates to perform.</p> <p>So, is it possible to merge the updates so it would only scan the table once? Or perhaps, there's a better way to deal with in a situation like this.</p> <p>EDIT: Note, that the real data I'm working with and the changes to the data I have to perform are not really that simple - the strings are longer and they don't follow any pattern (it is user data, so no assumptions can be made - it can be anything).</p>
[ { "answer_id": 412115, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 2, "selected": false, "text": "UPDATE tbl \nSET title = left(title, 1) + right(title, 1) \nWHERE title IN ('a-1', 'a.1', 'b-1', 'b.1')\n" }, { ...
2009/01/05
[ "https://Stackoverflow.com/questions/412101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1353085/" ]
412,103
<p>For the purposes of unit testing I'd like to create an iPhone project target in Xcode that includes all of the release application files, plus some additional files containing code useful for UI unit testing.</p> <p>I can do this by duplicating the original application target; however, the problem with this is that every time I add a new source file to the app target, I need to also add it to the UnitTestUI target. It's not a big deal, just inconvenient to always remember to add files to both targets. </p> <p>Is there some way to set up a dependency so that every file added to the original app target is also auto added the unit test target?</p>
[ { "answer_id": 4401819, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 0, "selected": false, "text": ".m" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51503/" ]
412,124
<p>I just did a clean build and reinstall of lighttpd 1.4.20 on Mac OS X 10.5 and I can't find the configuration file.</p> <p>My goal was to install lighty to a single directory instead of being spread around, so I used the following commands successfully:</p> <pre><code>./configure --prefix="/usr/local/lighttpd" sudo make clean sudo make </code></pre> <p>This successfully put the binaries and libs in /usr/local/lighttpd/ like I wanted. However, the configuration file was not installed at /usr/local/lighttpd/doc/lightppd.conf as indicated in the INSTALL doc.</p> <p>Any idea where it would be? Or did I miss an option on ./configure ?</p>
[ { "answer_id": 4401819, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 0, "selected": false, "text": ".m" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/68788/" ]
412,151
<pre><code>public void test() { List&lt;int&gt; list = new List&lt;int&gt;(); list.Add(1); list.Add(2); list.Add(3); for (int i = 1; i &lt;= list.Count; i++) { textBx.Text = list[i].ToString(); // I want it to be textBx1.Text = list[1].ToString(); textBx2.Text = list[2].ToString(); textBx3.Text = list[3].Tostring(); etc. // I can't create textbox dynamically as I need the text box to be placed in specific places in the form . How do I do it the best way? } } </code></pre>
[ { "answer_id": 412160, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 4, "selected": true, "text": " var textBox = this.Controls.Find(\"textBx\" + i, true) as TextBox;\n textBox.Text = list[i].ToString();\n var textBoxes ...
2009/01/05
[ "https://Stackoverflow.com/questions/412151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42564/" ]
412,165
<p>I've been learning C++, coming from C#, where I've gotten used to using service providers: basically a Dictionary&lt;Type, object&gt;. Unfortunately, I can't figure out how to do this in C++. So the questions are basically:</p> <ol> <li><p>How would I make a dictionary in C++.</p></li> <li><p>How would I use 'Type' with it, as far as I know there is no 'Type' in C++.</p></li> <li><p>Same as above, but with 'object'.</p></li> </ol> <p>Thanks!</p>
[ { "answer_id": 412168, "author": "duffymo", "author_id": 37213, "author_profile": "https://Stackoverflow.com/users/37213", "pm_score": 0, "selected": false, "text": "std::map<K, T>" }, { "answer_id": 412188, "author": "wilhelmtell", "author_id": 456, "author_profile":...
2009/01/05
[ "https://Stackoverflow.com/questions/412165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51071/" ]
412,169
<p>How do I find an item in array which has the most occurrences?</p> <pre><code>[1, 1, 1, 2, 3].mode =&gt; 1 ['cat', 'dog', 'snake', 'dog'].mode =&gt; dog </code></pre>
[ { "answer_id": 412177, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 7, "selected": true, "text": "arr = [1, 1, 1, 2, 3]\n\nfreq = arr.inject(Hash.new(0)) { |h,v| h[v] += 1; h }\n#=> {1=>3, 2=>1, 3=>1}\n arr.max_by {...
2009/01/05
[ "https://Stackoverflow.com/questions/412169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
412,174
<p>In debugging a game that is full screen (on one of my two monitors) when it crashes and the debugger (on the other monitor, not captured) displays the crash location, the cursor is still hidden. Is there any way to force the cursor to reappear? I can click around blindly and it works, but it's not terrible accurate.</p>
[ { "answer_id": 412177, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 7, "selected": true, "text": "arr = [1, 1, 1, 2, 3]\n\nfreq = arr.inject(Hash.new(0)) { |h,v| h[v] += 1; h }\n#=> {1=>3, 2=>1, 3=>1}\n arr.max_by {...
2009/01/05
[ "https://Stackoverflow.com/questions/412174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
412,178
<pre><code>int[] mylist = { 2, 4, 5 }; IEnumerable&lt;int&gt; list1 = mylist; list1.ToList().Add(1); // why 1 does not get addedto list1?? </code></pre>
[ { "answer_id": 413275, "author": "Andrei Rînea", "author_id": 1796, "author_profile": "https://Stackoverflow.com/users/1796", "pm_score": 1, "selected": false, "text": "int[] mylist = { 2, 4, 5 };\nIEnumerable<int> list1 = mylist;\nList<int> lst = list1.ToList();\nlst.Add(1);\nmylist = l...
2009/01/05
[ "https://Stackoverflow.com/questions/412178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42564/" ]
412,183
<p>I want to convert function object to function.</p> <p>I wrote this code, but it doesn't work.</p> <pre><code>#include &lt;iostream&gt; typedef int (*int_to_int)(int); struct adder { int n_; adder (int n) : n_(n) {} int operator() (int x) { return x + n_; } operator int_to_int () { return this-&gt;*&amp;adder::operator(); } }; int main(void) { adder add_two(2); int_to_int add_fn = add_two; std::cout &lt;&lt; add_two(3) &lt;&lt; std::endl; // expect 5 std::cout &lt;&lt; add_fn(3) &lt;&lt; std::endl; // expect 5 add_fn = adder(5); std::cout &lt;&lt; add_fn(3) &lt;&lt; std::endl; // expect 8 return 0; } </code></pre> <p>and I got message from g++, says <code>invalid use of non-static member function</code>.</p> <p>How do I get pointer to member function of instance?</p> <p><strong>Edit</strong>:My original problem is about Win32 API.</p> <p>I'm forced to write windows program with old Win32 API at school. but I don't want to write horrible switch statement like some example codes on text. Then, I decided to write wrapper in C++.</p> <p>I want to write the window class like ... </p> <pre><code>class Window { public: LRESULT update (HWND, UINT, WPARAM, LPARAM); void run(); // below methods are called by update() virtual void onclick(int, int); virtual void ondraw(); // ... and more methods }; </code></pre> <p>and I'm willing to write my application class with deriving this class and overloading some methods.</p> <p>Finally, my actual probrem is how to do this in C++.</p> <pre><code> // on initializing my window object, // I must register window class with callback which is // not a C++ function object. // I try to explain what I want to do with psudocode mixing C++ and javascript. WNDCLASS wndclass; Window *self = this; wndclass.lpfnWndProc = function () { return self.update.apply(self, argunemts); }; </code></pre> <p>In other word, I have to make closure into function pointer. I don't know how to do this, but I can't believe this can't do in C++.</p> <p><strong>Edit</strong>: The original title of this question was <em>How to get pointer-to-member-function of instance</em>. But this title and my question didn't tell my actual problem enough. Sorry to early answerers, and litb, thank you for suggestion and very useful answer!</p>
[ { "answer_id": 412199, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 3, "selected": true, "text": "LRESULT CALLBACK my_callback(HWND hwnd, UINT ui, WPARAM wp, LPARAM lp) {\n Window * self = reinterpret_ca...
2009/01/05
[ "https://Stackoverflow.com/questions/412183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28720/" ]
412,184
<p>Back in the ITAR era, there was a <a href="http://www.cypherspace.org/adam/rsa/perl-dh.html" rel="nofollow noreferrer">popular sig that performed Diffie-Hellman key exchange</a>:</p> <pre><code>#!/usr/bin/perl -- -export-a-crypto-system-sig Diffie-Hellman-2-lines ($g,$e,$m)=@ARGV,$m||die"$0 gen exp mod\n";print`echo "16dio1[d2%Sa2/d0&lt;X+d *La1=z\U$m%0]SX$e"[$g*]\EszlXx+p|dc` </code></pre> <p>With a modern dc, this can be reduced quite a bit to:</p> <pre><code>dc -e '16dio???|p' </code></pre> <p>While the modern dc form with the modular exponentiation command ('|' computes g^e % m via efficient exponential doubling) is likely unbeatable other than perhaps <a href="https://stackoverflow.com/questions/237496/code-golf-factorials">APL</a>, can the original form be improved upon? Keep in mind that the e and m values will be very large; they will both be on the order of 1024 bits each for cryptographic security.</p>
[ { "answer_id": 412254, "author": "ShreevatsaR", "author_id": 4958, "author_profile": "https://Stackoverflow.com/users/4958", "pm_score": 4, "selected": true, "text": "dc program g x m ./dh.pl 10 2 9\n4\n dc 16dio???|p dc | dc ls dc -e '16dio???|p' dc dc -e '16dio?|p'" }, { "answe...
2009/01/05
[ "https://Stackoverflow.com/questions/412184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14105/" ]
412,187
<p>I'm trying to implement the Media Player custom field control described in this MSDN article: <a href="http://msdn.microsoft.com/en-us/library/aa981226.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa981226.aspx</a></p> <p>I created a custom site column (of type Link) in a custom content type and followed all the instructions to deploy the solution into SharePoint and add the control to a Page Layout. </p> <p>However, when I create a page based on a page layout that uses this field control, nothing is displayed in either Edit or View mode of the page. </p> <p>I dug around in the SharePoint logs, and at the time the page is loaded, I see the following error in ULS:</p> <p>Control template "MediaPlayerFieldControl" does not exist.</p> <p>If you've implemented this control, did you have to implement anything other than what the article details? Pretty sure I don't need an ASCX here because the control is handling rendering the media player. </p> <p>Thank you</p>
[ { "answer_id": 414512, "author": "George Durzi", "author_id": 36057, "author_profile": "https://Stackoverflow.com/users/36057", "pm_score": 2, "selected": true, "text": "<Assembly DeploymentTarget=\"GlobalAssemblyCache\" Location=\"MyControlAssembly.dll\">\n <SafeControls>\n <SafeCon...
2009/01/05
[ "https://Stackoverflow.com/questions/412187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36057/" ]
412,214
<p>I would like to force my python app to the front if a condition occurs. I'm using Kubuntu &amp; QT3.1</p> <p>I've tried setActiveWindow(), but it only flashes the task bar in KDE.</p> <p>I think Windows has a function bringwindowtofront() for VB.</p> <p>Is there something similar for KDE?</p>
[ { "answer_id": 412294, "author": "lpfavreau", "author_id": 35935, "author_profile": "https://Stackoverflow.com/users/35935", "pm_score": 1, "selected": false, "text": "setActiveWindow show()\nraise() # this might be raiseW() in Python\nsetActiveWindow()\n" }, { "answer_id": 41518...
2009/01/05
[ "https://Stackoverflow.com/questions/412214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51517/" ]
412,218
<p>I'm currently a .NET developer, but I'm starting to work with Flex a little bit and I've found the community to be great. There are a lot of great resources out there, but one of the issues I'm running into conceptually is how to organize a flex project. Coming from the standpoint of a "traditional" ASP.NET web application I'd create folders of related pages, controls, CSS, JavaScript, etc. </p> <p>What's the best pattern for organizing a flex application? I like using the code behind pattern with my MXML files, but these aren't really "pages" per se, so how do you keep from just dumping everything into the root of your src folder?</p>
[ { "answer_id": 412298, "author": "Brandon", "author_id": 23133, "author_profile": "https://Stackoverflow.com/users/23133", "pm_score": 2, "selected": false, "text": "ProjectName\n-assets\n--images\n-lib\n-locale\n-src\n--com\n---company\n----project\n-----model\n-----events\n-----view\n-...
2009/01/05
[ "https://Stackoverflow.com/questions/412218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4541/" ]
412,227
<p>You always hear that functional code is inherently easier to parallelize than non-functional code, so I decided to write a function which does the following:</p> <p>Given a input of strings, total up the number of unique characters for each string. So, given the input <code>[ "aaaaa"; "bbb"; "ccccccc"; "abbbc" ]</code>, our method will returns <code>a: 6; b: 6; c: 8</code>.</p> <p>Here's what I've written:</p> <pre><code>(* seq&lt;#seq&lt;char&gt;&gt; -&gt; Map&lt;char,int&gt; *) let wordFrequency input = input |&gt; Seq.fold (fun acc text -&gt; (* This inner loop can be processed on its own thread *) text |&gt; Seq.choose (fun char -&gt; if Char.IsLetter char then Some(char) else None) |&gt; Seq.fold (fun (acc : Map&lt;_,_&gt;) item -&gt; match acc.TryFind(item) with | Some(count) -&gt; acc.Add(item, count + 1) | None -&gt; acc.Add(item, 1)) acc ) Map.empty </code></pre> <p>This code is ideally parallelizable, because each string in <code>input</code> can be processed on its own thread. Its not as straightforward as it looks since the innerloop adds items to a Map shared between all of the inputs.</p> <p>I'd like the inner loop factored out into its own thread, and I don't want to use any mutable state. <b>How would I re-write this function using an Async workflow?</b></p>
[ { "answer_id": 414242, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 3, "selected": true, "text": "#light\n\nlet input = [| \"aaaaa\"; \"bbb\"; \"ccccccc\"; \"abbbc\" |]\n\n// first discover all unique letters used\nlet Lett...
2009/01/05
[ "https://Stackoverflow.com/questions/412227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40516/" ]
412,230
<p>I'm working on a new project and I'm using the repository pattern, I have my repository that pulls the data from the database and a "service" class which uses the repository and does all the business logic.</p> <p>something similar to the following;</p> <pre><code>public class UserRepository : IUserRepository { public IQueryable&lt;User&gt; GetUsers() { // do stuff } } public class UserService { public IList&lt;User&gt; GetUserById { var rep = new UserRepository(); var users = rep.GetUsers(); // do business logic return users.ToList(); } } </code></pre> <p>Would you test both the UserService and the UserRepository or do you think testing just the Service would suffice? I figure since the service is using the repository it should be fun, but it does kill code coverage.</p>
[ { "answer_id": 412239, "author": "Norman Ramsey", "author_id": 41661, "author_profile": "https://Stackoverflow.com/users/41661", "pm_score": 2, "selected": false, "text": "UserService UserService UserService" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17176/" ]
412,256
<p>Can the iPhone determine if you're facing north, south, east or west?</p>
[ { "answer_id": 477290, "author": "Niels Hansen", "author_id": 56329, "author_profile": "https://Stackoverflow.com/users/56329", "pm_score": 0, "selected": false, "text": "[[self delegate] currentDirectionLat:newLocation.coordinate.latitude Long:newLocation.coordinate.longitude];\n -(void...
2009/01/05
[ "https://Stackoverflow.com/questions/412256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46182/" ]
412,300
<p>Smashed my head against this a bit too long. How do I prevent a user from browsing a site's pages after they have been logged out using FormsAuthentication.SignOut? I would expect this to do it:</p> <pre><code>FormsAuthentication.SignOut(); Session.Abandon(); FormsAuthentication.RedirectToLoginPage(); </code></pre> <p>But it doesn't. If I type in a URL directly, I can still browse to the page. I haven't used roll-your-own security in a while so I forget why this doesn't work.</p>
[ { "answer_id": 412312, "author": "jwalkerjr", "author_id": 689, "author_profile": "https://Stackoverflow.com/users/689", "pm_score": 4, "selected": false, "text": "<authentication mode=\"Forms\">\n <forms name=\"MyCookie\" loginUrl=\"Login.aspx\" protection=\"All\" timeout=\"90\" slidin...
2009/01/05
[ "https://Stackoverflow.com/questions/412300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38398/" ]
412,305
<p>If I create a TcpChannel using port zero i.e. allowing .Net Remoting to allocate an available port, is there anyway to then determine which port number has been allocated? </p> <p>I know that I can specify the port number when creating the channel, however I don't want to do this as I want to run multiple instances of the listening application on the same Citrix server - each instance listening on a different port. </p> <p>Ideally I don't want to have to go to the trouble of reserving a bunch of ports and then keeping track of which ones have been allocated. I'd just like to let the port be allocated automatically - but then I need to be able to know which port number has been allocated.</p>
[ { "answer_id": 412320, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": false, "text": "TcpServerChannel TcpServerChannel GetChannelUri() new Uri(s).Port var channel = new TcpChannel(0);\n var channelData ...
2009/01/05
[ "https://Stackoverflow.com/questions/412305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10135/" ]
412,314
<p>I'm trying to find out the best practices for real-world application development. I'm having trouble understanding how to properly configure third-party libraries for deployment as a standalone package. It seems that ASDF-INSTALL and ASDF are intended to install libraries to either home or site, changing the state of the development platform. That's fine if I were developing a server side application and I wanted to administer these dependencies for the entire CL installation on the box.</p> <p>But what if I wanted to create a standalone application, deployed via install scripts, and running alone in its own CL instance? I would want to avoid changing the CL instance or target system configuration for any other applications (i.e. overwrite other copies of libraries that other applications depend on). In Java, all I have to do is create an include directory that contains those libraries and set my CLASSPATH. How do I get the same level of isolation in CL, assuming that I don't install my own CL runtime, and instead use what's on the system?</p> <p>It occurs to me that this is a common issue with all dynamically compiled/interpreted languages, since the runtime will have a lifetime longer than any particular application that the runtime runs (i.e. Ruby or Python), and applications will share the same library load state. I don't have any experiences with such languages, so the best practice is probably staring me in the face.</p> <p>IDK if this would be implementation specific, but I am running Clozure CL.</p> <p>EDIT:</p> <p>Ramarren:</p> <p>I'll check out Mudballs. Thank you.</p> <p>Installing libraries is the opposite of what I want, since installing implies modifying the host system state. I think the key must be in your last paragraph. How do you create the startup script to set <em>central-registry</em> to an isolated directory? Is it possible to use ASDF-INSTALL to fetch stuff into said directory? And how do you bootstrap the whole thing if the base image of your CL implementation doesn't include ASDF (Clozure has ASDF by default, but how would CLISP do it)?</p> <p>I'm thinking in terms of a dev team too. After I create a new CL project stub and do that initial commit to CVS or SVN, how do other devs check it out to their local environment and work with it? Even assuming that everyone has ASDF in their profile/site startup, other devs may have a different set of libs in their <em>central-registry</em>. We shouldn't have to sync up just to work on a project together. There's got to be a clean way to launch an project specific instance of the CL runtime from Emacs/SLIME and load exactly what's specified in the project, no more, no less.</p> <p>If there's any best practice resources online, in CL or any other language, I'll be glad to roll my own solution and open source it.</p> <p>Luis:</p> <p>SAVE-APPLICATION is good for deployment, but not for the multiple-dev project stub I outlined.</p> <p>EDIT 2:</p> <p>vatine:</p> <p>Version dependency is precisely why this is a problem. If I were developing a Perl or Ruby web app, then I can depend on the existence of a webadmin to manage these dependencies. Developing apps for retail or for small-to-mid-size businesses where Lisp is alien technology (and I cannot convince them to "skill up" their IT org to admin it), that approach is unacceptable.</p> <p>I was able last night to kind of get what I want by creating a project-level .lisp file that loads its own project-specific ASDF instance, set a project-local <em>central-registry</em>, and manually downloading dependent libs (without ASDF-INSTALL, which was a painful cascade of dependencies for just CLSQL and Weblocks). It still isn't ideal from a dev tools standpoint, since I had to remove all customization from my home and site for both SLIME and Clozure itself. Also, shared dependencies aren't resolved either (CLSQL and Weblocks both use MD5).</p> <p>Java has class loader isolation, which is how it solves the version dependency issue. Then there's the separate issue of how to get the libs you want into the project (a la Maven). The former is a core language issue; the latter has to do with tools. I'm going to hack together a SLIME extension that does what ASDF-INSTALL does to a project include directory (a la Maven), and modifies lib source code to intercept defpackage calls to somehow prepend a gensym string to enforce isolation. There's plenty of holes in this approach, I know, and I don't know enough about the package spec to know how deep I can bury this.</p> <p>I don't know anything about Python, but I do know that retail-level apps exist; I use MusicBrainz Picard all the time. I'll look into how Python does it.</p>
[ { "answer_id": 413175, "author": "Ramarren", "author_id": 7770, "author_profile": "https://Stackoverflow.com/users/7770", "pm_score": 1, "selected": false, "text": "asdf:*central-registry* (setf asdf:*central-registry* (list #p\"pathtoprojectcentralregistry\"))" }, { "answer_id":...
2009/01/05
[ "https://Stackoverflow.com/questions/412314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45051/" ]
412,319
<p>I'm using the built-in system class for sending emails in .NET. It's in System.Mail namespace or something like that.</p> <p>I need to add an interface to this class so I can swap it out for testing or another implementation.</p> <p>To do this, I just define a class that wraps this built-in class?</p> <p>Is this an example of the decorator pattern? I'm just a bit confused because the description of the decorator pattern usually states that it is used to add functionality, and I won't be adding any.</p>
[ { "answer_id": 412327, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "IEmail BasicEmail LoggingEmail IEmail ForwardingEmail IEmail To `ForwardingEmail` => `LoggingEmail` => `BasicEmail` =...
2009/01/05
[ "https://Stackoverflow.com/questions/412319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
412,331
<p>I am trying to pass an XML list to a view but I am having trouble once I get to the view.</p> <p>My controller:</p> <pre><code> public ActionResult Search(int isbdn) { ViewData["ISBN"] = isbdn; string pathToXml= "http://isbndb.com/api/books.xml?access_key=DWD3TC34&amp;index1=isbn&amp;value1="; pathToXml += isbdn; var doc = XDocument.Load(pathToXml); IEnumerable&lt;XElement&gt; items = from m in doc.Elements() select m; </code></pre> <p>What would my view look like? Do I need to incorporate some type of XML data controller?</p>
[ { "answer_id": 412335, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 2, "selected": false, "text": "ViewData[\"XmlItems\"] = items;\n <% foreach(XElement e in ViewData[\"XmlItems\"] as IEnumerable<XElement>) { %>\n <!-- ...
2009/01/05
[ "https://Stackoverflow.com/questions/412331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67445/" ]
412,341
<p>Do I use varchar(36) or are there any better ways to do it?</p>
[ { "answer_id": 7168916, "author": "KCD", "author_id": 516748, "author_profile": "https://Stackoverflow.com/users/516748", "pm_score": 5, "selected": false, "text": "DELIMITER $$\n\nCREATE FUNCTION `GuidToBinary`(\n $Data VARCHAR(36)\n) RETURNS binary(16)\nDETERMINISTIC\nNO SQL\nBEGIN\...
2009/01/05
[ "https://Stackoverflow.com/questions/412341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50542/" ]
412,344
<p>I know downcasting like this won't work. I need a method that WILL work. Here's my problem: I've got several different derived classes all from a base class. My first try was to make an array of base class. The program has to select (more or less at random) different derived classes. I had tried casting from a base class to the derived class, putting it in the array of the base, but obviously that didn't work. I was sincerely hoping for another method than simply sticking arrays of all the derived classes, because there could be quite a few derived classes. Is there any better way to do this that I'm just brainfarting on? </p> <p>If y'all need code examples or more information, just let me know. It all makes sense to me, but It's late and it may not make sense to everybody else heh. </p> <p>Any help is very much appreciated, guys.</p>
[ { "answer_id": 412351, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 1, "selected": false, "text": "BaseClass* BaseClass" }, { "answer_id": 412356, "author": "Johannes Schaub - litb", "author_id": 34509, ...
2009/01/05
[ "https://Stackoverflow.com/questions/412344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48957/" ]
412,345
<p>Are there any lint tools available for actionscript? One source would be ideal, but anything is welcome.</p> <p>My team is starting to adopt more a more rigorous style guide (where "more rigorous" means "existant"), and I think a linter would help us all adhere more easily to the style rules we've agreed on. I'm not above writing my own, but I'd like to see what else is out there first.</p> <p>A quick search on Google reveals nothing (at least so far).</p>
[ { "answer_id": 705797, "author": "Ron DeVera", "author_id": 63428, "author_profile": "https://Stackoverflow.com/users/63428", "pm_score": 2, "selected": false, "text": "mxmlc mxmlc" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41177/" ]
412,362
<p>To find files containing a particular string, I use this often</p> <p>find . -name * | xargs grep -iH "string"</p>
[ { "answer_id": 412375, "author": "Drakonite", "author_id": 49436, "author_profile": "https://Stackoverflow.com/users/49436", "pm_score": 0, "selected": false, "text": "grep -ri 'string'\n" }, { "answer_id": 412377, "author": "bugmagnet", "author_id": 426, "author_prof...
2009/01/05
[ "https://Stackoverflow.com/questions/412362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43756/" ]
412,368
<p>I've been playing with Python for a while and wrote a little program to make a database to keep track of some info (its really basic, and hand written). I want to add the ability to create a website from the data that I will then pass to my special little place on the internet. What should I use to build up the website? After dabbling with Django, I've found it overkill and over my head, but if that's the only option I'll learn to use it.</p> <p>Does anyone know an easy way to output a database of arbitrary format to one or more HTML (or different format) files?</p>
[ { "answer_id": 412371, "author": "Autoplectic", "author_id": 49994, "author_profile": "https://Stackoverflow.com/users/49994", "pm_score": 5, "selected": true, "text": "public_html" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51532/" ]
412,378
<p>I come from a C++ background where I can use template mixins to write code that refers to FinalClass which is a template parameter that is passed in. This allows reusable functions to be "mixed-in" to any derived class, by simply inheriting from ReusableMixin with a template paramter of MyFinalClass. This all gets inlined into the class so it's as though I just wrote a big class that did everything -- ie very fast! Since mixins can chain, I can mix-in all sorts of behaviour (and state) into one object.</p> <p>If anyone wants clarification on the technique, please ask. My question is, how can I get reuse like that in C#? Note: C# generics don't allow inheriting from a generic parameter.</p>
[ { "answer_id": 412549, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "public class MyClass\n{\n private readonly Mixin1 mixin1 = new Mixin1();\n private readonly Mixin2 mixin2 = new Mixin2();...
2009/01/05
[ "https://Stackoverflow.com/questions/412378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43058/" ]
412,380
<p>Is there a Java equivalent for <a href="http://msdn.microsoft.com/en-us/library/system.io.path.combine.aspx" rel="noreferrer"><code>System.IO.Path.Combine()</code></a> in C#/.NET? Or any code to accomplish this?</p> <p>This static method combines one or more strings into a path.</p>
[ { "answer_id": 412495, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 9, "selected": false, "text": "java.nio.file.Path Path.resolve Paths Path path = Paths.get(\"foo\", \"bar\", \"baz.txt\");\n java.io.File File baseDire...
2009/01/05
[ "https://Stackoverflow.com/questions/412380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
412,385
<p>I am including Javascript code that is used to pop up a calendar. The problem with the code is that I want a '0' to be inserted in front of the month or day if the month lies between 1--9 and days between 1--9 in the calendar. The following is the script. Can anybody guide me to the modifications?</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt; &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; &lt;!-- var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); var days = new Array("S", "M", "T", "W", "T", "F", "S"); today = new getToday(); var element_id; function getDays(month, year) { // Test for leap year when February is selected. if (1 == month) return ((0 == year % 4) &amp;&amp; (0 != (year % 100))) || (0 == year % 400) ? 29 : 28; else return daysInMonth[month]; } function getToday() { // Generate today's date. this.now = new Date(); this.year = this.now.getFullYear() ; // Returned year XXXX this.month = this.now.getMonth(); this.day = this.now.getDate(); } function newCalendar() { var parseYear = parseInt(document.all.year [document.all.year.selectedIndex].text); var newCal = new Date(parseYear , document.all.month.selectedIndex, 1); var day = -1; var startDay = newCal.getDay(); var daily = 0; today = new getToday(); // 1st call if ((today.year == newCal.getFullYear() ) &amp;&amp; (today.month == newCal.getMonth())) day = today.day; // Cache the calendar table's tBody section, dayList. var tableCal = document.all.calendar.tBodies.dayList; var intDaysInMonth = getDays(newCal.getMonth(), newCal.getFullYear() ); for (var intWeek = 0; intWeek &lt; tableCal.rows.length; intWeek++) for (var intDay = 0; intDay &lt; tableCal.rows[intWeek].cells.length; intDay++) { var cell = tableCal.rows[intWeek].cells[intDay]; // Start counting days. if ((intDay == startDay) &amp;&amp; (0 == daily)) daily = 1; // Highlight the current day. cell.style.color = (day == daily) ? "red" : ""; if(day == daily) { document.all.todayday.innerText= "Today: " + day + "/" + (newCal.getMonth()+1) + "/" + newCal.getFullYear() ; } // Output the day number into the cell. if ((daily &gt; 0) &amp;&amp; (daily &lt;= intDaysInMonth)) cell.innerText = daily++; else cell.innerText = ""; } } function getTodayDay() { document.all[element_id].value = today.year + "/" + (today.month+1) + "/" + today.day; //document.all.calendar.style.visibility="hidden"; document.all.calendar.style.display="none"; document.all.year.selectedIndex =100; document.all.month.selectedIndex = today.month; } function getDate() { // This code executes when the user clicks on a day // in the calendar. if ("TD" == event.srcElement.tagName) // Test whether day is valid. if ("" != event.srcElement.innerText) { var mn = document.all.month.selectedIndex+1; var Year = document.all.year [document.all.year.selectedIndex].text; document.all[element_id].value=Year +"-"+mn+"-"+event.srcElement.innerText; document.all.calendar.style.display="none"; } } function GetBodyOffsetX(el_name, shift) { var x; var y; x = 0; y = 0; var elem = document.all[el_name]; do { x += elem.offsetLeft; y += elem.offsetTop; if (elem.tagName == "BODY") break; elem = elem.offsetParent; } while (1 &gt; 0); shift[0] = x; shift[1] = y; return x; } function SetCalendarOnElement(el_name) { if (el_name=="") el_name = element_id; var shift = new Array(2); GetBodyOffsetX(el_name, shift); document.all.calendar.style.pixelLeft = shift[0]; // - document.all.calendar.offsetLeft; document.all.calendar.style.pixelTop = shift[1] + 25 ; } function ShowCalendar(elem_name) { if (elem_name=="") elem_name = element_id; element_id = elem_name; // element_id is global variable newCalendar(); SetCalendarOnElement(element_id); //document.all.calendar.style.visibility = "visible"; document.all.calendar.style.display="inline"; } function HideCalendar() { //document.all.calendar.style.visibility="hidden"; document.all.calendar.style.display="none"; } function toggleCalendar(elem_name) { //if (document.all.calendar.style.visibility == "hidden") if(document.all.calendar.style.display=="none") ShowCalendar(elem_name); else HideCalendar(); } --&gt; &lt;/script&gt; &lt;style&gt; .today {COLOR: black; FONT-FAMILY: sans-serif; FONT-SIZE: 10pt; FONT-WEIGHT: bold} .days {COLOR: navy; FONT-FAMILY: sans-serif; FONT-SIZE: 10pt; FONT-WEIGHT: bold; TEXT-ALIGN: center} .dates {COLOR: black; FONT-FAMILY: sans-serif; FONT-SIZE: 10pt} &lt;/style&gt; &lt;/head&gt; &lt;body bgcolor="#FFF8DC"&gt; &lt;h5&gt;Diesel Generators&lt;/h5&gt;&lt;br&gt;&lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;script language="JavaScript"&gt; function toggle(source) { checkboxes = document.getElementsByName('DG1'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; checkboxes = document.getElementsByName('DG2'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; checkboxes = document.getElementsByName('DG3'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; checkboxes = document.getElementsByName('DG4'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; checkboxes = document.getElementsByName('DG5'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; } &lt;/script&gt; &lt;input type="checkbox" onClick="toggle(this)" /&gt; Select All&lt;br/&gt; &lt;form method=POST action="DGUsageServlet"&gt; &lt;INPUT TYPE="CHECKBOX" name="DG1"&gt;DG1 &lt;INPUT TYPE="CHECKBOX" name="DG2"&gt;DG2 &lt;INPUT TYPE="CHECKBOX" name="DG3"&gt;DG3 &lt;INPUT TYPE="CHECKBOX" name="DG4"&gt;DG4 &lt;INPUT TYPE="CHECKBOX" name="DG5"&gt;DG5 &lt;br&gt; &lt;br&gt; &lt;INPUT TYPE=TEXT NAME="StartDate"&gt; &lt;a href="JavaScript:;" onClick="toggleCalendar('StartDate')"&gt;StartDate&lt;/a&gt; &lt;INPUT TYPE=TEXT NAME="EndDate"&gt; &lt;a href="JavaScript:;" onClick="toggleCalendar('EndDate')"&gt;EndDate&lt;/a&gt; &lt;input name=plotgraph value=plotgraph align="CENTER" type=submit&gt; &lt;/form&gt; &lt;TABLE bgColor=#ffffff border=1 cellPadding=0 cellSpacing=3 id=calendar style="DISPLAY: none; POSITION: absolute; Z-INDEX: 4"&gt; &lt;TBODY&gt; &lt;TR&gt; &lt;TD colSpan=7 vAlign=center&gt; &lt;!-- Month combo box --&gt; &lt;SELECT id=month onchange=newCalendar()&gt; &lt;script type="text/javascript"&gt; // Output months into the document. // Select current month. for (var intLoop = 0; intLoop &lt; months.length; intLoop++) document.write("&lt;OPTION " + (today.month == intLoop ? "Selected" : "") + "&gt;" + months[intLoop]); &lt;/SCRIPT&gt; &lt;/SELECT&gt; &lt;!-- Year combo box --&gt; &lt;SELECT id=year onchange=newCalendar()&gt; &lt;script type="text/javascript"&gt; // Output years into the document. // Select current year. for (var intLoop = 1900; intLoop &lt; 2028; intLoop++) document.write("&lt;OPTION " + (today.year == intLoop ? "Selected" : "") + "&gt;" + intLoop); &lt;/SCRIPT&gt; &lt;/SELECT&gt; &lt;/TD&gt; &lt;/TR&gt; &lt;TR class=days&gt; &lt;!-- Generate column for each day. --&gt; &lt;script type="text/javascript"&gt; // Output days. for (var intLoop = 0; intLoop &lt; days.length; intLoop++) document.write("&lt;TD&gt;" + days[intLoop] + "&lt;/TD&gt;"); &lt;/SCRIPT&gt; &lt;/TR&gt; &lt;TBODY class=dates id=dayList onclick="getDate('')" vAlign=center&gt; &lt;!-- Generate grid for individual days. --&gt; &lt;script type="text/javascript"&gt; for (var intWeeks = 0; intWeeks &lt; 6; intWeeks++) { document.write("&lt;TR&gt;"); for (var intDays = 0; intDays &lt; days.length; intDays++) document.write("&lt;TD&gt;" +intDays+ "&lt;/TD&gt;"); document.write("&lt;/TR&gt;"); } &lt;/SCRIPT&gt; &lt;!-- Generate today day. --&gt;&lt;/TBODY&gt; &lt;TBODY&gt; &lt;TR&gt; &lt;TD class=today colSpan=5 id=todayday onclick=getTodayDay()&gt;&lt;/TD&gt; &lt;TD align=right colSpan=2&gt;&lt;A href="javascript:HideCalendar();"&gt;&lt;SPAN style="COLOR: black; FONT-SIZE: 10px"&gt;&lt;B&gt;Hide&lt;/B&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/TD&gt; &lt;/TR&gt; &lt;/TBODY&gt; &lt;/TABLE&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 13147904, "author": "breakdj", "author_id": 1786930, "author_profile": "https://Stackoverflow.com/users/1786930", "pm_score": 0, "selected": false, "text": "var iv=\"3\";\nalert((\"0\"+iv).substring(-2,2));\niv=1;\nalert((\"0\"+iv).substring(-2,2));\niv=2;\nalert((\"0\"+iv...
2009/01/05
[ "https://Stackoverflow.com/questions/412385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48094/" ]
412,386
<p>Is there a way to determine if a specific type has been configured in StructureMap? </p> <p>I want to return a generic type if it has not be specifically configured in StructureMap.</p>
[ { "answer_id": 415812, "author": "Jon Cahill", "author_id": 10830, "author_profile": "https://Stackoverflow.com/users/10830", "pm_score": 2, "selected": false, "text": "TryGetInstance<T>() TryGetNamedInstance<T>() T T" }, { "answer_id": 2251850, "author": "Andrew Bullock", ...
2009/01/05
[ "https://Stackoverflow.com/questions/412386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10830/" ]
412,387
<p>The problem with the below code is that Select All options works very well in Mozilla and not in Internet Explorer. </p> <pre><code>&lt;!-- Document : DG Created on : Sep 11, 2008, 12:48:37 PM Author : padmaja --&gt; &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt; &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; &lt;!-- var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); var days = new Array("S", "M", "T", "W", "T", "F", "S"); today = new getToday(); var element_id; function getDays(month, year) { // Test for leap year when February is selected. if (1 == month) return ((0 == year % 4) &amp;&amp; (0 != (year % 100))) || (0 == year % 400) ? 29 : 28; else return daysInMonth[month]; } function getToday() { // Generate today's date. this.now = new Date(); this.year = this.now.getFullYear() ; // Returned year XXXX this.month = this.now.getMonth(); this.day = this.now.getDate(); } function newCalendar() { var parseYear = parseInt(document.all.year [document.all.year.selectedIndex].text); var newCal = new Date(parseYear , document.all.month.selectedIndex, 1); var day = -1; var startDay = newCal.getDay(); var daily = 0; today = new getToday(); // 1st call if ((today.year == newCal.getFullYear() ) &amp;&amp; (today.month == newCal.getMonth())) day = today.day; // Cache the calendar table's tBody section, dayList. var tableCal = document.all.calendar.tBodies.dayList; var intDaysInMonth = getDays(newCal.getMonth(), newCal.getFullYear() ); for (var intWeek = 0; intWeek &lt; tableCal.rows.length; intWeek++) for (var intDay = 0; intDay &lt; tableCal.rows[intWeek].cells.length; intDay++) { var cell = tableCal.rows[intWeek].cells[intDay]; // Start counting days. if ((intDay == startDay) &amp;&amp; (0 == daily)) daily = 1; // Highlight the current day. cell.style.color = (day == daily) ? "red" : ""; if(day == daily) { document.all.todayday.innerText= "Today: " + day + "/" + (newCal.getMonth()+1) + "/" + newCal.getFullYear() ; } // Output the day number into the cell. if ((daily &gt; 0) &amp;&amp; (daily &lt;= intDaysInMonth)) cell.innerText = daily++; else cell.innerText = ""; } } function getTodayDay() { document.all[element_id].value = today.year + "/" + (today.month+1) + "/" + today.day; //document.all.calendar.style.visibility="hidden"; document.all.calendar.style.display="none"; document.all.year.selectedIndex =100; document.all.month.selectedIndex = today.month; } function getDate() { // This code executes when the user clicks on a day // in the calendar. if ("TD" == event.srcElement.tagName) // Test whether day is valid. if ("" != event.srcElement.innerText) { var mn = document.all.month.selectedIndex+1; var Year = document.all.year [document.all.year.selectedIndex].text; document.all[element_id].value=Year +"-"+mn+"-"+event.srcElement.innerText; document.all.calendar.style.display="none"; } } function GetBodyOffsetX(el_name, shift) { var x; var y; x = 0; y = 0; var elem = document.all[el_name]; do { x += elem.offsetLeft; y += elem.offsetTop; if (elem.tagName == "BODY") break; elem = elem.offsetParent; } while (1 &gt; 0); shift[0] = x; shift[1] = y; return x; } function SetCalendarOnElement(el_name) { if (el_name=="") el_name = element_id; var shift = new Array(2); GetBodyOffsetX(el_name, shift); document.all.calendar.style.pixelLeft = shift[0]; // - document.all.calendar.offsetLeft; document.all.calendar.style.pixelTop = shift[1] + 25 ; } function ShowCalendar(elem_name) { if (elem_name=="") elem_name = element_id; element_id = elem_name; // element_id is global variable newCalendar(); SetCalendarOnElement(element_id); //document.all.calendar.style.visibility = "visible"; document.all.calendar.style.display="inline"; } function HideCalendar() { //document.all.calendar.style.visibility="hidden"; document.all.calendar.style.display="none"; } function toggleCalendar(elem_name) { //if (document.all.calendar.style.visibility == "hidden") if(document.all.calendar.style.display=="none") ShowCalendar(elem_name); else HideCalendar(); } --&gt; &lt;/script&gt; &lt;style&gt; .today {COLOR: black; FONT-FAMILY: sans-serif; FONT-SIZE: 10pt; FONT-WEIGHT: bold} .days {COLOR: navy; FONT-FAMILY: sans-serif; FONT-SIZE: 10pt; FONT-WEIGHT: bold; TEXT-ALIGN: center} .dates {COLOR: black; FONT-F AMILY: sans-serif; FONT-SIZE: 10pt} &lt;/style&gt; &lt;/head&gt; &lt;body bgcolor="#FFF8DC"&gt; &lt;h5&gt;Diesel Generators&lt;/h5&gt;&lt;br&gt;&lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;script language="JavaScript"&gt; function toggle(source) { checkboxes = document.getElementsByName('DG1'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; checkboxes = document.getElementsByName('DG2'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; checkboxes = document.getElementsByName('DG3'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; checkboxes = document.getElementsByName('DG4'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; checkboxes = document.getElementsByName('DG5'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; } &lt;/script&gt; &lt;input type="checkbox" onClick="toggle(this)" /&gt; Select All&lt;br/&gt; &lt;form method=POST action="DGUsageServlet"&gt; &lt;INPUT TYPE="CHECKBOX" name="DG1"&gt;DG1 &lt;INPUT TYPE="CHECKBOX" name="DG2"&gt;DG2 &lt;INPUT TYPE="CHECKBOX" name="DG3"&gt;DG3 &lt;INPUT TYPE="CHECKBOX" name="DG4"&gt;DG4 &lt;INPUT TYPE="CHECKBOX" name="DG5"&gt;DG5 &lt;br&gt; &lt;br&gt; &lt;INPUT TYPE=TEXT NAME="StartDate"&gt; &lt;a href="JavaScript:;" onClick="toggleCalendar('StartDate')"&gt;StartDate&lt;/a&gt; &lt;INPUT TYPE=TEXT NAME="EndDate"&gt; &lt;a href="JavaScript:;" onClick="toggleCalendar('EndDate')"&gt;EndDate&lt;/a&gt; &lt;input name=plotgraph value=plotgraph align="CENTER" type=submit&gt; &lt;/form&gt; &lt;TABLE bgColor=#ffffff border=1 cellPadding=0 cellSpacing=3 id=calendar style="DISPLAY: none; POSITION: absolute; Z-INDEX: 4"&gt; &lt;TBODY&gt; &lt;TR&gt; &lt;TD colSpan=7 vAlign=center&gt; &lt;!-- Month combo box --&gt; &lt;SELECT id=month onchange=newCalendar()&gt; &lt;script type="text/javascript"&gt; // Output months into the document. // Select current month. for (var intLoop = 0; intLoop &lt; months.length; intLoop++) document.write("&lt;OPTION " + (today.month == intLoop ? "Selected" : "") + "&gt;" + months[intLoop]); &lt;/SCRIPT&gt; &lt;/SELECT&gt; &lt;!-- Year combo box --&gt; &lt;SELECT id=year onchange=newCalendar()&gt; &lt;script type="text/javascript"&gt; // Output years into the document. // Select current year. for (var intLoop = 1900; intLoop &lt; 2028; intLoop++) document.write("&lt;OPTION " + (today.year == intLoop ? "Selected" : "") + "&gt;" + intLoop); &lt;/SCRIPT&gt; &lt;/SELECT&gt; &lt;/TD&gt; &lt;/TR&gt; &lt;TR class=days&gt; &lt;!-- Generate column for each day. --&gt; &lt;script type="text/javascript"&gt; // Output days. for (var intLoop = 0; intLoop &lt; days.length; intLoop++) document.write("&lt;TD&gt;" + days[intLoop] + "&lt;/TD&gt;"); &lt;/SCRIPT&gt; &lt;/TR&gt; &lt;TBODY class=dates id=dayList onclick="getDate('')" vAlign=center&gt; &lt;!-- Generate grid for individual days. --&gt; &lt;script type="text/javascript"&gt; for (var intWeeks = 0; intWeeks &lt; 6; intWeeks++) { document.write("&lt;TR&gt;"); for (var intDays = 0; intDays &lt; days.length; intDays++) document.write("&lt;TD&gt;" +intDays+ "&lt;/TD&gt;"); document.write("&lt;/TR&gt;"); } &lt;/SCRIPT&gt; &lt;!-- Generate today day. --&gt;&lt;/TBODY&gt; &lt;TBODY&gt; &lt;TR&gt; &lt;TD class=today colSpan=5 id=todayday onclick=getTodayDay()&gt;&lt;/TD&gt; &lt;TD align=right colSpan=2&gt;&lt;A href="javascript:HideCalendar();"&gt;&lt;SPAN style="COLOR: black; FONT-SIZE: 10px"&gt;&lt;B&gt;Hide&lt;/B&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/TD&gt; &lt;/TR&gt; &lt;/TBODY&gt; &lt;/TABLE&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Please guide me</p> <p>Thanks in advance.</p>
[ { "answer_id": 412400, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 3, "selected": false, "text": "document.all.calendar.style.display=\"none\";\n document.getElementById('calendar').style.display=\"none\";\n" ...
2009/01/05
[ "https://Stackoverflow.com/questions/412387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48094/" ]
412,399
<p>Hope that all are fine.</p> <p>I have 22 UISwitch in a table view and I have created all these switch objects in one function and set them in the table view.</p> <p>How can I know which switch is on or off? I want to do this through only one action method but I don't know how to do that.</p> <p>If anyone has faced this problem, please give me ideas...</p> <p>Thanks, Haresh.</p>
[ { "answer_id": 413245, "author": "Brad Larson", "author_id": 19679, "author_profile": "https://Stackoverflow.com/users/19679", "pm_score": 0, "selected": false, "text": "[slider addTarget:self action:@selector(sliderValueDidChange:forEvent:) forControlEvents:UIControlEventAllTouchEvents]...
2009/01/05
[ "https://Stackoverflow.com/questions/412399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
412,406
<p>i am looking for a client application that can connect to an EAR file within websphere and give me information like memory usage, heap size, etc.</p>
[ { "answer_id": 413245, "author": "Brad Larson", "author_id": 19679, "author_profile": "https://Stackoverflow.com/users/19679", "pm_score": 0, "selected": false, "text": "[slider addTarget:self action:@selector(sliderValueDidChange:forEvent:) forControlEvents:UIControlEventAllTouchEvents]...
2009/01/05
[ "https://Stackoverflow.com/questions/412406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19875/" ]
412,409
<p>I wonder if it is a good practice to use JUnit's @Ignore. And how people are using it? </p> <p>I came up with the following use case: Let's say I am developing a class and writing a JUnit test for it, which doesn't pass, because I'm not quite done with the class. Is it a good practice to mark it with @Ignore? </p> <p>I'm a little concerned that we might miss the ignored test case later on or that people start using it to "force" tests to pass CI.</p>
[ { "answer_id": 412418, "author": "Adeel Ansari", "author_id": 42769, "author_profile": "https://Stackoverflow.com/users/42769", "pm_score": 6, "selected": true, "text": "@Ignore(\"not ready yet\")\n" }, { "answer_id": 9587312, "author": "korda", "author_id": 919801, "...
2009/01/05
[ "https://Stackoverflow.com/questions/412409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/198/" ]
412,410
<p>I'm trying to compile GNUstep on a linux box but gnustep-gui-0.16.0 package is failing. I downloaded GNUstep Startup stable 0.20.1 (<a href="http://wwwmain.gnustep.org/resources/downloads.php" rel="nofollow noreferrer">http://wwwmain.gnustep.org/resources/downloads.php</a>)and follow instructions about how to compile (./configure &amp;&amp; make). I'm getting this error:</p> <p><code>libgnustep-gui.so: undefined reference to 'png_sizeof'</code></p> <p>I have compiled latest libpng (1.2.34) and I can see that png_sizeof is defined as macro. However, I'm not quite sure how to fix the gnustep-gui-0.16.0 build. I tried to pass the include/lib directory where libpng is installed to configure build but nothing seems to help.</p> <p>I have quite up to date linux box but using gcc 3.3 (upgrade is not an option - but this should not be a problem).</p> <p>Full error:</p> <pre><code>Making all for tool set_show_service... Compiling file set_show_service.m ... Linking tool set_show_service ... ../Source/./obj/libgnustep-gui.so: undefined reference to `png_sizeof' collect2: ld returned 1 exit status gmake[3]: *** [obj/set_show_service] Error 1 gmake[2]: *** [set_show_service.all.tool.variables] Error 2 gmake[1]: *** [internal-all] Error 2 gmake[1]: Leaving directory `/home/bla/local/src/gnustep-startup-0.22.0/build/gnustep-gui-0.16.0' gmake[3]: *** [obj/set_show_service] Error 1 gmake[2]: *** [set_show_service.all.tool.variables] Error 2 gmake[1]: *** [internal-all] Error 2 </code></pre> <p>Any suggestions? Thanks</p>
[ { "answer_id": 2643476, "author": "MKroehnert", "author_id": 293175, "author_profile": "https://Stackoverflow.com/users/293175", "pm_score": 1, "selected": false, "text": "make messages=yes" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45654/" ]
412,412
<p>I'm using the MVC beta to write a simple application to understand ASP.Net MVC. The application is a simple photo/video sharing site with tagging. I'm working off the MVC skeleton project. I added some Html.ActionLink()'s to the navigation bar, but I'm having a problem with one of the Html.ActionLink()'s that I added in one spot. </p> <p>I want ~/Tags to show all tags from the database and I want ~/Tags/{tag} to show a listing of all the files that are tagged with {tag}. This works as expected, but when I follow a ~/Tags/{tag}, it changes the Html.ActionLink() in the navigation bar to be the same as the ~/Tags/{tag} link instead of just pointing to ~/Tags. I'm not understanding why the ActionLink() in my navigation bar is changing when I follow the ~/Tags/{tag}. If I navigate to a different link in the project, the ActionLink() works as expected.</p> <p>I have the actionlink and route set up like this. My TagsController has this Index action. The int? is for a paging control. I have two Views, one called All and one called Details. What am I doing wrong?</p> <pre><code> Html.ActionLink("Tags", "Index", "Tags") // In navigation bar routes.MapRoute( "Tags", "Tags/{tag}", new { controller = "Tags", action = "Index", tag = "", }); public ActionResult Index(string tag, int? id ) { // short pseudocode If (tag == "") return View("All", model) else return View("Details", model) } </code></pre>
[ { "answer_id": 412822, "author": "Dan Atkinson", "author_id": 31532, "author_profile": "https://Stackoverflow.com/users/31532", "pm_score": 3, "selected": true, "text": "routes.MapRoute(\n \"TagsIndex\", //Called something different to prevent a conflict with your other route\n \"Tags/...
2009/01/05
[ "https://Stackoverflow.com/questions/412412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1880/" ]
412,427
<p>We always write code like this formal:</p> <pre><code>void main(){ if(){ if() } </code></pre> <p><img src="https://i.stack.imgur.com/dPV7i.jpg" alt="Alt text"></p> <p>But when I use <a href="http://en.wikipedia.org/wiki/Notepad%2B%2B" rel="noreferrer">Notepad++</a>, the display is:</p> <pre><code>void main(){ if(){ if() } </code></pre> <p><img src="https://i.stack.imgur.com/1T37o.jpg" alt="Alt text"></p> <p>How do I use Notepad++ to auto indent?</p> <p>Thanks to <a href="https://stackoverflow.com/a/412449/325514">Jonathan</a>, I have set it, but it does not take any effect. The snapshot is below:</p> <p><img src="https://i.stack.imgur.com/1jOZS.jpg" alt="Alt text"></p> <p>I am using Notepad++ version 5.1.3.</p>
[ { "answer_id": 412449, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 5, "selected": false, "text": "if void main(){\n if(){\n if() { } # here\n }\n}\n" }, { "answer_id": 412492, "author": "scron...
2009/01/05
[ "https://Stackoverflow.com/questions/412427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51539/" ]
412,435
<p>I want to read a date in the format YYYY-MM-DD. </p> <p>But if I enter date say for example 2008-1-1, I want to read it as 2008-01-01.</p> <p>Can anybody help me? Thanks in advance</p>
[ { "answer_id": 412466, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "DateTimeFormatter parser = DateTimeFormat.forPattern(\"YYYY-M-D\");\nDateTimeFormatter formatter = DateTimeFormat.forPat...
2009/01/05
[ "https://Stackoverflow.com/questions/412435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48094/" ]
412,438
<p>Is there a way to undefine the += on strings and wstrings for chars and wchar_t?</p> <p>Basically I want to avoid bugs like the following:</p> <pre><code>int age = 27; std::wstring str = std::wstring(L"User's age is: "); str += age; std::string str2 = std::string("User's age is: "); str2 += age; </code></pre> <p>The above code will add the ascii character 27 to the string instead of the number 27.</p> <p><strong>I obviously know how to fix this, but my question is: how do I produce a compiler error in this situation?</strong></p> <p>Note: You can override += on std::string and int to properly format the string, but this is not what I want to do. I want to completely disallow this operator on these operands. </p>
[ { "answer_id": 412458, "author": "Frederick The Fool", "author_id": 32688, "author_profile": "https://Stackoverflow.com/users/32688", "pm_score": 2, "selected": false, "text": "std::string operator+=(int val) MyString str;\nstr += 27;\n" }, { "answer_id": 412524, "author": "K...
2009/01/05
[ "https://Stackoverflow.com/questions/412438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
412,440
<p>What are the best practices for implementing temporary transaction password feature for website?</p> <p>For e.g in banking/finance scenarios like - While transfering funds from one account to another, a transaction password is required - While commiting a trade, a transaction password is required - etc.</p> <p>The password should be temporary and time based i.e. this password should not work after x minutes has elapsed.</p> <p>What algorithm would you recommend? Do you suggest keeping track of used passwords i.e. store used password in some store?</p> <p>Some website use a OneTimePassword device. Apart from this please feel to highlight any other strategy you think may be appropriate.</p> <p>Any other thoughts/suggestions/algorithm welcome.</p> <p>Edit: Based on question from 'lassevk'</p> <ol> <li>The password would be communicated by email/phone/sms.</li> <li>There is no third site involved.</li> </ol> <p>I require this for additional level of security for critical points in the application. This may also be called as "AuthenticationCode". </p>
[ { "answer_id": 412458, "author": "Frederick The Fool", "author_id": 32688, "author_profile": "https://Stackoverflow.com/users/32688", "pm_score": 2, "selected": false, "text": "std::string operator+=(int val) MyString str;\nstr += 27;\n" }, { "answer_id": 412524, "author": "K...
2009/01/05
[ "https://Stackoverflow.com/questions/412440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34644/" ]
412,447
<p>I have this code:</p> <pre><code>&lt;script&gt; function toggle(source) { checkboxes = document.getElementsByName('DG1'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; checkboxes = document.getElementsByName('DG2'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; checkboxes = document.getElementsByName('DG3'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; checkboxes = document.getElementsByName('DG4'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; checkboxes = document.getElementsByName('DG5'); for each(var checkbox in checkboxes) checkbox.checked = source.checked; } &lt;/script&gt; &lt;input type="checkbox" onClick="toggle(this)" /&gt;Select All&lt;br/&gt; &lt;form method=POST action="DGUsageServlet"&gt; &lt;input type="checkbox" name="DG1"&gt;DG1&lt;/input&gt; &lt;input type="checkbox" name="DG2"&gt;DG2&lt;/input&gt; &lt;input type="checkbox" name="DG3"&gt;DG3&lt;/input&gt; &lt;input type="checkbox" name="DG4"&gt;DG4&lt;/input&gt; &lt;input type="checkbox" name="DG5"&gt;DG5&lt;/input&gt; &lt;/form&gt; </code></pre> <p>How can I make the above script to work in IE?</p>
[ { "answer_id": 412469, "author": "Matthew Crumley", "author_id": 2214, "author_profile": "https://Stackoverflow.com/users/2214", "pm_score": 6, "selected": false, "text": "function toggle(source) {\n var checkboxes = document.getElementsByName('DG1');\n for (var i = 0; i < checkbox...
2009/01/05
[ "https://Stackoverflow.com/questions/412447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48094/" ]
412,450
<p>I want to display whatever the response of flickr.test.echo was on the page using rest (jquery ajax - because thats what im using)</p> <p>I need to supply an api_key</p> <hr> <p>The REST Endpoint URL is <a href="http://api.flickr.com/services/rest/" rel="nofollow noreferrer">http://api.flickr.com/services/rest/</a></p> <p>To request the flickr.test.echo service, invoke like this:</p> <p><a href="http://api.flickr.com/services/rest/?method=flickr.test.echo&amp;name=value" rel="nofollow noreferrer">http://api.flickr.com/services/rest/?method=flickr.test.echo&amp;name=value</a></p> <p>By default, REST requests will send a REST response.</p> <p>To return the response in REST format, send a parameter "format" in the request with a value of "rest". When using the REST request method, the response defaults to REST.</p> <p>A method call returns this:</p> <p> [xml-payload-here] </p> <p>If an error occurs, the following is returned:</p> <p> </p> <p>I got that from here <a href="http://www.flickr.com/services/api/request.rest.html" rel="nofollow noreferrer">http://www.flickr.com/services/api/request.rest.html</a></p> <hr> <p>This is the method I'm interested in <a href="http://www.flickr.com/services/api/flickr.test.echo.html" rel="nofollow noreferrer">http://www.flickr.com/services/api/flickr.test.echo.html</a></p> <p>please help.</p>
[ { "answer_id": 413830, "author": "orip", "author_id": 37020, "author_profile": "https://Stackoverflow.com/users/37020", "pm_score": 2, "selected": false, "text": "jQuery.getJSON callback=? $.getJSON(\"http://api.flickr.com/services/feeds/photos_public.gnetags=cat&tagmode=any&format=json&...
2009/01/05
[ "https://Stackoverflow.com/questions/412450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
412,459
<p>I've got some data manipulation code which spits out csv at the end.</p> <p>I started upgrading it to add units of measure everywhere, but I now have a problem with my csv function:</p> <pre><code>val WriteCSV : string -&gt; 'a list array -&gt; 'b list -&gt; string -&gt; unit </code></pre> <p>(the parameters are fileName, column array, column headers, separator)</p> <p>Where I previously sent [|s;x;y|] to WriteCSV, I now have a problem, because I can't send [|skm; xmm; ymm|].</p> <p>I tried writing a function for generically removing units of measure, but it doesn't work.</p> <pre><code>let removeUnit (n:float&lt;_&gt;) = n/1.0&lt;_&gt; </code></pre> <p>My questions are:</p> <ul> <li>Why doesn't it work? </li> <li>Can it be made to work?</li> <li>Is there another way to solve this particular problem?</li> </ul>
[ { "answer_id": 412523, "author": "leen", "author_id": 26462, "author_profile": "https://Stackoverflow.com/users/26462", "pm_score": 4, "selected": true, "text": "[<Measure>] type m\n[<Measure>] type km\n\nlet removeUnit (x:float<_>) =\n float x\n\nlet foo = removeUnit 2.6<m>\nlet foo2...
2009/01/05
[ "https://Stackoverflow.com/questions/412459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11410/" ]
412,467
<p>Can anyone give me an idea how can we <em>show</em> or embed a YouTube video if we just have the URL or the Embed code?</p>
[ { "answer_id": 412499, "author": "Alec Smart", "author_id": 426996, "author_profile": "https://Stackoverflow.com/users/426996", "pm_score": 8, "selected": true, "text": "<object width=\"425\" height=\"350\" data=\"http://www.youtube.com/v/Ahg6qcgoay4\" type=\"application/x-shockwave-flas...
2009/01/05
[ "https://Stackoverflow.com/questions/412467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/455847/" ]
412,472
<p>I have code that looks like this:</p> <pre><code>import xmlrpclib class Base(object): def __init__(self, server): self.conn = xmlrpclib.ServerProxy(server) def foo(self): return self.conn.do_something() class Derived(Base): def foo(self): if Base.foo(): return self.conn.do_something_else() </code></pre> <p>How should I use mocking to test the behavior of the <code>Derived</code> class? I don't want to assume that whatever the XML-RPC connection talks to will actually exist, but I feel like mocking the <code>xmlrpclib</code> module requires too much knowledge of the implementation of the <code>Base</code> class (which I have other tests for).</p> <p>Or, I guess, should I even use mocking to test this? If not, how would you test it?</p>
[ { "answer_id": 412580, "author": "Ryan Ginstrom", "author_id": 10658, "author_profile": "https://Stackoverflow.com/users/10658", "pm_score": 2, "selected": false, "text": "class FakeServerProxy(object):\n def __init__(self, server):\n self.server = server\n def do_something(...
2009/01/05
[ "https://Stackoverflow.com/questions/412472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50773/" ]
412,498
<p>In my Apache webserver I put this:</p> <pre><code>&lt;Directory /var/www/MYDOMAIN.com/htdocs&gt; SetHandler mod_python PythonHandler mod_python.publisher PythonDebug On &lt;/Directory&gt; </code></pre> <p>Then I have a handler.py file with an index function.</p> <p>When I go to MYDOMAIN.com/handler.py, I see a web page produced by the index function (just a plain vanilla HTML page). Every other page is of this type: MYDOMAIN.com/handler.py/<em>somename</em> where <em>somename</em> corresponds to a funcion in handler.py file.</p> <p>But when I go to MYDOMAIN.com, I get this:</p> <blockquote> <p>Not Found</p> <p>The requested URL / was not found on this server.</p> </blockquote> <p>Is theres a way with mod_python and publisher to just use the root and not a name.py as a starting point?</p> <p>I already tried with this in the apache conf file:</p> <blockquote> <p>DirectoryIndex handler.py</p> </blockquote> <p>To no avail :(</p>
[ { "answer_id": 412567, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 0, "selected": false, "text": "DirectoryIndex index\n" }, { "answer_id": 412780, "author": "Seb", "author_id": 189, "author_pro...
2009/01/05
[ "https://Stackoverflow.com/questions/412498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51540/" ]
412,517
<p>I am developing a PHP/MySQL application using vertrigoserver. I need to enter the German text in tables. The problem is when I read the tables from PHP, some of character didn't show the exact typed one. Do I need additional steps to display all characters effectively?</p>
[ { "answer_id": 412588, "author": "Karsten", "author_id": 28144, "author_profile": "https://Stackoverflow.com/users/28144", "pm_score": 3, "selected": true, "text": "utf8_general mysql_connect();\nmysql_query(\"SET NAMES 'utf8'\");\n" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44984/" ]
412,536
<p>I have a textbox for 'Area '.I need a regularexpression to validate textbox such that it should allow decimals to enter but no characters.Anyone can help me</p>
[ { "answer_id": 412550, "author": "kender", "author_id": 4172, "author_profile": "https://Stackoverflow.com/users/4172", "pm_score": -1, "selected": false, "text": "'^[0-9]*$'" }, { "answer_id": 412558, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "...
2009/01/05
[ "https://Stackoverflow.com/questions/412536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42348/" ]
412,562
<p>How can I execute a terminal command (like <code>grep</code>) from my Objective-C Cocoa application?</p>
[ { "answer_id": 412573, "author": "Gordon Wilson", "author_id": 23071, "author_profile": "https://Stackoverflow.com/users/23071", "pm_score": 9, "selected": true, "text": "NSTask /usr/bin/grep foo bar.txt int pid = [[NSProcessInfo processInfo] processIdentifier];\nNSPipe *pipe = [NSPipe p...
2009/01/05
[ "https://Stackoverflow.com/questions/412562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46297/" ]
412,590
<p>I have a table containing hundreds of entries and I am trying to delete a small range. It is taking a long time, in fact it is not being executed.</p> <p>I monitored the query from the activity monitor and its status is "Suspended"</p> <p>Is there anyone knows what may cause this problem?</p>
[ { "answer_id": 412595, "author": "Steven Robbins", "author_id": 26507, "author_profile": "https://Stackoverflow.com/users/26507", "pm_score": 2, "selected": true, "text": "dbcc checkdb\ndbcc checkcatalog \n" } ]
2009/01/05
[ "https://Stackoverflow.com/questions/412590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44973/" ]