input
stringlengths
51
42.3k
output
stringlengths
18
55k
How to get CPU usage? <p>How do I get the cpu usage percentage to display in the label on a form?</p>
<pre><code>Import Namespace System.Diagnostics ' ... Dim cpu as New PerformanceCounter() With cpu .CategoryName = "Processor" .CounterName = "% Processor Time" .InstanceName = "_Total" End With ' ... myLabel.Text = cpu.NextValue() </code></pre>
How can i remove this console from my page? <p>Am testing my webpage on firefox and everything is looking fine, but when i run my page on IE or chrome a section with</p> <p><strong>Clear ReCSS console DOM Object Close</strong> </p> <p>What is it and how can i remove it?</p>
<p>This one had me going also for a while. If you are utilising the DOJO framework then you need to turn Debug=false as this is the firebug-lite console that is shipped with it! If not it is still the Firebug-lite console. Firebug-lite will not show on Firefox as it has the full Firebug hence why it shows up on other b...
round number to nearest 0.2 with PHP <p>I'm creating this rating system using 5-edged stars. And I want the heading to include the average rating. So I've created stars showing 1/5ths. Using "1.2" I'll get a full star and one point on the next star and so on...</p> <p>But I haven't found a good way to round up to the ...
<pre><code>round(3.78 * 5) / 5 = 3.8 </code></pre>
python method to extract content (excluding navigation) from an HTML page <p>Of course an HTML page can be parsed using any number of python parsers, but I'm surprised that there don't seem to be any public parsing scripts to extract meaningful content (excluding sidebars, navigation, etc.) from a given HTML doc. </p> ...
<p>Try the <a href="http://www.crummy.com/software/BeautifulSoup/">Beautiful Soup</a> library for Python. It has very simple methods to extract information from an html file.</p> <p>Trying to generically extract data from webpages would require people to write their pages in a similar way... but there's an almost infi...
API assembly <p>In my VB6.0 days I used tons of windows API. So I got the idea that all the API methods that I declared are pretty much procedure based - or it has a procedure based entry point.</p> <p>My question :</p> <p>I have written some code in C# which I need to access from VB6.0. Is it possible to compile my ...
<p>No, you can't expose the entry points to your C# DLL as Win32-style APIs. If you really, really need to create procedural entry points for a .NET library, probably the best thing to do is create a mixed-mode wrapper library using C++/CLI. But this seems like hard work: exposing your C# classes as COM objects is li...
Are there known false positives issues with Valgrind? <p>Are there any known false positives with Valgrind? I get a 'Conditional jump or move depends on uninitialised value(s)' with the <code>fmemopen</code> function, writing in C and compiling with GCC. Can I be sure it's real?</p> <p>EDIT: Are there known issues tha...
<p>Yes, there are false positives with Valgrind, that's why it has suppression files for particular glibc and gcc versions, for example. The false positives may arise if you are using older valgrind with newer gcc and glibc, i.e., valgrind 3.3 with glibc 2.9.</p> <p>Having said that, you still have to look into issue ...
How to use vs2005 libraries in vs2003 <p>Hi is there is any way to use VS2005 libraries in VS2003.Can any one help me how to use vs2005 libraries in vs2003</p>
<p>No, you cannot use .NET 2.0 assemblies (I assume we're talking .NET here) in .NET 1.x apps unless you recompile these to target 1.x version of the Framework.</p>
Dynamic LINQ to Entity Count() <p>I'm trying to write the following short line of code in a more generic way.</p> <p>What I want to achieve is a simple count of records, that have changed or were created since a certain date.</p> <pre><code> public int GetChanges(DateTime LastActivityDate) { KHS.Innopa...
<p>You might be able to pull this off using the dynamic linq query library. It allows you to pass clauses as strings. Example: <img src="http://www.scottgu.com/blogposts/dynquery/step2.png" alt="alt text" /></p> <p>More information can be found on <a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq...
IoC and dynamic objects <p>I'm having trouble figuring out how to resolve objects that depend on objects that are non deterministically created at runtime. What is the best approach?</p> <p>Imagine something like a word processor. For each document you open, you probably want to create a large number of objects that d...
<p>In autofac there is approach called <a href="http://code.google.com/p/autofac/wiki/DelegateFactories" rel="nofollow">DelegateFactories</a>. It is a bit similar to your first option however removes the huge amounts of hand coding.</p>
Creating an Infragistics Edit Template using code <p>We currently use Infragistics grid and we don't bind our datasets until run time, and then setup the grid settings in code. This seems a bit long winded, but its the way our senior developer wants it done.</p> <p>I would like to look into using the edit template an...
<p>There's a tutorial on building templates in code that you can follow. It's in the Infragistics documentation under the Using WebDataGrid section. Here's the link <a href="http://help.infragistics.com/Help/NetAdvantage/ASPNET/2009.1/CLR3.5/html/WebDataGrid_Using_the_Template_Collection.html" rel="nofollow">http://h...
Icon of project in Visual Studio <p>I want certain projects in my solution opened in Visual Studio have different icons..Just like how Visual Studio displays different icons for class project, web site project etc</p> <blockquote> <p>I am not talking about changing the icon of the winforms or other such app being pr...
<p>If you look in your SLN file, the project has a guid assigned to it.</p> <p>all the c# projects have</p> <pre><code>Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") </code></pre> <p>and all the build folders have ..</p> <pre><code>Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") </code></pre> <p>These define ...
Adding an anchor to generated URLs <p>I have tried finding a simialr example and using that to answer my problem, but I can't seem to get it to work, so apologies if this sounds similar to other problems.</p> <p>Basically, I am using Terminal Four's Site Manager CMS system to build my websites. This tool allows you to...
<p>sort of duplicate of this: <a href="http://stackoverflow.com/questions/179713/how-to-change-the-href-for-a-hyperlink-using-jquery">http://stackoverflow.com/questions/179713/how-to-change-the-href-for-a-hyperlink-using-jquery</a></p> <p>just copy the old href and add anchor to it and paste that back</p> <pre><code>...
What's the best way to write Mathematical Equations on the Web? <p>I am working on a Math related web page and am looking for a solution to writing Mathematical equations easily onto a web page. There are several solutions readily available to me at the moment:</p> <ul> <li>Use LaTeX and publish them on my web page as...
<p>The <strong>jsMath</strong> package is an option that uses LaTeX markup and native fonts. Quoting from their webpage <a href="http://www.math.union.edu/~dpvc/jsMath/">http://www.math.union.edu/~dpvc/jsMath/</a>:</p> <blockquote> <p>The jsMath package provides a method of including mathematics in HTML pages th...
Synchronous calculation-heavy method call that doesn't prevent redrawing <p>Newbie C#/.NET threading question here:</p> <p>Is it possible to have a synchronous (if that's the right term) method that doesn't return until it has finished some calculation but at the same time doesn't prevent the app from getting redrawn ...
<p>I assume that you want to block any user input while your calculation method is being executed. If so, this can be done with <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx" rel="nofollow">BackgroundWorker</a> class. Set <code>Enabled</code> property of your form to <code...
How to retrieve available branches from a Bitbucket repository? <p>It is possible to retrieve the local branches from a local repository with <code>hg branches</code>. Is it possible to do this also with a remote repository programatically?</p>
<p>Unfortunately, there is no way to determine the branches in a remote Mercurial repository without pulling in the repository. You can avoid saving data on disk, by getting the information you desire by using <code>hg incoming</code>, but that command works by pulling the entire repository data anyway--likely not wha...
for AJAX implementation : please suggest <p>which one should use i have following options available</p> <ol> <li><p>ASP.NET ajax with its ajax control toolkit controls</p></li> <li><p>ASP.NET ajax with jQuery</p></li> <li><p>Ajax Pro <a href="http://www.ajaxpro.info/" rel="nofollow">http://www.ajaxpro.info/</a></p...
<p>A month ago I would have chosen Ajax Control toolkit but after spending time behind the scenes with JQuery it will have my personal vote. Especially if using MVC, however I am having great success refactoring a older Ajax websites developed in Framework 2.0.</p> <p>JQuery offers a lot more then the Ajax control to...
Importing HTML in Word 2003 using C# <p>I am trying to export the web page content into Word. In word 2007 the datas are displaying in correct format. But in case of word 2003 the display format is not correct. What is the reason for this? What should I have to do to rectify this?</p> <p>I am displaying a textbox and ...
<ul> <li><strong>This is my .CS code</strong></li> </ul> <p>using System;</p> <p>using System.Data;</p> <p>using System.Configuration;</p> <p>using System.Collections;</p> <p>using System.Web;</p> <p>using System.Web.Security;</p> <p>using System.Web.UI;</p> <p>using System.Web.UI.WebControls;</p> <p>using Sys...
HowTo: Teamcity + GitHub <p>Has anybody successfully configured Teamcity to monitor, extract, and build from GitHub?</p> <p>I can't seem to figure how where and how to configure the SSH keys for Teamcity. I have Teamcity running as a system service, under a system account. So where does Teamcity stash its SSH config...
<p>Ok... I got this to start working on my Windows server. Here are the steps I took to configure <a href="http://www.jetbrains.com/teamcity/">TeamCity 4.5 Professional</a>:</p> <ol> <li>Downloaded the <a href="http://www.jetbrains.net/confluence/display/TW/Git">JetBrains Git VCS Plugin</a></li> <li>Copied the downl...
How many modules are there in Spring? What are they? <p>just i want to know How many modules are there in Spring? What are they?</p>
<p>What do you mean by modules? This is the <a href="http://www.springsource.org/projects/" rel="nofollow">list</a> of projects in SpringSource. The main Spring Framework has many <a href="http://www.springsource.org/about" rel="nofollow">features</a>, which are independent to each other.</p>
Conversion: uid_t to string, off_t to string <p>I am currently writing a systems programming homework and in one part i need to get some information of a file in a directory.</p> <p>for the stat of file, we have <code>ctime()</code> function which converts <code>time_t</code> type to <code>string</code> and returns a ...
<p>Both are defined as arithmetic types (<a href="http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/types.h.html" rel="nofollow">http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/types.h.html</a>), and in practice are positive and integral. So you can just cast to unsigned long long, and use sprintf ...
File uploading in AJAX updatepanel without full postback <p>I have a update panel, in the update panel I have fileupload control and button control, On button click, I need the file that I have upload in the fileupload control in updatepanel. </p> <p>Exact scenario, I have 8 tabs on page, each tab contains too much in...
<p>For solve this problem, Please see the following step.</p> <ol> <li><strong>Add ajax-upload to your detail view.</strong> <ul> <li><em>iframe-based uploader</em> like Resource#1.</li> <li><em>Silverlight-based &amp; Flash-based uploader.</em> I like this technique because it doesn't require any server-side script f...
Duration vbscript (vbs) function <p>Is there a function to convert a specified number of seconds into a week/day/hour/minute/second time format in vbscript?</p> <p>eg: 969234 seconds = 1wk 4days 5hrs 13mins 54secs</p>
<pre><code>Dim myDate dim noWeeks dim noDays dim tempWeeks dim pos myDate = DateAdd("s",969234,CDate(0)) tempWeeks = FormatNumber(myDate / 7,10) pos = instr(tempWeeks, ".") if pos &gt; 1 then tempWeeks = left(myDate, pos -1) end if noWeeks = Cint(tempWeeks) noDays = Cint(((myDate / 7) - noWeeks) * 7) wscript.ec...
Custom dropdown box using javascript? <p>Can we write custom dropdown box using javascript,html,css. and also placing backgroung-image for that.</p> <p>any sample example</p>
<p>yes you can. with <strong>css</strong> it goes like this. </p> <p>add couple of class to your css page, like this:</p> <pre><code>.cmdUnbelievable { width:200px; font-family:Trebuchet MS; background-color:#0b5925; color:#d4d5d4; border:dashed 2px #f2f2f2; } .cmdUnbelievable option { color:...
Qt4 existing slots are not recognized <p>I am currently trying to complete a project using Qt4 and C++. I am using buttons to switch between states. While trying to connect the buttons' clicked() signals to the textEdit to display the relevant state, I got stuck on an error:</p> <blockquote> <p>Object::connect No su...
<p>You can't pass in an argument (literally) to the append() slot when making a signal to slot connection.</p> <p>You refer to it like a method signature:</p> <pre><code>SLOT(append(QString)) //or const QString, I'm not sure </code></pre> <p>If you need the textbox to append the words "move state" every time that bu...
How are objects in an autorelease pool referenced? <p>I am wondering if the autorelease pool holds strong or weak references to the objects it holds. I would guess they are weak. When I add an object to an autorelease pool, it's just not immediately released but will be released when the pool is drained, right? So the ...
<p>Talking of strong versus weak references makes sense in the context of a garbage collected memory management environment (where weak pointers are automatically released and cleared even if referenced). With GC enabled, all retain/release/autorelease calls are essentially do nothing operations (though the NSAutorelea...
I get this error when I try to access file from iis of another system <p>You do not have permission to view this directory or page using the credentials you supplied.</p>
<p>It looks like you are trying to access files over network by IIS, however to do that, in network share you will need to add IUSER_ , IWAM_ or ASPNET user permissions as well.</p>
How to Include Variable inside Class in php <p>i have some file test.php</p> <pre><code>&lt;?PHP $config_key_security = "test"; ?&gt; </code></pre> <p>and i have some class</p> <p>test5.php</p> <pre><code> include test.php class test1 { function test2 { echo $config_key...
<pre><code> class test1 { function test2 { global $config_key_security; echo $config_key_security; } } </code></pre> <p>or</p> <pre><code> class test1 { function test2 { echo $GLOBALS['config_key_security']; } } </code>...
How do I determine which are the foreground .NET threads from WinDBG? <p>How do I determine which are the foreground .NET threads from WinDBG ? Using the !threads command the SOS extenstion tells us the count of the foreground threads but not which ones.</p>
<p>The state flag in the <code>!threads</code> output holds a lot of information. If the <code>0x00000200</code> flag is set the thread is a background thread. </p> <p>In SOS for .NET 4 and PSSCOR2, there's a <code>!threadstate</code> command, that will list the texts for a given flag value. If you don't have that, th...
How can i solve this error:"Column 'ASSET' does not belong to table ."? <p>How can i solve this error:"Column 'ASSET' does not belong to table ." ? i really learn it is belong this table: i want to do that: <br></p> <p>if(mydataset.hasgot(dr["asset"].tostring())) <br> {<br> // do something<br> }<br></p> <pre><code>...
<p><code>dr_["ASSET"].ToString()</code> returns a string representation of whatever happens to be in the DataRow <code>dr_</code> in column named "ASSET", which is obviously not what you need. Therefore, here's the correct one:</p> <pre><code>if(ds.Tables[0].Columns.Contains("ASSET")) </code></pre>
How to build a new VS2008 WPF solution/project when you've lost the .sln and .csproj files? <p>I have an old VS2008 solution that had one project in it.</p> <p>When I double-click on the .sln file it says that nothing can be found (<strong>I had renamed some directories</strong>).</p> <p>So now what is the best way t...
<p>Create a new solution and add everything.</p> <p>In short: do it manually.</p>
How to access to the elements properties inside a Repeater? <p><br /> I have a <em>Repeater</em> control who has its dataSource setted with a typed object list and in the inline code I want to access to its elements properties inside the <em>ItemTemplate</em> tag. I tried this with the eval expression but it does not w...
<p>You can use: <code>&lt;%# DataBinder.Eval(Container.DataItem, "field name") %&gt;</code></p>
C# - is it possible to mark overriden method as final <p>In C#, is it possible to mark an overridden virtual method as final so implementers cannot override it? How would I do it?</p> <p>An example may make it easier to understand:</p> <pre><code>class A { abstract void DoAction(); } class B : A { override void...
<p>Yes, with "sealed":</p> <pre><code>class A { abstract void DoAction(); } class B : A { sealed override void DoAction() { // Implements action in a way that it doesn't make // sense for children to override, e.g. by setting private state // later operations depend on } } class C: B...
Padding issues with a WPF ListBox <p>In my application, I defined a DataTemplate for a <code>ListBox</code> to be a grid with a stretched border, and with a label inside it. For some reason, I've got the following result:</p> <p><img src="http://dl.getdropbox.com/u/829214/q1.gif" alt="alt text"></p> <p>As you can see...
<p>I can't see the image because of a proxy issue, but I think you just need to set the background of the container:</p> <pre><code>&lt;ListBox&gt; &lt;ListBox.ItemContainerStyle&gt; &lt;Setter Property="Background" Value="White"/&gt; &lt;/ListBox.ItemContainerStyle&gt; &lt;/ListBox&gt; </code></pre> ...
Zend_Search_Lucene crashes during indexing <p>I wanted to create search engine for my webpage, but during indexing on server it crashes with errors : </p> <pre><code>Warning: opendir(/admin/lucene/) [function.opendir]: failed to open dir: Too many open files in /admin/includes/Zend/Search/Lucene/Storage/Directory/...
<p>It seems the problem is in the large number of segments in the index.</p> <p>Could you check how much files does index folder contain?</p> <p>There are two ways to solve this problem: a) Optimize index more often. b) Use another MaxBufferedDocs/MergeFactor parameters. See <a href="http://framework.zend.com/manual/...
EntityFramework ObjectQuery<T>.Include With Filter ability <p>I'm using ObjectQuery.CreateQuery() to create eSQL query. I want to use the ObjcetQuery.Include to load related data, like Customer => Orders so let the EF to load all the orders for customer at the same time. The issue is that i don't want all the related o...
<p>Include will not work if you intend to materialize a master entity (Customer) with only some of the related child entities (Orders). The Entity Framework will not materialize a partially-complete type. Instead, I would recommend projecting into a new, anonymous type. Then you can include whichever Orders you like.</...
SQL Server- ORDER BY CASE <p>I have the following the query running dynamically</p> <pre><code>SELECT * FROM Vehicles WHERE (DKID IN (69954)) ORDER BY case when ImageName1 = 'na' then 0 else 1 end, Make , Model, Year DESC </code></pre> <p>This is returning the following error: </p> <blockquote> <p>Error Executing ...
<p>are you running this query dynamically?, if so you might need to escape the quotes around 'na':</p> <pre><code>SELECT * FROM Vehicles WHERE (DKID IN (69954)) ORDER BY case when ImageName1 = ''na'' then 0 else 1 end, Make , Model, Year DESC </code></pre>
How to convert C# code to object code? <p>Hai guys, Can any help me how to convert c# code to compiler code or object code</p>
<p>If you mean MSIL (.NET bytecode) the easiest way to convert C# into that is to... compile it? Pressing build in Visual Studio ought to work. It might be better if the question was a little clearer.</p>
Is this the best way in C# to convert a delimited string to an int array? <p>Given the string below:</p> <pre><code>string str = "1,2,3"; </code></pre> <p>Will this be the best extension to convert it to an <code>int</code> array?</p> <pre><code>static class StringExtensions { public static int[] ToIntArray(this...
<p>It really depends what you want to do with the non-integer strings. At the moment you silently drop them. Personally, I'd want it to error. This also lets you use the more terse:</p> <pre><code>public static int[] ToIntArray(this string value, char separator) { return Array.ConvertAll(value.Split(separator), s=...
How do I customize all the names of the child threads of a ThreadFactory in Java? <p>If I am extending an existing ThreadFactory implementation, how would I go able ensuring that all threads created would have the same prefix? I'm sick and tired of looking at <code>Thread-9</code> in my logs and would like to distingui...
<p>Provide your own implementation of the ThreadFactory interface:</p> <pre><code>pool = Executors.newScheduledThreadPool(numberOfThreads, new TF()); class TF implements ThreadFactory { public synchronized Thread newThread(Runnable r) { Thread t = new Thread(r) ; t.setName("Something here...."); ...
How to order fields on index creation (SQL Server 2005 +)? <p>As <a href="http://msdn.microsoft.com/en-us/magazine/cc135978.aspx" rel="nofollow">this article</a>'s figure 4 says, SQL Server 2005 + can return you a list of missing indexes. It stores 2 important info about missing indexes:</p> <p>[EqualityUsage],[Inequa...
<p>col1, col2</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms345434.aspx" rel="nofollow">CREATE INDEX</a></p> <blockquote> <p>To convert the information returned by sys.dm_db_missing_index_details into a CREATE INDEX statement, <strong>equality columns should be put before the inequality columns<...
Extending an ActiveXObject in javascript <p>I want to add some functionality track certain calls to ActiveX object methods in javascript. </p> <p>I usually create my activeX object like this: var tconn = new ActiveXObject("Tconnector");</p> <p>I need to log every time the <strong>open</strong> method is called on tco...
<p>You can in fact override <code>ActiveXObject()</code>.</p> <p>This means you can try to build a transparent proxy object around the actual object and hook on method calls. This would mean you'd have to build a proxy around every method and property your ActiveX object has, unless you are absolutely sure there is no...
Searching the full-text of the files in the respository in svn? <p>Is there any way to search the full text of all the revisions (or just a specific revision) of a subversion repository? </p> <p>I mean I know that tools like Google Code search must do this somehow (or at least index the text), I was just wondering if...
<p>Might be a little heavyweight setup-wise, but <a href="http://opengrok.github.io/OpenGrok/" rel="nofollow">OpenGrok</a> is an invaluable tool for my dev team. We trigger updates by <a href="http://hudson-ci.org/" rel="nofollow">Hudson</a> after every build and we instantly search 1M+ lines</p>
Objective-c Iphone how to set default value for a property <p>Hi i've got the following code in a ViewController.h:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface CalcViewController : UIViewController { NSNumber* result; NSString* input; //NSString* input = @""; IBOutlet UITextField* display...
<p>You may find it useful to read some documentation on Objective-C or Cocoa. You probably can find some good suggestions on reading material if you perform a search here in StackOverflow or on Google.</p> <p>To answer your question, you should have a @implementation of CalcViewController. One would most often place t...
find the 10 largest files within a directory structure <p>How could one find the 10 largest files in a directory structure? </p>
<p>Try this script </p> <pre><code>gci -re -in * | ?{ -not $_.PSIsContainer } | sort Length -descending | select -first 10 </code></pre> <p>Breakdown:</p> <p>The filter block "<code>?{ -not $_.PSIsContainer }</code>" is meant to filter out directories. The sort command will sort all of the remaining entries b...
SUN IMQ topic messages preview <p>Is there any way to view the messages that reside inside a JMS Topic destiantion?</p> <p>I've got a problem with messages not being released from Topic destination. The Topic has got 1 producer and 7 consumers and none of them is durable.</p> <p>Thanks in advance for any suggestions....
<p>After some digging finally found out the answer.</p> <p>I need to use the following command:</p> <pre><code>imqcmd list msg -t t -n my_topic -nocheck </code></pre> <p>where my_topic is the name of my topic destination. After receiving a response like:</p> <pre><code>Listing messages for the destination --------...
Calling a Method of a Windows Form Without an Active Form Instance <p>I'm developing a windows application in C# using VS2005. Consider i need to call a non static method(Method1) which is in a class(Class1) from another class(Class2). In order to call the method, i need to create object for that class.</p> <p>But my ...
<p>It's hard to say what can be done to solve this particular problem. What <em>can</em> be said, though, is that having such a huge class is definitely a <a href="http://en.wikipedia.org/wiki/Code%5Fsmell" rel="nofollow">code smell</a>. Try refactoring your classes so that the class required for operation of a method ...
Algorithm for neatly indenting SQL statements (Python implementation would be nice) <p>I'd like to reformat some SQL statements that are a single string with newlines in to something that's much easier to read.</p> <p>I don't personally know of a good coding style for indenting SQL - how should nested queries / where ...
<p>You can try <a href="http://python-sqlparse.googlecode.com">sqlparse</a>. It's a Python module that provides simple SQL formatting. A online demo is available <a href="http://sqlformat.appspot.com">here</a>.</p>
jQuery validation field by range <p>How can I validate field by range?</p> <p>I use additional-methods, but i don't know how providing parametr with range to my validation method via HTML.</p> <p>Something of a<br /> <code>&lt;input type="text" class="rangeField" rel="[10, 20]" /&gt;</code></p> <p>It's nice, if i ca...
<p>Are you using the <a href="http://docs.jquery.com/Plugins/Validation/Methods/range#range" rel="nofollow">Validation</a> plugin? This plugin makes it trivial to validate against a range.</p> <pre><code>$("#myform").validate({ rules: { field: { required: true, range: [13, 23] } } }); &lt;inp...
Catching errors in an ASP.NET webpage from winforms <p>I am writing a WinForms app which will execute some web UI tests written in a web testing framework.</p> <p>Is there a way I can get the error on the page being tested (I specify the page through a method parameter) without screenscraping the page? For example, if...
<p>I would actually suggest you look into something called <a href="http://www.google.com/url?sa=t&amp;source=web&amp;ct=res&amp;cd=2&amp;url=http%3A%2F%2Fwww.raboof.com%2Fprojects%2FElmah%2F&amp;ei=RRT3ScDLGN2rtgfXpfHsDw&amp;usg=AFQjCNFyk56CNO6ygf7egvf8Qmv1DLrw4g" rel="nofollow">ELMAH</a>. If you put ELMAH on your ASP...
How can a custom markup extension for a graph of custom types loaded through XAML obtain a reference to the root object <p>I am attempting to write a <code>MarkupExtension</code> to support the process of instantiating custom types via XAML. My custom types are POCOs and not descendants of <code>DependencyObject</code>...
<p>I wrote a class that I use to bind to ViewModel commands, and it contains some code to retrieve the root of the XAML. It uses reflection on private WPF members, so it's not exactly clean, but it works... You can find it here</p> <p><a href="http://www.thomaslevesque.com/2009/03/17/wpf-using-inputbindings-with-the-m...
Testing if value is a function <p>I need to test whether the value of a form's <code>onsubmit</code> is a function. The format is typically <code>onsubmit="return valid();"</code>. Is there a way to tell if this is a function, and if it's callable? Using typeof just returns that it's a string, which doesn't help me ...
<blockquote> <p>I'm replacing a submit button with an anchor link. Since calling form.submit() does not activate onsubmit's, I'm finding it, and eval()ing it myself. But I'd like to check if the function exists before just eval()ing what's there. – gms8994</p> </blockquote> <pre><code>&lt;script type="...
Multi-threading strategies? (Modifying a scene in a multi-threaded engine through an Editor) <p>I'm trying to write an editor overtop a multi-threaded game engine. In theory, through the editor, the contents of the scene can be totally changed but I haven't been able to come up with a good way for the engine to cope wi...
<p>If memory is not a problem, you can could have a two-stage process, where the changes are done in one model, and then a snapshot is taken for the renderer, this way the renderer would always see a consistent view of the model.</p>
Where do I instantiate my Objects in CRUD n-Tiered WinForm App? <p>Say I have a WinForm CRUD(like) application. I want to follow best practices on this so I try and make it follow OOP and a n-Tiered design. </p> <p>Unfortunately I am familar with the words but not the practice of them. So lets go with the following...
<p>If you want to look at some more words around this problem you want to look at MVP and MVC. (These stand for Model View Controller and Model View Presenter). Some people will shoot me down for saying this but they are quite similar in concept. </p> <p>The aim of MVP and MVC is to allow you to design your applicatio...
Business rules validation in NHibernate Validator <p>Is it possible to define a validation method (for businbess rules validation) that will be used by NHibernate.Validator? I mean something that exists in EntLib:</p> <pre><code>[HasSelfValidation()] public class SomeClass { //... [SelfValidation()] publi...
<p>Yes, it can be done - but you will be missing a way to communicate more information on which rules were violated in the case of validation errors.</p> <p>NHibernate Validator, to my knowledge, only provides the ability to specify a text message, the name of the class, and - in the case of property level validation ...
Experiences using moq with VB.Net <p>I really like the moq mocking framework. I've used it on several projects. Unfortunately, one of my customers is demanding we use VB.Net. Not my preference, but hey, .Net is .Net, right?</p> <p>I've heard that moq has some trouble with VB. Is this true? Is so, what sorts of tr...
<p>The main problem of VB.net with regards to mocking frameworks is that, contrary to C#, VB does not have anonymous methods, only Lambda expressions (no way to declare an anonymous Action delegate). </p> <p>This severely limits the possibilities. There is also a known issue with properties with parameters.</p> <p>A...
preload FLV in Actionscript 3? <p>I'm working on a flash site with lots of video-based section-to-section transitions. The transition videos themselves are only a few seconds long but are fairly weighty (~700kb) as they're very high-resolution; given the number of sections and section-to-section transition combination...
<p>It's not much different in AS3. Just use a Timer instead of an interval. Were you having problems converting that code to AS3?</p>
How to turn a Ruby Hash into HTTP Params <p>That is pretty easy with a plain hash like </p> <pre><code>{:a =&gt; "a", :b =&gt; "b"} </code></pre> <p>which would translate into </p> <pre><code>"a=a&amp;b=b" </code></pre> <p>but what do you do with something more complex like </p> <pre><code>{:a =&gt; "a", :b =&gt; ...
<p>For basic, non-nested hashes, Rails/ActiveSupport has Object#to_query.</p> <pre><code>&gt;&gt; {:a =&gt; "a", :b =&gt; ["c", "d", "e"]}.to_query =&gt; "a=a&amp;b%5B%5D=c&amp;b%5B%5D=d&amp;b%5B%5D=e" &gt;&gt; CGI.unescape({:a =&gt; "a", :b =&gt; ["c", "d", "e"]}.to_query) =&gt; "a=a&amp;b[]=c&amp;b[]=d&amp;b[]=e" </...
What's the best way to calculate remaining download time? <p>Let's say you want to calculate the remaining download time, and you have all the information needed, that is: File size, dl'ed size, size left, time elapsed, momentary dl speed, etc'. How would you calculate the remaining dl time?</p> <p>Ofcourse, the strai...
<p>Well, as you said, using the absolutely current download speed isn't a great method, because it tends to fluctuate. However, something like an overall average isn't a great idea either, because there may be large fluctuations there as well.</p> <p>Consider if I start downloading a file at the same time as 9 others....
What should i choose? jquery, mootools, yui, scriptaculous or prototype? <p><strong>Duplicate:</strong> <a href="http://stackoverflow.com/questions/394601/which-javascript-framework-jquery-vs-dojo-vs">Which Javascript framework (jQuery vs Dojo vs … )?</a></p> <p>I am totally new to javascript, but i want to implemen...
<p>JQuery is currently extremely popular, so you're probably going to have the most luck finding recent tutorials/plugins/etc for it, as opposed to one of the other frameworks. That's probably a fairly good selling-point from the perspective of someone new to this.</p>
getting mx:CheckBox values from inside mx:Repeater <p>I have an an array of objects that I use as the datasource for my repeater.</p> <pre><code>&lt;mx:Repeater id="categoryRepeater" dataProvider="{this.allCategories}"&gt; &lt;mx:HBox&gt; &lt;mx:Spacer width="20"/&gt; &lt;mx:CheckBox id="categoryCheckBox" label="{cate...
<p>Use the <a href="http://www.few.vu.nl/~eliens/design/assets/flex3/langref/mx/core/Repeater.html#currentIndex" rel="nofollow"><code>currentIndex</code></a> property.</p>
is the main.m really the place, where the autorelease pool of the main run loop is created by every event? <pre><code>#import &lt;UIKit/UIKit.h&gt; int main(int argc, char *argv[]) { NSLog(@"new event..."); NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, ar...
<p>No. All Cocoa or CocoaTouch classes require the presence of an autorelease pool in order to not leak memory. Thus, an existing autorelease pool is required to call UIApplicationMain() in order to cover any (possibly) autoreleased objects that are instantiated in the context of UIApplicationMain(). This outer autorel...
How to determine if a string is a valid IPv4 or IPv6 address in C#? <p>I know regex is <a href="http://www.perlmonks.org/index.pl?node%5Fid=221512">dangerous</a> for validating IP addresses because of the different forms an IP address can take.</p> <p>I've seen similar questions for C and C++, and those were resolved ...
<p>You can use this to try and parse it:</p> <pre><code> IPAddress.TryParse </code></pre> <p>Then check <code>AddressFamily</code> which</p> <blockquote> <p>Returns System.Net.Sockets.AddressFamily.InterNetwork for IPv4 or System.Net.Sockets.AddressFamily.InterNetworkV6 for IPv6.</p> </blockquote> <p>EDIT: some s...
counting records from a grouped query with additional criteria <p>I have a table of reports that has these relevant fields:</p> <pre><code>user_id (int 11) submitted_date (datetime) approved_flag (shortint 1) </code></pre> <p>There are multiple rows per <code>user_id</code>, some with <code>approved_flag</code> = 0 a...
<pre><code>SELECT approved_flag, COUNT(*) FROM Table t INNER JOIN ( SELECT user_id, submitted_date = MAX(submitted_date) FROM Table GROUP BY user_id ) latest ON latest.user_id = t.user_id AND latest.submitted_date = t.submitted_date GROUP BY approved_flag </code></pre>
Tracing MFC message handling <p>Trying to upgrade an MFC app to use the new MFC feature pack, we are loosing the messages from a context menu. The menu appears and can be clicked, but the message seems not to be handled anywhere. We overrode OnCmdMsg() in lots of places but to no avail, the context menu's command messa...
<p>Try SPY++</p> <p><a href="http://msdn.microsoft.com/en-us/library/76712d27.aspx" rel="nofollow">> ...can be found on the Programs or All Programs menu in Windows. Click Microsoft Visual Studio 9.0, and then click Visual Studio Tools.</a> </p> <blockquote> </blockquote> <p>Provides a graphical view of the proce...
Changing a record in a table (sql server) that has foreign keys? <p>Does anyone know if there is a quicker way of editing a record that has foreign keys in a table (in sql server).. i will explain.. i have approx 5 tables that have there own ID but are linked together using a foreign key...</p> <p>Hence i needed to ch...
<p>I'm not an SQL expert, but can't you set something like ON UPDATE CASCADE to automatically update the foreign key when the primary key is changed?</p>
Is there any pre-built way to parse JSON from VB6? <p>Is there any existing JSON parser which can be used from VB6?</p> <p>I could obviously write my own parser, but I don't want to reinvent the wheel if I don't have to.</p> <p>Thanks!</p>
<p>I would look at <a href="http://www.ediy.co.nz/vbjson-json-parser-library-in-vb6-xidc55680.html">VB-JSON</a>:</p> <blockquote> <p>VB-JSON is a Visual Basic 6 class library for parsing and emitting JSON (Javascript Object Notation) and can handle nested arrays and objects in the data. It does not rely on the JScri...
Any way to shorten or simplify the item template markup for a repeater control? <p>Is there a way to shorten the markup for this repeater? I am binding a DataTable to this repeater. It bothers me because ((System.Data.DataRowView)Container.DataItem) is repetitive and makes the markup less readable especially when you...
<p>Why not use the simplified data binding statements introduced with ASP.NET 2.0?</p> <p>&lt;%# Eval("Name") %></p> <p>&lt;%# Eval("Definition") %></p>
using a transaction to avoid a race <p>I'm writing a daemon to monitor creation of new objects, which adds rows to a database table when it detects new things. We'll call the objects widgets. The code flow is approximately this:</p> <pre><code>1: every so often: 2: find newest N widgets (from external source) 3: f...
<p>Generally, you should always use transactions if you have more then one process or thread using the database at the same time.</p> <p>Isolation level "serializable" should actually work. It does not allow that data read from one transaction is changed by another. But it locks a lot and should not generally be used,...
I/O redirection in eclipse? <p>Is it possible to use IO redirection in eclipse? I want to redirect standard input/output on the command line like <code>java MyProgram &lt;input.txt &gt;output.txt</code>, but I can't seem to get it to work in eclipse. I tried including the &lt;'s as part of the program arguments, which ...
<p>You can redirect <em>output</em> using the Run dialog, Common tab, "Standard Input and Output" section.</p> <p>However, it doesn't look like you can redirect <em>input</em> as far as I can tell (and as far as <a href="http://stackoverflow.com/questions/188547/eclipse-reading-stdin-system-in-from-a-file/188654">this...
Valid JavaBeans names for boolean getter methods <p>I know most variable names will work with "is", such as <code>isBlue()</code>, but is "has" also a valid prefix, like <code>hasProperty()</code>?</p>
<p>According to the <a href="http://download.oracle.com/otndocs/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/">JavaBeans specification</a> section 8.3.2:</p> <blockquote> <p><b>Boolean properties</b><br/> In addition, for boolean properties, we allow a getter method to match the pattern:<p><code>public boolean is...
Should I -drain or -release an autorelease pool in iPhone OS? <p>The doc says:</p> <blockquote> <p>In a garbage-collected environment, sending a drain message to a pool triggers garbage collection if necessary; release, however, is a no-op. In a reference-counted environment, drain has the same effect as...
<p>It doesn't really matter, they both have the same effect. Apple recommends using drain in case you ever move to a garbage collected environment (if a future version of iPhone SDK supports it, or if you copy it to a Mac OS X project), so that's what I'd go with.</p>
How to use regex to extract groups of question-answer data from html files? <p>How can I use a regular expression to extract groups of html that will be formatted like this:</p> <p>.</p> <pre><code>. .irrelevant html... &lt;b&gt;Question 6&lt;/b&gt;&lt;br&gt; lots of text &lt;p&gt; lots of text &lt;p&gt; &l...
<p>I think you should look at some of the options from this question "<a href="http://stackoverflow.com/questions/122402/is-there-an-application-to-create-regular-expression-out-of-text-by-selecting-w">Is there an Application to Create Regular Expression Out of Text by Selecting Wanted Area?</a>"</p> <p><a href="http:...
LLBL: Delete Where NOT IN <p>I'm trying to perform the following query in LLBL and I'm not having much luck.</p> <pre><code>DELETE FROM dbo.MyTable WHERE MyTableId NOT IN ('39', '43', '44') </code></pre> <p>Essentially, I'm up to this point:</p> <pre><code>private static void Delete(MyTableCollection newRecs) { ...
<p>In order to get the "not in" to work, you've got to pass some kind of array. Try something like this:</p> <pre><code>List&lt;int&gt; idsNotToDelete = new List&lt;int&gt;(); foreach (MyTableEntity ent in newRecs) { idsNotToDelete.Add(ent.MyTableId); } PredicateExpression filter = new PredicateExpression(MyTabl...
Is a good idea to put all projects in the same trunk? <p>We understand the default and usually recommended svn repository organization, in case of having multiple projects, is something like this:</p> <pre><code>root/projectA/(trunk, branches, tags) root/projectB/(trunk, branches, tags) ... </code></pre> <p>Our proje...
<p>We do this at our company and have had a lot of success. </p> <p>We have 3 top level directories:</p> <ul> <li>tags</li> <li>branches</li> <li>trunk</li> </ul> <p>And then we have each project as a sub-directory of those.</p> <p>We still branch at the project level though and still use svn:externals. But if we...
Using vim for html decoration <p>Do you have any preferred methodology for managing html formatting tags in vim?</p> <p>The best I've come up with is creating some macros to insert tags at the current cursor position - ctrl-i for &lt;i>, ctrl-j for &lt;/i>, etc.</p> <p>It would be handy to be able to, say 2w{somethin...
<p>Give a look to the <a href="http://www.vim.org/scripts/script.php?script%5Fid=1697" rel="nofollow">surround.vim</a> plugin.</p>
Do you think of the database or objects first when building applications? <p>When you think about building an application, say for the web, and it uses a relational database, do you think about the database first and then putting you app as a front end or do you think of your program and objects and how a database can ...
<p>You'll obviously get a lot of different answers to this question, but I tend to think about the database first, and then build objects based on that. I think it's just easier for my brain to work that way, as I can visualize the database schema (and also, it is very easy to show relations in a database schema). @Tdp...
Get image width and height <p>I need to get an image's dimensions in javascript (jQuery) when no styles are specified for it (jQuery's css() returns 0).</p> <p>Maybe it is because I'm loading the image with jQuery just before asking for its dimensions. If this is the case, is there any event to listen that tells when ...
<p>Maybe the image has not fully loaded therefore the dimensions can not be given.But without your code I can't tell what you're doing wrong, but here is an <strong>Example</strong> that would work: </p> <pre><code> function LoadImage(isrc) { var oImg = new Image(); oImg.src = isrc; if (oImg....
Signal-slot architecture best practice <p>I am using libsigc++ to wire up an application, and is uncertain as to the easier way of going about it. </p> <p>There is a preexisting object hierarchy that manages the data layer, and the top level object exposes all functions. All good so far.</p> <p>To this I am adding a...
<p>Personally, I don't see any problem by 'skipping' layers with the signal/slots mechanism. I prefer to see it this way: a component is sending signals into the wild, and whoever is interested in those signals may listen to them.</p> <p>A couple of tips: avoid to send signals that are too generic, and don't rely on ...
What does the COLLATE keyword do when creating a sqlite index? <p>According to the <a href="http://www.sqlite.org/lang%5Fcreateindex.html">sqlite3 documentation</a>,</p> <blockquote> <p>The COLLATE clause following each column name defines a collating sequence used for text entries in that column. The default ...
<p>It is the way that the sql engine orders data internally. Binary Collation does what it suggests, it does a binary comparison. Generally its the fastest collation though I have never quantified it, as it checks bit patterns, which means it is case and accent insensitive.</p>
Using Mercurial locally, only with Subversion server <p>We are using a Subversion server at my job for source control. I was thinking that rather than keeping up with my own branch, I would run Mercurial on my workstation, commit locally, and then commit to the Subversion trunk whenever I’m done with whatever featur...
<p>Have you looked at <a href="http://www.selenic.com/mercurial/wiki/index.cgi/WorkingWithSubversion">http://www.selenic.com/mercurial/wiki/index.cgi/WorkingWithSubversion</a> ?</p>
How can WPF objects deriving from Freezable be frozen in XAML? <p>Many types in WPF derive from <code>Freezable</code>. It provides immutability to mutable POCO objects and allows for improved performance in certain situations.</p> <p>So my question is, how can I freeze objects in XAML markup?</p> <p>(Note that I ha...
<p>To freeze a <code>Freezable</code> object declared in markup, you use the <code>Freeze</code> attribute defined in XML namespace <code>http://schemas.microsoft.com/winfx/2006/xaml/presentation/options</code>.</p> <p>In the following example, a <code>SolidColorBrush</code> is declared as a page resource and frozen. ...
Remove carriage return in Unix <p>What is the simplest way to remove all the carriage returns <code>\r</code> from a file in Unix?</p>
<p>I'm going to assume you mean carriage returns (<code>"\r", 0x0d</code>) at the ends of lines rather than just blindly within a file (you may have them in the middle of strings for all I know. Using this test file:</p> <pre><code>$ cat infile hello goodbye $ cat infile | od -c 0000000 h e l l o \r \n ...
How to pass the following parameter? HitTestParameters3D in VisualTreeHelper.HitTest(,,,)? <p>I am trying to pass the HitTestParameters3D parameter to VisualTreeHelper.HitTest(,,,) but I've failed to find any examples as to how this can be done and information about HitTestParameters3D is scant.</p> <p>Help is appreci...
<p>Use <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.media3d.hittestparameters3d.aspx" rel="nofollow">RayHitTestParameters class for the parameter</a>.</p> <pre><code>RayHitTestParameters hitParams = new RayHitTestParameters( new Point3D(0, 0, 0), new Vector3D(1...
Two Way Data Binding With a Dictionary in WPF <p>I'd like to bind a <code>Dictionary&lt;string, int&gt;</code> to a <code>ListView</code> in WPF. I'd like to do this in such a way that the <code>Values</code> in the <code>Dictionary</code> get updated via the data binding mechanism. I don't want to change the <code>Key...
<p>I don't think you're going to be able to do what you'd like with a dictionary.</p> <ol> <li>Because the Dictionary doesn't implement INotifyPropertyChanged or INotifyCollectionChanged</li> <li>Because it's not going to allow two way binding like you want.</li> </ol> <p>I'm not sure if it fits your requirements exa...
Flex: How to add horizontal axes to a chart? <p>I have a dynamically created chart and I need to add a horizontal and vertical axis in a script. I can't put the chart into MXML because I'm dynamically changing the chart type, deleting and creating a new chart. Therefore, the variable that I use to create the chart, an ...
<p>I think you'll get better results by instantiating your chart as a proper type.</p> <p>For example, in a component I have a skeleton lineChart setup in the mxml...</p> <pre><code>&lt;mx:LineChart id="lineChart" dataProvider="{chartData}" dataTipFunction="dataTipFunction" width="100%" height="100%" showDataTips=...
TTY switch for Ctrl-Alt F1 and Alt-F1...F6 in Mac OS X <p><strong>Is it possible...</strong></p> <ol> <li>to have a terminal mode for the keybinding <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>F1</kbd></li> <li>to switch between TTYs for <kbd>Alt</kbd>+<kbd>F1</kbd>...<kbd>F6</kbd></li> </ol> <p>Ubuntu has the above commands...
<p>I am not sure what you are asking. Are you asking about accessing TTYs in Mac OS X? That is not possible. Use the terminal, /Applications/Utilities/Terminal.app</p>
php string parse with look ahead <p>I have this string in PHP:</p> <pre><code>$string = "name=Shake &amp; Bake&amp;difficulty=easy"; </code></pre> <p>For which I want to parse into array:</p> <pre><code>Array ( [name] =&gt; Shake &amp; Bake [difficulty] =&gt; easy ) </code></pre> <p>NOT:</p> <pre><code>Ar...
<p>There's probably a more effective way of doing this, but try</p> <pre><code>$foo = 'name=Shake &amp; Bake&amp;difficulty=easy'; $pairs = preg_split('{&amp;(?=[^\s])}',$foo); //$pairs = preg_split('/&amp;(?=[^\s])/',$foo); //equivalent, using different delimiters. //$pairs = preg_split('%&amp;(?=[^\s])%',$foo); //eq...
Windows Forms TreeView always selects a node on focus <p>The TreeView in Windows Forms always seems to want a node selected when it regains focus. If I have no nodes selected, and that treeview gains focus, I'll get an <code>AfterSelect</code> event with the first node selected, even though I didn't select it using th...
<p>I agree that using <code>TreeViewAction.Unknown</code> in this case is less than desirable. Consider using the <code>BeforeSelect</code> event, which provides an opportunity to prevent the <code>AfterSelect</code> event.</p> <p>Create a <code>GotFocus</code> event handler that sets a flag. Then, create a <code>Be...
Tips on setting up internet facing WSS 3.0 site without Active Directory <p>We're trying to setup an internet facing WSS 3.0 site without Active Directory. We have a single WFE and a single SQL Server (2005). The WFE will be outside our DMZ.</p> <p>We've successfully created the Central Admin site with a local admin...
<p>You want to setup your WSS3 site using Forms Based AUthentication, with an ASP.Net SQL Membership Provider and backend database.</p> <p><a href="http://msdn.microsoft.com/en-us/library/bb975136.aspx?ppud=4" rel="nofollow">Microsoft have a very nice guide on MSDN</a>.</p>
Recommended solution for scripting file operations over WebDAV? <p>I have a task: files available over WebDAV on a remote server (SSL required) must be checked for whether they may have been updated recently, and if so copied to a local folder. There are a number of other actions that need to be performed after they ar...
<p>It will work from powershell. Note this example:</p> <p><a href="http://thepowershellguy.com/blogs/posh/archive/2008/05/31/cd-into-sysinternals-tools-from-powershell.aspx" rel="nofollow">http://thepowershellguy.com/blogs/posh/archive/2008/05/31/cd-into-sysinternals-tools-from-powershell.aspx</a></p> <p>The proble...
IIS 7.0 with pipeline mode = Integrated doesn´t load any image/css in ASP .NET <p>I have a full system working in IIS 5.1 ... I migrated to IIS 7.0 with pipeline mode classic all works fine, but with pipeline Integrated my images/css are not loaded... </p> <p>I´m using ASP.NET 3.5 with a Web Application...</p> <p>A...
<p>In IIS 7 when you install the ASP.NET modules, static content is not installed by default. You will need to go into programs and features, then "Turn windows features on or off".</p> <p>Under IIS section, drill down into WWW services, Common Http features, and check "Static Content".</p> <p>Without that css, image...
Dark Blue styling <p>This is not a programming question, so I apologize if it doesn't really fit in this website.</p> <p>I want to create a 3 column website where the dominating background color is dark blue, and the secondary side column is more noticeable than the tertiary column, and where the primary content area ...
<p>Before this gets smacked down:</p> <p>Use <a href="http://colorschemedesigner.com/" rel="nofollow">http://colorschemedesigner.com/</a></p> <p>It will give you an example of what the website will look like in the color scheme and it will also generate the template for you which is nice.</p>
Do I need to explicitly alloc my NSNumber? <p>I am defining a number, as follows:</p> <pre><code>NSNumber *nn0 = [NSNumber numberWithInt:0]; </code></pre> <p>It works fine without any alloc. My understanding is that if I use numberWithInt, alloc and init are called automatically.</p> <p>If I try to release at the en...
<p>The "convenience constructors" for a lot of types produce an object that is automatically "autoreleased" - i.e. the new object will be retained by the current NSAutoreleasePool. You don't need to manually release these objects - they will be released when the current NSAutoreleasePool is released/drained.</p> <p>S...
What does the period do in this line of Fortran? <p>I am not sure what version of Fortran this is, but the line is:</p> <p><code>Term = F*F - 4.*E*G</code></p> <p>I know that it multiplies F by F and then subtracts something, but I don't know what the period after the 4 is doing there.</p>
<p>I'm going to venture a guess based on every other programming language I've ever seen, and say that it's making the constant "4" of type Real, rather than Integer. In other words, it's making sure the types in the expression all match up. "4.0" would be equivalent; whoever wrote this code was just feeling extra conc...
Is it possible to maintain a 43 page query? <p>I always thought an SQL compiler would break but apparently nesing can nearly be infinite. Is this code to be trashed immediately or is there some glimmer of hope that something like this can function?</p> <p>This query doesn't really belong to me so I cannot post it... H...
<p>Clearly, you've never seen the SQL that comes out of the Sharepoint DAL.</p>
C/C++ How to tell if a program is already running? <p>In a Windows environment, I don't want two instances of my program running at the same time. </p> <blockquote> <h3>Related</h3> <p><a href="http://stackoverflow.com/questions/646480/is-using-a-mutex-to-prevent-multipule-instances-of-the-same-program-from-run...
<p>I think you need to consider your scenario a bit before going forward. There are many different interpretations of "running the same program" more than once. For instance do you </p> <ol> <li>Once per machine</li> <li>Once per logon session</li> <li>Once per user </li> </ol> <p>All of these have different, albei...
Unable to have Zsh as a login shell at Screen's startup <p>I put the following to my .zshrc</p> <pre><code>if [[ $STY = '' ]] then screen -xR; fi </code></pre> <p>I get Bash when I start terminal now, although I have /bin/zsh at Terminal > Settings in Mac.</p> <p><strong>Which variable do I need to change to make Zs...
<p>A fast way to change your shell, for example to Zsh, is to run the following code</p> <pre><code>chsh -s /bin/zsh </code></pre>
SQL grouping by all the columns <p>Is there any way to group by all the columns of a table without specifying the column names? Like:</p> <pre><code>select * from table group by * </code></pre>
<p><h2>The DISTINCT Keyword</h2><br /> I believe what you are trying to do is:</p> <pre><code>SELECT DISTINCT * FROM MyFooTable; </code></pre> <p>If you group by all columns, you are just requesting that duplicate data be removed.</p> <p>For example a table with the following data:</p> <pre><code> id | value ...
How to implement 'undo' operation in .net windows application? <p>Assume that, a win form has certain input fields and user enters/re-enters some data.</p> <p>How to retain data previously entered by 'undo' operation?</p> <p>Just I want to know the best way to accomplish it.</p>
<p>There are a few options. The important thing is that you start designing it in early in the project. Trying to add it to an existing project can be <em>very</em> expensive if it wasn't designed with this capability in mind.</p> <p>There are a few fundamental patterns that you'll want to take advantage of:</p> <o...
Getting a parameterless method to act like a Func<ReturnT> <p>I'm trying to make a part of my code more fluent.</p> <p>I have a string extension that makes an HTTP request out of the string and returns the response as a string. So I can do something like...</p> <pre><code>string _html = "http://www.stackoverflow.com"...
<p>You can't use a method group for extension methods, or lambda expressions. I <a href="http://msmvps.com/blogs/jon%5Fskeet/archive/2008/01/08/extension-methods-on-lamdba-expressions-don-t-work-unfortunately.aspx" rel="nofollow">blogged about this a while ago</a>.</p> <p>I suspect you could cast to <code>Func&lt;stri...