input
stringlengths
51
42.3k
output
stringlengths
18
55k
Does IETester run the ACTUAL same code that existed for IE6 / IE7? Or is it an emulation? <p>I just realized (yes, this was stupid of me) that IE8 Compatibility Mode is NOT IE7.<br /> All the time I assumed they would be switching back to the IE7 binaries, which apparently they aren't, as indicated by another question ...
<p>Yes, the only true test is to use the vhd's. ietester is slow and bugridden &amp; has issues with iframes &amp; script sometimes + you dont get the cover across all the OS ie versions either which can make a big difference.</p>
sed: Replace part of a line <p>How can one replace a part of a line with sed?</p> <p>The line </p> <pre><code>DBSERVERNAME xxx </code></pre> <p>should be replaced to:</p> <pre><code>DBSERVERNAME yyy </code></pre> <p>The value xxx can vary and there are two tabs between dbservername and the value. This name...
<p>This works:</p> <pre><code>sed -rne 's/(dbservername)\s+\w+/\1 yyy/gip' </code></pre> <p>(When you use the -r option, you don't have to escape the parens.)</p>
Simulate loading on localhost <p>I have a site which uses AJAX and preloaders. Now I would like to see the impact of these preoloaders before deploying the site online.</p> <p>The "problem" is that localhost doesn't have loading time and the response is immediate, so that I can't see my preloaders.</p> <p>How can I s...
<p>If on windows, download <a href="http://www.fiddler2.com/fiddler2/" rel="nofollow">Fiddler</a> and set it to act like you are on a modem:</p> <p>Tools-->Performance-->Simulate Modem Speeds</p> <p>[edit] Since you said you are now on a MAC, you have Charles which has <a href="http://www.charlesproxy.com/documentati...
Efficient hashCode() implementation <p>I often auto-generate an class's <code>hashCode()</code> method using IntelliJ IDEA and typically the method takes the form:</p> <pre><code>result = 31 * result + ... </code></pre> <p>My question is what is the purpose of multiplying by 31? I know this is a prime number but why...
<p>Multiplying by 31 is fast because the JIT can convert it to a shift left by 5 bits and a subtract:</p> <pre><code>x * 31 == (x &lt;&lt; 5) - x </code></pre> <p>Without any particular extra information, I'd stick to this approach. It's reasonably fast and likely to end up with reasonably well-distributed hash codes...
how to catch exception of MVC view? <p>In controller, try...catch can catch exception. How to catch exception in view? for example, a view may have code like:</p> <pre><code>&lt;%= Html.Encode(Model.MyID)%&gt; </code></pre> <p>If Model is null, you will get exception when access the view. where to catch the exception...
<p>Simply add the [HandleError] attribute to the top of your Controller class. This way, any exception generated by your Controller will be handled and the user will be presented /Views/Shared/Error.aspx. The model passed to that view is a System.Web.Mvc.HandleErrorInfo object.</p> <p>The controller:</p> <pre><code...
ClearCase advantages/disadvantages <p>Because I'm currently struggling to learn IBM Rational ClearCase, I'd like to hear your professional opinion.</p> <p>I'm particularly interested in advantages/disadvantages compared to other version-control-systems like Subversion or Git.</p>
<p>You can find a good comparison between ClearCase and Git in my SO answer:<br> "<a href="http://stackoverflow.com/questions/645008/what-are-the-basic-clearcase-concepts-every-developer-should-know"><strong>What are the basic ClearCase concepts every developer should know?</strong></a>", illustrating some major differ...
PHP form removing line breaks <p>I use a php form processor script that works fine. Except when users submit text in a multi-line text field, any line breaks or new lines are stripped out of the resulting string variable that is passed on. This often makes it unreadable by whoever receives the form results.</p> <p>I'm...
<p>I believe you have an issue at the rendering phase. Have you tried:</p> <pre><code>echo nl2br($text); </code></pre> <p>Where $text is the text you're talking about.</p>
Generating excel documents programmatically <p>Has anyone used a Java based library for generating excel documents? Preferably support for 2003? </p>
<p>Whenever I have to do this I ask myself if one big html table would be enough.</p> <p>much of the time it is. You can simply write html tags and label it as a .xls file. Excel will open it correctly</p>
With a browser, how do I know which decimal separator does the client use? <p>I'm developing a web application.</p> <p>I need to display some decimal data correctly so that it can be copied and pasted into a certain <code>GUI</code> application that is not under my control.</p> <p>The GUI application is locale sensit...
<p>Here is a simple JavaScript function that will return this information. Tested in Firefox, IE6, and IE7. I had to close and restart my browser in between every change to the setting under Control Panel / Regional and Language Options / Regional Options / Customize. However, it picked up not only the comma and peri...
Using SelectParameters in ASP.NET gives 'Must declare variable' errors <p>I have an ASP SqlDataSource connected to Sybase DB query, using Select Parameters that are populated by a dropdown:</p> <p>Dropdown (works OK):</p> <pre><code>&lt;asp:SqlDataSource ID="dsBondIDList" runat="server" ConnectionString="&lt;%$ ...
<p>I just went through this problem 10 minutes ago and here's the fix:</p> <p>If you need to keep using the ODBC driver you have, change your query to use ? instead of Named Parameters. </p> <pre><code>SELECT [ticker], [name], [isin], [currency], [stock], [maturity], [bid], [ask] FROM [bonds] where [bondID] = ? </...
How do I zip on the fly and stream to Response.Output in real time? <p>I am trying to use the following code: I get a corrupted zip file. Why? The file names seem OK. Perhaps they are not relative names, and that's the problem? </p> <pre><code> private void trySharpZipLib(ArrayList filesToInclude) { /...
<p>Boy, that's a lot of code! Your job would be simpler using <a href="http://dotnetzip.codeplex.com">DotNetZip</a>. Assuming a HTTP 1.1 client, this works:</p> <pre><code>Response.Clear(); Response.BufferOutput = false; string archiveName= String.Format("archive-{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss")...
Remote Debugging Multiple Movies on a Single Page <p>I've got two flash movies on a page. Using the Flash IDE I'd like to implement remote debugging when a particular movie loads. My problem is that the debugger attaches to the first loaded movie - not the one I want.</p> <p>Thanks, Josh</p>
<p>Release SWFs will not attempt to connect to a remote debugger (or any debugger, for that matter), so if there's a SWF you want <em>not</em> to connect, one approach would be to issue it as a release SWF. (In the Flash IDE, that means publishing with the Permit Debugging option unchecked, whereas in Flex Builder, it...
building a jsonp wrapper for json data <p>Ive been tryin to solve this for a long time and now know why its not possible. The url </p> <p><a href="http://twittercounter.com/api/?username=Anand%5FDasgupta&amp;output=json&amp;results=3" rel="nofollow">http://twittercounter.com/api/?username=Anand_Dasgupta&amp;output=jso...
<p>Well the purpose of JSONP is to wrap the JSON (which will be evaluated as JavaScript on the client side) into a callback that only the client requesting the data knows. This prevents the client from executing unwanted JavaScript code. Without the callback ou will have the same origin policy problem (which JSONP solv...
Howto: Multiple versions of msvcrt9 as private SxS assemblies? <p>I have a project that comprises pre-build Dll modules, built some time in the past, using Visual Studio 9.</p> <p>The EXE of the project is built now, using SP1 of Visual Studio 9.</p> <p>When we deploy the EXE we don't want to require administrative a...
<p>I've never tried that but I think you can solve that with bindingRedirect in the manifest, I know that it works in the managed world.</p> <p>See example (You will need to change the values for your version)</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt; &lt;configuration&gt; &lt;win...
How to reduce redundant log messages for a web-app? <p>Does anybody have any advice on how to minimize my logs for a web application?</p> <p>Right now, I'm logging every error. So if there is a situation where an error occurs on every request (a db connection problem for example), it might get logged for every user o...
<p>You could create a logging system that logs to a DB, and have a flag set to determine whether to log individual entries, or just tally a counter for a base log entry. By tallying, you see the gross number of errors, but don't have an exploding log file.</p>
XML using Java <p>I have to write an XML file using java.The contents should be written from a map.The map contains items as key and their market share as value.I need to build an XML file withe two tags.I will use this XML to build a piechart using amcharts.Can anyone help with an existing code?</p> <pre><code>&lt;xm...
<p>I would beware of writing XML directly since you have to worry about entity encoding.</p> <p>e.g. writing text content with <code>&lt;</code>, <code>&gt;</code> or <code>&amp;</code> directly will generate invalid XML. The same will apply when using Velocity and Freemarker.</p> <p>If you do write the XML directly,...
mySQL - Using data from another table.field to determine results in a query <p>Buried in mySQL syntax and query structure problems once more. I'm currently doing this query fine:-</p> <pre><code>SELECT DATE_FORMAT(`when`, '%e/%c/%Y')date , COUNT(`ip`) AddressCount FROM `metrics` WHERE `projID` = '$projID' GRO...
<p>You DO want a join here. I won't get this 100% right because I don't know your column names, but here's a stab at it.</p> <p>It would be helpful if you posted more info about your two tables and their columns.</p> <pre><code>SELECT DATE_FORMAT(m.`when`, '%e/%c/%Y')date , COUNT(`ip`) AddressCount , o.`us...
MySQL - updating all records to match max value in group <p>I have a transaction table like so</p> <pre><code>id , name , code , flag 1 , john , 1234-3, 2 2 , joe , 1111-2, 1 3 , paul , 1234-3, 3 4 , asdf , 1234-3, 3 5 , asdf , 1111-2, 5 6 , asdf , 1234-3, 8 7, asdf , 1234-3, 0 </code></pre> ...
<pre><code>UPDATE t_transaction tu JOIN ( SELECT code, MAX(flag) AS flag FROM t_transaction GROUP BY code ) t ON tu.code = t.code SET tu.flag = t.flag </code></pre>
wpf listview right-click problem <p>so I have attached a context menu (right-click menu) to a wpf listview.</p> <p>unfortunately, when you right-click it brings up both the menu and <em>selects</em> whatever item you are over. Is there a way to shut off this right-click select behavior while still allowing the contex...
<p>The key is setting the PreviewMouseRightButtonDown event in the correct place. As you'll notice, even without a ContextMenu right clicking on a ListViewItem will select that item, and so we need to set the event on each item, not on the ListView.</p> <pre><code>&lt;ListView&gt; &lt;ListView.ItemContainerStyle&gt; ...
unique integer/long hash key generation over strings for faster compairson <p>I'm curious how others have solved this problem, and what problems might lurk behind the naive solution:</p> <p>I have a system which processes stock market data. There are tens of thousands of symbols, with associated prices/sizes, flowing...
<p>Maybe hash functions aren't the best approach here. If you're receiving a ticker symbol (and not the hash of the ticker symbol) you're going to have to compute the hash for it every single time it comes through. If its a hashing algorithm with no collisions, you'll need to look at every character of the symbol anywa...
MySQL: Why is it ignoring the text in the form field? <p>I am trying to teach myself MySQL/PHP from the very beginning. The following code was lifted from various tutorial sites. I'm using phpMyAdmin provided by my webhost.</p> <p>I made a table with an auto-incrementing field called "ID" and another field called "fir...
<p>Try</p> <pre><code>$step1 = "INSERT INTO tblHurray(ID, first) VALUES ('','".$_POST['first']."')"; </code></pre> <p>Although, if you're really going learn it, then start with <a href="http://php.net/manual/en/book.pdo.php" rel="nofollow">PHP PDO</a>. It will save you ALOT of trouble in the long run, especially wit...
How does Bing.com create enlarged thumbnails? <p>When I search images using Bing.com, I realize their images are well cropped and sorted. When you place your mouse on an image, another window will pop up with an enlarged image.</p> <p><a href="http://www.bing.com/images/search?q=Heros&amp;FORM=BIFD#" rel="nofollow">ht...
<p>If you look at the HTML, you'll see a span immediately above each of the images. It sets that frame's display style from "none" to "block". It then uses an animation library to resize the content of the covering frame.</p>
First Item on Dropdownlist in blank <p>How to put the first item on the DropDownList in blank ? In VB is something like, DropDownList.index[0] = ""; I did this:</p> <pre><code>string StrConn = ConfigurationManager.ConnectionStrings["connSql"].ConnectionString; SqlConnection conn = new SqlConnection(StrConn); ...
<p>After your DataBind call, add this code.</p> <pre><code>DropDownList1.Items.Insert(0, new ListItem(string.Empty, string.Empty)); </code></pre>
How to create subsets of a single set of elements (where element names are complex) with XSLT? <p>In continuation of the question I had asked concerning <a href="http://stackoverflow.com/questions/1068011/how-to-create-subsets-of-a-single-set-of-elements-with-xslt">"How to create subsets of a single set of elements wit...
<p>As I said in the comments to my answer in your previous question, you'll need a file that contains the fixed and known set names before you can begin to solve this. Ideally, it is structured, like this:</p> <pre><code>&lt;!-- SetNames.xml ---&gt; &lt;names&gt; &lt;Superset name="Classic_Authors"&gt; &lt;Set n...
What are good/bad ways of providing help for an application..? <p>I'm in the process of developling various applications for whom the end users are both engineers and salesman. Some of the operations and options may not be immediately obvious to all users. All applications are delivered with a PDF and paper manual - bu...
<p>In my experience nobody but programmers reads the help. So when you have a technical and non-technical target audience you end up providing 2 ways of doing everything:</p> <p>A Wizard with a few options. A property editor with lots of options.</p> <p>In either case, pictures are usually better than words for docu...
What is your workflow for creating websites based on WordPress? <p>I a starting a project where 2 people will be developing a site on WordPress. It also may be necessary to have a development server setup where my client can view changes to the site before we push it live. There also may be database changes (like wor...
<p>To deal with this type of DEV and PRODUCTION environment, I've written a perl script to help me with what would otherwise be manual work. I've given certain steps familiar names so I remember to run them in the correct order. I only have DEV under SVN. I create a PRODUCTION environment each time with this script....
Running PHP Zend Test in Eclipse <p>Is it possible to run PHP Zend test cases (those that extend Zend_Test_PHPUnit_ControllerTestCase, etc.) through Eclipse PDT?</p> <p>I would like to be able to run them in a similar fashion as you run JUnit tests in Eclipse, by right-clicking the test file and selecting "Run as a JU...
<p>I have never been able to get the <a href="http://simpletest.org/en/extension_eclipse.html" rel="nofollow">SimpleTest Eclipse plugin</a> to work with PHPUnit based tests, though it's theoretically possible. You can get PHPUnit to run in the Eclipse IDE, but it's in a way that just dumps output to the console. At lea...
Linq to SQL how to do "where [column] in (list of values)" <p>I have a function where I get a list of ids, and I need to return the a list matching a description that is associated with the id. E.g.:</p> <pre><code>public class CodeData { string CodeId {get; set;} string Description {get; set;} } public List&...
<p>Use</p> <pre><code>where list.Contains(item.Property) </code></pre> <p>Or in your case:</p> <pre><code>var foo = from codeData in channel.AsQueryable&lt;CodeData&gt;() where codeIDs.Contains(codeData.CodeId) select codeData; </code></pre> <p>But you might as well do that in dot notation:</p> ...
How do you add an edit button to each row in a report in Oracle APEX? <p>I'm using Oracle APEX and I have a report region in a page that displays columns from a SQL query. I want to add edit buttons to the first column of this report so that the user can click on it and edit/review one of the results. How do I add this...
<ol> <li><p>Add a column to the SELECT statement of the report like this:</p> <pre><code>SELECT '' edit_link, -- This is the new column ... </code></pre></li> <li><p>Go to the Report Attributes tab.</p></li> <li><p>Move the new column EDIT_LINK to the top of the list of columns (if you want it to be first).</p></l...
Running javascript standalone engine? <p>Bit of a strange question here i know.</p> <p>but i wanted to know if some kind of standalone engine for javascript exists..</p> <p>basically i want to test running of my javascript without having to load a web page...</p> <p>Maybe it doesn't exist? Like some kind of ide wher...
<p>Check out <a href="http://www.mozilla.org/rhino/">Rhino</a> or <a href="http://www.mozilla.org/js/spidermonkey/">Spidermonkey</a>. You might want to grab an implementation of the <a href="https://wiki.mozilla.org/ServerJS">ServerJS standard</a>, like <a href="http://narwhaljs.org/">Narwhal</a> while you're at it.</p...
jquery class inheritance <pre><code>var A=function(){ }; $.extend(A.prototype, { init:function(){ alert('A init'); } }); var B=function(){ }; $.extend(B.prototype,A.prototype,{ init:function(){ alert('B init'); } }); var p=new A(); p.init(); var x=new B(); x.init(); </code></pre> <p>is the above the best wa...
<p>For OO, it's best to look outside jQuery. jQuery is based on collections returned by selectors.</p> <p>If you want classes, some choices are <a href="http://code.google.com/p/base2/">Base2</a>, <a href="http://code.google.com/p/joose-js/">Joose</a>, and <a href="http://jsclass.jcoglan.com/">JS.Class</a>.</p>
How can I convert a character-encoded binary string to hexadecimal in SQL Server? <p>I'm trying to take a <code>VARCHAR(MAX)</code> with data in it as follows: "00001001010001010111010101..." etc.</p> <p>Then encode it as hexadecimal for more efficient return to the client.</p> <p>Is it possible to do this? Either di...
<p>Given your previous question, you're generating this string as part of another query. Why on Earth are you generating a string of ones and zeros when you can just multiply them by the appropriate power of 2 to make an <code>INT</code> out of them instead of a string? Converting from <code>INT</code> to hex string is...
UIApplication sharedApplication tel: add numbers to the current call (objective-c) <p>With iPhone you can dial a number and you can add some other persons to the call using the iPhone-panel (manually).</p> <p>I want to do it automatically.</p> <p>I can dial a number from my native iPhone-Application with:</p> <pre><...
<p>No, this not presently possible. First of all, your application can't do anything during a call, since it cannot run in the background. Second, Apple has, understandably, kept access to the phone pretty restricted and therefore has not provided API to do this.</p>
How to return query results from method that uses LINQ to SQL <p>Here is the code I'm working with, I'm still a bit new to LINQ, so this is a work in progress. Specifically, I'd like to get my results from this query (about 7 columns of strings, ints, and datetime), and return them to the method that called the method...
<blockquote> <p><em>Specifically, I'd like to get my results from this query (about 7 columns of strings, ints, and datetime), and return them</em></p> </blockquote> <p>Hi, the problem you've got with your query is that you're creating an anonymous type. You cannot return an anonymous type from a method, so t...
How do I Debug a SingleFileGenerator/ Custom Tool? <p>I am building a Custom Tool code generator using the Visual Studio SDK and basing it on the SingleFileGenerator example.</p> <p>My question is how to enter debug mode on this code? I can currently add my custom tool to a file in Visual Studio but it errors out, I'd...
<p>You need to debug Visual Studio, you can either do it by attaching to a running session <em>(Tools\Attach To Process)</em> or by setting Visual Studio (devenv.exe) to be your startup project of the Custom Tool Project. </p>
C# Custom Xml Serialization <p>I'm attempting to deserialize a custom class via the XmlSerializer and having a few problems, in the fact that I don't know the type that I'm going to be deserializing (it's pluggable) and I'm having difficulty determining it.</p> <p>I found <a href="http://stackoverflow.com/questions/59...
<p>To create an instance from a string, use one of the overloads of Activator.CreateInstance. To just get a type with that name, use Type.GetType.</p>
How to position view relative to parent? <p>I have a UIViewController with an MKMapView in it. In viewDidLoad of this controller, I add the MKMapView:</p> <pre><code>[self.view addSubview:mapView]; </code></pre> <p>I want to display this map in a tableview cell. In the tableview controller's cellForRowAtIndexPath:,...
<p>did you try setting the clipbounds property on the mapview?</p>
Create a new FileMaker layout showing unique records based on one field and a count for each <p>I have a table like this:</p> <p>Application,Program,UsedObject</p> <p>It can have data like this:</p> <p>A,P1,ZZ<br/> A,P1,BB<br/> A,P2,CC<br/> B,F1,KK<br/></p> <p>I'd like to create a layout to show:</p> <p>Applicatio...
<p>Create a a summary field as: cntApplicaiton = Count of Application </p> <p>Do this by going into define fields, create a field called cntApplication, type summary. In the options dialogue make the summary field a count on application</p> <p>Now create a new layout with a subsummary part and nobody. The subsummary ...
How do I make PDF the default export option for a Crystal Report? <p>I am working with CrystalDecisions.CrystalReports.Engine.ReportDocument in WinForms in Visual Studio 2008. Right now when the users click the export button the dialog defaults to saving the report as a CrystalReports formatted file. It's possible to c...
<p>As of CR XI, the only way I know is to replace the export dialog with your own. You can add your own button to the CrystalReportViewer control and hide their export button. </p> <p>Here's vb.net code to replace the export button with your own button/eventhandler...</p> <pre><code>Public Shared Sub SetCustomExportH...
How do I create unique IDs, like YouTube? <p>I've always wondered how and why they do this...an example: <a href="http://youtube.com/watch?v=DnAMjq0haic">http://youtube.com/watch?v=DnAMjq0haic</a></p> <p>How are these IDs generated such that there are no duplicates, and what advantage does this have over having a simp...
<p>Try this: <a href="http://php.net/manual/en/function.uniqid.php" rel="nofollow">http://php.net/manual/en/function.uniqid.php</a></p> <blockquote> <p>uniqid — Generate a unique ID...</p> <p>Gets a prefixed unique identifier based on the current time in microseconds.</p> <blockquote> <p><strong>Caut...
64 bit floating point porting issues <p>I'm porting my application from 32 bit to 64 bit. Currently, the code compiles under both architectures, but the results are different. For various reasons, I'm using floats instead of doubles. I assume that there is some implicit upconverting from float to double happening on...
<p>Your compiler is probably using SSE opcodes to do most of its floating point arithmetic on the 64 bit platform assuming x86-64, whereas for compatibility reasons it probably used the FPU before for a lot of its operations. </p> <p>SSE opcodes offer a lot more registers and consistency (values always remain 32 bits ...
DataReader hangs while mapping a record to an object <p>I'm in the middle of a project where we are querying a database with more than 20 million records, applying several set of filters our query returns about 200 records (after waiting for about 1.30 minutes). After querying the database I try to create objects from ...
<p>"A DataReader issue"?</p> <p>If you <em>wanted</em> to write a piece of code that behaved the way you believe that DataReader is behaving, could you do that? Sometimes it's good to think, "If I were a bug, where would I be hiding", or "where could I not be hiding?"</p> <p>Chances are there's more to it.</p> <p>Ex...
Extending Python with C/C++ <p>Can anyone please give me tips on the tools or sofware to use to extend Python with C/C++? Thanks.</p>
<p>I'll add the obligatory reference to <a href="http://www.boost.org/doc/libs/1%5F39%5F0/libs/python/doc/index.html">Boost.Python</a> for C++ stuff.</p>
Modify List.Contains behavior <p>I have a <code>List&lt;MyObj&gt;</code> with the <code>class MyObj : IComparable</code>. I wrote the method <code>CompareTo</code> in the <code>MyObj</code> class per the <code>IComparable</code> interface, but when I use the <code>List&lt;MyObj&gt;.Contains(myObjInstance)</code> it ret...
<p>The absolute easiest way to find out whether your CompareTo method is called is to set a breakpoint in it and hit F5 to run your program. But I believe that <code>List&lt;T&gt;.Contains</code> looks for the <a href="http://msdn.microsoft.com/en-us/library/ms131187.aspx"><code>IEquatable&lt;T&gt;</code></a> interface...
Live video broadcast and server resources using RED5 <p>how much ram do i need to run a server with red5 and broadcast live video</p> <p>I am starting a project that will include live video broadcasts from all over the world and it is expected to have at least 1000 users viewing those videos in real time.</p> <p>Afte...
<p>I'm running red5, and from my testing, you will certainly need more RAM there. To support a small userbase, I guess a gigabyte would be perfectly fine. But for thousands of users, things could scale very differently. Again I repeat, this is according to my testing, I would recommend a gigabyte, and scale from there,...
WCF - To Use [DataContract] or not with .NET 3.5 SP1? <p>I am working with WCF .NET 3.5 SP1 and have read that one does NOT have to decorate their Entities/Collections with such things as [DataMember], [DataConract], and/or [Serializable]? What is the best way to go? What have you all encountered?</p> <p>I am on 3.5...
<p>See <a href="http://msdn.microsoft.com/en-us/library/ms733127.aspx" rel="nofollow">Using Data Contracts</a>.</p> <blockquote> <p>New complex types that you create must have a data contract defined for them to be serializable. By default, the <code>DataContractSerializer</code> infers the data contract and...
PHP and SQL Parsing <p>Say I have an array of table DDL queries and I want to get the name of each table being created. What would the best approach be for extracting the table name?</p> <p>So for example:</p> <pre><code>$ddl = array( 'CREATE TABLE tableOne ...', 'CREATE TABLE tableTwo ...', 'CREATE TABLE...
<p>MySQL supports CREATE TABLE IF NOT EXISTS foobar, which you will have to take into account. The following code should do the trick:</p> <pre><code>foreach ($ddl as $tableDef) { if (preg_match("/^CREATE\s+(?:TEMPORARY\s+)?TABLE\s+(?:IF NOT EXISTS\s+)?([^\s]+)/i", $tableDef, $matches)) { $tableName = $ma...
JQuery UI disabling reorder in sortable lists <p>So I have two sortable lists in a web app I'm writing. What I want to do is make one of the lists not be reorder-able, but allow it's items to be dragged onto the other list. Items from list one can be dropped on list two, but items on list one can't be rearranged.</p> ...
<p>Neve mind! I found the answer after browsing the docs more. The solution is to use plain draggable+sortable elements:</p> <p><a href="http://jqueryui.com/demos/draggable/#sortable" rel="nofollow">http://jqueryui.com/demos/draggable/#sortable</a></p>
Rails Recaptcha plugin always returns false <p>I'm using the rails recaptcha plugin found here: <a href="http://github.com/ambethia/recaptcha/tree/master" rel="nofollow">http://github.com/ambethia/recaptcha/tree/master</a></p> <p>I have signed up for an account on recaptcha.com, obtained a public &amp; private key, an...
<p>Just as a note, make sure you didn't accidentally switch around the public and private keys; they are different.</p> <p>I can't tell if you're already handling the possibility that it <em>is</em> correct, in which case you would want to have something like this:</p> <pre><code>if verify_recaptcha @thing.save! ...
PowerPoint version compilation <p>Let's say I am using SharpDevelop/VS to develop an app that uses PowerPoint.</p> <p>Do I need to recompile the app so there is a build for each version of MS Office?</p> <p>I have MS Office 2007, but I would also like the app to work with Office 2003 and later, without having to reco...
<p>If you're using the Microsoft.Office.Interop libraries you just need the 2007 version, it will be backwards compatible with older docs</p>
Updating already-deployed SharePoint content types to handle additional item events <p>I have a site content type that was used for a handful of lists throughout my site collection. In that content type, I describe an event receiver to handle the ItemAdding event. This works fine. Now I need to update the content ty...
<p>Did you call ctype.Update(true) after adding the EventReceiver? If you don't it won't be persisted . And don't use the List content type, use SPWeb.ContentTypes instead.</p> <p>This code works for me:</p> <pre><code>var docCt = web.ContentTypes[new SPContentTypeId("0x0101003A3AF5E5C6B4479191B58E78A333B28D")]; //wh...
How to write strongly typed lambda expressions? <p>I want to write a lambda expression within an inline if statement. But inline if statement must have strong type results.</p> <pre><code>MyType obj = someObj.IsOk ? null : () =&gt; { MyType o = new MyType(intVal); o.PropertyName = false; return o; }; </code><...
<p>It has nothing to do with the lambda's typing here. You are trying to return either <code>null</code> or (a function taking no arguments and returning a MyType) but you are telling the compiler that the result of that statement is not a function, but just a MyType. I think what you want to do is</p> <pre><code>MyT...
DataContractSerializer doesn't call my constructor? <p>I just realized something crazy, which I assumed to be completely impossible : when deserializing an object, the <strong>DataContractSerializer doesn't call the constructor</strong> !</p> <p>Take this class, for instance :</p> <pre><code>[DataContract] public cla...
<p><code>DataContractSerializer</code> (like <code>BinaryFormatter</code>) doesn't use <strong>any</strong> constructor. It creates the object as empty memory.</p> <p>For example:</p> <pre><code> Type type = typeof(Customer); object obj = System.Runtime.Serialization. FormatterServices.GetUninitialized...
Warning: Sessions Permission Denied/Headers Already Sent in PHP <p>I am a beginner in PHP.</p> <p>I am receiving the following errors. I cannot view the error from my computer on FF, IE, and Chrome, but yet I see the error up top when browsing from another computer's browser.</p> <pre><code>Warning: session_start() [...
<p>seems that the /tmp/ dir is not readable or writable by the user php is running as.</p>
.NET writing a delimited text file <p>I am writing a framework for writing out collections into different formats for a project at my employer. One of the output formats is delimited text files (commonly known as the CSV -- even though CSVs aren't always delimited by a comma).</p> <p>I am using the Microsoft.Jet.OLEDB...
<p>How about "don't use OleDbConnection"... writing delimited files with <code>TextWriter</code> is pretty simple (escaping aside). For reading, <a href="http://www.codeproject.com/KB/database/CsvReader.aspx" rel="nofollow">CsvReader</a>.</p>
Form Fix in php <p>I have a website form that collects url of users to store in a database. They should not enter the http:// with their URL however many and the result is that when their url is displayed it looks like this </p> <p>http;//<a href="http://www.foo.com" rel="nofollow">http://www.foo.com</a> I need the fo...
<p>Use this on the url given by the user:</p> <pre><code>$url=str_replace("http://","",$_POST['url']); //Where $_POST['url'] is the users input </code></pre> <p>This function takes an argument and replaces all occurrences of that argument within a string. More on this function <a href="http://www.php.net/str%5Freplac...
Not null ForeignKey('self') <p>How can I make a ForeignKey refer back to the object itself? I'm trying :</p> <pre><code>Alias(MyBaseModel): type = models.ForeignKey('self') a = Alias() a.type = a a.save() </code></pre> <p>But then when I run it :</p> <pre><code>(1048, "Column 'type_id' cannot be null") </code><...
<p>The problem is that when you did <code>a.type = a</code>, a did not yet exist in the database, therefore it has no pk. </p> <p>One way around this is to save twice, first to save it into the database, referring to a dummy object that's already in the database, then save it again once you can get it from the databas...
How do I separate the colour and alpha blend functions in opengl? <p>In the process of trying to port my 2D shadow rendering technique from Directx to Opengl, I've run across a problem where I can't seem to get fine enough access to the opengl blender. </p> <p>But first, so that the following makes sense, my algorithm...
<p><a href="http://www.opengl.org/registry/specs/EXT/blend_func_separate.txt" rel="nofollow">http://www.opengl.org/registry/specs/EXT/blend_func_separate.txt</a></p>
GWT page layout practices <p>I am making a GWT app based off of an HTML mockup. The mockup has about 4 or 5 different layouts made with divs and css. Right now I have one HTML page with just the basic elements of my layout (header, body, footer). The other layouts are the same thing, with different layouts for the bo...
<p>You may want to look into HTMLPanel.</p> <p>i.e.</p> <pre><code>HTMLPanel hpanel = new HTMLPanel("&lt;div id='morehtml'&gt;&lt;/div&gt;"); hpanel.add(new Label("Hello, I am inside morehtml"), "morehtml"); RootPanel.get("main_area").add(hpanel); </code></pre>
Objective-C not recognizing .h? <p>I have the following in a project named testApp: (testAppViewController is the valid name of my view controller in the project)</p> <p><strong>PrevView.h</strong></p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "testAppViewController.h" @interface PrevView : UIView { testA...
<p>Does "testAppViewController.h" import "PrevView.h"?</p> <p>If so, you may want to delcare a forward class reference:</p> <pre><code>@class testAppViewController; </code></pre> <p>that replaces the import you have, and move the import into the .m file.</p>
Best way to return error messages on REST services? <p>I've been looking at examples of REST API's like Netflix <a href="http://developer.netflix.com/docs/REST_API_Reference#0_59705">http://developer.netflix.com/docs/REST_API_Reference#0_59705</a> and Twitter and they seem to place error messages in the statusText head...
<p>HTTP defines that you should put a descriptive error message in the response entity body, aka responseText.</p> <p>statusText is not rendered or processed by any client.</p> <p>I'd use the status text for the error message type, aka 400 Client Error, and the body for a description of the problem that can be render...
Moving Raw MYSQL Data Files to a Different Directory <p>I have a directory only backup of a previous server that hosted multiple sites. I had access to a few .sql backups for our databases, but there were some that had not been backed up in that fashion. I located the .MYD,.frm, and .MYI files for the tables in my db...
<p>Have you checked that the files in <code>/var/lib/mysql/db_name/</code> are owned by mysql and not root? Usually copying the files in should 'just work' (certainly it has and does for me). I assume you're using the same or very similar version of MySQL?</p>
The most elegant method for determing if two positions in a grid are adjacent <p>And by adjacent, I only mean one unit left, right, up, or down. Diagonals don't count. You know the x,y grid coordinates of both positions.</p> <p>Ultimately this is for AS3, but answers in pseudo code would be sufficient.</p>
<pre><code>abs(a.x - b.x) + abs(a.y - b.y) == 1 </code></pre>
Converting words to numbers in PHP <p>I am trying to convert numerical values written as words into integers. For example, "iPhone has two hundred and thirty thousand seven hundred and eighty three apps" would become "iPhone as 230783 apps"</p> <p>Before i start coding, I would like to know if any function / code exi...
<p>There are lots of pages discussing the conversion from numbers to words. Not so many for the reverse direction. The best I could find was some pseudo-code on Ask Yahoo. See <a href="http://answers.yahoo.com/question/index?qid=20090216103754AAONnDz">http://answers.yahoo.com/question/index?qid=20090216103754AAONnDz</a...
html button not inheriting font-size (css) <p>I'm sure it is meant to be like this (e.g. not a bug or browser flaw), but is it correct that the button text does not use the font size declared higher up?</p> <pre><code>&lt;div style="font-size:10px;"&gt; This text would be 10px sized &lt;div&gt; This t...
<p>Yes. The button is supposed to match the OS's style unless you <em>explicitly</em> style it using CSS.</p>
How do you use the maven-simian-plugin in Maven2? <p>I'm looking for a Maven2 reporting plugin for <a href="http://www.redhillconsulting.com.au/products/simian/" rel="nofollow">Simian</a> and the closest thing to such a reporting I found is <a href="http://repo1.maven.org/maven2/maven/maven-simian-plugin/1.6.1/" rel="n...
<p>The Simian plugin listed on central is actually for Maven 1 (if you inspect the contents you'll see a project.xml and a plugin.jelly). So that explains why it doesn't work. This is rubbish and should be removed in my opinion.</p> <p>As far as I can make out there isn't a publically available Maven 2 plugin, this ma...
Regarding gridview <p>I have a gridview in which when I click edit, update, and cancel button comes. I have a variable named status. If status=false then update should change to insert and if status=true then update should be update itself. What code do I have to write in rowcammand for this? </p> <pre><code>&lt;asp:T...
<p>GridView is not designed for insert operations. You should use FormView or DetailView for the insert purpose.</p> <p>Thought you can check if the record exists in <strong>GridView_RowCommand</strong> event, you need to filter the command of your interest using condiotnal match and write the code there.</p> <p>for ...
How can I determine the memory footprint of a session variable? <p>Also, web.config - please explain.</p> <pre><code>&lt;sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="120"/&gt; </code></pre> <p>W...
<p>From George Shepherd's ASP.NET FAQ at <a href="http://www.syncfusion.com/faq/aspnet/web%5Fc9c.aspx" rel="nofollow">http://www.syncfusion.com/faq/aspnet/web_c9c.aspx</a></p> <p>36.37 Is there any way to know how much memory is being used by session variables in my application? </p> <pre><code>No </code></pre> ...
Delete/Reset all entries in Core Data? <p>Do you know of any way to delete all of the entries stored in Core Data? My schema should stay the same; I just want to reset it to blank.</p> <p><hr /></p> <p><strong>Edit</strong></p> <p>I'm looking to do this programmatically so that a user can essentially hit a <code>res...
<p>You can still delete the file programmatically, using the NSFileManager:removeItemAtPath:: method.</p> <pre><code>NSPersistentStore *store = ...; NSError *error; NSURL *storeURL = store.URL; NSPersistentStoreCoordinator *storeCoordinator = ...; [storeCoordinator removePersistentStore:store error:&amp;error]; [[NSFi...
Javascript memory leaks after unloading a web page <p>I have been reading up to try to make sense of memory leaks in browsers, esp. IE. I understand that the leaks are caused by a mismatch in garbage collection algorithms between the Javascript engine and the DOM object tree, and will persist past. What I don't underst...
<p>Here's the problem. IE has a separate garbage collector for the DOM and for javascript. They can't detect circular references between the two.</p> <p>What we used to was to clean up all event handlers from all nodes at page unload. This could, however, halt the browser while unloading. This only addressed the case ...
How do you manage your own small project? <p>Since I have a job, and I want to write some of my own software at my spare time, I want to know how you you guys organize, plan and develop such small project. Since it is not a job, you may be interrupted by many other things, so how can I make it keep going well?</p>
<p>Here are a few things that I have found useful:</p> <ol> <li><strong>Figure out your peak productivity hours:</strong> Some people work better at 6 AM, some people at 6 PM, some at midnight. You probably have other commitments as well, so make sure you figure out the best times, out of the time that you have, to ge...
How to run CPPUnit unit tests <p>I have written few c++ Unit tests using CPPUnit</p> <p>But I do not understand how to run those.</p> <p>Is there any tool like Nunit-gui?</p> <p>Currently I have written and packed tests in a DLL.</p> <p>When i google i found this <a href="http://cppunit.sourceforge.net/doc/lastest...
<p>Group your TestCases into TestSuite, write a main(), compile, link against the cppunit library and run the executable from the command-line. </p> <p>Here is an example of a main function.: </p> <pre><code>CPPUNIT_TEST_SUITE_REGISTRATION(Test); int main( int ac, char **av ) { //--- Create the event manager and t...
Linux: How do I find out if a file has been updated by another process? <p>I am currently watching an XML file from log4j output. I have a custom viewer that displays the log-output in GUI. I need to watch this file as to when it gets updated so that the GUI can re-parse and update itself. In C# there is a FileWatcher ...
<p>Are you looking for something like <a href="http://www.ibm.com/developerworks/linux/library/l-ubuntu-inotify/index.html" rel="nofollow">inotify</a> ?</p> <p>Alternatively you could poll the file using <a href="http://www.opengroup.org/onlinepubs/000095399/functions/stat.html" rel="nofollow">stat</a>.</p>
In any languages, Can I capture a webpage and save it image file? (no install, no activeX) <p>I heard it is possible to capture webpages by using PHP(maybe above 6.0) on windows server. </p> <p>I got some sample code and tested. but there are no code to perform rightly. </p> <p>If you know some right ways to capture ...
<p>you could use the browsershots api <a href="http://browsershots.org/" rel="nofollow">http://browsershots.org/</a></p> <p>with the xml-rpc interface you really could use almost any language to access it.</p> <p><a href="http://api.browsershots.org/xmlrpc/" rel="nofollow">http://api.browsershots.org/xmlrpc/</a></p>
Good Lucene .NET alternative for ASP.NET website <p>Are there any good alternatives for <a href="http://incubator.apache.org/lucene.net" rel="nofollow">Lucene .NET</a> to use in a ASP.NET website?</p> <p>I want to index XML-, TXT-, PDF- and DOC-files.</p> <p>Thanks!</p>
<p>I couldn't say if this is better than Lucene.NET but you might want to look at <a href="https://searcharoo.codeplex.com/" rel="nofollow">https://searcharoo.codeplex.com/</a>.</p>
Problem in Custom tag in JSP <p>Hi i have a custom tag in JSP</p> <pre><code>&lt;dc:drawMultiSelect availableLabel='&lt;%=request.getAttribute("availableCoreColumn").toString()%&gt;' selectedLabel='&lt;%=request.getAttribute("selectedCoreColumns").toString()%&gt;' availableCName="selectCol" selectedCN...
<p>This is likely down to the way you're mixing script expressions and literals, you're confusing the JSp compiler.</p> <p>If this is JSP 2.0 or higher, you can make this much more readable by using EL expressions rather than scriptlets, like this:</p> <pre><code>helpURL="${requestScope.constants.WEB_CONTEXT + '/web/...
How to SELECT sum of numbers less than 30 and sum of numbers greater than 30? <p>I'm trying to write a SELECT statement to select the sum of field but I want to return the sum of numbers less than 30 and also the sum of numbers greater than 30. I realize I can do this with two selects joined together, but I was hoping ...
<p>Something along these lines (correct the syntax for your environment):</p> <pre><code>SELECT sum(case when Field &lt; 30 then Field else 0 end) as LessThan30, sum(case when Field &gt; 30 then Field else 0 end) as MoreThan30 FROM DaTable </code></pre>
Last record of Join table <p>I am lookign for the correct SQL code to join 2 tables and show only the last record of the details table.</p> <p>I have a DB with 2 tables, </p> <pre><code>Deals DealID Dealname DealDetails DealComments dcID DealID CommentTime CommentPerson Comment </code></pre>...
<pre><code>select a.dealid , a.dealname , a.dealdetails , b.dcid , b.commenttime , b.commentperson , b.comment from deals a, dealcomments b where b.dealid = a.dealid and b.commenttime = (select max(x.commenttime) from dealcomments x where x.dealid = b.dealid) </code></pre...
How can I determine if an object is reachable within an object graph in C#? <p>I have a pretty complex object graph <code>G</code> with an object <code>o1</code> in <code>G</code>. <code>G</code> is to be written into a database using NHibernate. However, if there already is a persistent entry of <code>o1</code> (let's...
<p>No, you can't ask the garbage collector how many references there are to o1: .NET doesn't use reference counting.</p> <p>Basically you'd have to do all the graph navigation yourself, which will probably mean making your object graph implement some sort of visitor algorithm, combined with a cache of objects you've a...
Subfigs of a figure on multiple pages <p>I am facing problem of stacking many figures</p> <p>The problem is the stack figure is overriding the page dimension vertically and placing all the figure in one page and not changing the page as the limitation of page is reached.</p> <p>How can page be changed while stacking ...
<p>Everything inside <code>\begin{figure}</code>...<code>\end{figure}</code> must not be larger than a single page. In order to break it over pages, you must do it manually. Use <code>\ContinuedFloat</code> from the <code>subfig</code> package to do this: (from the <a href="http://www.ctan.org/pkg/subfig">subfig docume...
Is Mono stable and fast enough? <p>C# looks great because it is a compiled language which seems to run quite well without too much CPU and does not consume too much memory. And StackOverflow and ServerFault are good examples of an MVC/.Net/C# stack that scales.</p> <p>C# is also interesting because despite being compi...
<p>Stable enough and fast enough to do what?</p> <p>It will have different levels of stability and performance depending on what you want to do, I'm sure. For example, one of my Protocol Buffers unit tests (which uses Rhino.Mocks) manages to make the Mono VM abort with an assertion error - but I have no idea (currentl...
How to find all Keys in a hash have a value in Perl <p>How do you determine if all hash keys have some value ? </p>
<p>From <code>perldoc -f exists</code>:</p> <pre><code> print "Exists\n" if exists $hash{$key}; print "Defined\n" if defined $hash{$key}; print "True\n" if $hash{$key}; print "Exists\n" if exists $array[$index]; print "Defined\n" ...
Javascript And CSS files loading problem <p>We have more java script and css files in our WUI project.</p> <p>In some times, the files are not loading properly, due to the huge size.</p> <p>Did any body face this problem? or Do you have any idea to resolve this issue.</p>
<p>check <a href="http://stackoverflow.com/questions/468329/inclusion-of-a-js-file-in-html/468391#468391">this</a> out you can check whether file is loaded properly or not</p>
How to I pass a checkbox value by reference with CLI? <p>I have a GUI app written in C++/CLI which has a load of configurable options. I have some overloaded functions which grab values from my data source and I'd like to connect my options to those values.</p> <p>So here's a couple of data retrievers:</p> <pre><code...
<p>The two overload of the method <code>GetConfigSingleFile</code> that you have mentioned both take two arguments whereas you are passing 4 arguments to the method. Are there any default arguments? If yes, can you please reproduce the original method declarations?</p> <p>Most probably, the 4 argument overload of this...
Array Searching code challenge <p>Here's my (code golf) challenge: Take two arrays of bytes and determine if the second array is a substring of the first. If it is, output the index at which the contents of the second array appear in the first. If you do not find the second array in the first, then output -1.</p> <p>E...
<p>Common lisp:</p> <pre> (defun golf-code (master-seq sub-seq) (search sub-seq master-seq)) </pre>
How can I add to beginning or end of a file in Perl? <p>What is the best way of writing the some content to the beginning and end of a File in Perl</p>
<p>This is covered by the <a href="http://perldoc.perl.org/perlfaq5.html#How-do-I-change%2c-delete%2c-or-insert-a-line-in-a-file%2c-or-append-to-the-beginning-of-a-file%3f" rel="nofollow">FAQ</a></p>
What issues if any have people had with TFS 2008? <p>We are just about to implement full blown TFS 2008 across our development team and I'd like to find out if there are any gotchas to b e aware fo or any installation issues I am likley to face. I have Googled all the obvious places and read the anti-panic blurb on the...
<p>We have some slight problems when checking in with the Visual Studio integration, it happens quite rarely but can be somewhat annoying. The VS plugin seems to think it's checked in stuff, but it really hasn't. Usually it can be resolved by checking out everything then checking it in again, and you can do it with the...
How can I call the Acrobat feature OCR from C#? <p>I want to write a C# application that can utilize the OCR function in Adobe Acrobat. How can I call this? Is there a public API?</p>
<p>I believe this is part of the Adobe Reader software and is not accessible through an API. There's an API and libraries for constructing PDF documents per the format specifications, but OCR is something that concerns the reader and not the format. I'm afraid you would either have to use another library or implement i...
Equivalent of 'more' or 'less' command in Powershell? <p>Is there a way to paginate the output by piping it to some 'more' command, which is available in linux\unix shells?</p>
<p>Yes there is:</p> <p><code>some-cmdlet | out-host -paging</code></p>
Code Profiling Tools for Perl <p>I need to test Perl Application ( File operation , Data base operation..etc ) . I am looking for some profile tool for Perl code </p> <p>is there any tools for Perl Code Profling like gprof in Linux </p>
<p>Some people might suggest to use Devel::DProf as the most standard way, but if you will look closely it's actually pretty bad solution.</p> <p><strong>The</strong> best profiler for perl now is <a href="http://search.cpan.org/perldoc/Devel::NYTProf">Devel::NYTProf</a>.</p> <p>If you'll google for it, you will see ...
Is there a way in Visual Stuio's compilation settings to combine other referenced DLLs into the built assembly? <p>I have an EXE that I want to distribute, but I don't want to ship all the associated DLLs with it (sort of).</p> <p>Currently I package them all together using .NET Reactor.</p> <p>I tried ILMerge a whil...
<p>There are <a href="http://blogs.msdn.com/jomo%5Ffisher/archive/2006/03/05/544144.aspx" rel="nofollow">many</a>, <a href="http://code.google.com/p/ilmerge-tasks/wiki/HowToUse" rel="nofollow">many</a>, <a href="http://odetocode.com/Blogs/scott/archive/2005/10/06/2326.aspx" rel="nofollow">many</a> places on the web the...
Can you expand #define's into string literals? <p>Is there a way to get the C++ pre-processor to expand a #define'ed value into a string literal?<br> for example: </p> <pre><code>#define NEW_LINE '\n' Printf("OutputNEW_LINE"); //or whatever </code></pre> <p>This looks to me like it should be possible as it's before ...
<p>This will do it:</p> <pre><code>#define NEW_LINE "\n" // Note double quotes Printf("Output" NEW_LINE); </code></pre> <p>(Technically it's the compiler joining the strings rather than the preprocessor, but the end result is the same.)</p>
How to make these dynamically typed functions type-safe? <p>Is there any programming language (or type system) in which you could express the following Python-functions in a statically typed and type-safe way (without having to use casts, runtime-checks etc)?</p> <p><code>#1</code>:</p> <pre><code># My function - Wha...
<p><strong>1#</strong> This is not typeable with a finite type. This means that very few (if any) programming languages will be able to type this.</p> <p>However, as you have demonstrated, there is a specific type for x that allows the function to be typed:</p> <pre><code>x :: t -&gt; B </code></pre> <p>Where <code>...
Partial database synchronization between secure and unsecure site? <p>I've been working with a couple different contact management solutions, but my security paranoia prevents me from wanting to put any sensitive data in the cloud. While I'm not dealing with anything like credit transactions that have detailed securit...
<p>1) This sounds like it'll end up being a lot of pain. Are you sure you want the public system being able to push changes to the private one? </p> <p>2) Mysql replication with the public system as the master should do the trick. You'll want to use the --replicate-do-* options to restrict what statements the slave wi...
Javascript / jQuery: How to prevent active input field from being changed? <p>how do I prevent the user to change the value in an input field (which contains a certain value to be copied into the clipboard) without using disabled="true"? The text should be selected once the user clicks in the field (that's working alre...
<p><strong>readonly</strong> in the html of the input is all you need to prevent the user from editing the input. </p> <pre><code>&lt;input readonly="readonly" type="text" value="You can't edit me!"/&gt; </code></pre>
mysql connections bottle neck via PHP <p>Currently we are restoring MySQL connections in a $_SESSION in order to save round trip time to set up connection to MySQL,</p> <p>but the problem is that the number of connections exceed the limit quickly,</p> <p>so what's your guys' solution?</p> <p>Do you create a new conn...
<p>Further to <strong>DGM</strong>'s comment, <code>resource</code> types (like a MySQL connection reference) are not restored with a session. The contents of <code>$_SESSION</code> are serialized using <code>serialize()</code> and stored with the session ID, to be restored when the session is started again.</p> <p>Th...
2D motion blur solutions <p>I'm thinking of chucking motion blur into my 2D program, but I doubt the results of my current algorithm.</p> <p>My approach looks like this at the moment:</p> <ul> <li>Draw to backbuffer. </li> <li>When time to update front buffer, blend the backbuffer onto the front buffer.</li> <li>Repe...
<p>Really you should render many intermediate frames and blend them into one result. Say, for example, that your output frame rate is 50 fps. You'd probably get a reasonable result if you rendered internally at 500 fps and blended groups of ten frames together before showing that to the user.</p> <p>The approach you a...
Objective C Warning: passing argument 1 of 'touchesForView:' from distinct Objective-C type <p>I'm using some code from <a href="http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/EventHandling/EventHandling.html" rel="nofollow">here</a> to determine when determining when...
<p>That particular warning comes up when you provide an object of a type that is different from the one that was expected.</p> <p>In this case, <code>touchesForView:</code> expects a <code>UIView</code> object, but you are passing it an object of whatever type <code>self</code> happens to be in this code.</p> <p>In o...
Threadsafe Generic Extension method usage syntax issue <p>Here's my extension method for invoke on a control:</p> <pre><code>public static void Invoke&lt;T&gt;(this T c, Action&lt;System.Windows.Forms.Control&gt; DoWhat) where T:System.Windows.Forms.Control { if (c.InvokeRequired) c.Invoke(o=&gt; DoWha...
<p>The problem is that your action is only declared (in the method) to act on <code>Control</code>. Change it to this:</p> <pre><code>public static void Invoke&lt;T&gt;(this T c, Action&lt;T&gt; DoWhat) where T:System.Windows.Forms.Control { if (c.InvokeRequired) c.Invoke((EventHandler) delegate { DoWh...
How to determine position of row in sql result-set? <p>i have a sql query:</p> <pre><code>select id, name from table order by name </code></pre> <p>result looks like this:</p> <pre><code>52 arnold 33 berta 34 chris 47 doris 52 emil </code></pre> <p>for a given id=47 how can i determine the position in the result...
<p>The previous posts are correct. Use ROW_NUMBER if using Microsoft SQL Server 2005 or greater.</p> <p>However, your tags do not specify that you're using MSSQL, so here's a solution that should work across most RDBMS implementations. Essentially, use a correlated subquery to determine the count of rows in the same s...