input
stringlengths
51
42.3k
output
stringlengths
18
55k
Freebase MQL filter where value != null? <p>I'm trying to write an MQL query that filters out null values.</p> <p>The query I have now (can be executed using the <a href="http://www.freebase.com/tools/queryeditor">MQL Query Editor</a>):</p> <pre><code>[ { "/common/topic/image" : [ { "id" : null ...
<p>To filter out articles that don't have any content assigned to them you'll have to expand the content id attribute and set the optional directive to false.</p> <pre><code>[ { "/common/topic/image" : [ { "id" : null } ], "article" : [ { "content" : { "id" : n...
ISNULL not working in TSQL Select <p>I have a TSQL SELECT that can return a null. I tried using ISNULL to replace it with 0 but for some reason it is not working. The table selecting from has the following columns:</p> <ul> <li>storeID --> int </li> <li>penaltyPercent --> decimal(9,2) </li> <li>penaltyDate --> dateT...
<p>When you say "When the date is before the first penalty date", do you mean when the value of <code>@date</code> is less than the value returned from this query?</p> <pre><code>SELECT MIN(penaltyDate) FROM Penalty </code></pre> <p>Because then your inner query is going to return null, and (if you're using ANSI null...
Need help with Converting Points to Shapes <p>below are a whole length of code i have copied from NEHE Production (Lesson 25).. i was just trying to play around but seem to not able to change/convert each points into a individual spheres nor cylinder.. <br>somehow when i did my adjustment they are not arranged in the w...
<p>A good place to start is to replace glBegin(GL_POINTS) with glBegin(GL_TRIANGLES) or GL_QUADS or GL_POLYGONS.</p> <p>See the help page on glBegin/End <a href="http://www.opengl.org/documentation/specs/man%5Fpages/hardcopy/GL/html/gl/begin.html" rel="nofollow">here</a>.</p>
Capturing the first frame of a video with WPF <p>I need to capture the first frame of a video uploaded on an asp.net website. I really would like to do this with WPF (if it's even possible), but if anyone knows an easier way, I am open to that too. </p> <p>I have seen examples of this using MediaPlayer and RenderTar...
<p>I don't know that this is advisable at all, as it will more than likely require that you run a message pump of some kind, which is a really bad idea in an ASP.NET site.</p> <p>Rather, I would use the DirectShow API to try and process the video. You <em>should</em> be able to stream the content as bytes using it, a...
Why does -[NSTextStorage replaceCharactersInRange: withAttributedString:] sometimes, sometimes not honor fonts in other character sets? <p>I'm trying to diagnose a problem in UKSyntaxColoredTextDocument 0.4 <a href="http://www.zathras.de/angelweb/blog-uksctd-oh-four.htm" rel="nofollow">http://www.zathras.de/angelweb/bl...
<p>Try [[textView textStorage] fixFontAttributeInRange:range]; after the [[textView textStorage] replaceCharactersInRange: range withAttributedString: vString] in recolorRange:</p> <p>I think the problem is editing the text storage again in response to processEditing, which is already the tail end of an edit. -[NSText...
How do I make an http request using cookies on Android? <p>I'd like to make an http request to a remote server while properly handling cookies (eg. storing cookies sent by the server, and sending those cookies when I make subsequent requests). It'd be nice to preserve any and all cookies, but really the only one I car...
<p>It turns out that Google Android ships with Apache HttpClient 4.0, and I was able to figure out how to do it using the "Form based logon" example in the <a href="http://hc.apache.org/httpcomponents-client/examples.html">HttpClient docs</a>:</p> <p><a href="http://svn.apache.org/repos/asf/httpcomponents/httpclient/t...
How can I create a group footer in a WPF ListView ( GridView ) <p>I have a ListView that displays sales orders, and groups them by status. In WinForms I had a footer at the bottom of each group that displayed the Total sale price for each group, and I would like to do the same in WPF.</p> <p>I have figured out how to ...
<p>If your looking for something like this:</p> <p><img src="http://www.bendewey.com/code/GroupingSum.png" alt="WPF Grouping with Total Sums" /></p> <p>Then you can use the Template property of the ContainerStyle for the GroupStyle. In this example I use a DockPanel, with the Grid you supplied Docked on the bottom a...
Why doesn't git-svn use the Subversion repositories UUID instead of its URL <p>Relocating a git-svn mirror of a Subversion repository isn't trivial:</p> <p><a href="http://stackoverflow.com/questions/268736/git-svn-whats-the-equivalent-to-svn-switch-relocate">git-svn: what’s the equivalent to <code>svn switch —rel...
<p>The git wiki has the answer, use the first method documented here:</p> <p><a href="https://git.wiki.kernel.org/index.php/GitSvnSwitch" rel="nofollow">https://git.wiki.kernel.org/index.php/GitSvnSwitch</a></p> <p>I just tested it on a test repo and it seems to work.</p>
How do I consolidate entries from multiple employee blogs into a single RSS feed <p>Our current SharePoint environment has Mysites setup as separate site collections where users create their blogs. It is a real challenge to know these blogs indivdually and I usually grab the RSS feed the first time I visit and then sus...
<p>I would consolidate these top feeds into an <a href="http://en.wikipedia.org/wiki/OPML" rel="nofollow">OPML</a> file. Here's a <a href="http://www.scripting.com/feeds/top100.opml" rel="nofollow">great example</a>. <a href="http://office.microsoft.com/en-us/outlook/HA012299401033.aspx" rel="nofollow">Outlook</a> 2007...
call a number using skype in a webpage <p>I am trying to add a link or button to the webpage so that the user can call a number directly if the skype is installed. it seems the link is like </p> <p>skyp:....?call....</p> <p>but cannot find any sample or documents. thanks for your help.</p>
<p>This is the format for the link:</p> <pre><code>&lt;a href="skype:echo123?call"&gt;Click&lt;/a&gt; (make a call to echo123) </code></pre> <p>It will work provided the visitor have Skype installed.</p> <p>You can find all the options and an alternative javascript to redirect the user to download skype is he/she do...
Mystery HAVING clause <p>Can anyone please explain the following HAVING clause from an Access database? How can Format with all '0' ever return a string of spaces?</p> <pre><code>HAVING Format([PerNr],'0000000') &lt;&gt; ' ' </code></pre>
<p>Possible if field value is set to spaces...</p> <p>VBA:</p> <pre><code>Dim x As String x = " " MsgBox "x = " &amp; Format(x, "0000000") &amp; " : Len(x) = " &amp; Len(Format(x, "0000000")) </code></pre>
Boolean logic failure <p>I am having a strange problem with boolean logic. I must be doing something daft, but I can't figure it out. In the below code firstMeasure.isInvisibleArea is true and measureBuffer1 is nil. Even though test1 is evaluating to NO for some reason it is still dropping into my if statement. It work...
<p>When in doubt, you should fully parenthesize. Without looking up the precedence rules, what I think what is happening is that = is getting higher precedence than == or &amp;&amp;. So try:</p> <pre><code>BOOL test1 = ((measureBuffer1 == nil) &amp;&amp; !firstMeasure.isInVisibleArea); </code></pre>
Best practice for removing Database calls from MVC Controller classes <p>I have an Action method in an ASP.NET MVC Controller class that handles form posts from a fairly basic "create/edit a user" page. I'm new to MVC so I've been following code samples from various Microsoft tutorials, this is how the method looks cur...
<p>Most people will suggest using the "Repository Pattern" to move that data access code out of the controller (and to enable unit testing with mock objects instead of the real database).</p> <p>Here are some places to read more:</p> <ul> <li><a href="http://stackoverflow.com/questions/125453/implementation-example-f...
How to check if a database exists in SQL Server? <p>What is the ideal way to check if a database exists on a SQL Server using TSQL? It seems multiple approaches to implement this.</p>
<p>Actually it's best to use:</p> <pre><code>if db_id('dms') is not null --code mine :) print 'db exists' </code></pre> <p>See <a href="https://msdn.microsoft.com/en-us/library/ms186274.aspx">https://msdn.microsoft.com/en-us/library/ms186274.aspx</a> </p>
How to Return Generic Dictionary in a WebService <p>I want a Web Service in C# that returns a Dictionary, according to a search:</p> <pre><code>Dictionary&lt;int, string&gt; GetValues(string search) {} </code></pre> <p>The Web Service compiles fine, however, when i try to reference it, i get the following error: "is ...
<p>There's no "default" way to take a Dictionary and turn it into XML. You have to pick a way, and your web service's clients will have to be aware of that same way when they are using your service. If both client and server are .NET, then you can simply use the same code to serialize and deserialize Dictionaries to XM...
Verifying a user in "Email Submission" use case <p>I'm building a system that allows people to submit text and photos via email in addition to standard access on the website. I'm trying to weight the security advantages of two strategies in particular for verifying submissions from a user. Here they are as follows:</...
<p>I would suggest that you not use From based authentication, at least not without some additional credentials (a passphrase, etc) </p> <p><a href="http://www.google.com/search?q=send%20fake%20email" rel="nofollow"><strong>It's way too easy to forge</strong></a>, and certainly not difficult if you know someone's emai...
ImageButton event does not fire if ImageButton does not have Image? <p>Is it normal behavior for an ImageButton event to not fire if it can't find the image for it. For example, assume I have the following piece of code:</p> <pre><code>imageLink = new ImageButton(); imageLink.ImageUrl = "~/images/arrow.png"; </code><...
<p>No, that is not normal. I just tested and even if you never set <code>ImageUrl</code> the button will still post back. Are you certain that the issue is not related to event handling?</p>
Best practice for Parent / Child UI design in ASP.Net? <p>Coming from a desktop client background, with no real data-driven web design experience, I am studying ASP.NET UI design to determine the best UI pattern for Parent/Children data.</p> <p>I always tend to experiment with Parent/Child presentation when learning a...
<p>I won't comment on the Parent/Child portion of what you're asking, but rather on the WebForms vs ASP.NET MVC you asked about at the end.</p> <p>I found developing using WebForms <strong><em>highly</em></strong> annoying. Every time I wanted to do something out of the "norm" I had to fight with the framework to get ...
Dynamic search result when typing <p>I'm using asp.net and want to filter a search result everytime the user enter letters in a textbox. For exmaple this website do exactly what I want: <a href="http://www.prisjakt.nu/" rel="nofollow">http://www.prisjakt.nu/</a> (try searching in the right top corner). I have tried jus...
<p>If you're open to using jQuery, take a look at <a href="http://www.pengoworks.com/workshop/jquery/autocomplete.htm" rel="nofollow">jQuery Autocomplete</a>.</p>
DataContractSerializer documentation <p>I'm looking for a good in depth documentation/how-to for DataContractSerializer. Google turns up a number of related articles but nothing jumped out at me. (I'm not looking for the <a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserialize...
<p>Try this MSDN link instead, <a href="http://msdn.microsoft.com/en-us/library/ms733127.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms733127.aspx</a></p> <blockquote> <p>but I'd rather not hunt trough a pile of MSDN class documentation looking for how they expect me to do it.</p> </blockquote> ...
How can I use a dynamically sized texture array with glTexImage2D? <p>Currently, I'm able to load in a static sized texture which I have created. In this case it's 512 x 512.</p> <p>This code is from the header:</p> <pre><code>#define TEXTURE_WIDTH 512 #define TEXTURE_HEIGHT 512 GLubyte textureArray[TEXTURE_HEIGHT][...
<p>Ok since this took me ages to figure this out, here it is:</p> <p>My task was to implement the example from the OpenGL Red Book (9-1, p373, 5th Ed.) with a dynamic texture array.</p> <p>The example uses:</p> <pre><code>static GLubyte checkImage[checkImageHeight][checkImageWidth][4]; </code></pre> <p>Trying to al...
Is it more secure to store using a database or a file? <p>This question is from a decomposition of <a href="http://stackoverflow.com/questions/678471/what-are-good-programming-practices-to-prevent-malware-in-standalone-applications">http://stackoverflow.com/questions/678471/what-are-good-programming-practices-to-preve...
<p>It is easier to infect user-space API than kernel space API.</p> <p>In other words, the point is moot if you can't trust the services you're using to read the data.</p>
DXGetErrorString newbie question <p>I'm new to C++ and Direct X, and I was wondering what is the proper use of DXGetErrorString and DXGetErrorDescription?</p> <p>According to <a href="http://msdn.microsoft.com/en-us/library/bb173057(VS.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/bb173057(VS.85).as...
<p>Most likely, the functions return a static string, so it doesn't need to be free'd.</p> <p>It'd be similar to writing code like this, where you would not worry about freeing the return value:</p> <pre><code>PCWSTR GetErrorCode(int error) { switch (error) { case 1: return L"File not found"...
How do I build a PXE-bootable boot loader from Workbench? <p>I'm trying to build a VxWorks boot loader that is PXE-bootable from Workbench, but not having any success. Here is a run-down of my environment:</p> <ul> <li>VxWorks 6.6 + latest patches</li> <li>Workbench 3.0 + latest patches</li> <li>Montevina BSP release ...
<p>Wind River got in touch with me and said this is not supported at present.</p>
Scala API design; a service which returns a Set<I> where I is some interface (abstract/trait) <p>I have asked quite a few questions about the Scala collection types and how they might actually be used. Consider how I might write some service API/implementation in Java:</p> <pre><code>public interface JavaProductAPI { ...
<p>Your last block of code more closely mimics the Java code you're emulating: returning a read-only view of a mutable Set.</p> <p>That said, in this situation, if your backing implementation is an immutable.Set[ProductImpl] and you want to return an immutable.Set[IProduct], it's safe to cast.</p> <pre><code>import s...
Advice on a better way to extend C++ STL container with user-defined methods <p>I inherited from C++ STL container and add my own methods to it. The rationale was such that to the clients, it will look act a regular list, yet has application-specific methods they can readily be called. </p> <p>This works fine, but I h...
<p>This is a <strong>bad</strong> idea.</p> <p>There are a lot of reasons you shouldn't derive from STL classes, foremost of which is that they're not designed for it. Vector doesn't have a virtual destructor, so if you extend it, the superclass's destructor may not be called properly and you'll get memory leaks.</p>...
Automatic selection of <p></p>-text rendered in browser <p>who would know of a possibility to automatically select Paragaph text as it gets rendered in a browser, preferably using JavaScript?</p> <p>In my case I have an amount of text in <code>&lt;p&gt;&lt;/p&gt;</code> tags and would like the page to appear with the ...
<p>Insert this near the very end of your page:</p> <pre><code>&lt;script type='text/javascript'&gt; ptags = window.document.getElementsByTagName("p"); current_selection = window.getSelection(); for (i=0; i&lt; ptags.length; i++) { var r1 = document.createRange(); r1.setStartBefore(ptags[i]); r1.setEndAft...
Why are Doctype declarations split on two lines? <p>I know there's more important questions to discuss probably, but at the cost of appearing a fool, I'd like an answer ;-)</p> <p>Take this for instance:</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; </...
<p>It's just line-wrapping.</p> <p>Also, XML will take either quote mark, but convention is the double quote.</p>
How do I define a generic std::list of a custom type? <p>I'm getting the following error trying to define a list of "Lines":</p> <blockquote> <p>line-clip.cpp:44: error: expected initializer before '&lt;' token</p> </blockquote> <pre><code>#include &lt;list&gt; using namespace std; class Line { public: Poi...
<p>You need a semicolon after your class declaration :-).</p> <pre><code>class Line { ... }; // put a semicolon here. </code></pre>
Best way to profile/optimize a website on google's appengine <p>I'm currently trying to optimize my website, which run on the google's appengine. It's not an easy task, because I'm not using any powerful tool.</p> <p>Does anyone have experience in optimizing python code for this purpose? Have you find a good python pr...
<p>I have found <a href="http://code.google.com/p/jrfonseca/wiki/Gprof2Dot" rel="nofollow">Gprof2Dot</a> extremely useful. The output of the profiling modules I've tried as pretty unintuitive to interpret.</p> <p>Gprof2Dot turns the cProfile output into a pretty looking graph, with the slowest chain(?) highlighted, an...
Is it possible to create a page from a string in ASP.Net? <p>I can create a page from a file with:</p> <pre><code>Page page = BuildManager.CreateInstanceFromVirtualPath( virtualPath, typeof(Page)) as Page; </code></pre> <p>How can I instantiate a page from a stream or a string?</p> <p>Thank you.</p>
<p>You can create your own <a href="http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx" rel="nofollow">VirtualPathProvider</a>, which sits between the ASP.NET parser and the file system. The default provider in ASP.NET reads ASPX markup from disk, but you can create your own to read it ...
Fastest way to format a phone number in C#? <p>What is the fastest way to format a string using the US phone format [(XXX) XXX-XXXX] using c#?</p> <p>My source format is a string. </p>
<pre><code>String.Format("{0:(###) ###-#### x ###}", double.Parse("1234567890123")) Will result in (123) 456-7890 x 123 </code></pre>
Sort a DataGrid by clicking on column headers in the Compact Framework? <p>Is this even possible in the .Net Compact Framework? There's all sorts of stuff it leaves out when comparing with the Desktop Framework. </p> <p>I'm wondering if the Compact Framework's got the upper hand on me with this feature request in our ...
<p>Because that website is no longer available, here are the contents:</p> <pre><code> public static void SortDataGrid(object sender, MouseEventArgs e) { DataGrid.HitTestInfo hitTest; DataTable dataTable; DataView dataView; string columnName; DataGrid dataGrid; /...
LINQ to SQL - Is it true that SubmitChanges() automatically starts a transaction? <p>I need to use transactions with LINQ to SQL and I was reading around to get familiar with it.</p> <p>Is it true that SubmitChanges is already transactioned?</p>
<p>When you call SubmitChanges, LINQ to SQL examines the set of known objects to determine whether new instances have been attached to them. If they have, these new instances are added to the set of tracked objects. </p> <p>Immediately before any actual changes are transmitted, <strong>LINQ to SQL starts a transaction...
How can I use the DRY principle to in ASP.NET MVC to refactor this code? <p>I have several methods in one of my controllers that does this: </p> <pre><code>ViewData["Customers"] = LoadCustomers(); ViewData["Employees"] = LoadEmployees(); ViewData["Statuses"] = LoadStatuses(); etc...... </code></pre> <p>Here is LoadC...
<p>This looks like it might be a good candidate for generics:</p> <pre><code>private static SelectList LoadItems&lt;T&gt;() where T : new, ... { // Add any additional interfaces // that need to be supported by T ...
Drupal - Apache's Mod_Deflate breaks CSS <p>We have enabled Apache's mod_deflate on our drupal site. From that point onwards, we are noticing that CSS files aren't getting loaded properly. It doesn't happen every time. Kinda random.</p> <p>Did anyone else notice this issue? If so, any suggested solutions?</p>
<p>You might have better luck with the <a href="http://drupal.org/project/css%5Fgzip" rel="nofollow">CSS Gzip module</a> than doing it with Apache directly.</p>
How to locate the theme folder in Asp.net? <p>I'm binding some image controls dynamically but don't set image URL. When I use a skin file and then set the SkinId, I get the following error:</p> <pre><code>The 'SkinId' property can only be set in or before the Page_PreInit event for static controls. For dynamic control...
<p>Set the SkinId on the markup</p> <pre><code>&lt;asp:Image runat="server" id="LogoImage" SkinId="LogoImage" /&gt; </code></pre> <p>To set it programatically you need to set it up on the PreInit event</p> <pre><code>public void Page_PreInit(object sender, EventArgs e) { LogoImage.SkinID = "LogoImage"; } </code></...
Where to stop/destroy threads in Android Service class? <p>I have created a threaded service the following way:</p> <pre><code>public class TCPClientService extends Service{ ... @Override public void onCreate() { ... Measurements = new LinkedList&lt;String&gt;(); enableDataSending(); } @Override pu...
<p><strong>Addendum</strong>: The Android framework provides many helpers for one-off work, background work, etc, which may be preferable over trying to roll your own thread in many instances. As mentioned in a below post, AsyncTask is a good starting point to look into. I encourage readers to look into the framework p...
Application log aggregation, management and notifications <p>I'm wondering what everyone is using for logging, log management and log aggregation on their systems.</p> <p>I am working in a company which uses .NET for all it's applications and all systems are Windows based. Currently each application looks after its ow...
<p>If you can, I'd recommend writing to the EventLog and creating rules in SCOM to monitor. We use this extensively and it works well, even to a point of putting together pieces of code which monitor certain elements of our apps and writing values to the event log, where SCOM parses for the errors, and graphs those, pl...
How to create sub domain from asp.net code <p>I need to create sub domain from code. For example my web site register new user named battulga. After automatically create battulga.mydomain.com. How to do this?</p>
<p>Here is a <a href="http://forums.asp.net/p/1267157/2384859.aspx" rel="nofollow">thread</a> about this in ASP.net forum.</p>
Operator overloading with memory allocation? <p>The sentence below is from, <strong><a href="http://www.artima.com/weblogs/viewpost.jsp?thread=252441" rel="nofollow">The Positive Legacy of C++ and Java</a></strong> by Bruce Eckel, about operator overloading in C++:</p> <blockquote> <p>C++ has both stack allocation a...
<p>I can imagine a couple possible interpretations:</p> <p>First, in C++ <code>new</code> and <code>delete</code> are both actually operators; if you choose to provide custom allocation behavior for an object by overloading these operators, you must be very careful in doing so to ensure you don't introduce leaks.</p> ...
Django ORM: caching and manipulating ForeignKey objects <p>Consider the following skeleton of a models.py for a space conquest game:</p> <pre><code>class Fleet(models.Model): game = models.ForeignKey(Game, related_name='planet_set') owner = models.ForeignKey(User, related_name='planet_set', null=True, blank=Tr...
<p>Django's ORM does not implement an <a href="http://en.wikipedia.org/wiki/Identity%5Fmap">identity map</a> (it's in the <a href="http://code.djangoproject.com/ticket/17">ticket tracker</a>, but it isn't clear if or when it will be implemented; at least one core Django committer has <a href="http://spreadsheets.google...
Error in C Program <p><code>while(((long)(1000*ratio*((long)clock()-(long)t0))%100)/1000)&lt;Data_Read_Rate);</code></p> <p>The above line is generating the following error: "Syntax Error before &lt; token".</p> <p>Why is this error coming up?</p> <p>I use MINGW32 for development(GCC compiler).</p> <p>Thanks...</p>...
<p>One paren is missing on the left. This will parse:</p> <pre><code>while ((((long)(1000*ratio*((long)clock()-(long)t0))%100)/1000)&lt;Data_Read_Rate); </code></pre> <p>Aside from the parse issue:</p> <ul> <li>Use an editor that highlights matching parentheses :)</li> <li>Why not calculate the time remaining until ...
Function Point Analysis in SAS <p>Would some be able to help me with some links on how FPA is done for SAS related projects.If someone of yuo have already done I guess it would be even more usefull if yuo could share some tips on how it could be done</p>
<p>I think the question is a bit too broad. FPA is a big subject area and has some general guidelines around how it is conducted. ( See a good article here: <a href="http://www.qpmg.com/fp-intro.htm" rel="nofollow">clicky</a> ) I don't know of any specific examples where SAS was incorporated. However this type of analy...
order by case and alias <p>How can I use</p> <pre><code>ORDER BY CASE @AccountOperator WHEN '&gt;' THEN AccountTrxValue END ASC, CASE @AccountOperator WHEN '&lt;' THEN AccountTrxValue END DESC </code></pre> <p>when AccountTrxValue is an alias and a result of the following in the "select"?</p> <pre><code>CASE WHEN...
<pre><code>ORDER BY CASE @AccountOperator WHEN '&gt;' THEN AccountTrxValue WHEN '&lt;' THEN -AccountTrxValue END </code></pre> <p>You should be allowed to use column aliases in the ORDER BY clause, assuming SQL Server</p> <p>Otherwise:</p> <pre><code>ORDER BY CASE @AccountOperator ...
Explicit nulling <p>In what situations in java is explicit nulling useful. Does it in any way assist the garbage collector by making objects unreachable or something? Is it considered to be a good practice?</p>
<p>In Java it <em>can</em> help if you've got a very long-running method, and the only reference to the an object is via a local variable. Setting that local variable to null when you don't need it any more (but when the method is going to continue to run for a long time) <em>can</em> help the GC. (In C# this is very r...
2 Mutually exclusive RadioButton "Lists" <p>I think this has to be THE most frustrating thing I've ever done in web forms. Yet one would think it would be the easiest of all things in the world to do. That is this:</p> <p>I need 2 separate lists of radiobuttons on my .aspx page. One set allows a customer to select an ...
<p>As you have two groups of radio buttons that you want to function as one group of radio buttons, the solution is simple: Make it one group of radio buttons.</p> <p>The only problem you have then is that the value that you get has the same name from both lists, but that can be solved by adding a prefix to the values...
where can I find a good delphi library? <p>I'm using delphi6, and it lacks the following abilities:</p> <ul> <li>a library object,</li> <li>a list object(looks like TList,TStringList is good enough?)</li> <li>a algorithm library(like sort,) </li> <li>template library like STL</li> <li>dynamic language feature or GC.</...
<p>Try <a href="http://sourceforge.net/projects/jcl/" rel="nofollow">Jedi Code Library</a>. There are good replacements for container classes and sorting algorithms. I don't think there is GC or STL-like library for Delphi 6. </p> <p>Delphi 6 is behind the times, check <a href="http://www.codegear.com/products/delphi/...
Django Imagefield not working properly via ModelForm <p>I'm certain I'm doing something really obviously stupid, but I've been trying to figure it out for a few hours now and nothing is jumping out at me.</p> <p>I'm using a ModelForm so I can expose a few fields from a model for editing. 2x ImageField, 1x TextField. T...
<p>Well I feel like an idiot. In order for Django to be able to process uploaded files, you need to pass the request.FILES variable to the form (makes sense, right?!) </p> <p>In my case the following line goes from:</p> <pre><code>f = AdminEditForm(request.POST, instance = company) </code></pre> <p>To:</p> <pre><co...
MSBuild, properties and imported files <p>Is it possible to run an msbuild task that populates a property or Item from an imported file "A" and then use these values in another file which imports file "A"?</p> <p>EDIT: FileX imports FileA and FileY imports FileA. One of FileA's property is changed in FileX. Can this c...
<p>Sorry its a bit confusing: </p> <p>Are you saying FileX imports FileA and FileY imports FileA. FileX sets property P in FileX but FileY reads it? If there is no relationship between X &amp; Y then the only way to do it would be use the fact that properties in MSBUILD overlap with evironment vars. So possbly calling...
Different format for whole numbers and decimal <p>is there a way of formatting a string to show whole numbers of a decimal number if it follows 00.</p> <p>example show 10 if number is 10.00. but show 10.2 if number is 10.2</p> <p>this is for c#, asp.net</p>
<p>In .NET:</p> <pre><code>if (Math.Floor(d) == d) return d.ToString("0"); else return d.ToString(); </code></pre>
Listen to events from preloader in flex <p>I have a preloader in my flex application:</p> <pre><code>public class Preloader extends DownloadProgressBar { private var _preloader:PreloaderAnimation; public function Preloader() { super(); _preloader = new PreloaderAnimation; addChi...
<p>The Preloader's INIT_COMPLETE event is fired after the preloader receives the Application's CREATION_COMPLETE event.</p> <p>The order of initialisation is this:</p> <ul> <li>Preloader starts loading your app;</li> <li>Application downloaded, starts initialising;</li> <li>Application is initialised, dispatches CREA...
Object Validation <p>I have an object which i need to validate. This object has properties which cannot be null, strings which cannot exceed a given size and date strings which i need to check for format correctness.</p> <p>How would you perform this validation. I don't want to go over the whole object, I'm looking fo...
<p>Without the exact scenario, I can recommend you use the object's setter methods (you <em>did</em> make the fields private, right?) to validate every change to the values. the String setters can call the length-validating code, the Date setters can call the format-validating code, etc.</p> <p>Hope this helps,</p> <...
Access events added with attachEvent() / addEventListener() in JavaScript <p>How can I access events added with <code>attachEvent()</code> / <code>addEventListener()</code> in JavaScript?</p> <p>Use case: debug events using FireBug's console.</p>
<p>There is no way to access them. </p> <p>Depending on what you're trying to achieve, better way to debug the events might be to output the <a href="http://www.quirksmode.org/js/events%5Fproperties.html">event properties</a> you're interested in from the event handler function...</p>
How to use 2 C libs that export the same function names <p><strong>Duplicate of the following question: <a href="http://stackoverflow.com/questions/678254/c-function-conflict">C function conflict</a></strong></p> <p><hr /></p> <p>Hi, in my current project I have to use some kind of interface lib. The function names a...
<p>Namespaces in C solved using library names prefixes like:</p> <p>libfoo --> foo_function1<br /> libbar --> bar_function1</p> <p>These prefixes are actual namespaces. so if you write libbar</p> <pre><code>int bar_function1(int a) { function1(a); } </code></pre> <p>This is the way to solve problems.</p> <p>C...
Game map from Code <p>It's a long one so you might want to get that cup of tea/coffee you've been holding off on ;)</p> <p>I run a game called World of Arl, it's a turn based strategy game akin to Risk or Diplomacy. Each player has a set of cities, armies and whatnot. The question revolves around the display of these ...
<p>I'd store a game map in code as a <a href="http://en.wikipedia.org/wiki/Graph%5F%28mathematics%29" rel="nofollow">graph</a>. </p> <p>Each node would represent a country/city and each edge would represent adjacency. Once you have a map like that, I'm sure you can find many resources on AI (pathfinding, strategy, e...
Constructor chaining with "this" <p>Why does the first constructor in ClassA cause the compiler error 'cannot use "this" in member intializer'?</p> <p>... or how can i get this to work?</p> <p>Thanks</p> <pre><code>public sealed class ClassA : IMethodA { private readonly IMethodA _methodA; public ClassA():t...
<p>You are allowed to use the <code>this(...)</code> syntax to invoke another constructor at the same level - however, you cannot use <code>this</code> (the current instance) in this context.</p> <p>The easiest option here is to duplicate the assignment code (<code>_methodA = methodA</code>).</p> <p>Another option mi...
Why is Internet Explorer 6 still a corporate favorite in some organizations? <p>... or</p> <p>How can I convince my organization to ditch Internet Explorer 6?</p> <p>Having to maintain Internet Explorer 6 compatibility when developing web applications is a nightmare - but until my client decides to ditch it as the o...
<p>Internet Explorer 6 has been around for ages, and the vast majority of websites and web applications work correctly with it.</p> <p>In order to change to a different browser (which, BTW, will probably be Internet Explorer 7), you need to, first of all, do a cost benefit analysis to justify this decision to everyone...
Where are the asp.net Dynamic Data limits? <p>What are the limitations of asp.net dynamic data?<br /> What is not possible to do in dynamic data, so that you have to use web forms?</p>
<p>Not sure what you mean DD just sits on top standard ASP.Net site so you can switch in an out of DD, the really great flexibility is that you can just use the bits of DD you need in your ASP.Net project (you don't need to scaffold the site) you can just make use of the business rules and FieldTemplate to speed develo...
C# to format (indent, align) C# properly <p>We have a code generator that <a href="http://www.codegeneration.net/tiki-index.php?page=CodeMungerModel" rel="nofollow">munges</a> the schema of a given database to automate our inhouse n-tier architecture. The output is various C# partial classes, one per file. </p> <p>I...
<p>Take a look at <a href="http://www.narrange.net/" rel="nofollow">Narrange</a>.You'll probably need to automate these things as part of the build.<br /> Not sure if it meets all your requirements though.<br /> <em>To quote:</em></p> <blockquote> <p>NArrange is a .NET code beautifier that automatically organizes ...
Safe JavasScript that calls PHP script that calls external web service <p>I have a PHP page that needs to make a call to a external web service. This Web service call takes a bunch of sensitive data from a html form on the PHP page, e.g. SSN, and returns info related to that person.</p> <p>The problem is that the web ...
<p>1) $.get("myscript.php", function(response) { alert(response) });</p> <p>2) I wouldn't encrypt using jQuery, it would be slow and easy to decrypt. Enabling SSL on the server would be a better solution.</p>
Use C++ CLI template class in C# <p>I have the following class in C++/CLI and an explicit template instantiation for the int primitive..</p> <pre><code>template&lt;typename T&gt; public ref class Number { T _value; public: static property T MinValue { T get() { return T::MinValu...
<p>Reflector is <em>lying</em> a little bit here. The name of the class is not actually Number&lt;int&gt;. It is actually 'Number&lt;int&gt;'. Notice the single quotes. These are only visible when you view the type name with ildasm. </p> <p>I <strong>believe</strong> this is done to make the type unbindable in mo...
TFS Branch/Merge meets History View <p>We have a setup with a development "trunk" in our recently-migrated-to-from-VSS TFS system and developers have been doing work in branches off the trunk, which are merged back in.</p> <p>We've been diligently commenting our changesets at check in time, something we never did in t...
<p>Looking at the history of a change prior to the merge has been a bit of a pain point with TFS. So much so that Microsoft have done a lot of work to address this in the next version of TFS (TFS 2010). In TFS 2010 (when it comes out), when you get to a merge in the history view it is actually a little twistie that yo...
Interface naming convention <p>This is a subjective thing of course, but I don't see anything positive in prefixing interface names with an 'I'. To me, <code>Thing</code> is practically always more readable than <code>IThing</code>.</p> <p>My question is, why does this convention exist then? Sure, it makes it easier t...
<p>Conventions (and criticism against them) all have a reason behind them, so let's run down some reasons behind conventions</p> <ul> <li><p><strong>Interfaces are prefixed as I to differentiate interface types from implementations</strong> - e.g., as mentioned above there needs to be an easy way to distinguish betwee...
How can one implement a Compact Directed Acyclic Word Graph (CDAWG) in C? <p>How would one implement <a href="http://www.i.kyushu-u.ac.jp/~takeda/papers/PSC01.pdf" rel="nofollow">this data structure</a> in C? It is a structure similar to but twice as space-efficient as the DAWG, that is more efficient than the trie whi...
<p>From what I can see from this <a href="http://www.i.kyushu-u.ac.jp/~takeda/papers/PSC01.pdf">paper</a></p> <p>It's a trie with suffix compression to reduce the final state changes for a match, since I'd worked on something similar that, I had also considered doing that to save space. This was the solution I had tho...
How to programmatically get SVN revision description and author in c#? <p>How do I programmatically get the revision description and author from the SVN server in c#?</p>
<p>Using <a href="http://sharpsvn.net/" rel="nofollow">SharpSvn</a>:</p> <pre><code>using(SvnClient client = new SvnClient()) { Collection&lt;SvnLogEventArgs&gt; list; // When not using cached credentials // c.Authentication.DefaultCredentials = new NetworkCredential("user", "pass")l SvnLogArgs la = ...
Binding DropDownList to an Enumeration <p>How do i bind a regular asp.net dropdownlist to an enum?</p>
<p>This page explains it well:</p> <p><a href="http://geekswithblogs.net/jawad/archive/2005/06/24/EnumDropDown.aspx" rel="nofollow">http://geekswithblogs.net/jawad/archive/2005/06/24/EnumDropDown.aspx</a></p>
Reader Writer Problem <p>Sorry if I am asking same question again but want to verify!</p> <p>I have two processes P1 and P2.</p> <p>P1 is a writer (Producer).<br /> P2 is a reader (Consumer).</p> <p>There is some shared memory or a file that P1 writes to and as soon as P1 writes, P2 should be notified for reading.<...
<p>The answer is: locking is necessary if (and only if) both threads can use the same shared resources at the same time. There isn't enough information about your specific implementation, but I have few remarks:</p> <ol> <li>Locking only during writing makes no sense. It only adds some overhead, but not prevent from a...
How many RewriteRules can you have in .htaccess without trouble? <p>Simple question. Is there a limit as to how many RewriteRules I can have in my .htaccess or can I put a zillion of them in there without Apache going all funky on me?</p> <p>Is there a relative limit where the server simply dives because there are to ...
<p>You have to know that the <a href="http://httpd.apache.org/docs/2.2/howto/htaccess.html#when">.htaccess configuration files are being processed on every request</a>.</p> <p>So if you have a .htaccess file with 1000 rules, the worst case is that every 1000 rules are tested every time a request hits this directory.</...
WPF label counterpart for HTML "for" attribute <p>Is there some attribute in WPF that I can add to element, so when I click it the target control get focus? The closest thing I have found is 'Target', but it works only with access keys and clicking it has no effect.</p>
<p>No, but an <a href="http://blogs.msdn.com/johngossman/archive/2008/05/07/the-attached-behavior-pattern.aspx" rel="nofollow">attached behavior</a> could be made to work for this.</p>
TDD in Visual Studio 2008 add-ins <p>I am trying to create an addin for Excel using Visual Studio 2008 and I would like to use Test Driven Development (TDD).</p> <p>Pure TDD would start from an empty solution.<br /> The following methods are autogenerated when creating a shared addin project: </p> <pre><code>public c...
<p>The code is generated by a framework and as such does not require testing. I would propose to exclude this code from code coverage (if you use that).</p>
How to link multiple visual studio solutions together? <p>I have 3 solutions and solution A requires built versions of the dlls from solution B and C in order to compile. it is not possible to merge it to one solution...</p> <p>So far it seems that Visual Studio doesnt support solution references and msbuild is clever...
<p>This question has popped up in <a href="http://stackoverflow.com/questions/200954/">different</a>, but <a href="http://stackoverflow.com/questions/284856/">related</a>, forms. There is actually an <a href="http://msdn.microsoft.com/en-us/library/ee817674.aspx">MSDN page that covers this</a>.</p> <p>What you're loo...
How can I change the view of an MS Access subform at runtime in VBA code? <p>This seems like it would be a simple affair, and I am sure I have done this before, but it has been a while since I have done any UI programming in Access. What I need to do is put a button on a form to toggle between datasheet and form view f...
<p>I found it on my own. I was missing it because it used the silly and clunky RunCommand syntax instead of a simple property or method on the control or form classes.</p> <p>It ain't pretty, but for posterity, here is the answer.</p> <pre><code>'You have to set focus to the subform control or the change view call wi...
Does a typed dataset use reflection at runtime? <p>Does a typed dataset use reflection on runtime?</p>
<p>No. It is just a code generated wrapper that completely compiled and does no reflection in runtime.</p>
OnLive: How does it work? <p><a href="http://www.onlive.com/" rel="nofollow">OnLive</a> is a cloud computing solution for gaming. It offers streaming of high-end games to any pc, regardless of its hardware. I wonder how it works: sending raw HD res image and audio data seems unlikely. Would relatively simple compressio...
<p>Have you read <a href="http://pc.ign.com/articles/965/965535p1.html" rel="nofollow">this</a> article? Excerpts thereof:</p> <blockquote> <p>It's essentially the gaming version of cloud computing - everything is computed, rendered and housed online. In its simplest description, your controller inputs are uploaded,...
Returning JSON from PHP to JavaScript? <p>I have a PHP script that's being called through jQuery AJAX. I want the PHP script to return the data in JSON format to the javascript. Here's the pseudo code in the PHP script:</p> <pre><code>$json = "{"; foreach($result as $addr) { foreach($addr as $line) { $jso...
<p>Php has an inbuilt JSON Serialising function.</p> <pre><code>json_encode </code></pre> <p><a href="http://nz.php.net/json%5Fencode">json_encode</a></p> <p><strong>Please</strong> use that if you can and don't suffer Not Invented Here syndrome.</p>
Java inheritance - added methods <p>I want to have a base class, <code>BaseConnect</code>, which contains an <code>OutputStream</code> and children classes <code>ObjectStreamConnect</code> and <code>DataStreamConnect</code>. In my <code>BaseConnect</code> class I have <code>OutputStream os;</code> And in my Two child...
<p>What you seem to be saying is "my two objects use some shared methods, and I'm sharing them through inheritance of a superclass".</p> <p>Then you get stuck because inheritance actually says "this <em>is</em> one of these, and so has this API" when it isn't - as your difficult-to-implement method suggests.</p> <p>I...
Getting Local Windows User login session timestamp in C# <p>I've been trying to look around the various .NET class library's for some where I can get the logged in user of the local machine, either connected to a domain or not. So far </p> <pre><code>System.Security.Principal.WindowsPrincipal LoggedUser = System.Thre...
<p>You can query Active Directory for much of the data that you need through LDAP queries using the <a href="http://msdn.microsoft.com/en-us/library/system.directoryservices.aspx" rel="nofollow">System.DirectoryServices</a> namespace. For example, the sample below shows the user's last logon time.</p> <p>Of course, th...
SQL create a temporary 'mapping' table in a select statement <p>I'm building up results by joining tables</p> <pre><code>select t1.*, t2.col2 from t1, t2 where t1.col1=t2.col1 </code></pre> <p>Is there a way to create a temporary 'mapping' table 'inline' in a select statement for instances where the t2 table doesn't ...
<p>Table with <code>1</code> row:</p> <pre><code>SELECT t1.*, t2.col2 FROM t1, ( SELECT 1 AS col2 FROM dual ) t2 </code></pre> <p>Table with <code>0</code> rows:</p> <pre><code>SELECT t1.*, t2.col2 FROM t1, ( SELECT 1 AS col2 FROM dual WHERE 1 = 0...
Adding OCX Control to a Resource Dialog (how Do I control it) <pre><code>I'm adding an OCX to a resource dialog that I've created in my C++ project. </code></pre> <p>The ocx adds properly; but my question is how do I access the ocx programatically?<br /> I don't see a member variable (or even a class) attached to it. ...
<p>When using MFC:</p> <ol> <li>In resource editor Right click in the OCX control,</li> <li>Select "Add Variable...",</li> <li>Put a name like m_object, then press finish to terminate.</li> </ol> <p>Now you can access your OCX control with m_object.</p> <p>If you want to resize your object you have to trap WM_WINDOW...
ASP.Net MVC have An Action render another Action <p>I have two pages I need, and want to show for the url /index and /review. The only difference between the two pages is on the review I will have a review comment section to show and Submit button. Otherwise the two pages are identical. I thought I could create a u...
<p><strong>Model example</strong></p> <pre><code>public class MyModel { public bool ShowCommentsSection { get; set; } } </code></pre> <p><strong>Controller actions</strong></p> <pre><code>public ActionResult Index() { var myModel = new MyModel(); //Note: ShowCommentsSection (and the bool type) is false by def...
java.net.SocketException: Broken pipe <p>I am getting this for all the database connections from my app server..<br /> This exception occured for couple of hours, then got fixed by itself.<br /> Something to do with network connection from the appserver?</p> <pre> java.net.SocketException: Broken pipe com.inet.tds.SQL...
<p>For MySQL, "By default, the server closes the connection after eight hours if nothing has happened." And, MySQL has a reconnect feature that supports auto-reconnect after the closed connection is detected on the client side.</p> <p>Eight hours? With the use of connection pooling or a long-running background job, th...
Does F# provide you automatic parallelism? <p>By this I meant: when you design your app side effects free, etc, will F# code be automatically distributed across all cores?</p>
<p>No, I'm afraid not. Given that F# isn't a <em>pure</em> functional language (in the strictest sense), it would be rather difficult to do so I believe. The primary way to make good use of parallelism in F# is to use <strong>Async Workflows</strong> (mainly via the Async module I believe). The TPL (Task Parallel Libra...
Returning a host object in Rhino <p>What is the best way to return an host object to JavaScript in Rhino? I have two classes like this:</p> <pre><code>public class Hosted extends org.mozilla.javascript.ScriptableObject { private static final long serialVersionUID = 1; public Hosted() {} public void jsConst...
<pre><code> public Scriptable jsGet_member() { Scriptable scope = ScriptableObject.getTopLevelScope(this); Member m = new Member(); m.setParentScope(scope); // defineClass("Member") must have previously been called. m.setPrototype(ScriptableObject.getClassPrototype(scope, "Mem...
Rotation and Scaling -- How to do both and get the right result? <p>I've got a set of Java2D calls that draw vectors on a graphics context. I'd like for the image to be doubled in size and then rotated 90 degrees.</p> <p>I'm using the following code to do this:</p> <pre><code>Graphics2D g2 = // ... get graphics 2d s...
<p>I believe those transforms are implemented like a stack - so the last transform is performed first. Try reversing the order of the rotate and scale transformations and you should get what you are looking for.</p> <pre><code>newTransform.concatenate(AffineTransform.getTranslateInstance(x1, x2)); newTransform.concat...
Unix - substitution <p>i have problem with substitution. I have a file with 1 line of random characters with brackets "{}" around 1 character. I want to move with these brackets on the previous character or on the next one. (I know how to do it if the line of character is still, non-changing.) But I wonder how to do it...
<p>Move backward one character:</p> <pre><code>sed -e 's/\(.\){\(.\)}/{\1}\2/g' file </code></pre> <p>Move forward one character:</p> <pre><code>sed -e 's/{\(.\)}\(.\)/\1{\2}/g' file </code></pre> <p>To modify the file in-place, use the <code>-i</code> flag:</p> <pre><code>sed -i -e 's/\(.\){\(.\)}/{\1}\2/g' file ...
ASP.NET MVC on Mono <p>what steps should I perform in order to run asp.net mvc 1.0 web application on mono?</p>
<p>It requires the same steps as for 3.0.<br /> minus</p> <pre><code>System.Web.Razor.dll System.Web.WebPages.Razor.dll </code></pre> <p>But why do you even want to run a 1.0 application, when 4.0 works already ?</p> <p>Here: <br /> <a href="http://stackoverflow.com/questions/4239645/does-the-razor-view-engine-wor...
Why does my Perl script complain about 'Global symbol "$connection" requires explicit package name'? <pre><code>my $now = &amp;GetDate; my $myHeader = &amp;ReadMessage; my $mySoftwareVersions = param('mySoftwareVersions'); my $q = new CGI;print $q-&gt;header(); use CGI::Carp(fatalsToBrowser); getAllSoftwareVersions();...
<p>Although Kent's answer is thinking ahead, the error is simply telling you that you did not <em>declare</em> <code>$connection</code> as a lexical ( "my" ) variable. So therefore, perl interprets it as that you must be referring to a package global. </p> <p>Raw Perl does not complain when you use an undefined variab...
DeleteOnSubmit LINQ exception "Cannot add an entity with a key that is already in use" <p>edit: in case anyone is wondering, the actionhandler invokes code that creates and disposes the same kind of datacontext, in case that might have anything to do with this behaviour. the code doesn't touch the MatchUpdateQueue tabl...
<p>You could do something to the effect of </p> <pre><code>db.MatchUpdateQueues.DeleteOnSubmit(db.MatchUpdateQueues.Single(theItem =&gt; theItem == item)); </code></pre> <p>Just a note as other answers hinted towards Attach.. you will not be able to use attach on a context other then the original context the item was...
Persisting the state column on transition using rubyist-aasm (acts as state machine) <p>What is the best way to persist the object's state to the database on a transition using aasm? I had thought that this would happen automatically but this doesn't seem to be the case.</p> <p>(Edit: when I manually save the object, ...
<p>If you call the <em>bang!</em> form of the transition event method, the state will persist. For example, say you have an object with the following event:</p> <pre><code>class Book &lt; ActiveRecord::Base # ... aasm_event :close do transitions :to =&gt; :closed, :from =&gt; [:opened] end # ... end </...
Using acts_as_list and in_place_editing at the same time <p>I have a rails project where the the view displays a list of items. I use acts_as_list to make the list DnD orderable and in_place_editing on each item to, well, edit it.</p> <p>My problem is that when I DnD the items around, the item I drag automagically be...
<p>This happens because the element you are dragging has a listener on mouseup that begins the edit. You can specify an :external_control in the options hash if you want a different element to trigger the edit.</p> <pre><code>&lt;div id="&lt;%= dom_id(@obj) -%&gt;"&gt; &lt;span&gt;&lt;%= @obj.to_s -%&gt;&lt;/span&gt...
Why does CreateDIBSection() fail when the window is offscreen? <p>I'm building a Delphi component to embed an <a href="http://www.libsdl.org" rel="nofollow">SDL</a> rendering surface on a VCL form. It works just fine as long as the form is on-screen at the moment that the SDL surface is created. Otherwise, it's not ab...
<p>Just an idea.... Have you watched the window Handle? Isn't it butchered and recreated?</p>
Load old XML data into new version of InfoPath form <p>We have an ASP.NET application with an InfoPath forms component, delivering InfoPath forms to the browser using InfoPath Forms Server. Rather than save the forms in SharePoint, we submit the XML form data to a ASP.NET web service, which saves the data as an XML da...
<p>It's been a while since I did anything InfoPath, so apologies for this being a little vague:</p> <p>Part of the InfoPath template, which is pretty much just a ZIP archive with a different extension, is a file called "upgrade.xsl". This file contains one or more XSL transformations that "upgrade" documents targeting...
SQL language differences between MSSQL 2000 and 2005 <p>My company has an application developed for SQL Server 2005 (among others), and a potential client is attempting to install it on SQL Server 2000. Naturally, installation failed. Specifically, it failed with syntax errors in our CREATE TABLE statements.</p> <p>...
<p>You can take a look at the list of breaking changes <a href="http://technet.microsoft.com/en-us/library/ms143532%28SQL.90%29.aspx" rel="nofollow">here</a> at technet.</p>
How do I make a field global to my site? <p>Okay, this is a bit abstract, but here goes:</p> <p>I'm creating a website and I want to have a field, "foo", that I can access from any page on the site. I figured the best way to do this would be to create a subclass of Page called "bar", add the protected field "foo" to...
<p>If you need every user to have their own instance you can store it in the session. </p> <pre><code> Session["foo"]=data; </code></pre> <p>Then on your other pages you can use:</p> <pre><code> Control ctl = (Control) Session["foo"]; </code></pre> <p>Keep in mind you will have to cast Session["foo"] to whatever t...
Is this extern harmless? <p>main.h</p> <pre><code>extern int array[100]; </code></pre> <p>main.c</p> <pre><code>#include "main.h" int array[100] = {0}; int main(void) { /* do_stuff_with_array */ } </code></pre> <p>In the main.c module, the array is defined, and declared. Does the act of also having the e...
<p>The correct interpretation of <code>extern</code> is that you tell something to the <strong>compiler</strong>. You tell the compiler that, despite not being present right now, the variable declared will somehow be found by the linker (typically in another object (file)). The linker will then be the lucky guy to find...
Getting the "diff" between two arrays in C#? <p>Let's say I have these two arrays:</p> <pre><code>var array1 = new[] {"A", "B", "C"}; var array2 = new[] {"A", "C", "D"}; </code></pre> <p>I would like to get the differences between the two. I know I could write this in just a few lines of code, but I want to make sure...
<p>If you've got LINQ available to you, you can use <a href="http://msdn.microsoft.com/en-us/library/system.linq.enumerable.except.aspx"><code>Except</code></a> and <a href="http://msdn.microsoft.com/en-us/library/system.linq.enumerable.distinct.aspx"><code>Distinct</code></a>. The sets you asked for in the question ar...
How to make a window always stay on top in .Net? <p>I have a C# winforms app that runs a macro in another program. The other program will continually pop up windows and generally make things look, for lack of a better word, crazy. I want to implement a cancel button that will stop the process from running, but I cann...
<p><code>Form.TopMost</code> will work unless the other program is creating topmost windows. </p> <p>There is no way to create a window that is not covered by new topmost windows of another process. Raymond Chen <a href="http://blogs.msdn.com/oldnewthing/archive/2005/06/07/426294.aspx">explained</a> why. </p>
Assigning values to Instance variables in Objective C <p>The function I'm looking at:</p> <pre><code>-(void)viewDidLoad { NSBundle *bundle = [NSBundle mainBundle]; NSString *plistPath = [bundle pathForResource:@"statedictionary" ofType:@"plist"]; NSDictionary *dictionary = [[NSDictionary alloc] initWithCo...
<p>No one seems to have addressed the fact that the line</p> <pre><code>self.statesZips = dictionary; </code></pre> <p>is not directly an instance variable assignment. <code>stateZips</code> is a property, and so that line of code calls the <code>setStateZips:</code> method. That method retains or copies the dictiona...
DRY LINQ statements for tables with common columns <p>Here's an interesting problem. Is there a way to write some code using LINQ to SQL which is capable of performing a table UPDATE knowing only that the table it is given contains columns x, y, z but not knowing at compile time which table it is dealing with?</p> <p>...
<p>Simply create a base class for your entities and move the common properties to it as virtual properties. Override these properties in your entities and specify Column attributes on them. Here's a detailed <a href="http://blogs.msdn.com/dinesh.kulkarni/archive/2007/11/09/linq-to-sql-how-to-2-base-class-for-all-entiti...