instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I am looking for a Regular expression to match only if a date is in the first 28 days of the month. This is for my validator control in ASP.NET</p>
| <p>Don't do this with Regex. Dates are formatted differently in different countries. Use the DateTime.TryParse routine instead:</p>
<pre><code>DateTime parsedDate;
if ( DateTime.TryParse( dateString, out parsedDate) && parsedDate.Day <= 28 )
{
// logic goes here.
}
</code></pre>
<p>Regex is nearly the <a... | <p>Why not just covert it to a date data type and check the day? Using a regular expression, while it could be done, just makes it overly complicated.</p>
| 7,252 |
<p>How have you guys handled working with jQuery includes </p>
<pre><code><script type="text/javascript" src="jquery.js"></script>
</code></pre>
<p>in Asp.Net MVC when working with partial views/view controls? Basically, I don't want to make the jquery include in the master page because I am not using jq... | <p>If you use JQuery in a high percentage of your pages, I'd just put it in the master page. It's only going to be downloaded once at which point it's cached on the browser and will have negligible impact on perf for rendering your page.</p>
| <p>You could always do this:</p>
<p>make a lightweight util.js that is in every page, in it you could put various common stuff, plus this:</p>
<pre><code>function loadJSInclude(scriptPath, callback)
{
var scriptNode = document.createElement('SCRIPT');
scriptNode.type = 'text/javascript';
scriptNode.src = ... | 34,640 |
<p>Has anyone got to some good code to zoom into an image using javascript?</p>
<p>I know I could just resize it etc but was being lazy and looking for something clever to zoom to different levels, move around when zoomed etc</p>
| <p>This really depends on what quality you are after. If you need a hires hiquality image with detailed zoom levels and proper interpolation you will need to write a backend service to serve up zoomed portions of your images. If you have no care for quality or speed, you could download the entire image and fit it to di... | <p>Check this:</p>
<ul>
<li><a href="http://www.mind-projects.it/blog/jqzoom_v10" rel="nofollow noreferrer">jQZoom</a></li>
<li><a href="http://www.eyecon.ro/zoomimage/" rel="nofollow noreferrer">Zoomimage - jQuery plugin</a></li>
<li><a href="http://plugins.jquery.com/project/imgzoom" rel="nofollow noreferrer">jQuery... | 23,666 |
<p>It seems to me that phpMyAdmin imports tables by default with collation latin1_swedish_ci, how i change this?</p>
| <p>In your Mysql configuration change the default-character-set operative under the [mysqld] tab. For example:</p>
<pre><code>[mysqld]
default-character-set=utf8
</code></pre>
<p>Don't forget to restart your Mysql server afterwards for the changes to take effect.</p>
| <p>I wanted to use utf8mb4 instead, and the configuration had to be the following:</p>
<pre><code>collation_server = utf8mb4_general_ci
character_set_server=utf8mb4
</code></pre>
<p>the server would not start if the character_set was set to <code>utf8</code></p>
| 18,558 |
<p>In my limited experience with them executable requirements (i.e. specifying all requirements as broken automated tests) have proven to be amazingly successful. I've worked on one project in which we placed a heavy emphasis on creating high-level automated tests which exercised all the functionality of a given use c... | <p>The primary tool I've also used was FitNesse. I've used it at several companies, with very good results. We did have test cases numbering in the many thousands, and we had to be very disciplined in how we organized and used them.</p>
<p>I've tried some other tools, including writing my own DSL (domain-specific lang... | <p>My experience is limited to personal projects and found much the same advantages you mentioned. I recommend <a href="http://metacpan.org/pod/Test::Simple::Tutorial" rel="nofollow noreferrer">http://metacpan.org/pod/Test::Simple::Tutorial</a> which was my inspiration for trying out testing-based development. The pe... | 3,388 |
<p>I've used the StAX API in Java quite a bit, and find it quite a clean way of dealing with XML files. Is there any equivalent library I could use for performing similar processing in C?</p>
| <p><a href="http://xmlsoft.org/" rel="nofollow noreferrer">libxml</a> is a heavily used and documented XML library for C, which provides a SAX API. <a href="http://expat.sourceforge.net/" rel="nofollow noreferrer">Expat</a> is another, but in my experience is not as well documented.</p>
| <p>Expat does StAX</p>
<p><pre><code>
#include "expat.h"`
VRM_parser = XML_ParserCreate("ISO-8859-1");
XML_SetElementHandler(VRM_parser, CbStartTagHandler, CbEndTagHandler);
XML_Parse(VRM_parser, text, strlen(text), 0); // start of XML
XML_Parse(VRM_parser, text, strlen(text), 0); // more XML
XML_Parse(VRM_parser, te... | 5,812 |
<p>How can I optimize the following code, which currently takes over 2 minutes to retrieve and loop through 800+ records from a pool of over 100K records, returning 6 fields per record (adds approximately 20 seconds per additional field):</p>
<pre><code><cfset dllPath="C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\S... | <p>How large is the list of items for the inner loop?</p>
<p>Switching to an array <em>might</em> be faster if there is a significantly large number of items.</p>
<p>I have implemented this alongside x0n's suggestions...</p>
<pre><code><cfset dllPath="C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.DirectoryS... | <p>I would think that you'd want to stop doing so many evaluations inside of your loops and instead use variables to hold counts, pointers to the col object and to hold your pipe-delim string until you're ready to commit to the query object. If I've done the refactoring correctly, you should notice an improvement if yo... | 11,025 |
<p>I am trying to mock out HttpContext so that I can unit test my controller's Request.IsAuthenicated call. I am using the <a href="http://www.hanselman.com/blog/ASPNETMVCSessionAtMix08TDDAndMvcMockHelpers.aspx" rel="noreferrer">code that I found at Scott Hanselman's</a> blog to simulate HttpContext using rhino.mocks. ... | <p>This should work:</p>
<pre><code>PostsController postsController = new PostsController(postDL);
var context = mocks.Stub<HttpContextBase>();
var request = mocks.Stub<HttpRequestBase>();
SetupResult.For(request.IsAuthenticated).Return(true);
SetupResult.For(context.Request).Return(request);
postsCont... | <p>Now, for disclosure, I have yet to get my hands dirty with most of the stuff you are working with, however:</p>
<p>If you want to mock the IsAuthenticated, why not just create a static class to return a bool that can the be manipulated by your test code?</p>
<p>This is a bit rough round the edges, but hopefully yo... | 29,577 |
<p>I've got a windows form in Visual Studio 2008 using .NET 3.5 which has a WebBrowser control on it. I need to analyse the form's PostData in the Navigating event handler before the request is sent. Is there a way to get to it?</p>
<p>The old win32 browser control had a Before_Navigate event which had PostData as o... | <p>That functionality isn't exposed by the .NET WebBrowser control. Fortunately, that control is mostly a wrapper around the 'old' control. This means you can subscribe to the BeforeNavigate2 event you know and love(?) using something like the following (after adding a reference to SHDocVw to your project):</p>
<pre><... | <h2>C# version</h2>
<pre><code> /// <summary>
/// Fires before navigation occurs in the given object (on either a window or frameset element).
/// </summary>
/// <param name="pDisp">Object that evaluates to the top level or frame WebBrowser object corresponding to the navigation.</p... | 17,117 |
<p>I have an idea about what it is. My question is :-</p>
<p>1.) If i program my code which is amenable to Tail Call optimization(Last statement in a function[recursive function] being a function call only, no other operation there) then do i need to set any optimization level so that compiler does TCO. In what mode o... | <p>Most compilers support TCO, it is a relatively old technique. As far as how to enable it with a specific compiler, check the documentation for your compilers. gcc will enable the optimization at every optimization level except -O1, I think the specific option for this is <code>-foptimize-sibling-calls</code>. As ... | <p>If you want your compiler to do tail call optimization, just check either </p>
<p>a) the doc of the compiler at which optimization level it will be performed or</p>
<p>b) check the asm, if the function will call itself (you dont even need big asm knowledge to spot the just the symbol of the function again)</p>
<p... | 40,123 |
<p>I run a non-profit designed to expose high school students to 3D printing and entrepreneurship. The concept is based on pop-up shop-style sales of 3D printed trinkets, toys, artifacts, etc.</p>
<p>Can I legally sell models we print from the many open source and publicly available museum collections that are availabl... | <h1>Not all museum pieces are out of copyright!</h1>
<p>Let's start with a general primer: an Artwork is out of copyright if it was made by someone that died more than about 70 years ago. For items created by companies a different rule applies.</p>
<p>When the copyright on an artwork lapses, anyone can reproduce it.</p... | <p>Just read the license that comes with the STL. Most I have seen prohibit commercial use without permission.</p>
<blockquote>
<p>good places to find fully licensed models that we could sell without having to worry about copyright infringement.</p>
</blockquote>
<p>Draw them yourself and there's no issues. Or buy the ... | 2,159 |
<p>The Drupal API has <a href="http://api.drupal.org/api/function/drupal_get_path/6" rel="noreferrer"><code>drupal_get_path($type, $name)</code></a> which will give the path of any particular theme or module. What if I want the path of the current theme?</p>
| <p>Use the <a href="http://api.drupal.org/api/function/path_to_theme/6" rel="noreferrer"><code>path_to_theme</code></a> function.</p>
| <p>For D8, the theme folder is available in preprocess functions: </p>
<pre><code>function hook_preprocess_page(&$variables) {
$variables['some_logo_file'] = "/{$variables['theme']['path']}/images/logo.png";
}
</code></pre>
<p>page.html.twig: </p>
<pre><code><img src="{{ logo_src }}">
</code></pre>
| 39,027 |
<p>If I've got an array of values that are basically zerofilled string representations of various numbers and another array of integers, will <code>array_intersect()</code> still match elements of different types?</p>
<p>For example, would this work:</p>
<pre><code>$arrayOne = array('0003', '0004', '0005');
$arrayTwo... | <p>$ cat > test.php</p>
<pre><code><?php
$arrayOne = array('0003', '0004', '0005');
$arrayTwo = array(4, 5, 6);
$intersect = array_intersect($arrayOne, $arrayTwo);
print_r($intersect );
?>
</code></pre>
<p>$ php test.php </p>
<p>Array
(
)</p>
<p>$</p>
<p>So no, it will not. But if you add </p>
<pre><co... | <p>From <a href="http://it2.php.net/manual/en/function.array-intersect.php" rel="nofollow noreferrer">http://it2.php.net/manual/en/function.array-intersect.php</a>:</p>
<blockquote>
<pre><code>Note: Two elements are considered equal if and only if
(string) $elem1 === (string) $elem2.
In words: when the string represe... | 32,416 |
<p>In some existing code there is a test to see if the user is running IE, by checking if the object Browser.Engine.trident is defined and returns true.</p>
<p>But how can I determine if the user is running IE6 (or earlier) or IE7 (or later)?</p>
<p>The test is needed inside a JavaScript function so a conditional com... | <p>From <a href="http://msdn.microsoft.com/en-us/library/ms537509.aspx" rel="noreferrer">detecting Internet Explorer More Effectively</a> at msdn:</p>
<pre><code>function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
var rv = -1; // Ret... | <p>This is the script I use and it seems to work well enough:</p>
<pre><code>// Returns 0 if the browser is anything but IE
function getIEVersion() {
var ua = window.navigator.userAgent;
var ie = ua.indexOf("MSIE ");
return ((ie > 0) ? parseInt(ua.substring(ie+5, ua.indexOf(".", ie))) : 0);
}
</code></pre>... | 35,528 |
<p>How would one structure a table for an entity that can have a one to many relationship to itself? Specifically, I'm working on an app to track animal breeding. Each animal has an ID; it's also got a sire ID and a dame ID. So it's possible to have a one to many from the sire or dame to its offspring. I would be i... | <p>Well, this is a "normal" one-to-many relationship and the method you suggest is the classical one for solving it.</p>
<p>Note that two tables are denormalized (I can't point out exactly where the superkey-is-not-well-should-be-subset-of-other-key-fsck-I-forgot part is, but I'm pretty sure it's there somewhere); the... | <p>Use the "connect by" clause with SQL to tell it which hierarchy to follow.</p>
| 19,344 |
<p>Specifically in .NET, but I'm leaving it open.</p>
| <p>MSDN:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/0yf5t4e8(VS.71).aspx" rel="nofollow noreferrer">Enumerating Installed Fonts</a></p>
| <p>I believe what you are looking for is InstalledFontCollection.
(What were the chances that the ONE piece of code that required .net would be relevant to anything here! It boggles the mind!)</p>
| 11,532 |
<p>I'm doing some revision on an old app that is written in classic ASP/VbScript.</p>
<p>It has a feature to send out an e-mail to the members of the application, but because the member list is quite large, the server rejects new e-mails after the first hundred or so are sent.</p>
<p>I've written some code to make it... | <p>Not to my knowledge. You'll have to use some external code written in class VB or whatever to do it.</p>
<p>Or busy-wait (gak).</p>
| <p>The answer is don't use the server to wait, use the client.
You can write a javascript that keeps calling Send() every second using <a href="http://www.w3schools.com/jsref/met_win_setinterval.asp" rel="nofollow">setInterval</a> until the queue is empty.Use an <a href="http://api.jquery.com/jquery.ajax/" rel="nofollo... | 49,771 |
<p>I'm trying to programmatically set the constructor sting of a COM+ component from a C# application. I found the following sample code online, but it throws an exception:</p>
<pre><code> COMAdminCatalogCollection Components;
COMAdminCatalogClass Catalog = new COMAdminCatalogClass();
string st... | <p>I found a way to avoid the exception. Rather than doing this in C#, I can take advantage of VB.NET's optional weak typing to remove all of the casts and a couple of the variable declaration types. The resulting code looks like this:</p>
<pre><code> Dim Components As COMAdminCatalogCollection
Dim Catalog As... | <p>I'm sure you have moved well passed this but I am working on a project currently that needs a similar functionality and I was able to come up with a solution using .NET and PowerShell to do so. First I created a custom cmdlet in C# as follows: </p>
<pre><code>using COMAdmin;
using System;
using System.Runtime.Inter... | 38,833 |
<p>I just saw <a href="http://www.codeplex.com/CloneDetectiveVS" rel="nofollow noreferrer">Clone Detective</a> linked on YCombinator news, and the idea heavily appeals to me. It seems like it would be useful for many languages, not just C#, but I haven't seen anything similar elsewhere.</p>
<p>Edit: For those who don'... | <p>I don't think this is a concern.</p>
<p>Yes, the mythical "somebody" can replace the implementation of MD5 with something insecure. But in order to do that, the mythical somebody must actually be able to get his code into the Ruby process. And if he can do that, then he presumably could also inject his code into a ... | <p>If someone monkeypatched an object or a module, then you need to look at 2 cases: He added a new method. If he is the only one adding this meyhod (which is very likely), then no problems arise. If he is not the only one, you need to see if both methods do the same and tell the library developer about this severe pr... | 5,224 |
<p>My dad called me today and said people going to his website were getting 168 viruses trying to download to their computers. He isn't technical at all, and built the whole thing with a WYSIWYG editor.</p>
<p>I popped his site open and viewed the source, and there was a line of Javascript includes at the bottom of th... | <p>Try and gather as much information as you can. See if the host can give you a log showing all the FTP connections that were made to your account. You can use those to see if it was even an FTP connection that was used to make the change and possibly get an IP address.</p>
<p>If you're using a prepacked software lik... | <p>We had been hacked from same guys apparently! Or bots, in our case. They used SQL injection in URL on some old classic ASP sites that nobody maintain anymore. We found attacking IPs and blocked them in IIS. Now we must refactor all old ASP.
So, my advice is to take a look at IIS logs first, to find if problem is in ... | 2,510 |
<p>The DOM method <code>getChildNodes()</code> returns a <code>NodeList</code> of the children of the current <code>Node</code>. Whilst a <code>NodeList</code> is ordered, is the list guaranteed to be in document order?</p>
<p>For example, given <code><a><b/><c/><d/></a></code> is <code>a... | <p>In my experience, yes. The <a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1451460987" rel="nofollow noreferrer">DOM spec</a> isn't any clearer. If you're paranoid, try something like</p>
<pre><code>current = node.firstChild;
while(null != current) {
...
current = current.nextS... | <p>I'd love to tell you that this is guaranteed (as I believe it is) but the <a href="http://www.w3.org/DOM/" rel="nofollow noreferrer">Document Object Model specification</a> itself seems ambiguous in this case. I'm pretty sure that it's always document-order, though.</p>
| 9,171 |
<p>I'm doing some testing on Firefox toolbars for the sake of learning and I can't find out any information on how to store the contents of a "search" drop-down inside the user's profile.</p>
<p>Is there any tutorial on how to sort this out?</p>
| <p>Since it's taking quite a bit to get an answer I went and investigate it myself.
Here is what I've got now. Not all is clear to me but it works.</p>
<p>Let's assume you have a <textbox> like this, on your .xul:</p>
<pre><code><textbox id="search_with_history" />
</code></pre>
<p>You now have to add so... | <p>Gustavo,
I wanted to do the same thing - I found an answer <a href="http://support.mozilla.com/tiki-view_forum_thread.php?locale=sk&comments_parentId=193208&forumId=1" rel="nofollow noreferrer">here</a> on the Mozilla support forums. (Edit: I wanted to save my search history out of interest, not because I wa... | 14,616 |
<p>Apparently you can easily obtain a client IP address in WCF 3.5 but not in WCF 3.0. Anyone know how?</p>
| <p>This doesn't help you in 3.0, but I can just see people finding this question and being frustrated because they are trying to get the client IP address in 3.5. So, here's some code which should work:</p>
<pre><code>using System.ServiceModel;
using System.ServiceModel.Channels;
OperationContext context = OperationC... | <p>You can if you are targeting .NET 3.0 SP1.</p>
<pre><code>OperationContext context = OperationContext.Current;
MessageProperties prop = context.IncomingMessageProperties;
RemoteEndpointMessageProperty endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
string ip = endpoint.Address;... | 11,867 |
<p>Should I use them as separate releases? Do I check them back into trunk or branches? Is this all in the red book and I've just wasted your time?</p>
| <p>Do not forget that a tag and a <a href="https://stackoverflow.com/questions/333785#333809">branch</a> are essentially the same thing in SVN: both are the result of <code>svn copy</code></p>
<p>The trick is, since a tag represents a snapshot, it should be an "immutable" one, in that you should not make any modificat... | <p>I prefer following structuring of my <em>tags</em> repository directory:</p>
<pre><code>/tags
/builds
/PA
/A
/B
/releases
/AR
/BR
/RC
/ST
</code></pre>
<p><code>PA</code> means <strong>pre-alpha</strong>
<code>A</code> means <strong>alpha</strong>
<c... | 48,668 |
<p>I've read the book <a href="http://oreilly.com/catalog/9780596529321/" rel="noreferrer" title="Programming Collective Intelligence">Programming Collective Intelligence</a> and found it fascinating. I'd recently heard about a challenge amazon had posted to the world to come up with a better recommendation engine for... | <p>You don't want to use "overall popularity" unless you have no information about the user. Instead, you want to align this user with similar users and weight accordingly.</p>
<p>This is exactly what <a href="http://en.wikipedia.org/wiki/Bayesian_inference" rel="noreferrer">Bayesian Inference</a> does. In English, ... | <p>@Lao Tzu, I agree with you.</p>
<p>According to me, recommendation engines are made up of: </p>
<blockquote>
<ul>
<li>Context Input fed from context aware systems (logging all your data)</li>
<li>Logical reasoning to filter the most obvious</li>
<li>Expert systems that improve your subjective data over the... | 7,778 |
<p>Why is <code>Array.Length</code> an int, and not a <code>uint</code>. This bothers me (just a bit) because a length value can never be negative. </p>
<p>This also forced me to use an int for a length-property on my own class, because when you
specify an int-value, this needs to be cast explicitly...</p>
<p>So the... | <p>Unsigned int isn't CLS compliant and would therefore restrict usage of the property to those languages that do implement a <code>UInt</code>. </p>
<p>See here:</p>
<p>Framework 1.1</p>
<blockquote>
<p><a href="http://msdn.microsoft.com/en-us/library/hfa3fa08(VS.71).aspx" rel="noreferrer">Introduction to the .NE... | <p>Typically, integer values are signed, unless you explicitly need an unsigned value. It's just the way they are used. I may not agree with that choice, but that's just the way it is.</p>
<p>For the time being, with todays typical memory constraints, if your array or similar data structure needs an UInt32 length, you... | 2,806 |
<p>My current project involves deploying an upgraded .exe file that runs as a Windows Service. In order to overwrite the existing .exe with the new version, I currently need to:</p>
<ol>
<li>Stop the service</li>
<li>Uninstall the service</li>
<li>Reboot the system (so Windows releases it's hold on the file)</li>
<li... | <pre><code>sc delete "service name"
</code></pre>
<p>will delete a service. I find that the <a href="http://technet.microsoft.com/en-us/library/bb490995.aspx" rel="noreferrer">sc utility</a> is much easier to locate than digging around for installutil. Remember to stop the service if you have not already.</p>
| <p>I am using the InstallUtil.exe packed with .NET Framework.</p>
<p>The usage to uninstall is: InstallUtil '\path\to\assembly\with\the\installer\classes' /u so for example: <code>installutil MyService.HostService.exe /u</code></p>
<p>The <code>/u</code> switch stands for uninstall, without it the util performs norma... | 38,393 |
<p>What role is Spring taking in Struts + Spring + Hibernate?</p>
| <p>Spring provides many different "modules" and different programmers will use different parts of Spring.</p>
<p>However, commonly in this sort of stack, you will see Spring being used as a provider of</p>
<ul>
<li>An inversion of control container for dependency injection</li>
<li>An abstraction to Hibernate called ... | <p>Well to add;</p>
<p>(Views and Controllers) Struts for its extensive JSP features with Struts tags and web request handling features</p>
<p>(Service and application management) Spring to handle the ORM and service layers with its excellent dependency injections,etc.</p>
<p>(ORM with db independence) Hibernate for... | 19,632 |
<p>My application hangs. Pressing the home button doesn't return to the springboard anymore. Additionally pressing the power button for 10 seconds doesn't turn the iphone off at all.</p>
<p>Is there any way to force a shutdown?</p>
| <p>1 - To 'Force Quit' an iPhone application, hold down the Home button for up to 5 seconds.</p>
<p>2 - To force a reset (in rare occassions when 1 does not work), hold down the Power and Home buttons together for 10 seconds.</p>
<p>(this is documented in a Apple Support article - <a href="http://support.apple.com/kb... | <p>My iPhone hanged during boot when it tried to reset & erase all the iphoe contents.</p>
<p>Following are the steps to get your iPhone booting in Recovery Mode:
Step 1: Before getting the iphone in recovery mode, Open iTunes on your MAC or PC & attach the cable to iPhone.
Step 2: Hold down the Power & Ho... | 28,321 |
<p>I have an application that is currently running against a 32-bit SQL Server 2005 Standard Edition database. For reasons I won't go into here, I need to move the database to a 64-bit SQL Server 2005 Standard edition running on 64-Bit Windows Server 2003 R2 Datacenter. </p>
<p>Are there any migration issues I should ... | <p>In general, it's a piece of cake. We do that exact thing all of the time, with no problems. Functionality of pure t-sql code is identical (64 bit just performs better ;-).</p>
<p>The one exception to this that I have encountered is extended stored procedures. Since these are written in C they would have to be recom... | <p>The <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=167907&SiteID=1" rel="nofollow noreferrer">main thing I'm aware of</a> is that the SSIS 32-bit mode version of dtexec needs to be run in when dealing with data sources where there are no 64-bit version of Jet (Excel or Access, basically).</p>
| 38,945 |
<p>I need to get a list of attribute values from child elements in Python.</p>
<p>It's easiest to explain with an example.</p>
<p>Given some XML like this:</p>
<pre><code><elements>
<parent name="CategoryA">
<child value="a1"/>
<child value="a2"/>
<child value="... | <p>I'm not really an old hand at Python, but here's an XPath solution using libxml2.</p>
<pre><code>import libxml2
DOC = """<elements>
<parent name="CategoryA">
<child value="a1"/>
<child value="a2"/>
<child value="a3"/>
</parent>
<parent name... | <p>I must admit I'm a fan of <a href="http://www.aaronsw.com/2002/xmltramp/" rel="nofollow noreferrer">xmltramp</a> due to its ease of use.</p>
<p>Accessing the above becomes:</p>
<pre><code> import xmltramp
values = xmltramp.parse('''...''')
def getValues( values, category ):
cat = [ parent for parent in ... | 11,284 |
<p>I recently installed Ubuntu on a VirtualBox VM it installed just fine (much easier than on VirtualPC). However I'm unable to get internet access from the guest OS (ie. Ubuntu). Can anyone give me any pointers on how I might enable this?</p>
<p>The Host OS is Windows Vista and the hardware is an IBM Lenovo.</p>
| <p>How did you configure networking when you created the guest? The easiest way is to set the network adapter to NAT, if you don't need to access the vm from another pc.</p>
| <p>I had a similar issue in windows 7 + ubuntu 12.04 as guest. I resolved by</p>
<ul>
<li>open 'network and sharing center' in windows</li>
<li>right click 'nw-bridge' -> 'properties'</li>
<li>Select "virtual box host only network" for the option "select adapters you want to use to connect computers on your local netw... | 5,586 |
<p>I'm not a JS guy so I'm kinda stumbling around in the dark. Basically, I wanted something that would add a link to a twitter search for @replies to a particular user while on that person's page. </p>
<p>Two things I am trying to figure out:</p>
<ol>
<li>how to extract the user name from the page so that I can cons... | <p>Here's a pure-DOM method of the above -- and for kicks, I played with the extraction of the username as well:</p>
<pre><code>var menuNode = document.getElementById('tabMenu');
if (menuNode!=null)
{
// extract username from URL; matches /ev and /ev/favourites
var username = document.location.pathname.split("... | <p>Here is a way to do it, not really tested (no twitter account).</p>
<pre><code>var userName = window.location.href.match(/^http:\/\/twitter\.com\/(\w+)/)
if (userName == null)
return; // Problem?
userName = userName[1];
var menuNode = document.getElementById('tabMenu');
if (menuNode != null)
{
var html = '<a... | 47,653 |
<p>I just noticed that you can not use standard math operators on an <code>enum</code> such as <code>++</code> or <code>+=</code>.</p>
<p>So what is the best way to iterate through all of the values in a C++ <code>enum</code>?</p>
| <p>The typical way is as follows:</p>
<pre><code>enum Foo {
One,
Two,
Three,
Last
};
for ( int fooInt = One; fooInt != Last; fooInt++ )
{
Foo foo = static_cast<Foo>(fooInt);
// ...
}
</code></pre>
<p>Please note, the enum <code>Last</code> is meant to be skipped by the iteration. Utilizing this "... | <p>C++ doesn't have introspection, so you can't determine this kind of thing at run-time.</p>
| 32,766 |
<p>I have a MySQL table where an indexed <code>INT</code> column is going to be 0 for 90% of the rows. If I change those rows to use <code>NULL</code> instead of 0, will they be left out of the index, making the index about 90% smaller?</p>
| <p><a href="http://dev.mysql.com/doc/refman/5.0/en/is-null-optimization.html" rel="noreferrer">http://dev.mysql.com/doc/refman/5.0/en/is-null-optimization.html</a> </p>
<p>MySQL can perform the same optimization on <code>col_name IS NULL</code> that it can use for <code>col_name = constant_value</code>. For example, M... | <p>No, it will continue to include them, but don't make too many assumptions about what the consequences are in either case. A lot depends on the range of other values (google for "cardinality").</p>
<p>MSSQL has a new index type called a "filtered index" for this type of situation (i.e. includes records in the index ... | 36,792 |
<p>I have a large legacy codebase with very complicated makefiles, with lots of variables. Sometimes I need to change them, and I find that it's very difficult to figure out why the change isn't working the way I expect. What I'd like to find is a tool that basically does step-through-debugging of the "make" process,... | <p>Have you been looking at the output from running <code>make -n</code> and <code>make -np</code>, and the biggie <code>make -nd</code>?</p>
<p>Are you using a fairly recent version of <code>gmake</code>?</p>
<p>Have you looked at the free chapter on <a href="http://oreilly.com/catalog/make3/book/index.csp" rel="nor... | <p>There is a GNU make debugger project at <a href="http://gmd.sf.net" rel="nofollow">http://gmd.sf.net</a> which looks quite useful. The main feature supported by gmd is breakpointing, which may be more useful than stepping. To use this, you download gmd from <a href="http://gmd.sf.net" rel="nofollow">http://gmd.sf.ne... | 7,834 |
<p>Sql server complaining about this IF NOT EXISTS statement, saying that there is 'incorrect syntax near the keyword 'OR'.</p>
<p>My query:</p>
<pre><code>IF NOT EXISTS (
(SELECT * FROM Users where userID = 1)
OR
(SELECT * FROM sales WHERE saleID = 1)
)
... | <p>try it this way instead</p>
<pre><code>IF
NOT EXISTS (SELECT 1 FROM Users where userID = 1)
AND
NOT EXISTS (SELECT 1 FROM sales WHERE saleID = 1)
BEGIN
-- blah blah blah
END
</code></pre>
<p>or, if you insist on a disjunction:</p>
<pre><code>IF NOT (
EXISTS (SELECT 1 FROM Users where userI... | <p>Maybe this is what you are trying to do:</p>
<pre><code>IF NOT EXISTS(SELECT * FROM Users WHERE userID = 1) OR (AND) NOT EXISTS(SELECT * FROM sales WHERE saleID = 1)
</code></pre>
| 37,046 |
<p>What is the best solution for maintaining backup and revision control on live websites?</p>
<p>As part of my job I work with several live websites. We need an efficient means of maintaining backups of the live folders over time. Additionally, updating these sites can be a pain, especially if a change happens to br... | <p>You can still use SVN, but instead of doing a checkout on your live environment, do an export, that way no .svn directories will be created. The downside, of course, is that no code changes on your live environment can take place. This is a good thing.</p>
<p>As a general rule, code changes on production systems sh... | <p>Any source control solution you pick is going to have problems if people are moving, deleting, or adding files and not telling the source control system about it. I'm not aware of any source control item that could solve this problem. </p>
<p>In the case where you just can't educate the people working on the proj... | 4,695 |
<p>I do mostly Windows development. We use <a href="http://www.mantisbt.org/" rel="noreferrer">Mantis</a> and <a href="http://subversion.tigris.org/" rel="noreferrer">Subversion</a> for our development but they aren't integrated together, in fact they are on different servers.</p>
<p>I did a little googling about int... | <p>We've used scmbug for quite some time to link SVN to Bugzilla. Worked very well until we upgraded to Bugzilla 3.2 recently, which broke the integration. It takes a little while for the scmbug team to catch up when new releases of the SCM tools come out, which is understandable.</p>
| <p>We followed the steps in your link - the only difference is that on Windows you have post-commit.bat instead. If you scroll down someone posts a sample. We modified that so it logs the files changed and who changed them - a fairly easy hack to the batch file. We tried including the diffs at one point - but it was ob... | 15,163 |
<p>Does anybody have any experience with different fonts for OCR? I am generating an ID then trying to scan it with tesseract. At the moment I am just T&E'n different fonts, but this seems pretty inefficient. I've tried the OCR* family of fonts, and various others such as Arial and Georgia. The tesseract tends to g... | <p>Okay, a search on google comes up with this, a specific OCR font:
<a href="http://www.myfonts.com/fonts/linotype/ocr-a/" rel="noreferrer">OCR Font</a></p>
<p>Looks like it's a standard adopted in 1973.</p>
| <p>Currently using Monospace. Tried very many fonts, but this is the most accurate one for me.</p>
| 40,808 |
<p>I am having some 10 lac records in my single SQL Table. I need to load this much record in my record. I need to know whether this will load. when i tried loading to report its showing out of memory exception.</p>
| <p>Reporting Services (and Cognos, Business Objects, and other BI reporting suites) generally have problems rendering reports that have hundreds of thousands of records or millions of records in the OUTPUT. Most of these systems don't have much of a problem aggregating the data into tens of thousands of records, but o... | <p>Are you trying to display tens of thousands of records? What user would ever read that? Have you tried scheduling and emailing the report?</p>
| 16,763 |
<p>I'm learning ASP.NET MVC and bugged by one issue.</p>
<p>In the HomeController, the Index action has OutputCache attribute, but it seems doesn't work.</p>
<pre><code>[HandleError]
public class HomeController : Controller
{
[OutputCache(Duration=5, VaryByParam="none")]
public ActionResult Index()
{
... | <p>I think this is a bug in ASP.NET MVC. We have logged the issue in our database and will investigate a fix for this issue.</p>
<p>Thanks,
Eilon</p>
| <p>using VarByParam="" seems to make it work</p>
| 41,869 |
<p>I need to create a windows service that will monitor a directory for newly uploaded files.
The files will be around 100K to 400K in size.</p>
<p>Is there a chance that my monitoring system will notice a new file, but the file hasn't completetly finished copying over? i.e. it is still streaming in and the EOF hasn't... | <p>Yes, there is a chance that this will happen. You should upload the file to a temporary directory first, then move it to the directory you're monitoring when the entire file is present on your file system.</p>
| <p>yes. With small files the risk is fairly low, but if you want to be certain have it check when it sees a file to make sure it's size stays stable over a second or two.</p>
| 22,093 |
<p>Is there a way to determine if the loop is iterating for the last time. My code looks something like this:</p>
<pre><code>int[] array = {1, 2, 3...};
StringBuilder builder = new StringBuilder();
for(int i : array)
{
builder.append("" + i);
if(!lastiteration)
builder.append(",");
}
</code></pre>
<p... | <p>Another alternative is to append the comma before you append i, just not on the <em>first</em> iteration. (Please don't use <code>"" + i</code>, by the way - you don't really want concatenation here, and StringBuilder has a perfectly good append(int) overload.)</p>
<pre><code>int[] array = {1, 2, 3...};
StringBuild... | <p>Another approach is to have the length of the array (if available) stored in a separate variable (more efficient than re-checking the length each time). You can then compare your index to that length to determine whether or not to add the final comma.</p>
<p>EDIT: Another consideration is weighing the performance... | 36,253 |
<p>I have a draggable div element with a hover style. This works fine, but the div contains some form elements (label, input). The problem is that when the mouse is over these child elements the hover is disabled.</p>
<pre><code><div class="app_setting">
<label">Name</label>
<input type="text"... | <pre><code>.app_setting *:hover { cursor:move }
</code></pre>
| <p>You might have to resort to JS to make it happen for IE6.</p>
| 16,627 |
<p>I have the following code which works just fine when the method is "POST", but changing to "GET" doesn't work:</p>
<pre><code>HttpWebRequest request = null;
request = HttpWebRequest.Create(uri) as HttpWebRequest;
request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
request.Method = "POST"; // D... | <p>This is <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.begingetrequeststream.aspx" rel="noreferrer">specified in the documentation</a>. Basically GET requests aren't meant to contain bodies, so there's no sensible reason to call <code>BeginGetRequestStream</code>.</p>
| <p>BeginGetRequestStream is used to get a stream specifically for writing data to the request. This is not applicable to GET requests.</p>
<p>The documentation for the BeginGetRequestStream method states explicitly that the method will throw a ProtocolViolationException if the Method is GET or HEAD.</p>
<p>Morale: re... | 31,608 |
<p>I have a windows service that runs fine, but I have to have it run under a special user account.</p>
<p>Currently I go into services and change the logon as section, but for deployment this has to be done more professionally.</p>
<p>Is there a way for me to have it logon as a custom user account programatically, o... | <p>When you open the Service COntrol Manager,(SCM), of course,there is a tab labeled Logon.. In there you can specify which domain or machine account it should run under... </p>
<p>But programatically. if you use a Service Installer class in your code you can specify it there..</p>
<pre><code> public class MyServiceI... | <p>How are you installing? Is this a .net service (in which case, I think you can specify the account on the installer object). </p>
<p>Generally the installer technology allows you to change the credentials (with the possible exception of COM's service registration)</p>
<p>If you're doing an xcopy registration and... | 49,509 |
<p>I have a databound <code>DataGridView</code>. When a new row is added and the user presses <kbd>Esc</kbd> I want to delete the entire row. How can I do this?</p>
| <p>quite easy actually</p>
<pre><code>private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)27)
{
if (dataGridView1.Rows.Count > 0)
{
dataGridView1.Rows.RemoveAt(dataGridView1.Rows.Count - 1);
MessageBox.Show("Last row delete... | <p>Rows cannot be programmatically removed unless the <code>DataGridView</code> is data-bound to an <code>IBindingList</code> that supports change notification and allows deletion.</p>
| 25,490 |
<p>I have several Models and want to return a queryset of all the Models belonging to a User, I'm wondering if its possible to return one Queryset from multiple Models?</p>
| <p>I am assuming that you mean you would like to return a single queryset of all the objects belonging to the user from each model.</p>
<p>Do you need a queryset or just an iterable? AFAIK, heterogeneous qs's are not possible. However, you could easily return a list, a chained iterator (itertools) or a generator to ... | <p>Your models must contain relationship fields (ForeigKey and ManyToManyField), with related_name keyword argument set. Check documentation <a href="http://docs.djangoproject.com/en/dev/topics/db/queries/#backwards-related-objects" rel="nofollow noreferrer">here</a>.</p>
| 46,605 |
<p>Lots of people have things that their systems do for them or for their teams. Source control post-commit hooks are a standard example: have an automated build system that checks out the latest source, compiles, tests, and packages it is a back-office hack that most of us probably use.</p>
<p>What other cool things ... | <p>We had one developer in our team who wasn't familiar with the concept of a subversion conflict. He deduced that if he simply deleted all that weird stuff in his code and clicked resolve that everything was ok (i.e. knocking out all the other changes in the file....)</p>
<p>Regardless to say, after the 5th time thi... | <p>Back in the 1993, when source control systems were really expensive and unwieldy, the company I worked about had an in-house source control built as 4DOS scripts. It wasn't as sofisticated as most current source control systems, for example it didn't have branching or integrates, but it did the basic job of supporti... | 34,074 |
<p>I have a simple 2D array of strings and I would like to stuff it into an SPFieldMultiLineText in MOSS. This maps to an ntext database field.</p>
<p>I know I can serialize to XML and store to the file system, but I would like to serialize without touching the filesystem.</p>
<pre><code>public override void ItemAdd... | <pre><code>StringWriter outStream = new StringWriter();
XmlSerializer s = new XmlSerializer(typeof(List<List<string>>));
s.Serialize(outStream, myObj);
properties.AfterProperties["myNoteField"] = outStream.ToString();
</code></pre>
| <p>IN VB.NET</p>
<pre><code>Public Shared Function SerializeToByteArray(ByVal object2Serialize As Object) As Byte()
Using stream As New MemoryStream
Dim xmlSerializer As New XmlSerializer(object2Serialize.GetType())
xmlSerializer.Serialize(stream, object2Serialize)
Return stream.ToArray()
... | 38,901 |
<p>I'd like to create some small websites using PHP as the programming language. I've looked at several frameworks but they all appear to be rather large and am not sure how well they will run in a shared hosting environment. I was wondering if anyone knew of frameworks that work well in shared hosting? I'm looking for... | <p>ElisLabs codeigniter(<a href="http://codeigniter.com/" rel="nofollow noreferrer">http://codeigniter.com/</a>) should fit the bill like a glove.</p>
<p>This is my framework of choice when i do php projects.</p>
| <p>Take a look at Sonic. It's built to be really light and fast. The core framework is less than 3000 lines of code, and you can create an entire app with just a single 26kb file.</p>
<p>It has an extension framework set up to allow you to install extensions on top of it (ORM, Database, Cache, etc).</p>
<p>view sit... | 26,325 |
<p>What I'm looking for is a basic equivalent of JavaScript's <code>Array::join()</code> whereby you pass in a separator character and uses that in its return string of all the subscripts. I could certainly write my own function using a <code>StringBuilder</code> or whatnot, but there <em>must</em> be something built ... | <p>If the array contains strings, you can just use <a href="http://msdn.microsoft.com/en-us/library/57a79xd0.aspx" rel="nofollow noreferrer"><code>String.Join()</code></a>. If the array does not contain strings, you'll need something a little more complicated so you can handle the cast or conversion process for each i... | <p>I'm unclear as to whether or not you are joining an array of characters or strings.</p>
<p>For Strings</p>
<pre><code>
char sep = GetSeparatorChar();
string[] toJoin = GetToJoin();
string joined = toJoin.Aggregate((x,y) => x+sep.ToString()+y);
</code></pre>
| 27,020 |
<p>I'm curious if it's possible to intercept the default methods of 'Edit' mode on a UITableView. Typically you get a free 'delete' button if you side swipe a UITableViewCell that has delegate methods associated with it. I'd like to change the delete to some other, arbitrary selector. Instead of deleting the cell, I'd ... | <p>Editing is implemented as a method on your UITableView’s delegate object. In your table controller, have whatever control activates editing call this:</p>
<pre><code>[tableView setEditing: YES animated: YES];
</code></pre>
<p>Then, make sure that your delegate object implements this:</p>
<pre><code>- (void)tableV... | <p>I would implement a subclass of UITableViewCell and handle touch events in there. You would likely have to do all the animation stuff yourself, but I think it's probably the easiest solution. There's not a "Supported" method for changing the delete button, I don't think</p>
| 46,982 |
<p>I'm developing a performance critical application for Intel Atom processor.</p>
<p>What are the best gcc optimization flags for this CPU?</p>
| <p>GCC 4.5 will contain the -march=atom and -mtune=atom options.</p>
<p>Source: <a href="http://gcc.gnu.org/gcc-4.5/changes.html" rel="noreferrer">http://gcc.gnu.org/gcc-4.5/changes.html</a></p>
| <p>i686 is closest. Don't go for core2.</p>
<p>GCC 4.1 -O3 -march=i686
GCC 4.3 -O3 -march=native</p>
<p>GCC 4.1 -O4 -ffast-math
GCC 4.3 -O4 -ffast-math</p>
<p><a href="http://macles.blogspot.com/2008/09/intel-cc-compiler-gcc-and-intel-atom.html" rel="nofollow noreferrer">http://macles.blogspot.com/2008/09/intel-cc-c... | 13,588 |
<p>Do you know of any compilers that only requires one or two clicks on the source code to compile? Having to configure it to do it doesn't count, nor does having to go to a terminal and write a word or two.</p>
<p>Extra points are given if you can give your own view as to why so few compilers have a gui included, or ... | <p>We have CMake, Makefiles and other build systems (MSBuild). Why should compiler have a gui?</p>
<p>After generating a build with cmake or writing makefiles issuing 'make' is usually sufficient.</p>
| <blockquote>
<p>Having to configure it to do it doesn't count,</p>
</blockquote>
<p>Theres a logic flaw there. Either you configure it, or the installer configures it. It <em>won't</em> just automagically happen all on its own ;) </p>
| 12,636 |
<p>I'm printing a object with a pretty sizable overhang. And the results, after support removal, are pretty ugly.</p>
<p>Here is the print before support removal.
<a href="https://i.stack.imgur.com/VOWiG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VOWiG.jpg" alt="3d print with support" /></a></p... | <p>Judging from the print quality of support material (very "fat") and of top surfaces (which look with ripples and a lot of material), you have at least 3% overxtrusion, which will result also in stronger connection between support and print, and more difficult removal, lower quality parts.</p>
<p>I would re... | <p>I'm not terribly familiar with slic3r, but it looks like you have a setting (possibly a default one) to slow down on printing overhangs. This was a popular "feature" in slicing software (Cura has it I know) but it's <strong>exactly the opposite</strong> of what you should be doing. When slowing down to print an over... | 1,678 |
<p>I have a database that contains a date and we are using the MaskedEditExtender (MEE) and MaskedEditValidator to make sure the dates are appropriate. However, we want the Admins to be able to go in and change the data (specifically the date) if necessary. </p>
<p>How can I have the MEE field pre-populate with the ... | <p>We found out this morning why our code was mishandling the extender. Since the db was handling the date as a date/time it was returning the date in this format 99/99/9999 99:99:99 but we had the extender mask looking for this format 99/99/9999 99:99 </p>
<pre><code>Mask="99/99/9999 99:99:99"</code></pre>
<p>the ... | <p>Are you referring to the asp.Net Ajax toolkit extensions at:</p>
<p><a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/MaskedEdit/MaskedEdit.aspx" rel="nofollow noreferrer">http://www.asp.net/AJAX/AjaxControlToolkit/Samples/MaskedEdit/MaskedEdit.aspx</a></p>
<p>If so have you checked that your data is com... | 3,328 |
<p>This is probably a silly question, but curiosity has gotten the better of me. I've been seeing code lately that seems to "reverse" the order of expressions for relational operators e.g.:</p>
<pre><code>if (0 == someVariable)
</code></pre>
<p>As opposed to what I normally see/write:</p>
<pre><code>if (someVariable... | <p>I understand that this is personal preference. Although by putting the variable second you can ensure that you don't accidentally assign the constant to the variable which used to concearn c developers. This is probably why you are seeing it in c# as developers switch language.</p>
| <p>The first method exists as a way to remind yourself not to do assignments in an IF statement, which could have disasterous consequences in some languages (C/C++). In C# you'll only get bitten by this if you're setting booleans.</p>
<p>Potentially fatal C code:</p>
<pre><code>if (succeeded = TRUE)
{
// I could ... | 11,746 |
<p>CSS width value = display width of inside?</p>
<p>or</p>
<p>CSS width value = display width of inside + CSS margin-left + CSS margin-right?</p>
| <p>You have to make yourself familiar with the <a href="http://www.w3.org/TR/CSS2/box.html" rel="noreferrer">CSS Box Model</a>. It explains where padding, margin and border as well as width work.</p>
<p>However do note that different browsers implement this differently: most notably, <a href="http://en.wikipedia.org/w... | <p>It not only depends from the browser and version you choose, but also from the doctype of your html document. Internet explorer in "quirks mode" is for example completely different from Internet explorer with doctype XHTML 1.0 Transitional.</p>
| 13,846 |
<p>I'm stuck on a fix to a legacy Visual C++ 6 app. In the C++ DLL source I have put</p>
<pre><code>extern "C" _declspec(dllexport) char* MyNewVariable = 0;
</code></pre>
<p>which results in MyNewVariable showing up (nicely undecorated) in the export table (as shown by dumpbin /exports blah.dll). However, I can't fig... | <p>you must link against the lib generated after compiling the DLL. In the linker options of the project, you must add the <code>.lib</code> file. And yes, you should also declare the variable as:</p>
<pre><code>extern "C" { declspec(dllimport) char MyNewVariable; }
</code></pre>
| <p>I've never used _declspec(dllimport) when I was programming in Windows. You should be able to simply declare </p>
<pre><code>extern "C" char* MyNewVariable;
</code></pre>
<p>and link to the .libb created when DLL was compiled.</p>
| 8,044 |
<p>I need a function called <code>SizeOfPipe()</code> which should return the size of a pipe - I only want to know how much data is in the pipe and not actually read data off the pipe itself. </p>
<p>I thought the following code would work:</p>
<pre><code>fseek (pPipe, 0 , SEEK_END);
*pBytes = ftell (pPipe);
rewind (... | <p>Depending on your unix implementation ioctl/FIONREAD might do the trick</p>
<pre>
err = ioctl(pipedesc, FIONREAD, &bytesAvailable);
</pre>
<p>Unless this returns the error code for "invalid argument" (or any other error) bytesAvailable contains the amount of data available for unblocking read operations at that ti... | <p>On Windows you can always use <code>PeekNamedPipe</code>, but I doubt that's what you want to do anyway.</p>
| 9,738 |
<p>I have a mission-critical real-time data application that uses a TCP connection between the client and server. In some cases, the connection periodically dies (SocketException). No problem - just reconnect and move on. However, the customers aren't thrilled with these intermittent drops in connectivity.</p>
<p>I'd ... | <p>Firstly, you should inspect the details of the SocketExceptions you're getting. I don't know what they contain in .Net, but in Java the detailed message provides a useful hint, such as "Connection closed by peer" or "Connection reset".</p>
<p>In my experience, a common cause of socket connections being dropped is a... | <p>Perfmon is your friend, run a log for all the IP, TCP and networking counters. If you can tell when the connection died, you can look in the graph to see if there's anything - network errors, no transmission, no IO bytes transferred, etc.</p>
<p>Add some .NET counters too, like GC, memory and CPU usage.</p>
<p>The... | 25,305 |
<p>I have a simple panel that is used as a drawing surface. The goal here is to draw a 4 pixel wide outline around a child ListView under certain circumstances. I would like to make the outline pulsate when something can be dragged into it. </p>
<p>I am just drawing a simple rectangle around the ListView and updati... | <p>I stumbled on a solution for this if anyone is interested. It turns out that the flashing is caused by the painting of the background. I used SetStyle to tell the control that I will be handling all of the painting. </p>
<pre><code>SetStyle(ControlStyles.SupportsTransparentBackColor |
ControlStyles.Opaq... | <p>Long shot, but have you tried</p>
<pre><code>SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
</code></pre>
<p>On the Panel Control?</p>
| 22,390 |
<p>I have a block of code that is repeated within a DB2 stored procedure.
I would like to separate this out into a new procedure that I can call with parameters and have it return a value.</p>
<p>How do I create a procedure to return a value and how do I call this procedure from inside my original procedure?</p>
| <p>Yes, an output parameter is all it took.
I couldn't find the right calling syntax in the manual or google though.</p>
<p>You create the procedure like this:</p>
<pre><code>CREATE PROCEDURE myschema.add(IN a INT, IN b INT, OUT c INT)
BEGIN
SET c = a + b;
END
</code></pre>
<p>And then call it like this (this is... | <p>How about an output parameter in the proc you call from within your original proc? Calling a proc is done through the CALL command. It's in the manual ;)</p>
| 48,835 |
<p>We have a Ruby on Rails app that uses some javascript in the views. Since we have good test coverage on the rest of the app, we want to continue that here. The js we use manipulates the DOM to show/hide divs and perform incremental searching for a combobox selecting from a table.</p>
<p>Does anyone know of ways t... | <p>jQuery library ships with a pretty good unit testing library you can use to test dom manipulation. The library's called QUnit.</p>
| <p>In the past I've done this with <a href="https://github.com/pivotal/jsunit" rel="nofollow noreferrer">jsUnit</a>.</p>
| 37,880 |
<p>Assume that I have a field called <em>price</em> for the documents in Solr and I have that field faceted. I want to get the facets as ranges of values (eg: 0-100, 100-500, 500-1000, etc). How to do it?</p>
<p>I can specify the ranges beforehand, but I also want to know whether it is possible to calculate the ranges... | <p>To answer your first question, you can get facet ranges by using the the generic facet query support. <a href="http://wiki.apache.org/solr/SimpleFacetParameters#head-1da3ab3995bc4abcdce8e0f04be7355ba19e9b2c" rel="nofollow noreferrer">Here</a>'s an example:</p>
<pre><code>http://localhost:8983/solr/select?q=video&am... | <p>There may well be a better Solr-specific answer, but I work with straight Lucene, and since you're not getting much traction I'll take a stab. There, I'd create a populate a <code>Filter</code> with a <code>FilteredQuery</code> wrapping the original <code>Query</code>. Then I'd get a <code>FieldCache</code> for the ... | 5,410 |
<p>Generally speaking what do you get out of extending an artificial neural net by adding more nodes to a hidden layer or more hidden layers?</p>
<p>Does it allow for more precision in the mapping, or does it allow for more subtlety in the relationships it can identify, or something else?</p>
| <p>There's a very well known result in machine learning that states that a single hidden layer is enough to approximate any smooth, bounded function (the paper was called <a href="http://portal.acm.org/citation.cfm?id=70408" rel="noreferrer">"Multilayer feedforward networks are universal approximators"</a> and it's now... | <p>The number of units per hidden layer accounts for the ANN's potential to describe an arbitrarily complex function. Some (complicated) functions may require many hidden nodes, or possibly more than one hidden layer.</p>
<p>When a function can be roughly approximated by a certain number of hidden units, any extra nod... | 43,113 |
<p>I have a strange requirement to ship an application without bundling .Net framework (to save memory footprint and bandwidth). </p>
<p>Is this possible? Customers may or may not have .Net runtime installed on their systems.</p>
<p>Will doing Ngen take care of this problem? I was looking for something like the good ... | <p>One option without using Ngen may be to release using the .Net Framework 3.5 SP1 "Client Profile". This is a sub-set of the .Net Framework used for building client applications which can be downloaded as a separate, much smaller, package.</p>
<p>See details from the <a href="http://blogs.msdn.com/bclteam/archive/2... | <p>If your software requires .NET then your end users will need the same version of .NET. You cannot "link in" .NET into your executable to create a single .exe, like you can with MFC or Delphi. If your installer doesn't install the .NET runtime then you will need to ensure that the user is aware if this and point them... | 13,832 |
<p>I've been a Unix-based web programmer for years (Perl and PHP). I'm also competent with C and C++ (and bash and that sort of sysadmin sort of stuff) in terms of the language itself. I've never had a problem learning a new language (I mucked around with Java a few years ago and whilst I could write it I just didn't... | <p>It depends on how 'close to the metal' you want to be. Choose .Net/C#/Windows Forms/WPF if you want to quickly write Windows-only applications. Choose C++/MFC if you are determined to learn a platform that is not easy to use and has wards from 15 years of legacy code, but gives you infinite control over every little... | <p>C# is the language of choice for Windows development, for me. I came from the same kind of background as you, and I found C# incredibly refreshing. I really love this language, and .NET is now my platform of choice. Plus, it's easy to keep in touch with your Unix roots via Mono development. Really, .NET is a great p... | 11,803 |
<p>So like most new .NET developers you start of passing DataSets everywhere and although things do the job it doesn't seem right. </p>
<p>The next progression is usually to create entity objects that extend a DAL base class so you have i.e. </p>
<pre><code>public class User : UserDAL
{
//User specific methods
}
... | <p>I came to the same conclusion. The load usually doesn't make sense in the entity because once you have an instance, you're either creating a new entity or you've already got a loaded entity. I've been using entities with Save (create and update) and Delete for years now without any issues. That being said, it's usua... | <p>Keeping persistence out of your domain classes' inheritance models largely serves the goal of writing understandable and maintainable code.</p>
<p>Persistence is an orthogonal concern to what your class's real responsibilities are. I've noticed that the inherit-from-DAO approach arbitrarily divides the world into t... | 28,116 |
<p>I need to execute a SQL Server system stored procedure, programmatically, and since it executes in the current schema, I need to change it on the fly.</p>
<p>Like this</p>
<p>Statement st = connection.createStatement();
st.execute("EXEC SP_ADDUSER ' ', ' '");</p>
<p>But SP_ADDUSER only executes on the current sch... | <p>I don't believe it's possible to change which database a connection points to.</p>
<p>You'll probably need to create a separate DataSource/Connection for each database (schema).</p>
| <p><code>EXEC <DatabaseName>..sp_adduser</code> can be run from a connection to any database (even <code>master</code>, say). The connection will not be affected.</p>
<p>For instance, the following appears to work fine on my system:</p>
<pre><code>USE master
EXEC sp_addlogin 'test1'
EXEC SandBox..sp_adduser 't... | 35,685 |
<p>I understand what the .Net Client Profile is, but what does "PREVIEW" mean? (<a href="http://www.microsoft.com/downloads/details.aspx?familyid=8CEA6CD1-15BC-4664-B27D-8CEBA808B28B&displaylang=en" rel="nofollow noreferrer">http://www.microsoft.com/downloads/details.aspx?familyid=8CEA6CD1-15BC-4664-B27D-8CEBA808B2... | <p>It does look like the title is in error, because it says RTM further down on that page.</p>
<p>HOWEVER, a new version of 3.5 SP1 (known as 3.5 SP1 GDR) is about to be released any day now, to fix regressions which were in SP1. You might want to wait for that before a big deployment.</p>
| <p>As I understand it, the difference between a BETA and a PREVIEW in MS parlance is that a BETA's feature set is pretty much fixed while a PREVIEW, though it should be of a similar quality, may still see significant feature changes.</p>
| 45,136 |
<p>My project is about to introduce SOAP. It's going to be used for C++ <-> Java and C++ <-> Flex communication. I'm responsible for refactoring our apps to take advantage of Java business rules engine and new Flex gui.</p>
<p>What resources are must read for C++ SOAP? I've read W3 materials. We're probably be u... | <pre><code>UserRelationship
====
RelatingUserID
RelatedUserID
Type[friend, block, etc]
</code></pre>
<p>Agree that mutuality doesn't belong as a column; breaks normalization.</p>
| <p>I think you should be create two table:<br></p>
<p>
1. user<br>
u_id int<br>
u_username string<br>
balahhh............<br>
</p>
<p>
2. friendship<br>
fs_id int<br>
relating_id int<br>
related_id int<br>
</p>
| 49,681 |
<p>I have only recently started working with the MVC approach, so I suppose this is an easy one for you gurus here:</p>
<p><strong>Where do I put access control?</strong></p>
<ol>
<li>In a view? I don't want to have any logic besides switches and flags in my templates, so that sounds like the least viable option</li>... | <p>This will depend on what framework you're using as that and the language will dictate a lot of the tools you have available to you.</p>
<p>From a high level, you should have access security configured at points-of-entry. And you should double-check access security at every level that could be considered autonomous ... | <p>For Model (aka data) security, the Model would "control" the access and the Controller would "facilitate" the access. This provides for the reuse of the Model independently of the Controller and minimizes if not negates the general code replication necessary across dissimilar Controllers which use the Model.</p>
<p... | 37,148 |
<p>How can I retrieve raw time-series data from a Proficy Historian/iHistorian?</p>
<p>Ideally, I would ask for data for a particular tag between two dates.</p>
| <p>There are several different sampling modes you can experiment with.</p>
<ul>
<li>Raw</li>
<li>Interpolated</li>
<li>Lab</li>
<li>Trend</li>
<li>Calculated</li>
</ul>
<p>These modes are available using all of the following APIs.</p>
<ul>
<li>User API (ihuapi.dll)</li>
<li>SDK (ihsdk.dll)</li>
<li>OLEDB (iholedb.dl... | <p>Michael--in IP21 there is an "Interpolated" table, as well as the "actual" data point table. Does Proficy have that as well?</p>
| 39,448 |
<p>I really like the fact that Microsoft has taken a commitment to bring MVC to the Web. To this end, I have become excited about converting one of my existing ASP.NET apps to MVC and wanted to know if I may be jumping the gun. While this site is using MVC, it's still technically in beta...what are your thoughts?</p>... | <p>From Preview 5 to RTM, there will be less and less breaking changes. So if the concern is how much churn your project will face, it shouldn't be as bad as it was with earlier releases.</p>
<p>If the concern is support, we do ship the source code and you're allowed to modify (but not redistribute) the source for you... | <p>I re-coded my site using the Preview 5 of ASP.NET MVC and I completely fell in love with it. I would not, however, convert any existing applications to it until it's in Go-Live. Too much could possibly change...</p>
| 14,091 |
<p>I am setting up a rails app and I just finished making some unit tests and my friend said that apparently fixtures are no longer cool and people are now using RSpec or shoulda. I was wondering what the actual benefits are to use these other toolkits. Any information at all is appreciated.</p>
<p>-fREW</p>
| <p>RSpec and similar frameworks are tooling designed to aid in Behavior Driven Development. They're not just a prettier way to write tests, though they do help with that. </p>
<p>There is plenty of information on BDD here: <a href="http://behaviour-driven.org/" rel="noreferrer">http://behaviour-driven.org/</a>
And wik... | <p>You may use testing framework like Cucumber which is even more faster than RSpec..</p>
| 13,521 |
<p>I have a system where I have multiple keyboards and really need to know which keyboard the key stroke is coming from. To explain the set up:</p>
<ol>
<li>I have a normal PC and USB keyboard</li>
<li>I have an external VGA screen with some hard-keys</li>
<li>The hard keys are mapped as a standard USB keyboard, send... | <p>Yes I stand corrected, my bad, learning something new every day.</p>
<p>Here's my attempt at making up for it :) :</p>
<ul>
<li><p>Register the devices you want to use for raw input (the two keyboards) with ::RegisterRawInputDevices().</p></li>
<li><p>You can get these devices from GetRawInputDeviceList()</p></li>... | <p>No way to do this. Windows abstracts this for you. As mentioned, you need to write/modify a device driver.</p>
| 11,662 |
<p>I have a "numeric textbox" in C# .NET which is nothing more than a derivation of Textbox, with some added logic to prevent the user entering anything non-numeric. As part of this, I have added a Value property of type <code>double?</code> (or <code>Nullable<double></code>). It's nullable to support the case wh... | <p>Or, if you don't want the designer adding any code at all... add this to the Property.</p>
<pre><code>[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
</code></pre>
| <p>Could it help to setting the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.defaultvalueattribute(VS.80).aspx" rel="nofollow noreferrer">DefaultValue attribute</a> on that property to new Nullable(1)?</p>
<pre><code>[DefaultValue(new Nullable<double>(1))]
public double? Value ...
</c... | 8,046 |
<p>I cannot seem to compile mod_dontdothat on Windows. Has anybody managed to achieve this?</p>
<p>Edit:</p>
<p>I've tried compiling the file according to the readme on the site and I've tried to add extra libs to reduce the link errors. Ive got the following installed:</p>
<ol>
<li>Apache 2.2.9</li>
<li>Visual Stud... | <p>I managed to compile the module. Prerequisites:</p>
<ul>
<li>Apache 2.2.11</li>
<li><a href="http://www.apachelounge.com/download/apxs_win32.zip" rel="noreferrer">apxs-win32</a> from www.apachelounge.com</li>
<li>Visual Studio 2005</li>
<li><a href="http://www.activestate.com/activeperl/" rel="noreferrer">Active Pe... | <p>Thanks for revising the question.</p>
<p>It looks like a definite linker issue. I see that the first undefined symbol is related to webdav. Are you sure you have that library in the right place? I see you give a nice long path with lots of svn libs, maybe it's possible you overlooked just one?</p>
| 10,051 |
<p>For example which is better:</p>
<pre><code>select * from t1, t2 where t1.country='US' and t2.country=t1.country and t1.id=t2.id
</code></pre>
<p>or</p>
<pre><code>select * from t1, t2 where t1.country'US' and t2.country='US' and t1.id=t2.id
</code></pre>
<p>better as in less work for the database, faster result... | <p>I don't think there is a global answer to your question. It depends on the specific query. You would have to compare the execution plans for the two queries to see if there are significant differences.</p>
<p>I personally prefer the first form:</p>
<p>select * from t1, t2 where t1.country='US' and t2.country=t1.... | <p>I'd lean towards only including your constant in the code once. There might be a performance advantage one way or the other, but it's probably so small the maintenance advantage of only one parameter trumps it.</p>
| 9,833 |
<p>I'm using the repository pattern to query our database using NHibernate. It makes it really easy to do things like:</p>
<p>public T GetById(int id) {...}</p>
<p>But that doesn't help much when someone start mucking with the querystrings to see things they aren't allowed to. </p>
<p>To compound it, some objects ar... | <p>You could implement the Decorator Pattern - I presume you're using an DP/IoC Container to inject your IRepositories?</p>
<p>You'd create an ISecureRepository that checks the calls made are valid for the specific user/request type, and then passed the call back onto the IRepository. This also give you the ability to... | <p>This might be a good implementation for your needs: <a href="http://www.codeproject.com/KB/web-security/objectlevelsecurity.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/web-security/objectlevelsecurity.aspx</a>, it's an ACL-based model.</p>
| 39,039 |
<p>I'm working on a Linux machine through SSH (Putty). I need to leave a process running during the night, so I thought I could do that by starting the process in background (with an ampersand at the end of the command) and redirecting stdout to a file.</p>
<p>To my surprise, that doesn't work. As soon as I close the ... | <p>Check out the "<a href="http://en.wikipedia.org/wiki/Nohup" rel="noreferrer">nohup</a>" program.</p>
| <p>On systemd/Linux, <a href="https://www.freedesktop.org/software/systemd/man/systemd-run.html" rel="nofollow noreferrer">systemd-run</a> is a nice tool to launch session-independent processes.</p>
| 36,176 |
<p>Is there any regular expression library written in T-SQL (no CLR, no extended <code>SP</code>, pure T-SQL) for SQL Server, and that should work with shared hosting?</p>
<p>Edit:</p>
<ul>
<li>Thanks, I know about <code>PATINDEX</code>, <code>LIKE</code>, <code>xp_</code> <code>sps</code> and CLR solutions</li>
<li>... | <p>How about the <a href="http://msdn.microsoft.com/en-us/library/ms188395.aspx" rel="noreferrer">PATINDEX</a> function?</p>
<p>The pattern matching in TSQL is not a complete regex library, but it gives you the basics.</p>
<p>(From Books Online)</p>
<pre><code>Wildcard Meaning
% Any string of zero or more charact... | <p>You can use VBScript regular expression features using OLE Automation. This is way better than the overhead of creating and maintaining an assembly. Please make sure you go through the comments section to get a better modified version of the main one.</p>
<p><a href="http://blogs.msdn.com/b/khen1234/archive/2005/05... | 23,654 |
<p>Seems a great C++ unit testing framework. I'm just wanting something a bit more sophisticated than the console output for running the test, also something that makes it really easy to run specific tests (since gtest supports all kinds of test filtering)</p>
<p>If there is nothing, I'll probably roll my own</p>
| <p>I opened a google code project that adds UI to google test. Runs on both Windows and Unix.
It is not a plugin to any IDE by design - I did not want to tie myself. Instead you open it in the background and press the "Go" button whenever you want to run.</p>
<p>As of this writing V1.2.1 is out and you are invited to ... | <p>The industrial logic plugin, which doesn't seem to be available anymore, was based on the cute eclipse plugin: <a href="http://r2.ifs.hsr.ch/cute/" rel="nofollow noreferrer">http://r2.ifs.hsr.ch/cute/</a>.</p>
<p>I think it should be minimal effort to adapt it. The original plugin used to parse the command line. Us... | 38,002 |
<p>I would like to receive suggestions on the data generators that are available, for SQL server. If posting a response, please provide any features that you think are important. </p>
<p>I have never used a application like this, so I am looking to be educated on the topic. Thank you.</p>
<p>(My goal is to fill a dat... | <p>I have used the <a href="http://www.generatedata.com/#generator" rel="noreferrer">data generator</a> in the past. May be worth a look.</p>
<h3>3rd party edit</h3>
<p>If you do not register you can only generate 100 rows. Below you can find a sample how the interface looks today (october 2016)</p>
<p><a href="http... | <p>I have used this before</p>
<p><a href="http://sqlmanager.net/en/products/mssql/datagenerator" rel="nofollow noreferrer">http://sqlmanager.net/en/products/mssql/datagenerator</a></p>
<p>Its not free though.</p>
<p>Ref integrity checking is quite important, or your tests will be no good without correlating related... | 19,061 |
<p>I have a string.</p>
<pre><code>string strToProcess = "fkdfdsfdflkdkfk@dfsdfjk72388389@kdkfkdfkkl@jkdjkfjd@jjjk@";
</code></pre>
<p>I need to add a newline after every occurence of "@" symbol in the string.</p>
<p>My Output should be like this</p>
<pre><code>fkdfdsfdflkdkfk@
dfsdfjk72388389@
kdkfkdfkkl@
jkdjkfjd... | <p>Use <code>Environment.NewLine</code> whenever you want in any string. An example:</p>
<pre><code>string text = "fkdfdsfdflkdkfk@dfsdfjk72388389@kdkfkdfkkl@jkdjkfjd@jjjk@";
text = text.Replace("@", "@" + System.Environment.NewLine);
</code></pre>
| <pre><code>protected void Button1_Click(object sender, EventArgs e)
{
string str = "fkdfdsfdflkdkfk@dfsdfjk72388389@kdkfkdfkkl@jkdjkfjd@jjjk@";
str = str.Replace("@", "@" + "<br/>");
Response.Write(str);
}
</code></pre>
| 27,701 |
<p>I hava an ajax application that will not display an image, or make a popup window from html stored in a file.</p>
<p>This is the code I am usiong for the popup:</p>
<pre><code>echo '<script>
function makewindows(){
child1 = window.open ("about:blank");
child1.document.write(' . json_encode($row2["ARTICLE_DE... | <p>Your HTML looks invalid - you have:</p>
<pre><code><style ty
<p><strong>Location</strong></p> float: right;
<p><strong>Conditions</strong></p> margin: 0px;
</code></pre>
<p>Firstly the <code><style></code> tag is not closed (1. the opening tag is not ev... | <p>If you carry this response through Ajax using innerHTML substitution it won't work. You need to parse the <code><script>...</script></code> in callback and <code>eval()</code> it.</p>
<p>And in general, you should be using some decent PHP framework on server side and Javascript library on client side. O... | 43,712 |
<p>Anyone have suggestions for security auditing of an .NET Web Application?</p>
<p>I'm interested in all options. I'd like to be able to have something agnostically probe my application for security risks.</p>
<p>EDIT:</p>
<p>To clarify, the system has been designed with security in mind. The environment has been... | <p><strong>Best Thing to do:</strong></p>
<ul>
<li>Hiring a security guy for source code analysis</li>
<li>Second best thing to do hiring a security guy / pentesting company for black-box analysis </li>
</ul>
<p><strong>Following tools will help :</strong> </p>
<ul>
<li>Static Analysis Tools Fortify / Ounce Labs - ... | <p>One of the first things that I have started to do with our internal application is use a tool such as Fortify that does a security analysis of your code base.</p>
<p>Otherwise, you might consider enlisting the services of a third-party company that specializes in security to have them test your application</p>
| 46,199 |
<p>In the application I'm writing using a combination of development environments and languages, I have need of accessing a cookie from two different subdomains, each on a separate host.</p>
<p>The cookie is being set on <code>www.mydomain.com</code> using the PHP code that follows, and I'm attempting to access it fro... | <p>For the benefit of anyone reading this question the code and information contained in the original post are exactly correct and work fine.</p>
<p>The problem is when you introduce other technology. For instance, <strong>I have since learned that sending PHP code through a Python module, one that allows Django to s... | <p>From php.net about the <a href="http://no2.php.net/setcookie" rel="nofollow noreferrer">setCookie</a>-function:</p>
<blockquote>
<p>The path on the server in which the cookie will be available on. If set to '/', the cookie will be available within the entire domain . If set to '/foo/', the cookie will only be ava... | 49,273 |
<p>I have some code which utilizes parameterized queries to prevent against injection, but I also need to be able to dynamically construct the query regardless of the structure of the table. What is the proper way to do this?</p>
<p>Here's an example, say I have a table with columns Name, Address, Telephone. I have ... | <p>Instead of passing the column names, just pass an identifier that you code will translate to a column name using a hardcoded table. This means you don't need to worry about malicious data being passed, since all the data is either translated legally, or is known to be invalid. Psudoish code:</p>
<pre><code>@colum... | <p>The trick is to be confident in your escaping and validating routines. I use my own SQL escape function that is overloaded for literals of different types. Nowhere do I insert expressions (as opposed to quoted literal values) directly from user input.</p>
<p>Still, it can be done, I recommend a separate — a... | 13,152 |
<p>I want to format my existing comments as 'RDoc comments' so they can be viewed using <code>ri</code>.</p>
<p>What are some recommended resources for starting out using RDoc?</p>
| <p>A few things that have bitten me:</p>
<ul>
<li><code>:main:</code> -- RDoc uses only the last one evaluated; best to make sure there's only one in your project and you don't also use the <code>--main</code> command-line argument.</li>
<li>same as previous, but for <code>:title:</code></li>
<li><code>:section:</code... | <p>RDoc uses SimpleMarkup so it's fairly simple to create lists, etc. using *, - or a number. It also treats lines that are indented at the same column number as part of the same paragraph until there is an empty line which signifies a new paragraph. Do you have a few examples of comments you want RDoc'ed so we could s... | 2,248 |
<p>That's the question: Which library can help me to access data available via WebDAV in my Java-programs? OpenSource is preferred.</p>
| <p>The now deprecated <a href="http://jakarta.apache.org/slide/" rel="noreferrer">Apache Jakarta Slide</a> project includes a Java <a href="http://jakarta.apache.org/slide/clientjavadoc/index.html" rel="noreferrer">WebDAV client library</a> - but this project is retired due to the lack of a developer community.</p>
<p... | <p><a href="http://jakarta.apache.org/" rel="nofollow noreferrer">Apache's Jakarta Project</a> has a <a href="http://jakarta.apache.org/slide/wck.html" rel="nofollow noreferrer">WebDav Construction Kit</a>, which should fit this need.</p>
| 14,921 |
<p>So I'm not quite convinced about OpenID yet, and here is why:</p>
<p>I already have an OpenID because I have a Blogger account. But I discovered that Blogger seems to be a poor provider when I tried to identify myself on the <a href="http://altdotnet.org" rel="nofollow noreferrer">altdotnet</a> page and recieved th... | <p>Ideally Stack Overflow would allow you to change your OpenID.</p>
<p>OTOH, ideally you would have set up <a href="http://wiki.openid.net/Delegation" rel="nofollow noreferrer">OpenID delegation</a> on your own site, and used that to identify yourself.</p>
<p>With delegation, you would need only change which service... | <p>This is a problem for me because I changed my email in the way of the new fad of firstName.lastName@gmail.com. After much scouring of this Web site, I am confirming that those of you in my situation are out of luck until further notice because of the issue described in the question.</p>
<p>Either hold on to that ol... | 3,471 |
<p>This is what I have, which works in IE7, but not in Firefox:</p>
<pre><code>@media screen { @import 'screen.css'; }
</code></pre>
<p>It works outside of the @media block in Firefox:</p>
<pre><code>@import 'screen.css';
</code></pre>
<p><strong>UPDATE:</strong> </p>
<p>This works:</p>
<pre><code>@media screen ... | <p>Firefox is following the CSS2 specification, while IE is playing fast and loose, as it were.</p>
<p>The exact reason is that <code>@import</code> directives must be the first directives after the optional <code>@charset</code> directive. They cannot appear inside of any block. If you want an <code>@import</code> ... | <p>Ok, so Firefox doesn't like the method I chose, favouring:</p>
<pre><code>@import 'stylesheet.css' media_type;
</code></pre>
<p>But IE7 doesn't understand this method, but this could be good:</p>
<pre><code>@import 'firefox-screen.css' screen;
@media screen { @import 'IE7-screen.css'; }
</code></pre>
| 27,647 |
<p>Currently it's a big PITA to create timesheet report for say a week or month in FogBugz... maybe someone knows about a plugin to that for you?</p>
| <p>This question is kind of old so I am assuming you were using FB6, but if you are now using FB7 to do exactly this: <a href="http://www.fogcreek.com/FogBugz/Plugins/plugin.aspx?ixPlugin=10" rel="noreferrer">ClarkKent</a>.</p>
| <p>If you have FogBugz hosted on your own server, you can query the database manually and get timesheet results that way. If its hosted by FogBugz, then you can download the database, do the same query, or, use the API to get all the time entries. Some programs already exists for that, one of them is TimeSprite, but it... | 34,505 |
<p>I feel that it should be something very simple and obvious but just stuck on this for the last half an hour and can't move on.</p>
<p>All I need is to split an array of elements into N groups based on element index.</p>
<p>For example we have an array of 30 elements [e1,e2,...e30], that has to be divided into N=3 ... | <p>What about something like this?</p>
<pre><code>for(i=0;i<array_size;i++) {
print "group" + (Math.floor(i/(array_size/N)) + 1)
}
</code></pre>
| <p>I think the problem is a little more complicated; and considering that your only look at group as a 1 dimensional problem your going to get a very odd view of what groups actually are.</p>
<p>Firstly the problem is dimensional according to the number of group primes, and group combinations you are dealing with. In ... | 41,733 |
<p>Maps are great to get things done easily, but they are memory hogs and suffer from caching issues. And when you have a map in a critical loop that can be bad.</p>
<p>So I was wondering if anyone can recommend another container that has the same API but uses lets say a vector or hash implementation instead of a tree... | <p>You can use std::tr1::unordered_map, which is already present in most STL implementations, and is part of the C++0x standard.</p>
<p>Here is it's current signature :</p>
<pre><code>template <class Key,
class T,
class Hash = std::tr1::hash<Key>,
class Pred = std::equal_to<K... | <p>If your key is a simple type that can be very quickly compared and you have no more than a few thousands of entries, you could have better performance by simply putting your pairs in an <code>std::vector</code> and iterating to find your value.</p>
| 15,310 |
<p>Imagine I use the .NET graphic classes to draw a rectangle.</p>
<p>How could I then assign an event so that if the user clicks a certain point, or a certain point range, something happens (a click event handler)?</p>
<p>I was reading CLR via C# and the event section, and I thought of this scenario from what I had ... | <p>You can assign Click event handler to control whose surface will be used to draw rectangle.
Here is a small example:
When you click on form inside of rectangle it will be drawn with red border when you click outside it will be drawn with black border.</p>
<pre><code>public partial class Form1 : Form
{
private R... | <p><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.pointtoclient.aspx" rel="nofollow noreferrer">PointToClient</a> method translates cursor coordinates to control-relative coordinates. I.e. if you cursor is at (screenX, screenY) position on the screen it can be at (formX, formY) position r... | 47,191 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.