input
stringlengths
51
42.3k
output
stringlengths
18
55k
What is the easiest way to fixed pivot transform this data in C# (linq?)? <p>Given this example data (in .NET classes where Po, Sku, Qty are properties):</p> <pre><code>PO, Sku, Qty 1,ABC,1 1,DEF,2 1,GHI,1 1,QWE,1 1,ASD,1 1,ZXC,5 1,ERT,1 2,QWE,1 2,ASD,11 2,ZXC,1 3,ERT,1 3,DFG,1 3,DFH,1 3,CVB,4 3,VBN,1 3,NMY,1 </code><...
<p>Firstly, here's the query that will generate the correct hierarchy of objects. I'm using anonymous types but it's easy enough to change it to use your own proper classes.</p> <pre><code>var query = yourData .GroupBy ( x =&gt; x.PO ) .SelectMany ( x =&gt; x.Select ( ...
JavaScript function aliasing doesn't seem to work <p>I was just reading <a href="http://stackoverflow.com/questions/954417/make-alias-to-document-getelementbyid-in-javascript">this question</a> and wanted to try the alias method rather than the function-wrapper method, but I couldn't seem to get it to work in either Fi...
<p>I dug deep to understand this particular behavior and I think I have found a good explanation.</p> <p>Before I get in to why you are not able to alias <code>document.getElementById</code>, I will try to explain how JavaScript functions/objects work.</p> <p>Whenever you invoke a JavaScript function, the JavaScript ...
Setup Project for Windows Service won't build under Server 2008 (Visual Studio 2008) <p>We've got new machines here for doing development on running Server 2008.</p> <p>With Visual Studio 2008 we're having problems building a Setup Project which installs the Windows Service - Under Custom Actions then Uninstall, "Inst...
<p>Make sure you add the service in the custom actions otherwise the service will not be registered. Other than that, are you having any compilation errors?</p>
Is it possible to make pointers to distinct template types convertible? <p>I have a template class that will bundle some information with a type:</p> <pre><code>template &lt;typename T&gt; class X { int data[10]; // doesn't matter what's here really T t; public: // also not terribly relevant }; </code></pre> <p...
<p>Rephrasing the question to a more general: <em>is it possible to convert pointers from unrelated types if the unrelated types are themselves convertible?</em>, the answer is not. And different template instantiations define different unrelated types.</p> <p>You can implicitly convert (see note below) a pointer to a...
traversing a table with javascript DOM <p>I know this is the simplest problem ever, but I can't seem to find the answer and I'm searching in the dark, so a little help is appreciated. I'm trying to get the text in the node where class='song_artist'. I have a reference to the parent node, but just can't get to the text ...
<p>You can do:</p> <pre><code>var collection = document.getElementsByTagName( "td"); for( var i = 0; i &lt; collection.length; ++i) { if ( collection[i].getAttribute("class") === "whateveryouwant") { } } </code></pre> <p>But my advise to switch using javascript framework like jquery, since then on...
How to declare a resource from a private inner class in WPF? <p>I'm trying to declare a resource in a WPF UserControl, and I'd like the resource to be an instance of a private inner class. How do I do this?</p> <p>XAML:</p> <pre><code>&lt;UserControl ...&gt; &lt;UserControl.Resources&gt; &lt;local:MyConve...
<p>You can't do it if the class is private, you could make it internal instead</p> <p>Regarding the declaration of an inner class in XAML, you should have a look at <a href="http://stackoverflow.com/questions/863180/binding-converter-as-inner-class/">this discussion</a></p>
How to break dependencies without modifying production code? <p>From my initial readings on unit testing (I'm a beginner) it is wise to put all of your setups and tests in a separate project from the code being tested. This seems ideal to me, as well. However, I've recently begun reading The Art of Unit Testing, tryi...
<p>There is no way to break dependencies without making some sort of change. What is important is that the changes you make don't change the behavior of production code in production, and that you aren't introducing worse dependencies.</p>
Properly assigning Namespaces (with ReSharper's suggestions) <p>Lets say we have the following <em>file</em> and [folder] structure in a project with a main namespace of <code>MyNamespace</code>:</p> <ul> <li>[Entities] <ul> <li><em>Article.cs</em></li> <li><em>Category.cs</em></li> </ul></li> <li>[Interfaces] <ul> <l...
<p>I think ReSharper's suggestions are fine. I think it's a mistake to group classes, etc., by what they are instead of what they do.</p> <p>An analogy is grouping documents in subfolders Word, Excel, etc. instead of by Project or some other functional grouping.</p>
What are all the available ActionResults for ASP.NET MVC? <p>What are all the methods that return an ActionResult in ASP.NET MVC as of right now (ie. RedirectToAction, etc.)</p> <p>I haven't found a good documentation resource that lists this kind of stuff.</p>
<p>Found from <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.actionresult.aspx">here</a></p> <pre> System.Web.Mvc.ActionResult System.Web.Mvc.ContentResult System.Web.Mvc.EmptyResult System.Web.Mvc.FileResult System.Web.Mvc.HttpUnauthorizedResult System.Web.Mvc.JavaScriptResult ...
XSLT Insert html content <p>I'm trying to insert some HTML at a given point. The XML file has a content node, which inside that has actual HTML. For exmaple here is the content section of the XML:</p> <pre><code>----------------- &lt;content&gt; &lt;h2&gt;Header&lt;/h2&gt; &lt;p&gt;&lt;a href="..."&gt;some lin...
<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt; &lt;xsl:template match="/content"&gt; &lt;xsl:copy-of select="h2"/&gt; &lt;a href=""&gt;foo&lt;/a&gt; &lt;xsl:copy-of select="p"/&gt; &lt;/xsl:template&gt;...
Timeout Errors occuring when calling web service in c# .Net 2.0 <p>I have inherited some code and I'm not very familiar in dealing with web services. Here is how the project is set up:</p> <p>Under "Web References" there is a reference to the web service we are using. In that service's Reference.cs file there is cla...
<p>Please post the complete exception you're seeing, including all InnerException. For instance:</p> <pre><code>try { using (CandidateService svc = new CandidateService()) { svc.CandidateAdd(); } } catch (Exception ex) { string what_I_should_post = ex.ToString(); } </code></pre> <p>You may think i...
Proxying IIS <p>I'm getting XSS errors when trying to consume a .NET web service and I'm sure I can fix it with a bit of proxying. However, I've never proxied IIS before. Can anyone point me in the right direction for a good guide/tutorial please?</p> <h2>UPDATE</h2> <p>First off my apologies for being so vague!</p> ...
<p>After causing a lot of confusion and getting nowhere with this post I decided to commit the cardinal sin of reposting ... I'm sorry but it was the only way to etch-a-sketch the topic as far as I saw it.</p> <p>Anyway, that didn't seem to get any response either but, through a long and arduous path, I eventually man...
xcode can't find a standard c++ include file <p>When i mix .m and .cpp i have a problem with xcode not finding the default cpp include (like <code>&lt;map&gt;</code>) </p> <p>update: i'm adding a static lib in my iphone project (which does compile without any problems) and then use the include inside the .m, then the ...
<p>If you are using Objective-C++ (i.e. mixing Objective-C and C++ in one source file or importing a C++ header into an Objective-C file), then you should be using the <code>.mm</code> extension on your source code files. By default, Xcode will compile <code>.mm</code> files using the Objective-C++ compiler. <code>.m</...
jQuery Selectors <p>I am trying to take this from view source, i.e.:</p> <pre><code>&lt;a href="javascript:validateCB();"&gt;&lt;img src="wwv_flow_file_mgr.get_file?p_security_group_id=1343380920146312332&amp;p_flow_id=222&amp;p_fname=submit_btn.gif" alt="Submit Details" border="0" /&gt; </code></pre> <p>into jQuer...
<p>The problem is with the attribute selector: <code>$('img[src^="wwv_flow_file_mgr"]')</code></p> <p>You're experiencing a <a href="http://dev.jquery.com/ticket/4244">known bug</a> in jQuery v1.3.2 - jQuery is trying to interpret the image path using its absolute URL, which means the URL it's comparing actually start...
Take a sequence of elements from an array from i to j using C# and extension method <p>I have an <code>Array&lt;string&gt;</code>. I have to take all elements from <code>i</code> to <code>j</code>. How can I make this using an extension method?</p>
<p>Try the following.</p> <pre><code>public static IEnumerable&lt;T&gt; GetRange&lt;T&gt;(this IEnumerable&lt;T&gt; enumerable, int start, int end) { return enumerable.Skip(start).Take(end-start); } </code></pre> <p>Then you can do</p> <pre><code>Array&lt;string&gt; arr = GetSomeArray(); var res = arr.GetRange(i,...
Can't instantiate COM component in C# - error 80070002 <p>I'm attempting to instantiate a Windows Media Player COM object on my machine:</p> <pre><code>Guid mediaPlayerClassId = new Guid("47ac3c2f-7033-4d47-ae81-9c94e566c4cc"); Type mediaPlayerType = Type.GetTypeFromCLSID(mediaPlayerClassId); Activator.CreateInstance(...
<p>80070002 is a File Not Found error.</p> <p>My guess is your machine is missing a dependency. Try running the com component through depends.exe to see if you have all of the required libraries installed.</p>
C# Getting Enum values <p>I have a enum containing the following (for example):</p> <ul> <li>UnitedKingdom,</li> <li>UnitedStates,</li> <li>France,</li> <li>Portugal</li> </ul> <p>In my code I use <strong>Country.UnitedKingdom</strong> but I want to have the value be <strong>UK</strong> if I assign it to a <strong>s...
<p>You can't assign an enum value to a string to start with. You'd have to call <code>ToString()</code>, which would convert <code>Country.UnitedKingdom</code> to "UnitedKingdom".</p> <p>Two options suggest themselves:</p> <ul> <li>Create a <code>Dictionary&lt;Country, string&gt;</code></li> <li>A switch statement</l...
Jquery Tabs: spinner option not working <p>I need an ajax animation while the remote page is loaded in tabs. </p> <p>I am using </p> <pre><code>$('#tabs2').tabs({ spinner: ''&lt;img src="../../Content/images/Jquery/spinner.gi'' }); </code></pre> <p>Even <code>$('#tabs2').tabs({ spinner: 'Loading..' });</code> also d...
<p>Sorry problem solved. I Put a <code>&lt;span&gt;</code> tag in the tabs. Found the solution in Jquery support discussions. <a href="http://docs.jquery.com/Discussion" rel="nofollow">http://docs.jquery.com/Discussion</a> </p> <p>e.g. </p> <pre><code>&lt;li&gt;&lt;a href="../URL"&gt;**&lt;span&gt;Text to display in ...
ClearCase : list the content of a directory (ls) using CAL <p>In ClearCase, you can list the content of a directory using "cleartool ls".</p> <p>My question is how can I do the same thing using CAL (ClearCase Automation Layer). The reason I prefer the COM API is because I won't have to parse the output of "ls".</p> <...
<p>May be this is a good start:</p> <pre><code>Set CC = Wscript.CreateObject("ClearCase.Application") Set DirVer = CC.Version(".") Set FSO = CreateObject("Scripting.FileSystemObject") Set Folder = FSO.GetFolder(DirVer.Path) Wscript.Echo "Files under source control: " For Each File in Folder.Files On Error R...
What is the best-practice casing style for javascript? Why? <p>One aspect of javascript that it's hard to find information on is casing practices. By casing practices, I mean what casing style (ie. camel-case, pascal-case, etc) should be used for what elements (Constructors, private functions, public functions).</p> ...
<p>I prefer PascalCase for constructors and camelCase for everything else. That's the style that JS standard library uses and well... every JS framework I've seen so far :)</p> <p>And I use all_lowercase naming convention for all files served from web. There are <em>some</em> case-insensitive file systems out there.</...
'Invalid Argument' Error in IE, in a line number that doesn't exist <p>I'm getting the following error in IE 6:</p> <pre><code>Line: 454 Char: 13 Error: Invalid Argument Code: 0 URL: xxxxx/Iframe1.aspx </code></pre> <p>and I can't for the life of me find what's causing this.</p> <p>This only happens in a sit...
<p>IE's Javascript engine is disgusting when it comes to debugging. You can try enabling script debugging in the Advanced Options, and then if you have Visual Studio installed it will jump to the place of error... if you're lucky. Other times you don't get anything, especially if the code was eval()'ed.</p> <p>Another...
Hiding Table Columns With JQuery <p>This method is used to hide columns in a table based on a collection of metadata json objects. There is an object per column in the table. Currently on a table that has ~500 rows and ~15 columns with 6 being hidden this method takes ~2 seconds to execute.</p> <p>I am attempting to o...
<p>I'm not sure where <code>$table</code> comes from, but how about good old DOM instead of a complex jQuery selector:</p> <pre><code>$table.each( function() { var rows = this.rows; var rowCount = rows.length; for (var i = 0; i &lt; rowCount; i++) { var cells = rows[i].cells; if (cells.length &gt; index...
MVVM, Animations and Commanding - Best way to kick off animations? <p>Users love animations. See the iphone for a good example :) Everything a user does in the iphone kicks off an animation.</p> <p>Enter MVVM and Commanding (I'm thinking about Silverlight 2 specifically). A user action triggers an event via Command...
<p>Typically I use events to fire the animations from the viewmodel in Silverlight 2</p>
javan-whenever not writing crontab with Capistrano deploy <p>I’ve been trying to get whenever running on an ec2 instance that was created with ec2 on rails.</p> <p>When I deploy with Capistrano it indicates that the crontab was written, but when I log into the server and run crontab -l it does not seem to have been ...
<p>you should be able to just require the whenever capistrano command in your cap deploy file like so:</p> <p>require 'whenever/capistrano'</p> <p>if you're using bundler, you'll need to add this as well:</p> <p>set :whenever_command, 'bundle exec whenever'</p>
Silverlight image viewer control suggestions <p>Can anyone suggest a good control that can be used to display images (png's most likely and it will always be one type that I can dictate). The images would be available server side only so I don't have to worry about clients uploading anything. Just displaying images o...
<p>ShineDraw.com has a comparison between 6 silverlight and flash image rotators. It explains how they work with some code and examples. The sourcecode is available. You should definitly have a look at those:</p> <p><a href="http://www.shinedraw.com/3d-illusion/6-new-silverlight-image-rotators/" rel="nofollow">http://...
swf to jpg using actionscript <p>Is it possible to convert an swf to image using actionscript.</p>
<p>You question needs a bit more detail. So I will make some assumptions.</p> <p>I assume that you want to take a snapshot of the current state of you SWF, and then save that as an image file. You don't tell us where you want to save the image e.g. on a server, on the users local machine, or even keep it inside flash ...
My Rails queries are starting to get complicated, should I switch to raw SQL queries? What do you do? <p>My Rails app is starting to need complicated queries. Should I just start using raw SQL queries? What is the trend in the Rails community?</p> <p><strong>Update:</strong> </p> <p>I do not have written queries ri...
<p>The general idea is to stick to <code>ActiveRecord</code>-generated queries as much as possible, and use SQL fragments <strong>only where necessary</strong>. SQL fragments are explicitly supported because the creators of <code>ActiveRecord</code> realised that SQL cannot be completely abstracted away.</p> <p>Using ...
IDE / Emacs mode for Shell scripting in Bash/Sh, etc <p>I use Emacs for shell scripts. I know I read somewhere there's some mode to make it easier (code completion, autocomplete, bracket matching, syntax highligting, check syntax) to write Shell scripts on Emacs but haven't been able to find it. In short, I would like ...
<p>Well, there's a built-in shell mode that does syntax highlighting, if it's not already turned on, <code>M-x shell-script-mode</code> will do it for you.</p> <p>Regarding a tool to make scripting easier. There's a <a href="http://bashdb.sourceforge.net/">bash shell debugger</a>, so if you program in bash, that woul...
Simple RegEx PHP <p>I have a string and I need to see if it contains the following "_archived".</p> <p>I was using the following:</p> <pre><code>preg_match('(.*)_archived$',$string); </code></pre> <p>but get:</p> <pre><code>Warning: preg_match() [function.preg-match]: Unknown modifier '_' in /home/storrec/classes/c...
<p>strstr($string, "_archived");</p> <p>Is going to be way easier for the problem you describe.</p> <p>As is often quoted </p> <blockquote> <p>Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. - Jamie Zawinski</p> </blockquote>
Write a file "on-the-fly" to the client with C# <p>I'm using C# and ASP.NET 2.5.</p> <p>I want a simple way to generate a "file" on-the-fly (let's say a csv file for this example) and transmit it to the client without actually writing it to the server file system. </p>
<p>After some searching and trial and error, I developed the following. It seems to fit the bill exactly. It should be very easily adaptable to PHP or any other server-side software since it mostly involves modifying headers.</p> <pre><code>protected void streamToResponse() { Response.Clear(); Response.AddHead...
Is there any difference between these two statements? <ol> <li><code>float ff = 1.2f;</code></li> <li><code>Float fo = new Float(1.2f);</code></li> <li><code>double fg = 3.2d;</code> </li> <li><code>Double fh = new Double(2.1d);</code> </li> </ol> <p>Can I use '=' between the (1) and (3) or between the (2) and (4)??</...
<p>Yes.</p> <ol> <li>Makes a plain old data type (AKA a primitive type) called "float."</li> <li>Makes a Java Object called Float that holds that value that happens to be identical to (1)</li> </ol> <p>Responding to the edit questions:</p> <p>You will see </p> <ol> <li>"possible loss of precision" message if you tr...
How to read Result of SELECT * from Joined Tables With Duplicate Column Names in .NET <p>I am a PHP/MYSQL developer, slowly venturing into the realm of C#/MSSQL and I am having a problem in C# when it comes to reading an MSSQL query that joins two tables.</p> <p>Given the two tables:</p> <p>TableA:</p> <pre><code>in...
<p>The result set only sees the returned data/column names, not the underlying table. Change your query to something like </p> <pre><code>SELECT TableA.Name as Name_TA, TableB.Name as Name_TB from ... </code></pre> <p>Then you can refer to the fields like this:</p> <pre><code>data_reader["Name_TA"]; </code></pre>
Selecting nodes with the default namespace <p>I've got an XML document with many different namespaces in use and a schema to validate against. The schema requires that all elements be "qualified", and I assume this means that they need to have full QNames without a null namespace.</p> <p>However, some elements in this...
<pre><code>&lt;!-- Identity transform by default --&gt; &lt;xsl:template match="node() | @*"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="node() | @*"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;!-- Override identity transform for elements with blank namespace --&gt; &lt;xsl:template match="*[names...
Apache Reverse Caching Proxy - why isn't it caching? <p>I am attempting to set up a reverse caching proxy for ad graphics (gif, jpg, swf) serving. The proxying is working fine and sending the request on to the origin server, but I can't seem to figure out why the content isn't being cached. My current config is below. ...
<p>Adding these directives seemed to kick the cache mechanism into gear. I figure it has to do with expiration and cache-control headers as sent from the origin server since I'm serving up images with Symfony/PHP5 instead of directly from the filesystem.</p> <pre> &lt;IfModule mod_disk_cache.c&gt; CacheEnable disk...
Multi Band Infragistics UltraGrid Row Select problem <p>I am bringing in data from SQL that is to be displayed in a multi band ultragrid. This works great. It does what it is supposed to in this regard; however, if I try to select a row other than the first one, in any band of the bands, it freezes the program.</p> <p...
<p>Are you using <code>BindingList&lt;&gt;</code> as your data source? Try converting to <code>List&lt;&gt;</code>.If you have to use BindingList&lt;> then set the SyncWithCurrencyManager property on ultragrid to false. This tells the grid not to synchronize the current row with the current position of the CurrencyMan...
Learning NHibernate <p>I am interested in learning NHibernate.</p> <p>So, I found this: <a href="http://www.summerofnhibernate.com/">http://www.summerofnhibernate.com/</a></p> <p>I would like to watch these, but I am afraid that the videos are for a previous version of NHibernate. Is this true and if so should I stil...
<p>You should still watch them, they are great, and almost all of it still applies.</p> <p>Some great articles:</p> <ul> <li><a href="http://dotnetslackers.com/articles/ado%5Fnet/Your-very-first-NHibernate-application-Part-1.aspx">Your very first NHibernate application – Part 1</a></li> <li><a href="http://dotnetsl...
Get the area of a PictureBox which is covered by a panel <p>I have two controls which are both contained within a user control. </p> <ul><li>Panel location: 49, 400</li> <li>Panel size: 787, 70</li> </ul> <ul><li>Picturebox location: 25, 0</li> <li>Picturebox Size: 737, 700</li> </ul> <p>Picturebox is seen unde...
<p>You can use the Rectangle.Intersect method (together with a tiny bit of calculation) to get the result you want. C# sample:</p> <pre><code>Rectangle rect = Rectangle.Intersect(_pictureBox.Bounds, _panel.Bounds); rect = new Rectangle(rect.Top - _panel.Top, rect.Left - _panel.Left, rect.Width, rect.Height); e.Graphic...
C++/OpenGL - Rotating a rectangle <p>For my project i needed to rotate a rectangle. I thought, that would be easy but i'm getting an unpredictable behavior when running it..</p> <p>Here is the code:</p> <pre><code> glPushMatrix(); glRotatef(30.0f, 0.0f, 0.0f, 1.0f); glTranslatef(vec_vehicle_position_.x, ve...
<p>You need to flip the order of your transformations:</p> <pre><code>glRotatef(30.0f, 0.0f, 0.0f, 1.0f); glTranslatef(vec_vehicle_position_.x, vec_vehicle_position_.y, 0); </code></pre> <p>becomes</p> <pre><code>glTranslatef(vec_vehicle_position_.x, vec_vehicle_position_.y, 0); glRotatef(30.0f, 0.0f, 0.0f, 1.0f); <...
Reverse the ordering of words in a string <p>I have this <code>string s1 = "My name is X Y Z"</code> and I want to reverse the order of the words so that <code>s1 = "Z Y X is name My"</code>. </p> <p>I can do it using an additional array. I thought hard but is it possible to do it inplace (without using additional dat...
<p>Reverse the entire string, then reverse the letters of each individual word.</p> <p>After the first pass the string will be</p> <pre><code>s1 = "Z Y X si eman yM" </code></pre> <p>and after the second pass it will be</p> <pre><code>s1 = "Z Y X is name My" </code></pre>
Set environment variables from Delphi (Win32) <p>I'm trying to set a system wide environment variable from within my delphi application. The Documentation says to add a registry key to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and then broadcast a WM_SETTINGCHANGE message. Anyone k...
<p>Call <a href="http://msdn.microsoft.com/en-us/library/ms644950.aspx" rel="nofollow"><code>SendMessage</code></a>. Use <code>HWnd_Broadcast</code> as the target window.</p> <p>A better option may be <a href="http://msdn.microsoft.com/en-us/library/ms644953.aspx" rel="nofollow"><code>SendNotifyMessage</code></a>, whi...
How to test iphone p2p aplications? <p>Is there a way to test iphone OS 3.0 p2p applications? Can I run multiple iphone simulator instances? Aperantly no. Any help?</p>
<p>I put up a detailed post on how to do this a couple weeks ago, so I'll just refer you to it: <a href="http://ramin.firoozye.com/2009/06/18/debugging-peer-to-peer-and-wifi-apps-on-the-iphone/" rel="nofollow">http://ramin.firoozye.com/2009/06/18/debugging-peer-to-peer-and-wifi-apps-on-the-iphone/</a></p>
Qt Build Error <p>After configuring with</p> <pre><code>$./configure -embedded arm -xplatform qws/linux-arm-g++ -opensource </code></pre> <p>I get this output when Making and can't figure out why:</p> <p>../../src/corelib/arch/qatomic_arm.h: In function <code>char q_atomic_swp(volatile char*, char)': ../../src/c...
<p>Check this post out from the QT mailing lists:</p> <p><a href="http://lists.trolltech.com/pipermail/qt-embedded-interest/2009-March/000224.html" rel="nofollow">http://lists.trolltech.com/pipermail/qt-embedded-interest/2009-March/000224.html</a></p>
Most efficient idiom to read one integer only from a file? <p>In trying to resolve Facebook's Puzzle "Hoppity Hop", <a href="http://www.facebook.com/careers/puzzles.php?puzzle_id=7" rel="nofollow">http://www.facebook.com/careers/puzzles.php?puzzle_id=7</a>, I'm reading one integer only from a file. I'm wondering if thi...
<p>The <em>shortest</em> method would be with a <a href="http://java.sun.com/javase/6/docs/api/java/util/Scanner.html" rel="nofollow"><code>Scanner</code></a>:</p> <pre><code>private static int readSoleInteger(String path) { Scanner s = new Scanner(new File(path)); int ret = s.nextInt(); s.close(); ret...
How can I detect with JavaScript/jQuery if the user is currently active on the page? <p>I am needing to detect when a user is inactive (not clicking or typing) on the current page for more than 30 minutes.</p> <p>I thinking it might be best to use event blubbling attached to the body tag and then just keep resetting a...
<p>This is what I've come up with. It seems to work in most browsers, but I want to be sure it will work everywhere, all the time:</p> <pre><code>var timeoutTime = 1800000; var timeoutTimer = setTimeout(ShowTimeOutWarning, timeoutTime); $(document).ready(function() { $('body').bind('mousedown keydown', function(ev...
How do I perform vector addition in Ruby? <p>How do I perform vector addition in Ruby so that</p> <pre><code>[100, 100] + [2, 3] </code></pre> <p>yields</p> <pre><code>[102, 103] </code></pre> <p>(instead of joining two arrays)?</p> <p>Or it can be another operator too, such as </p> <pre><code>[100, 100] @ [2, 3]...
<p>See the <a href="http://ruby-doc.org/stdlib/libdoc/matrix/rdoc/Vector.html" rel="nofollow">Vector</a> class:</p> <pre><code>require "matrix" x = Vector[100, 100] y = Vector[2, 3] print x + y E:\Home&gt; ruby t.rb Vector[102, 103] </code></pre> <p>See <a href="https://github.com/psorowka/vectorops" rel="nofollow"...
FileInfo object property question - C#? <p>Does the following <code>System.IO.FileInfo</code> properties map to the following properties in the Windows Explorer application:</p> <ul> <li>CreationTime = Date Created</li> <li>LastWriteTime = Date Modified</li> <li>LastAccessTime = Date Accessed</li> </ul>
<p>Yes, in a nutshell.</p> <p>(I'm not sure I can add <em>anything</em> else of any use here...)</p>
How to determine which control is eating my keyboard events <p>In my .Net app, I keep running into the issue of a particular form/control which I expected to receive a keyboard event does not actually receive it. My debugging of this has not progressed much beyond caveman, eg setting breakpoints in all my controls, an...
<p>The first thing I would do is that I would check in the Properties window (or in the Designer file) to make sure that the event handler is indeed hooked up to the event.</p>
Label.Text change being blocked? <p>I am attempting to use a Microsoft.SqlServer.Management.Smo.Restore object to restore a SQL Server 2000 database. Just before I begin the restore operation, I change the text of a label so that the user knows what is going on. However, the changed text isn't visible on the GUI (i.e.,...
<p>You're blocking on the GUI thread, which is preventing it from updating. You can call lblStatus.Refresh(), or move your Wait to a background thread (which is ultimately the right thing to do).</p>
Any way to "bulk load" a Qt data model to avoid excess signal invocations? <p>I have a <code>QStandardItemModel</code> with some manually implemented "select all" functionality. This loops through and updates the data for all items (or certain items—there's a filter involved). The problem is that I have some slots co...
<p>Try using the <a href="http://doc.trolltech.com/4.5/qobject.html#blockSignals" rel="nofollow">QObject::blockSignals</a> method on the object emitting the signals. This will allow you to suppress and then later restore signal generation. Very useful for exactly this type of operation. </p>
Why does this only work in Firefox? <p>I've created a self-contained example to find out why this is only working in Firefox:</p> <pre><code>var ul = jQuery('&lt;ul&gt;&lt;/ul&gt;'); jQuery(selector).children().each(function() { var li = jQuery('&lt;li&gt;&lt;/li&gt;'); var label = '&lt;label for="' + this.id +...
<p>The problem is, that "this" is a DOM node already located at some place. You can't move DOM nodes around, that already are located somewhere without first removing or copying them.</p> <p>If you want to:</p> <ul> <li><p>move it, you have to do</p> <p>li.append ($(this).remove())</p></li> <li><p>copy it, you'll do...
Linq to XML (Base64 Encoded) <p>I have got to convert a PDF to a Base64 Encoded and write it to a element in a XML file.<br> I have got the Base64 Encoded string (very long/big) but the spec im working from says the following:</p> <p>This has been chosen, to ensure the XML file may be displayed and validated without a...
<pre><code>Convert.ToBase64String(pdfBytes, Base64FormattingOptions.InsertLineBreaks); </code></pre>
A database system for storing mobile device data? <p>I'm starting to build an app, a mobile device. Performance is quite important (as it is in anything else) and I'd like to maximize it.</p> <p>The database will be used pretty often. I'm looking to access it through the QtSQL library of the C++ Qt library.</p> <p>I ...
<p>Since Apple uses sqlite on the iPhone and iPod Touch, I would take a good look at that. I assume that they will have evaluated everything available to them at the time to get to this conclusion.</p> <p>Since sqlite is FOSS and "endorsed" by a well-known vendor of mobile devices, give it a try.</p>
why do people use .net for web development <p>I just want to know why people use dot net over something like php for web dev. What are the advantages? Is it true that .net generates your javascript and html? </p>
<p>WebForms provides an abstraction of Web development that mimics classic Windows development. plus, the C# and VB.NET can be used to develop desktop programs, and the business object libraries that can be shared between ASP.NET and Desktop applications easily. </p> <p>I know developers who develop ASP.NET applicatio...
Is the distribution provisioning profile associated with the iPhone device? <p>I installed the distribution (for Appstore) provisioning profile in Xcode, but it doesn't show up under Devices, only the Developer provisioning profile shows up. I cannot "Build and Go" with the distribution provisioning profile in Xcode e...
<p>That's right. You can only use this profile to build App Store builds. For your testing you need a development profile. The distribution provisioning profile has nothing to do with the devices you registered on the iPhone development site.</p>
Selecting option by text content with jQuery <p>I want to set a dropdown box to whatever has been passed through a querystring using jquery. </p> <p>How do I add the selected attribute to an option such that the "TEXT" value is equal to a certain param from the query string?</p> <pre><code> $(document).ready(function...
<p>Replace this:</p> <pre><code>var $dd = $('#cbCategory'); var $options = $('option', $dd); $options.each(function() { if ($(this).text() == cat) $(this).select(); // This is where my problem is }); </code></pre> <p>With this:</p> <pre><code>$('#cbCategory').val(cat); </code></pre> <p>Calling <a href="http://d...
Why does ie8's user agent return 'opera'? <p>My code at: <a href="http://www.mgxvideo.com/mgxcopy-dev/get%5Fbrowser.php" rel="nofollow">http://www.mgxvideo.com/mgxcopy-dev/get_browser.php</a>, returns Opera when I run IE8. My source is:</p> <pre><code>&lt;?php $browser = get_browser(null, true); echo $browser['browse...
<p>It doesn't. The <code>get_browser()</code> function is making educated (but ill-informed) guesses about which browser the user-agent is running. Your browser capabilities file is likely outdated, probably because it was made before IE8 was released. Update it <a href="http://browsers.garykeith.com/downloads.asp" rel...
Syntax of HTTP-status headers <p>There're many ways to write an HTTP-status header:</p> <pre><code>HTTP/1.1 404 Not Found Status: 404 Status: 404 Not Found </code></pre> <p>but which is the semantically-correct and spec-compliant way?</p> <p>Edit: By status headers I mean <a href="http://www.w3.org/Protocols/rfc2616...
<p>Adding some information some time later, since I came across this question whilst researching something related.</p> <p>I believe the Status header field was originally invented as part of the CGI specification, RFC 3875:</p> <p><a href="https://tools.ietf.org/html/rfc3875#section-6.3.3" rel="nofollow">https://too...
Command Line Arguments In Python <p>I am originally a C programmer. I have seen numerous tricks and "hacks" to read many different arguments. </p> <p>What are some of the ways Python programmers can do this?</p> <h3>Related</h3> <ul> <li><a href="http://stackoverflow.com/questions/20063/whats-the-best-way-to-grab-pa...
<pre><code>import sys print "\n".join(sys.argv) </code></pre> <p><code>sys.argv</code> is a list that contains all the arguments passed to the script on the command line.</p> <p>Basically,</p> <pre><code>import sys print sys.argv[1:] </code></pre>
Blackberry Development - Any suggestions on references and tools? <p>I'm looking for good reference materials and open to recommendations about good IDE tools that I can use to develop for the Blackberry. I've been to RIM's site and experimented with their IDE however as of my last use it had issues with Vista and use...
<p>You can use Eclipse to develop for the Blackberry platform, using the <a href="http://na.blackberry.com/eng/developers/javaappdev/javaeclipseplug.jsp" rel="nofollow">Blackberry JDE plugin</a>.</p> <p>I've only played around with it personally, but had no issues (running Vista SP1 at the time).</p>
Calling setNeedsDisplay on a UIView from another class <p>I have a UIView subclass that I manipulate a lot of graphics on based on touches. All the [self setNeedsDisplay] calls seem to be fine.</p> <p>However, I used an instance variable pointer to my same UIView subclass instance, and then tried manipulating it and...
<p>drawRect: will only be called when it makes sense; ie, the view must be visible, onscreen, and dirty. Is your drawRect: <em>ever</em> called? It should be called when the view is first brought onscreen as well.</p>
Android Eclipse Plugin: Instrumentation Test Runner not specified <p>I'm getting this error when trying to run unit tests from Eclipse with an Android Project. The list of Instrumentation Test Runners is empty in the Android preferences.</p> <blockquote> <p>[2009-06-17 23:57:51 - MyApp] ERROR: Application does not...
<p>You're probably missing the following in your <code>AndroidManifest.xml</code>:</p> <pre>&lt;instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="your.package" android:label="your tests label" /&gt;</pre> and <pre><code>&lt;uses-library android:name="android.test.runn...
What value is the ThreadState Property? <p><a href="http://stackoverflow.com/questions/1006691/how-to-check-if-a-win32-thread-is-running-or-in-suspended-state">This question</a> got me thinking about the .NET equivalent. What value is there to the ThreadState property of the Thread class? In this code example:</p> <pr...
<p>ThreadState is one of those fantastic properties that look promising at first, but once you dive deep into the way in which in functions, you find that it's almost totally useless. </p> <p>The main problem with ThreadState is the enumeration names are very misleading. For instance take ThreadState.Runnning. This ...
Handling massive in memory objects in .NET <p>hey guys, here's the issue,</p> <p>Essentially, I have a very large List containing in turn relatively large Dictionaries</p> <p>So basically, I have a very big in memory collection.</p> <p>I then serialize this collection manually to XML, and send it over http. needless...
<p>Why don't you just stream the data so you just convert to XML on the fly avoiding having a huge XML file in memory?</p>
Python - Get original function arguments in decorator <p>I am trying to write a "login_required" decorator for the views in a WSGI+Werkzeug application.</p> <p>In order to do this, I need to get at the user's session, which is accessible via the Request object that is passed into the view methods.</p> <p>I can't figu...
<p>The decorator <code>login_required</code> is passed the function (<code>hello</code> in this case).</p> <p>So what you want to do is:</p> <pre><code>def login_required(f): # This function is what we "replace" hello with def wrapper(*args, **kw): args[0].client_session['test'] = True logged_in = 0 ...
Java, XSLT: How to handle the dynamic namespaces generated by Axis in XSLT <p>I have an application that calls a web service (axis based) to get a response in the following format: </p> <pre> &lt;?xml version="1.0"?> &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> &lt;soapenv:Body> ...
<p>Is the <em>namespace</em> dynamic, or the namespace <strong><em>prefix</em></strong> dynamic?</p> <p>The actual namespace for the XML is <strong><code>urn:myco:com:mapping:service:3.0</code></strong></p> <p>So, an example stylesheet to transform the results doesn't need to know what the namespace <em>prefix</em> i...
Maximum number of groups in Java Regex <p>I had assumed the maximum was 9 but after some experimentation I know it is not. The javadocs for <a href="http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html" rel="nofollow">Pattern</a> and <a href="http://java.sun.com/javase/6/docs/api/java/util/regex/Matcher...
<p>There's no explicit ceiling, so theoretically the max would be Integer.MAX_VALUE. Practically speaking, the max will vary according the resources available, but I'm sure it's a lot more than you'll ever need.</p>
Search website page content in VB.NET - 3rd party tools? Code Examples? <p>I am hoping to implement search in my asp.net website. I have been searching the web, but I am not sure which way to go. Here is what I am looking for:</p> <ul> <li>ability to search the text in static pages on my site</li> <li>exclude pages or...
<p>Hmmm...if you want quick, you should probably go with google integration. </p> <p>My preferred search engine that you can implement custom is Lucene.NET, however. There should be plenty of examples out there and the documentation is quite good. Depending on your skill level, you may be able to get it in place quick...
SSL not verified in IE <p>I have a SSL cert that verifies fine in all browsers but IE, and I have no idea why.</p>
<p>If the certificate is a wildcard cert, note that IE only allows "*" to represent one DNS label (e.g. no dots in it).</p> <p>However, as others have noted, the only way to get a real answer is to provide the URL of the site so we can take a look.</p>
In HTML5, can you save an image to cache programmatically? <p>I love that in HTML5 you can save text data out to a local database, and can even use SQL to do it. (<a href="http://webkit.org/blog/126/webkit-does-html5-client-side-database-storage/">http://webkit.org/blog/126/webkit-does-html5-client-side-database-storag...
<p>Look at the application cache in html5, that does basically exactly what you want (it's also what you want to use if you want to support completely offline web applications).</p> <p>Alternatively you could (somewhat ugly)daw the image to canvas, then to canvas.toDataURL() to get a data url for the image, which you ...
RegEx - Matching a set of words <p>I've been on this one for a while and can't seem to work it out. Here's what I am trying to do. Given three words word1, word2 and word3, I would like to construct a regex which will match them in that order, but with a set of potential words between them (except a new line).</p> <...
<p><code>"\bwhat(\s*\b\w*\b\s*){0,5}the(\s*\b\w*\b\s*){0,5}hell"</code> works for me (in Ruby)</p> <pre><code>list = ["what the hell", "what in the hell", "what the effing hell", "what in the 9 doors of hell", "no match here hell", "what match here hell"] list.map{|i| /\bwhat(\s*\b\w*\b\s*){0,5}the(\s*\b\w*\b\s*){...
C comparison char and int <p>In the code block below what's the impicit conversion that takes place in the if statement for 7? I would have though it would end up being (0x98 &lt;= 0x07) but that's not what happens as the condition evaluates to true and DoMyStuff gets called.</p> <pre><code>char minstogo = 0x98; if(mi...
<p>Whenever you have a binary operator (one of <code>+</code> <code>-</code> <code>*</code> <code>/</code> <code>%</code> <code>&lt;&lt;</code> <code>&gt;&gt;</code> <code>&amp;</code> <code>|</code> <code>^</code> <code>==</code> <code>!=</code> <code>&lt;</code> <code>&lt;=</code> <code>&gt;</code> <code>&gt;=</code>...
How do I launch a process with low priority? C# <p>I want to execute a cmd line tool to process data. It does not need to be blocking. I want it to be low priority. So I wrote the below</p> <pre><code> Process app = new Process(); app.StartInfo.FileName = @"bin\convert.exe"; app.StartInfo.Arguments = TheArgs; app....
<p>Try setting the PriorityClass AFTER you start the process. Task Manager works this way, allowing you to set priority on a process that is already running.</p>
Is checking mousemove a good way to determine whether or not to download assets? <p>So I've got a web app that is for all intents and purposes a photo viewer. </p> <p>When a thumbnail is clicked, the app </p> <ol> <li>requests the image asset,</li> <li>injects it into the DOM as an IMG tag</li> <li>and disposes the ...
<p>To answer your question directly, I don't think there will be an issue except that checking for mouse movement will have a degree of performance overhead. I would measure the performance on a slow machine, once you are done, to see if this is a problem.</p>
What namespace has JObject in json.net? <p>What namespace has JObject in json.net?</p> <p>Just installed int and can't seem to find that class?</p>
<p><a href="http://james.newtonking.com/projects/json/help/html/T%5FNewtonsoft%5FJson%5FLinq%5FJObject.htm">JObject Class > Namespaces > Newtonsoft.Json.Linq > JObject</a> </p>
why does resharper default to warning if you don't declare using var? <p>why does resharper default to warning if you don't declare using var?</p> <p>I don't see the point?</p>
<p><a href="http://resharper.blogspot.com/2007/08/resharper-vs-c-30-implicitly-typed.html">Straight</a> from the PM's mouth. More <a href="http://resharper.blogspot.com/2008/03/varification-using-implicitly-typed.html">here</a>.</p>
Javascript packing problem <p>I have a minified/packed javascript file which is causing problems. The issue is that the non-packed input file has some missing semicolons <em>somewhere</em> which aren't a problem when there's line breaks, but when the file is packed, the line breaks are removed and that causes a parser ...
<p>Uh... Have you tried <a href="http://www.jslint.com/lint.html" rel="nofollow">JSLint</a>?</p>
can you use multiple threads to ptrace an application? <p>I am writing a GUI oriented debugger which targets Linux primarily, but I plan ports to other OSes in the future. Because the GUI must stay interactive at all times, I have a few threads handling different things.</p> <p>Primarily I have a "debug event" thread ...
<p>I had the same issue (plus many others!) while implementing the Linux-specific part of the <a href="http://wikis.sun.com/display/MaxineVM/Inspector">Maxine VM debugger</a>. You are correct in your guess that only one thread in the debugger can use ptrace to control the debuggee. We accomplish this by making all call...
Ajax back button with dynamic content <p>I've created a page using JQuery and Ajax that helps a user filter through a series of options and ultimately displays a filtered list of products meeting their specification.</p> <p>This all works fine.</p> <p>The problem i'm having is the "Back Button" problem with Ajax, i k...
<p>Every time you want to be able to go back to the previous step, change window.location.hash.</p> <p>Ie.</p> <pre><code>window.location.hash = 'step1'; </code></pre> <p>This changes the #foo part in the URL. You will also need a timer in JavaScript which checks if the hash was changed, as there is no way to reliab...
I'd like to port simple C++ echo server to C# <pre><code>SOCKET client = accept(listen_sock, 0, 0); timeval client_to; client_to.tv_sec = 1; client_to.tv_usec = 0; setsockopt(client, SOL_SOCKET, SO_RCVTIMEO, (char*)&amp;client_to, sizeof(client_to)); char buffer[1024]; while ((ret = recv(client, buffer, 1024,...
<p>Check out <strong><a href="http://www.kodart.com/download/" rel="nofollow">XF.Server</a></strong> socket library by <strong><a href="http://www.kodart.com/" rel="nofollow">kodart</a></strong> for .net. When you download the library it comes with an echo server as example implementation of Xf.Server library. This wil...
Managing multiple configuration files in Visual Studio for a C# project <p>I have learned that builds should be very straight forward and requires less human intervention. In my situation, I have 3 environments, DEV (development version), SIT (STG integration testing) and UAT (user acceptance testing). All these enviro...
<p>2 -- You're absolutely right -- you should attempt to automate your build and deployment process as much as possible. Your best bet is to set up an automated build / deploy script using something like <a href="http://nant.sourceforge.net/" rel="nofollow">NAnt</a>. Your script can have targets for each of your envi...
What would you do if you just had this code dumped in your lap? <p>Man, I just had this project given to me - expand on this they say.</p> <p>This is an example of ONE function:</p> <pre><code>&lt;?php //500+ lines of pure wonder. function page_content_vc($content) { global $_DBH, $_TPL, $_SET; $_SET['ignoreT...
<p>Global search and replace are your friends. </p> <p>Start by:</p> <ol> <li>Breaking the huge "if ... else" into individual functions which you can rename later once you figure out what they do.</li> <li>Do global search/replace on the $_GET[...] and $_SESSION['dash'] variables to give them more meaningful names</l...
Why am I getting an error in CakePHP that my view is not found? <p>I am using cakephp for form designing application.</p> <p>In my code</p> <pre><code>&lt;?php echo $html-&gt;link('Delete', array('action' =&gt; 'deleteForm', 'id' =&gt; $r['Form']['id']), null, 'Are you sure?' )?&gt; </code></pre> <p>In my controller...
<p>This is your second very basic question about PHP and CakePHP, might I suggest you to read the respective documentation?</p> <ul> <li><a href="http://www.php.net/manual/" rel="nofollow">PHP Documentation</a></li> <li><a href="http://book.cakephp.org/" rel="nofollow">CakePHP Documentation</a></li> </ul> <p>And just...
How to test an ajax submition in ASP.NET MVC? <p>Specifically, how can I pass the static method Request.IsAjaxRequest()? </p> <p>I get the exception 'System.ArgumentNullException' when I try to test the following code:</p> <pre><code>if (Request.IsAjaxRequest()) { return Json(data); } return View(data2); </code></p...
<p>You need mocking Request and Request.Headers to work with Request.IsAjaxRequest():</p> <pre><code>var request = new Mock&lt;HttpRequestBase&gt;(); request.SetupGet(x =&gt; x.Headers).Returns(new System.Net.WebHeaderCollection { {"X-Requested-With", "XMLHttpRequest"} }); var context = new Mock&lt;HttpContextBas...
CSS Framework - off the shelf or homegrown? <p>Is there an existing framework that satisfies the needs of your projects with minor modifications, or have you developed your own along the way? What do you recommend for someone trying to make that decision with these priorities:</p> <ol> <li>CSS reset</li> <li>Attention...
<p>No framework out there is going to do everything you want. </p> <p>But <a href="http://code.google.com/p/blueprintcss/" rel="nofollow">Blueprint</a> should have enough to get you started. </p>
How does ebook to exe application compile to self-contained executable? <p>I am trying to understand how various ebook applications compile their output into a self-contained executable file with no dependencies when you run the exe. How can it be done? Do they use real embedded compiler? </p>
<p>The ebook application probably creates an application with an integrated web browser. The application will be pre-compiled and the only thing missing will be the html content. This will be added as a resource. A full compiler isn't necessary. All is needed is to add the resources to an existing executable.</p> <p>S...
PHP Class error <p>I am getting the following error:</p> <p>Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}'</p> <p>The referenced lines are:</p> <pre><code>class Food { private $q = array(); private $nutrients = array(); ... </code></pre> <p>How can I fix ...
<p>you can only use "private" in a php 5 environment. It looks like you're running that in PHP 4.</p>
NSUnknownKeyException, KVC compliance code not working <p>the following piece of code which gets successfully built and also seems alright to me but doesn't work... mind that i am new to key value coding and your help will be greatly appreciated... in table view delegate didSelectRowAtIndexPath: method here the catego...
<p>[rootDict allKeys]; //this is an array of NSStrings, NOT Array of NSDictionarys</p> <p>This code can't work</p> <pre><code>NSArray *allRootKeys = [rootDict allKeys]; NSDictionary *newDict = [allRootKeys objectAtIndex:index]; </code></pre>
Database Records - Effective Start and End Dates and Foreign Keys <p>Does anyone have any experience having worked with datasets where records become valid and invalid based on an effective start and end date? The issue is when records in these tables have foreign keys to other tables that also have effective start and...
<p>The approach we're using for such problems is to not hold the ownership of the elements in the same table but in a mapping table which includes the timelines.</p> <pre><code>Table DOGS - ID - NAME Table OWNER - ID - NAME Table LOCATION - ID - HOUSE_NAME Table DOGS_OWNERSHIP: - DOG_ID (FK-&gt;DOGS.ID) - O...
GMail SMTP to send mail, receiving error (4.7.0), but mail is sent! <p>I am using GMail SMTP server to send mails. And PHPMailer as the mail sending script.</p> <p>I have received this error (I log all SMTP errors, that is whenever, PHPMailer::Send fails): -</p> <pre><code>SMTP Error: Data not accepted.&lt;p&gt;SMTP ...
<p>I think that SMTP does not guarantee delivery anyway. It is a store-and-forward mechanism. That is why some emails can go missing (for e.g. if a relay crashed while in the midst of relaying the message). </p> <p>If you are depending on email for important functions, you may want to enforce some sort of feed-back me...
IIS 6 compression on Urlrewritten pages doesn't work <p>I'm developing a asp.net site (running .net 3.5 SP 1) and using UrlRewriter.Net (<a href="http://urlrewriter.net/" rel="nofollow">http://urlrewriter.net/</a>) for urlrewriting.</p> <p>The site is hostet on a Windows 2003 server with all servicepacks and so forth....
<p>Probably because of the wildcard, IIS sends the request to ASP.NET, which further handles page generation etc. The compression happens to late in the pipeline, so it gets bypassed...</p>
Customize Oracle AWR report <p>Oracle creates nicely HTML-formatted workload reports (AWR) that list things like instance statistics, wait events, the top ten heavy SQL statements (by number of executions, number of disk reads, and so on).</p> <p>Are there (easy) ways to customize this report?</p> <p>For example, I w...
<p>See the awr*.sql files in $ORACLE_HOME/rdbms/admin - they are the files that produce the reports. I've copied these files and tweaked them to alter the reports for my own use.</p> <p>[Edit]</p> <p>It occurred to me after my original answer that you might have only been interested in modifying the top-N parameter ...
Prototype vs JQuery <blockquote> <p><strong>Possible Duplicate:</strong><br /> <a href="http://stackoverflow.com/questions/394601/which-javascript-framework-jquery-vs-dojo-vs">Which Javascript framework (jQuery vs Dojo vs &hellip; )?</a> </p> </blockquote> <p>What is the best? I mean: what I need is simple AJAX f...
<p>Neither is the "best". It's all preference. Try them both and see which one you like more.</p> <p>That said, I find jQuery much easier to use for simple things like you mention. Prototype is more "advanced", so to speak, and takes longer to master (and you will probably never use 90% of it).</p>
How to sort two arraylists according to their size into a new arraylist <p>I have two objects each with an id and a list.I would like to have a third arraylist sorting this object according to the list size.and still have the correaponding id along with the list</p>
<p>Here's the approach:</p> <ol> <li><p>Create a <a href="http://java.sun.com/javase/6/docs/api/java/util/Comparator.html" rel="nofollow"><code>Comparator</code></a> which can compare two of the "id/list pairs" -- in this case, we compare the list sizes of the list component.</p></li> <li><p>Create an <a href="http://...
How To Create a SQL Index to Improve ORDER BY performance <p>I have some SQL similar to the following, which joins four tables and then orders the results by the "status" column of the first:</p> <pre><code>SELECT * FROM a, b, c, d WHERE b.aid=a.id AND c.id=a.cid AND a.did=d.id AND a.did='XXX' ORDER BY a.status <...
<p>I would say it's slow because the engine is doing scans all over the place instead of seeks. Did you mean to do SELECT a.* instead? That would be faster as well, SELECT * here is equivalent to a.*, b.*, c.*, d.*.</p> <p>You will probably get better results if you put a separate index on each of these columns:</p> ...
Regular expression to transform 1.2.3 to 1.02.03 <p>i'm really not good with regular expressions and i need one to transform "1.2.3" to "1.02.03" in a way that first part stays always as it was and second and third one will transform 2 to 02, 7 to 07 and so on but if there is 10, 15, 17 and so on it will leave it as i...
<pre><code>/\.(\d)(?=\D|$)/g =&gt; .0$1 </code></pre> <p>Works with any number of dots :)</p> <p><strong>Edit:</strong> when look-ahead isn't supported but word boundaries are, you can use</p> <pre><code>/\.(\d)\b/g =&gt; .0$1 </code></pre> <p>... or just because it's simpler :)</p>
What makes Ruby slow? <p>Ruby is slow at certain things. But what parts of it are the most problematic?</p> <p>How much does the garbage collector affect performance? I know I've had times when running the garbage collector alone took several seconds, especially when working with OpenGL libraries.</p> <p>I've used ...
<blockquote> <p>Ruby is slow. But what parts of it are the most problematic?</p> </blockquote> <p>It does "late lookup" for methods, to allow for flexibility. This slows it down quite a bit. It also has to remember variable names per context to allow for eval, so its frames and method calls are slower. Also it la...
Inheriting For Multiple Shapes - ASP.NET MVC <p>I'm returning multiple shapes to a page and am using a ViewData class that I've created. The namespace of this class is:</p> <pre><code>namespace IntranetMvcAreas.Areas.Accounts.Views.ContractsControl.ViewData </code></pre> <p>which I'm not sure it correct. In the pag...
<p>Firstly you shouldn't have to fully qualify your namespace so the below will be ok.</p> <pre><code>Inherits="System.Web.Mvc.ViewPage&lt;ContractsViewData&gt;" </code></pre> <p>You will then need to import that namespace for the ViewModel to be accessible on the ViewData.Model property within the view.</p> <p>I te...
Automated FTP <p>I need to set up some sort of infrastructure to automatically FTP some files from one remote server to another. The FTP transaction will occur on a scheduled basis. Both these server are windows boxes and the location of the files that need to be FTP'ed will depend on the current date (the folder they ...
<p>Windows Command Line <code>ftp</code> will read input from a text file. For example:</p> <pre><code>ftp -ni &lt; ftpscript.txt </code></pre> <p>Where these options are used:</p> <ul> <li><code>-n</code> - Suppresses auto-login upon initial connection.</li> <li><code>-i</code> - Turns off interactive prompting du...
Windows Folder Share API <p>is there a WIN32 API available to manage folder sharing in Windows? Some links to examples will be helpful. Thanks.</p>
<p>Yes, since Windows 2000 Professional there's a networking API available in netapi32.dll which provides this functionality. Functions like NetShareAdd, NetShareCheck, NetShareDel let you manage the shared files. See</p> <p><a href="http://msdn.microsoft.com/en-us/library/bb525393(VS.85).aspx" rel="nofollow">http://m...
Suppress backspace, delete keys in MaskedTextbox <p>The question is simple: how to do it? I've a couple of MaskedTextboxes which are filled by some indirect user actions (so not by typing in values directly). The text within the textboxes is colored red when the input is being rejected by the mask. Fine so far.</p> <p...
<p>I think it's a good idea to set the <code>MaskedTextBox</code>'s <code>ReadOnly</code> property to <code>true</code>. But instead of handling the <code>MaskInputRejected</code> event, you should use the <code>TypeValidationCompleted</code> event like this:</p> <pre><code>private void maskedTextBox1_TypeValidationCo...