input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
How can I replace the text in the button for an upload-input-field in html? <p>In HTML you can define in a form an input-field for uploading files. This input-field has a button attached, that pops up a file-chooser-dialog. How can I set the text for this button?</p>
| <p>It involves a few hacks because browsers don't really want you to do it. Here is a nice tutorial on how to change the appearance and text of the browse button: <a href="http://www.quirksmode.org/dom/inputfile.html" rel="nofollow">Click here</a></p>
|
What is the biggest mistake people make when starting to use LINQ? <p>What are the fundamental misunderstandings people have when they first start using LINQ? </p>
<p>For instance, do they think it is one thing when it is really something else? </p>
<p>And, are there some best practices to employ to avoid these mista... | <p>That it should be used for everything.</p>
|
Can someone point me to a very reliable network communication library? <p>Can someone give me a link to a very reliable asynchronous communication library created using sockets which can simply send text messages from client to server and vice versa?</p>
<p>The asynchronous library should work without memory leakage e... | <p>In c#? Assuming you are targeting the .net platform?
The .net framework comes with plenty of classes for networking. Look in the System.Net namespace and the documentation for it on msdn.</p>
|
C++ Letting a boost thread wait for 1 second <p>I have created a boost thread using:
boost::thread thrd(&connectionThread); where connectionThread is a simple void function. This works fine, however, when I try to make it wait for some seconds, for example using:</p>
<pre><code>boost::xtime xt;
boost::xtime_get(&... | <blockquote>
<p>Is there an easier way</p>
</blockquote>
<p>Maybe something along these lines:</p>
<pre><code>boost::this_thread::sleep(boost::posix_time::seconds(1));
</code></pre>
<p><strike></p>
<pre><code>boost::thread::sleep(boost::posix_time::seconds(1));
</code></pre>
<p></strike></p>
|
How can I ensure my GIFs keep animating even after document.location="" has been run <p>Take the following HTML:</p>
<pre><code><img src="/any-animated-gif.gf" alt="" />
<br /><br />
<a href="#" onclick="document.location='/anything-that-takes-a-few-seconds-to-load.html';return false;">Click He... | <p><a href="http://elliottback.com/wp/animated-gif-stops-javascript-click/" rel="nofollow">http://elliottback.com/wp/animated-gif-stops-javascript-click/</a></p>
<p>According to that link, reassigning the src of the image tag after you have made the redirect with javascript will keep the image animated. Not sure how t... |
Resharper Hotkeys <p>I just started using resharper and I am trying to learn all the hotkeys - Is there a list of all the hotkeys somewhere for the standard install? Something this is possibly in printable format. </p>
| <p>See <a href="http://www.jetbrains.com/resharper/documentation/documentation.html" rel="nofollow">here</a>: </p>
<ul>
<li><a href="http://www.jetbrains.com/resharper/docs/ReSharper45DefaultKeymap.pdf" rel="nofollow">ReSharper 4.5 Default Keymap: Visual Studio scheme</a></li>
<li><a href="http://www.jetbrains.com/res... |
OpenGL primitives too dark when multitexturing? <p>I'm having a problem getting accurate primitive colours when I'm using multi-texturing elsewhere in the scene. Basically, I have some lines and polygons that I am trying render over a video texture (I'm using 3 stage multitexturing to create the video texture)... Anyho... | <p>Make sure to disable multitexturing when not using it. OpenGL uses a state machine, so if you turn on a texture it will stay on until you explicitly turn it off.</p>
<p>Just because you're not setting coordinates, doesn't mean OpenGL will assume you're not using the texture.</p>
|
Impact of changing a Unique key in SQL Server 2005 <p>What is the impact of changing a Unique key in SQL Server 2005</p>
<p>I am having a table one primary key ID int and composite unique key for 4 fields.
But due to nature of my project one of the keys(fields) of the composite key keeps on changing.</p>
<p>Does anyo... | <p>there is maintenance involved since all nonclustered keys point to either the clustered key or to the row if you have a heap (table without a clustered key)</p>
<p>Since the clustered key holds all the data for the table (in essence it is the table) whenever you make changes to the nonclustered key the clustered ke... |
Measuring when only certain page elements have loaded <p>We use a modified version of <a href="http://code.google.com/p/jiffy-web/" rel="nofollow">Jiffy</a> to measure actual client-side performance.</p>
<p>The most important thing we do is measure the time between when the request was received and when the page load ... | <p>You can achieve this for multiple iframes without dynamically adding them by:</p>
<ol>
<li>setting the <code>src</code> attribute for all frames to <code>about:blank</code> before body load,</li>
<li>letting the body load event fire,</li>
<li>adding an <code>onload</code> handler to capture the load time of each fr... |
How to efficiently delete rows from a Postgresql 8.1 table? <p>I'm working on a PostgreSQL 8.1 SQL script which needs to delete a large number of rows from a table.</p>
<p>Let's say the table I need to delete from is Employees (~260K rows).
It has primary key named id.</p>
<p>The rows I need to delete from this tabl... | <p>Don't guess, measure. Try the various methods and see which one is the shortest to execute. Also, use <a href="http://www.postgresql.org/docs/8.1/interactive/sql-explain.html">EXPLAIN</a> to know what PostgreSQL will do and see where you can optimize. Very few PostgreSQL users are able to guess <strong>correctly</st... |
Is there an alternative to padding for IE that doesn't make the text disappear? <p>Is there an clean alternative that doesn't make the text disappear in the following:</p>
<pre><code><div style="background-color:#ddd; padding:10px 0 50px 0;">
<ol><li>In what year were you born?</li></ol>
... | <p>Adding position:relative; to your style will fix this problem. It's called affectionately the Peekaboo bug.</p>
<p><a href="http://www.communitymx.com/content/article.cfm?page=3&cid=7A8DF" rel="nofollow">Here</a> is a link that explains it in a little more detail.</p>
<p>I would agree that you should just try... |
Flash playing video half speed, audio at normal speed <p>I have a swf on a web page playing an flv. On the server it plays the video at half speed and the audio at normal speed. When I play the same swf on my local machine everything is played correctly. Here is the object code on the page:</p>
<p><br /><br /></p>
... | <p>Well, first off, the playback issues really won't have much to do with your embed code, although it does raise the question of why you're targeting FP6. If it's not a client requirement, I'd use a more modern version of flashplayer.</p>
<p>I think preloading / buffering more of the flv is a good solution if this is... |
How to apply an alphanumeric sort in XSLT <p>Based on the following XML, what is the best way to achieve an alphanumeric sort in XSL?</p>
<p><strong><em>Edit</strong>: to clarify, the XML below is just a simple sample the real XML would contain much more variant values.</em></p>
<pre><code><colors>
<item&g... | <p>Splitting the label text into text and number part using <code>substring-before</code> and <code>substring-after</code> will do in your example (however, this is not a general approach, but you get the idea):</p>
<pre><code><xsl:template match="/">
<xsl:apply-templates select="colors/item">
&l... |
Setting a custom 404 error page programmatically <p>In a regular ASP.NET application, you might have a customErrors section like the following:</p>
<pre><code><customErrors mode="On">
<error statusCode="404" redirect="Nice-FileNotFound-Page.aspx"/>
</customErrors>
</code></pre>
<p>Is it possible t... | <p>You can put that logic in Nice-FileNotFound-Page.aspx and redirect from there to the appropriate page using any business logic you need.</p>
|
c# Non-Linear gradient brushes? <p>Is there a method I can use to generate non-linear Gradient brushes in c#?</p>
<p>To clarify: Im not looking for a gradient that can be applied to a non-linear path. Rather, I am looking for a gradient between 2 colours that fades between the two in a non-linear fashion i.e. the rate... | <p>Yep, set the blend for the Brush.</p>
<pre><code>LinearGradientBrush blendBrush = new LinearGradientBrush(Rectangle, Color.Red, Color.White, 360f);
Blend blend = new Blend();
blend .Factors = new float[] { 1.0f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f };
blend .Positions = new float[] { 0, 0.1f, ... |
Why doesn't this Java regular expression work? <p>I need to create a regular expression that allows a string to contain any number of:</p>
<ul>
<li>alphanumeric characters</li>
<li>spaces</li>
<li>(</li>
<li>)</li>
<li>&</li>
<li>.</li>
</ul>
<p>No other characters are permitted. I used <a href="http://www.regexb... | <p>That regular expression tests for any amount of whitespace, followed by any amount of alphanumeric characters, followed by any amount of open parens, followed by any amount of close parens, followed by any amount of ampersands, followed by any amount of periods.</p>
<p>What you want is...</p>
<pre><code>test.match... |
Recordset Iterating <p>I want to iterate through records returned from a MySQL database using Perl, but only ten records at a time. The reason is that the server component can only handle 10 items per request. </p>
<p>For example:</p>
<blockquote>
<p>If the query returned 35 records then
I have to send the data i... | <p>Look at the LIMIT clause for MySQL. You could have a query like:</p>
<pre><code>SELECT * from some_table LIMIT 0, 10;
SELECT * from some_table LIMIT 10, 10;
</code></pre>
<p>etc. where the first number after LIMIT is the offset, and the second number is the number of records.</p>
<p>You'd of course first need t... |
Create PopUp with <asp:HyperLink> that is passing parameters <p>This <code>HyperLink</code> syntax is not working to pass parameters to a small PopUp window:</p>
<pre><code><asp:HyperLink ID="HyperLink2" runat="server" Text="Manage Related Items"
NavigateUrl='<%# "editRelatedItems.aspx?" + "ProductSID=" + Ev... | <p>From the server side code you can do </p>
<pre><code>HyperLink2.Attributes.Add("OnClick", "yourstuffhere");
</code></pre>
<p>that will allow you to specify the OnClick items.</p>
<p>You could also set the <code>NavigateUrl</code> to be something like "javascript: window.open..." if you wanted, again, can be done ... |
Manipulate the output of <xsl:apply-templates> <p>How do I string manipulation on the output of <code><xsl:apply-templates></code>? </p>
<p>I need to escape quotes etc as it's finally being passed to a JavaScript variable.</p>
| <p>The nice and clean approach would be to change your XSLT so that it's output does not need any additional manipulation. </p>
<p>If your call to <code><xsl:apply-templates></code> produces a string that must be manipulated for some reason, you would need to capture it in a variable first:</p>
<pre><code><x... |
Excel Print Worksheets by Name <p>I've got an Excel 2007 Spreadsheet and I'd like to write a VBA procedure to print particular worksheets by name. How do I do this?</p>
<p>For example,
I'd like to print <code>"FirstSheet","ThirdSheet",</code> and <code>"FourthSheet"</code> but not <code>"SecondSheet".</code></p>
| <p>If you know the sheet name simply call the <code>PrintOut</code> function like this:</p>
<pre><code>Sheets("Name").PrintOut
</code></pre>
<p>For small amounts of sheets it is quite more easy by this way!</p>
|
WiX - trying to figure out install sequences <p>I'm installing a large app, and part of it is a custom written tool called "DbUpdateManager" to mass execute SQL scripts against our target database.</p>
<p>Right now, the WiX 2.x install works - but it has one flaw: during install, I also install a couple of Windows ser... | <p>Well, I finally got it working - with a bit of help from everyone who responded, and by consulting some of the WiX tutorials and help pages out there on the web. MSI installer stuff isn't easy to figure out and learn......</p>
<p>Basically, I changed execution of my custom action to "deferred" (as suggested by Rob)... |
IIS 7 Default document setting for a mapped handler url <p>I have a web site that serves only one page from the root. The page (call it stuff.htm) is generated by a custom handler, and doesn't physically live on disk.</p>
<p>I'd like stuff.htm to be the default doc for the site, but the standard configuration method o... | <p>Is ASP.NET set to handle the file extension you are trying to serve? If so I would expect it to work correctly; otherwise here are some "cheap and dirty" answers.</p>
<p>The "cheap and dirty" answer is to create an empty file named stuff.htm at the root, set it as the default page, and then ensure that ASP.NET is ... |
AVAudioPlayer hanging the entire application <p>I'm using AVAudioPlayer to play sound effects in an iPhone game.
This is part of my code:</p>
<pre><code>AVAudioPlayer *player = [dict objectForKey:@"Player"];
if (player.playing) {
player.currentTime = 0;
} else {
[player play];
}
</code></pre>
<p>One sound tha... | <p>I could not find a way to solve this issue. I worked around it by using OpenAL for my sound needs instead.</p>
|
Connecting console application to access database problems <p>I am trying to connect a console application to a access database.</p>
<p>This is the query that i have am using:</p>
<p>"SELECT [Type], [Name], [Phone Number], [Start Time], [End Time], [IM Session File], [Notes] FROM [Call History] WHERE [Start Time] >= ... | <p>I believe your select statement should be like this:</p>
<p>SELECT [Type], [Name], [Phone Number], [Start Time], [End Time], [IM Session File], [Notes] FROM [Call History] WHERE [Start Time] >= @date ORDER BY [Call History].[Start Date]</p>
|
Good Naming Convention for Anonymous Types <p>An anonymous type can be thought of as a "Set Once" <code>Object</code> type, whereas an plain old <code>Object</code> or Variant can be set many times. An object or variant tends to be short lived, while an anonymous type is expected to live longer, making it important to ... | <p>When I use anonymous types in Java Swing apps I use them in the following fashion:</p>
<pre><code>private ActionListener [actionPerforming]Action = new ActionListener(){ /*Stuff Here*/};
</code></pre>
<p>That way it is clear what the variable is doing.</p>
|
Best way to embed an IRC client in a webpage <p>I'm looking for a good, free, preferrably open source, IRC client to be embedded in a web page.</p>
<p>The obvious requirements of supporting most browsers, if requiering a plug-in it should be a plug-in that is allready widley deployed and it should not put too much str... | <p>Not really a programming question, but <a href="http://mibbit.com/" rel="nofollow">Mibbit</a> is quite capable, I've used it for a few different applications, it's always worked well.</p>
<p>Note that it will work best if your channel is on one of <a href="http://mibbit.com/networks/" rel="nofollow">the networks li... |
DSL vs Method calls: pros and cons <p>I have a rather peculiar data source I have to work with (an interface to an accounting application actually). While it is pretty powerful, I have to jump through pretty many hoops to get the data I want out of it. For example, if I want to get the contents of a table and specify w... | <p>You have to be careful about what you call a DSL. See <a href="http://www.martinfowler.com/bliki/DomainSpecificLanguage.html" rel="nofollow">Martin Fowler's Bliki post on DSL</a>. Your example of the method chaining is very close to an internal DSL. Modify it slightly and it is:</p>
<pre><code>DataTable result =... |
Calling C# code from C++ <p>I need to be able to invoke arbitrary C# functions from C++. <a href="http://www.infoq.com/articles/in-process-java-net-integration">http://www.infoq.com/articles/in-process-java-net-integration</a> suggests using ICLRRuntimeHost::ExecuteInDefaultAppDomain() but this only allows me to invoke... | <p>There are several ways for a C++ application to invoke functions in a C# DLL.</p>
<ol>
<li>Using C++/CLI as an intermediate DLL
<ul>
<li><a href="http://blogs.microsoft.co.il/sasha/2008/02/16/net-to-c-bridge/">http://blogs.microsoft.co.il/sasha/2008/02/16/net-to-c-bridge/</a></li>
</ul></li>
<li>Reverse P/Invoke
<... |
How to center a GNOME pop-up notification? <p>To display a GNOME pop-up notification at (200,400) on the screen (using Python):</p>
<pre><code>import pynotify
n = pynotify.Notification("This is my title", "This is my description")
n.set_hint('x', 200)
n.set_hint('y', 400)
n.show()
</code></pre>
<p>I'm a gtk noob. H... | <p>Since you're using GNOME, here's the GTK way of getting the screen resolution</p>
<pre><code>import gtk.gdk
import pynotify
n = pynotify.Notification("This is my title", "This is my description")
n.set_hint('x', gtk.gdk.screen_width()/2.)
n.set_hint('y', gtk.gdk.screen_height()/2.)
n.show()
</code></pre>
|
Is it safe to use the stack below esp? <p>I have a simple assembly function called from a c program and I have to use a instruction (<code>FIDIV</code>) that needs a memory operand.</p>
<p>Is it safe to move the value to <code>[esp - 2]</code> and use it in the next instruction or is it never safe to use the stack tha... | <p>Using an offset like that will definately expose the data to corruption any time any action on the thread needs to touch the stack again. This can occur during interrupts, APCs, context switches, exceptions, etc. What you'll want to do instead is to actually reserve space on the stack and save a pointer to it.</p>
... |
Modify fields in anonymous types? <p>In this example:</p>
<pre><code>var p1 = new {Name = "A", Price = 3};
</code></pre>
<p><strong>And this translates into IL:</strong></p>
<pre><code>class __Anonymous1
{
private string name ;
private int price;
public string Name{ get { return name; } set { name = value ;... | <p>Let me turn that around on you: why restrict it?</p>
|
Connecting to MS SQL Server with JRuby <p>I'm working on a project that involves some scripting and data storage. The database that I have available to me is MS Sql Server and it is on a windows platform. </p>
<p>Despite this I'm looking to leverage Ruby to write the script, specifically JRuby. There are a couple o... | <p>MS SQL should have a JDBC driver; use that with the JRuby-JDBC bridge: <a href="http://wiki.jruby.org/wiki/JDBC">http://wiki.jruby.org/wiki/JDBC</a></p>
|
Zend Framework Zend_Form Decorators: <span> Inside Button Element? <p>I have a button element that I've created like so:</p>
<pre><code>$submit = new Zend_Form_Element_Button('submit');
$submit->setLabel('My Button');
$submit->setDecorators(array(
'ViewHelper',
array('HtmlTag', array('tag' => 'li'))
... | <p>I have tried and, ultimately, failed to achieve this myself using the same approach. It would seem that the easiest way to do this would be to do:</p>
<pre><code>...
$submit->setLabel('<span>My Button</span>');
...
</code></pre>
<p>However, the span will be escaped. It's perfectly possible to turn... |
What's the best description for "embedded hardware system"? <p>When I hear that, I always think about an mobile device. But why is the hardware "embedded" there? Isn't the whole device the hardware? Why is a personal computer no embedded hardware system?</p>
| <p>In today's world embedded simply refers to a system with one or more of the following traits:</p>
<ul>
<li>Single purpose (ie, not a general purpose computer, like your desktop)</li>
<li>Firmware rather than software - still software, but not as easily updated (flash, etc)</li>
<li>Hardware and software are designe... |
How to override List<T>.IsReadOnly in C# <p>I'm trying to derive from List and selectively turn the <em>IsReadOnly</em> property on and off. I was hoping that the Add/Remove/[] functions would honor this property, but they don't.
What's the right way of doing this?</p>
<p>My derived class has some additional propertie... | <p>Use encapsulation instead of inheritance in this case.</p>
<p>You should just make your class implement IList<T>, and have a private List<T> variable.</p>
<p>You can pass through any functions you wish, but also can completely override them, change behavior, etc. This gives you complete control (at th... |
How to upload a pristine Python package to PyPI? <p>What's the magic "<code>python setup.py some_incantation_here</code>" command to upload a package to PyPI, in a form that can be downloaded to get the original package in its original form?</p>
<p>I have a package with some source and a few image files (as package_da... | <p>When you perform an "sdist" command, then what controls the list of included files is your "MANIFEST.in" file sitting next to "setup.py", not whatever you have listed in "package_data". This has something to do with the schizophrenic nature of the Python packaging solutions today; "sdist" is powered by the <a href=... |
Generic Authentication Call to Active Directory in C# <p>I would like to have a clean C# class that authenticates from Active Directory. </p>
<p>It should be pretty simple, it just has to ask for credentials and check if it matches what AD is expecting.</p>
<p>I am responsible for a number of C# applications, and I w... | <p><a href="http://support.microsoft.com/kb/316748">http://support.microsoft.com/kb/316748</a></p>
<pre><code>public bool IsAuthenticated(String domain, String username, String pwd)
{
String domainAndUsername = domain + "\\" + username;
DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd);
t... |
Impersonation fails authorization with same credentials on workstation A and B <p>Case 1. When I browse a little test site from my own PC called JOHNXP (e.g. <a href="http://localhost/WebClient" rel="nofollow">http://localhost/WebClient</a> ), my .aspx page invokes my ASMX webservice picks up my credentials and passes ... | <p>My knowledge of authentication is a bit hazy, but if I understood your description correctly:</p>
<ul>
<li><p>in the first case, you're browsing to localhost, which is impersonating the caller, then calling a web service on a different machine. The impersonation is being done on the same machine as the client. I ... |
AdvancedDataGrid SummryRow <p>One update:
I tried using the SummaryRow on the datagrid for its basic functionalities and it is working. Now, I need to embed the text in the summary fields. E.g. If one of my summaryfields returns me the count then it should be able to display 'TOTAL (count)'</p>
<p>Is it possible with ... | <p>The advancedDataGrids introduction from adobe contained a demo, but it doesn't seem to be on the web anymore. Have you tried looking at the SummaryField reference? I haven't used summary fields in a while, but it seemed pretty straightforward.</p>
<p><a href="http://livedocs.adobe.com/flex/3/langref/mx/collections/... |
Using MySQL triggers to log all table changes to a secondary table <p>I have a table:</p>
<pre><code>CREATE TABLE `data_table` (
`data_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`field1` INT NOT NULL ,
`field2` INT NOT NULL ,
`field3` INT NOT NULL
) ENGINE = MYISAM ;
</code></pre>
<p>I would log to log any chances... | <p>The insert syntax is</p>
<pre><code>INSERT INTO table (columns_list) VALUES (values_list)
</code></pre>
<p>so your insert would look something like this (i'm not a MySQL expert but you can fit the query):</p>
<pre><code>INSERT INTO data_tracking
(`data_id` , `field` , `old_value` , `new_value` , `modified` )
VA... |
Set new id with jQuery <p>"this" is a text field, "new_id" is an integer.</p>
<p>When I apply the following snippet:</p>
<pre><code>$(this).attr('id', this.id + '_' + new_id);
$(this).attr('name', this.name + '_' + new_id);
$(this).attr('value', 'test');
</code></pre>
<p>the id changes, the name changes too, but n... | <p>I just wrote a quick plugin to run a test using your same snippet and it works fine</p>
<pre><code>$.fn.test = function() {
return this.each(function(){
var new_id = 5;
$(this).attr('id', this.id + '_' + new_id);
$(this).attr('name', this.name + '_' + new_id);
$(this).attr('v... |
Should QA report to development? <p>Here's a question I've run across in many, many companies: should QA teams report to the development organization, or be equivalent to development in the company hierarchy?</p>
| <p>Quite the opposite. Development <em>should</em> report to QA. </p>
<p>If you imagine the QA department to be your customer (note: QA, not test) then you will do very well. Bugs will get fixed, products will get developed to good standards, development will realise they are there to serve the business and code produ... |
Asp.Net MVC how to get view to generate PDF <p>I would like to call an action on a controller. Have the controller get the data from the model. The view then runs and generates a PDF. The only example I have found is in an article by Lou <a href="http://whereslou.com/2009/04/12/returning-pdfs-from-an-aspnet-mvc-ac... | <p>I use iTextSharp to generate dynamic PDF's in MVC. All you need to do is put your PDF into a Stream object and then your ActionResult return a FileStreamResult. I also set the content-disposition so the user can download it.</p>
<pre>
public FileStreamResult PDFGenerator()
{
Stream fileStream = GeneratePDF();
... |
Testing an object's state at save <p>I'm looking to write unit tests for a method such as this one:</p>
<pre><code>public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer)
{
ISPMembershipUserDao userDao = GetISPMembershipUserDao();... | <p><strong>Warning: personal opinion ahead</strong></p>
<p>Ok, now that that's out of the way.... for me, it comes down to what I need to do to feel that my code properly implements the needed logic. In this case? I'd have two test cases:</p>
<ul>
<li>Dealing with ValidateUser returning false
<ul>
<li>Should return... |
Are there any rendering alternatives to rasterisation or ray tracing? <p>Rasterisation (triangles) and ray tracing are the only methods I've ever come across to render a 3D scene. Are there any others? Also, I'd love to know of any other really "out there" ways of doing 3D, such as not using polygons.</p>
| <p>Aagh! These answers are very uninformed!</p>
<p>Of course, it doesn't help that the question is imprecise.</p>
<p>OK, "rendering" is a really wide topic. One issue within rendering is camera visibility or "hidden surface algorithms" -- figuring out what objects are seen in each pixel. There are various categori... |
Equivalent of CppUnit protectors for boost::test? <p>I've used both <code>CppUnit</code> and <code>boost::test</code> for C++ unittesting. Generally I prefer <code>boost::test</code>, mainly because the auto-test macros minimise the effort to setup tests. But there's one thing I really miss from <code>CppUnit</code>:... | <p>I've never used CppUnit, so not sure how protectors work. Are you looking for something that wraps individual tests, or the entire test suite?</p>
<p>For the former, you could use fixtures as you mention, but as I understand it, fixtures should be considered "outside" the test. They set up whatever the test needs, ... |
Where on the file system was my Java class loaded from? <p>I think this is a situation every Java programmer runs into if they do it long enough. You're doing some debugging and make a change to class. When you go to re-run the program, these changes don't seem to be picked up but rather the old class still seems to b... | <p>Simply run <code>java</code> using the standard command line switch"<code>-verbose:class</code>" (see <a href="http://java.sun.com/javase/6/docs/technotes/tools/solaris/java.html">the <code>java</code> documentation</a>). This will print out each time a class is loaded and tell you where it's loaded from.</p>
|
What is the recommended batch size for SqlBulkCopy? <p>What is the recommended batch size for <code>SqlBulkCopy</code>? I'm looking for a general formula I can use as a starting point for performance tuning.</p>
| <p>I have an import utility sitting on the same physical server as my SQL Server instance. Using a custom <code>IDataReader</code>, it parses flat files and inserts them into a database using <code>SQLBulkCopy</code>. A typical file has about 6M qualified rows, averaging 5 columns of decimal and short text, about 30 by... |
Eclipse SWT Virtual Composite Question <p>Is it possible to create a virtual composite using SWT, i.e. one could scroll horizontally or vertically beyond the maximum display area of the composite?</p>
<p>I want the length and height of my widgets (images) to stay constant regardless what size the composite is changed ... | <p>Do you mean a <a href="http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/Scrollacontrolinascrolledcomposite.htm" rel="nofollow">scrolled composite</a>?</p>
|
In Javascript, can you extend the DOM? <p>In Javascript, you can extend existing classes by using its prototype object:</p>
<pre><code>String.prototype.getFirstLetter = function() {
return this[0];
};
</code></pre>
<p>Is it possible to use this method to extend DOM elements?</p>
| <p>you can extend the DOM by using the Element's prototype. However, this does not work in IE7 and earlier. You will need to extend the specific element, one at a time. The Prototype library does this. I recommend looking through the <a href="http://prototypejs.org/assets/2008/9/29/prototype-1.6.0.3.js">source</a> to s... |
Should I use char** argv or char* argv[] in C? <p>I'm just learning C and was wondering which one of these I should use in my main method. Is there any difference?</p>
<p><strong>Edit:</strong> So which one is more common to use?</p>
| <p>As you are just learning C, i recommend you to really try to understand the <em>differences</em> between arrays and pointers first instead of the <em>common</em> things. </p>
<p>In the area of parameters and arrays, there are a few confusing rules that should be clear before going on. First, <strong>what you declar... |
WhiteSpace Form TextBoxes <p>I am repopulating a form field that a user previously filled out with Sessions in HTTP. I am grabbing the fields from the form through a servlet:</p>
<pre><code>//On servlet
String polyNum = request.getParameter("policyNum")
session.setAttribute("policyNum", polyNum);
//On JSP
<td alig... | <p>You can trim it like this:</p>
<pre><code>String polyNum = request.getParameter("policyNum");
polyNum = polyNum == null ? null : polyNum.trim();
session.setAttribute("policyNum", polyNum );
</code></pre>
<p>and if your jsp looks like </p>
<pre><code><input type ="text" value="
<%= session.getAttribute( "po... |
What is the best way to handle all SPItem's on SharePoint web Application level? <p>What is the best way to handle all the newly added documents and items to the SharePoint lists and Document Libraries on Share Point Web Application Level. </p>
<p>My case is that I want to do some insertions to database when any new d... | <p>We use event receivers extensively on our Sharepoint system. They are very reliable and easy to write. <a href="http://msdn.microsoft.com/en-us/library/ms475328.aspx" rel="nofollow">You can register an event receiver</a> using a feature scoped at the site level, so it will fire for all SPListItem events (adding, upd... |
Cannot add Entity Data Model in Visual Studio <p>I am running Visual Studio 08 Team Edition with .NET Framework 3.5 SP1 on WinXP. I am trying to add a Entity Data Model to my project, however, the option to add an "ADO.NET Entity Data Model" selection does not appear. To give you a visual, I am essentially following ... | <p>I'm guessing that your VS 2008 SP1 installation did not complete successfully. Here are some things to verify:</p>
<ol>
<li><p>Take a look at <a href="http://download.microsoft.com/download/A/2/8/A2807F78-C861-4B66-9B31-9205C3F22252/VS2008SP1Readme.htm" rel="nofollow">http://download.microsoft.com/download/A/2/8/A2... |
Maximum length of [NSXMLNode stringValue] <p>I have an XML document which contains an element that is over 90,000 characters in length<sup>*</sup>. </p>
<pre><code>NSXMLNode* node = ...;
NSString* val = [node stringValue]; // this is not the full contents of the node!
</code></pre>
<p>The second line only gives me 80... | <p>What does <code>[node objectValue]</code> give you?</p>
|
Custom about dialogs in Eclipse applications <p>I have an Eclipse workbench application composed of many plugins. I'd like to set the about text of the app to reflect the build number. </p>
<p>There seems to be a couple of places to do this:
- Inside the application's .product file (setting text here doesn't seem to... | <p>It (text and picture of an about dialog) should be in the <a href="http://www.ibm.com/developerworks/opensource/library/os-ecfeat/index.html" rel="nofollow">about.ini</a> of a <a href="http://www.eclipse.org/articles/article.php?file=Article-Update/index.html" rel="nofollow">feature</a> or product plugin.</p>
<p><i... |
log4j - trigger log rolling when application starts <p>With log4j, I want the behaviour of the DailyRollingFileAppender so that date-pattern based log rolling can occur when an application starts up. BUT once the application has started, I don't want it to do any automatic log rotation until the next time the applicati... | <p>You will have to programatically set the logger properties by iterating over all the loggers, getting your logger and then asking ti not to roll anymore. Thats the only way I think.</p>
|
Convert a number to a list of integers <p>How do I write the <code>magic</code> function below?</p>
<pre><code>>>> num = 123
>>> lst = magic(num)
>>>
>>> print lst, type(lst)
[1, 2, 3], <type 'list'>
</code></pre>
| <p>You mean this?</p>
<pre><code>num = 1234
lst = [int(i) for i in str(num)]
</code></pre>
|
Identity management/SSO solution? <p>What are your recommendations for a basic, centralized identity management/SSO service? It must be open source, have a pluggable identity manager (eg: LDAP, DB, openID, etc.) and provide a decent range of API access options (eg: web services, REST, etc.). It must also be clusterabl... | <p>There are a number of open source SSO solutions, <a href="http://forgerock.com/openam.html" rel="nofollow">OpenAM/OpenSSO</a>, <a href="http://www.jasig.org/cas" rel="nofollow">CAS Server</a> and <a href="http://shibboleth.internet2.edu/" rel="nofollow">Shibboleth</a>. </p>
|
Script with nawk doesn't print output to screen <p>I came across a nice one-liner to search for text and print out the results with a given number of trailing and following lines. I'm trying to create a script out of this.
So far this is what I have:</p>
<pre><code># ***************************************************... | <p>Try using:</p>
<pre><code>xgrep "bin/sh" '*' 0 3
</code></pre>
<p>instead.</p>
<p>The expansion of the wildcard term is happening in the current shell before the arguments are passed to your script as shown in this transcript:</p>
<pre><code>pax: xgrep include *.c 0 3
#include <stdio.h>
gawk: (FILENAME=bin... |
Animated GIF in IE stopping <p>Does anyone know a work around to make animated GIF's continue to be animated after you click a link or submit a form on the page your on in IE? This works fine in other browsers.</p>
<p>Thanks.</p>
| <p>The accepted solution did not work for me.</p>
<p>After some more research I came across <a href="http://www.webproworld.com/graphics-design-discussion-forum/63262-gif-show-page-loading.html">this workaround</a>, and it actually does work.</p>
<p>Here is the gist of it:</p>
<pre class="lang-js prettyprint-overrid... |
Round Off decimal values in C# <p>how do i round off decimal values ?<br />
Example : </p>
<p>decimal Value = " 19500.98"</p>
<p>i need to display this value to textbox with rounded off like " 19501 "</p>
<p>if decimal value = " 19500.43" </p>
<p>then</p>
<p>value = " 19500 "</p>
| <p>Look at <a href="http://msdn.microsoft.com/en-us/library/3s2d3xkk.aspx"><code>Math.Round(decimal)</code></a> or <a href="http://msdn.microsoft.com/en-us/library/ms131274.aspx">the overload which takes a <code>MidpointRounding</code> argument</a>.</p>
<p>Of course, you'll need to parse and format the value to get it... |
Why this sample works? <pre><code> typedef pair<double, double> dd;
const double epsilon = 1e-6;
struct sort_by_polar_angle {
dd center;
// Constuctor of any type
// Just find and store the center
template<typename T> sort_by_polar_angle(T b, T e) {
int count = 0;
... | <p>When you call <code>sort_by_polar_angle()</code> in the <code>sort()</code> function, you are creating a temporary object of type <code>sort_by_polar_angle</code> (i.e. its constructor is called). Inside the sort algorithm, the functor object you passed is used something like <code>functor()</code> which will be tra... |
Python base class method call: unexpected behavior <p>Why does <code>str(A())</code> seemingly call <code>A.__repr__()</code> and not <code>dict.__str__()</code> in the example below?</p>
<pre><code>class A(dict):
def __repr__(self):
return 'repr(A)'
def __str__(self):
return dict.__str__(self)... | <p><code>str(A())</code> does call <code>__str__</code>, in turn calling <code>dict.__str__()</code>. </p>
<p>It is <code>dict.__str__()</code> that returns the value repr(A).</p>
|
C/C++: Static function in header file, what does it mean? <p>I know what it means when declared in source file. I reading some code, find that static function in header files could be invoke in other files. </p>
| <p>Is the function defined in the header file? So that the actual code is given directly in the function, like this:</p>
<pre><code>static int addTwo(int x)
{
return x + 2;
}
</code></pre>
<p>Then that's just a way of providing a useful function to many different C files. Each C file that includes the header will g... |
What does SnapsToDevicePixels in WPF mean in layman terms? <p>Anybody? Say I have a Window Class and I give SnapsToDevicePixels = true? what happens?</p>
| <p>It will enable <a href="http://msdn.microsoft.com/en-us/library/aa970908.aspx">pixel snapping</a> for every element in your window as this property is inherited by child UI elements. It won't have an effect on the appearance of the window itself, though (i. e. window frame or similar).</p>
|
Is there a tool like Reflector for COM libraries? <p>Is there a tool like Reflector for COM libraries? I would like to open a COM library and browse the classes and interfaces just like in Reflector. I would rather not install Visual Basic 6.0 in order to do this, if possible.</p>
| <p>Not in the same way however there are number of tools that allow you to examine the type library. For example <a href="http://www.microsoft.com/downloads/details.aspx?familyid=5233b70d-d9b2-4cb5-aeb6-45664be858b6&displaylang=en" rel="nofollow">OleView</a>.</p>
<p>You can also get a good idea of the types insid... |
How to get the uuid of the mainboard with c <p>I need a code snippet for reading the mainboard uuid in c (in Windows XP and Windows Vista if there is a difference, else just for Windows).</p>
| <p><a href="http://msdn.microsoft.com/en-us/library/aa394072.aspx" rel="nofollow">This MSDN example</a> shows how to use Windows Management Instrumentation APIs to read information about the local computer. It doesn't access the "UUID" (which I guess would be the motherboard's serial number) directly, but it should be ... |
Batch Update in NHibernate <p>Does batch update command exist in NHibernate? As far as I am aware it doesn't. So what's the best way to handle this situation? I would like to do the following:</p>
<ol>
<li>Fetch a list of objects ( let's call them a list of users, <code>List<User></code> ) from the database</li>... | <p>I know I'm late to the party on this, but thought you may like to know this is now possible using HQL in NHibernate 2.1+</p>
<pre><code>session.CreateQuery(@"update Users set Country = 'Antarctica'")
.ExecuteUpdate();
</code></pre>
|
How to create hidden Firefox Extension? <p>Is it possible to create Firewox extension that will not shown in Extensions List? And so cannot be deinstalled manually?</p>
| <p>To Hide an extensions/addons in the list of extension <code>about:addons</code> simply follow these few simple steps:</p>
<ul>
<li>(1) Create an a zipfile <strong>myextenios.zip</strong> (firefox extension are actually zip files) having this structure:</li>
</ul>
<pre>myextension.zip
|
|--chrome.manifest
|--instal... |
Monitor clicks/goals Google Analytics with iframes? <p>We've got a site that shows some content in iframes loaded from another domains. What I'd like to do is setup some Goals to track if this stuff is clicked, is this possible to track these clicks?</p>
<p>I know that this content us outside our domain but is it stil... | <p>It is possible. Since Goal Tracking is Profile based, the key is to have a tracking of all domains into one Profile. See the <em><a href="http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55503" rel="nofollow">How do I install the tracking code if my site spans multiple domains?</a></em> entry i... |
Reference-counting for objects <p>In my code I use a small data-storing class, which is created in different places. To avoid memory leaks and simplify things, I want to use reference counting, so I did</p>
<pre><code>type TFileInfo = class (TInterfacedObject, IInterface)
</code></pre>
<p>and removed all my manual ca... | <p>The reference counting in Delphi only works if you only have a reference to your instance via an interface. As soon as you mix interface references and class references then you are in trouble. </p>
<p>Essentially you want reference counting without the need to create an interface with all the methods and propert... |
C#, ASP.NET 3.5 - Load code at run-time <p>A friend of mine is building a Content Management System in PHP.</p>
<p>PHP is a scripting language where code is evaluated at run-time, and therefore it is fairly simple to add code.. at run-time (think: a forum, a contact form, etc.)</p>
<p>Doing the same in ASP.NET (which... | <p>I think you can use the App Code folder for this. I heard of a solution where the developers weren't allowed to upload dlls so they used the app code folder which is compiled just in time. So you can add classes to it and they will be compiled on demand.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/t990k... |
WPF Page refresh <p>1.How to close or cancel the pop up window in Button click.?</p>
<ol>
<li>When i update the data in pop up window, the same time how to refresh the datagrid in main page.?</li>
</ol>
| <p>Close a popup by optionally setting DialogResult to true/false and then calling Close().
You can set the IsDefault or IsCancel property on a button to automatically set the result & close.</p>
<p>You need to provide more information for your datagrid question.</p>
|
Need job scheduler in asp.net <p>We have a website where we need a scheduler to receive notifications (e-mail) on specific time. eg. a person setting reminder at 5 PM to attend the meeting at 4:45 PM, will receive email at 4:45 PM about same.</p>
<p>As this site is hosted on shared server, we don't have any control o... | <p>How about this: <a href="http://www.codeproject.com/KB/aspnet/ASPNETService.aspx">Simulate a Windows Service using ASP.NET to run scheduled jobs</a>.</p>
<p>At one point this technique was <a href="http://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet">used on Stack Overflow</a>, although I don't th... |
can't modify frozen string <p>I'm using the following code in the view which I got from </p>
<p><a href="http://www.igvita.com/2006/10/20/adding-social-bookmarks-in-rails/" rel="nofollow">http://www.igvita.com/2006/10/20/adding-social-bookmarks-in-rails/</a></p>
<p><a href="http://pastie.org/455683" rel="nofollow">Th... | <p>In your comment you say you have a helper method named title. That's probably causing a name collision with the title variable. </p>
<p>Rename your title variable to <code>page_title</code>. Change it at the top, before the list of sites, and at the bottom, where it's generating the links.</p>
|
Are leapseconds taken in account in dotNet (or C#)? <p>Does the DateTime struct takes care of this?
Does any other class/struct?</p>
<p>UPDATE : </p>
<p>I now have read that leapseconds are only announced 6 months in advance, since the rotation of the earth is not that predictable...</p>
<p>Since there's no possibi... | <p>As far as I know, .NET's DateTime struct does NOT automatically handle leap seconds. I don't think you can even set seconds higher than 59 in .NET's DateTime. However, in Java, you are allowed to set seconds to be 0 - 61, because the ISO standard for it allows for 2 leap seconds per year.</p>
<p><strong>EDIT</str... |
Appending a vector to an empty MATLAB matrix <p>I've got MATLAB code inserting n-dimensional points (n >1) into a matrix (<code>myPointMatrix</code>) and am having thoughts about how to insert the first point.</p>
<p>Right now the program checks the size of <code>myPointMatrix</code> before inserting a point. If it is... | <p>There are several ways to append a matrix or vector to any matrix, empty or not. Much depends upon the size of the matrix, and how often you will do the append. (Note that sparse matrices are an entirely different animal. They need to be deal with separately.)</p>
<p>The simple scheme would use concatenation. For e... |
ASP.NET C#: Which Design Pattern should I use and why? <p>I am developing an app in ASP.NET C# and came across the following scenario:</p>
<ol>
<li>I will have to create some maintenance screens for different entities (tables)</li>
<li>Those entities will basically have the same behaviour within the UI: Search, GetByI... | <p>For a set of admin screens that are just doing CRUD (Create, Read, Update, Delete) operations and with little in the way of business logic, I'd be quite tempted to more or less eschew design patterns and take a look at <a href="http://www.asp.net/dynamicdata/" rel="nofollow">asp.net dynamic data</a>. This is especia... |
DataBinding a DataGridview rows BackColor <p>I have a DataGridView that uses databinding, with manually created columns, and this works fine.</p>
<p>However I want the rows' BackColor to be databound as well, and so far my attempts have hit errors.</p>
<p>This is my latest attempt:</p>
<pre><code>dataGridFileTransfe... | <p>I think the problem is <code>files.DisplayColor</code>. <code>files</code> is a collection an has no property <code>DisplayColor</code> but each item of the collection has. So you are trying to bind a not existing property. Further binding collection <code>DataGridView.DataBindings</code> allows you to data bind pro... |
which vmware server is a better choice and which host OS (for QE) <p>we are setting up new QE testing server. I guess host OS will be win2008</p>
<p>Which vmware server to choose - 1.x or 2.x ?</p>
<p>A year ago I tried vmware 1 server with Win2008 and it did not work at all.</p>
<p>However, Vmware server 2 did not ... | <p>Hyper-V Server or ESXi would probably be the best performing and most trouble free options - ie virtualisation not really dependant on the host operating system (but still free).</p>
<p>You can use tools like <a href="http://vmtoolkit.com/blogs/announcements/archive/2006/11/20/vmdk-to-vhd-converter-available.aspx" ... |
Secure captive portal? <p>We would like to run a wireless access point for public use. However, in case of misbehavior, we would like some personal information to be able to pass on to law enforcement.</p>
<p>The proposed solution involves a captive portal where users enter their email addresses, and are then given te... | <p>Collecting email would also be futile since you have no good way of confirming it without also providing compromised access. You should simply log the traffic that the user generates.</p>
|
TFS and SVN <p>I'm about to begin working on a collaborative effort with another vendor. The vendor has the source code and an SVN repository, while we have TFS. I'm interesting in using the Work Item tracking available in TFS but use SVN as the source control. Does anyone know if this is possible?</p>
<p>Another opti... | <p>I suppose it's possible, but you'll have no way to associate work items with changesets or shelvesets, which to me is one of the things I love most about TFS.</p>
<p>I think either way you're going to have some tricky merging/synchronizing to do. In my opinion, your best bet is to agree on a single source control ... |
Copy constructor with pointers <p>I have recently discovered that when I have pointers within a class, I need to specify a Copy constructor.</p>
<p>To learn that, I have made the following simple code. It compiles, but gives me runtime error when performing the copy constructor.</p>
<p>I am trying to copy just the va... | <p>With the statement <code>int* pointer</code> you have just defined a pointer but has not allocated any memory. First you should make it point to a proper memory location by allocating some memory like this: <code>int* pointer = new int</code>. Then in the copy constructor again you have to allocate the memory for t... |
Can the parent window be notified when a child window closes? (on a diff domain) <p>Can the parent window be notified when a child window closes? (on a different domain?)</p>
<p>Trying to get around the window.opener not working when on different domains.</p>
<p>Can I at least be notified somehow when the child windo... | <p>You can't directly be notified of the window closing, but you can work out when the child window has been closed by inspecting the <a href="https://developer.mozilla.org/En/DOM/Window.closed"><code>closed</code></a> property on the window object reference returned by <a href="https://developer.mozilla.org/En/DOM/Win... |
Transparent Winform with image <p>I have an image (PNG file) that has an alpha channel that is set to 50% opaque. When I try to draw the image on a form that has the TransparencyKey set to white, and the backcolor set to white I expect the image to be drawn 50% see-through. However, it is being blended with the forms b... | <p>I ended up using a layered window, using the WS_EX_LAYERED extended window style.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms997507.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms997507.aspx</a></p>
|
problems arranging css layers with heading and table <p>I am having trouble arranging items with the css below.</p>
<p>One of the more obvious problems I am having is that The strong text for the headings of the table columns is black, and does not match the strong text in the information above the table.</p>
<p>My ... | <p>The rule float:bottom; is not valid. There are <a href="http://www.w3schools.com/css/pr%5Fclass%5Ffloat.asp" rel="nofollow">three valid values</a> for float. They are left, right and none. If you want that div to wrap down then you should set it to clear the previous div's float by changing float:bottom; to clear... |
Robust Event Logging <p>This seems, to me, a slightly more specific question that those already asked, so: How reliable is the Windows Event Log service if I'm looking for a 'fire and forget' logging service, so that even an error in calling the service does not impact the caller, and is noted somewhere, somehow, by th... | <p>On Windows side, the event log is fine. Being used for so long by so many applications, it is definitely stable. I'm sure you can find creative ways to crash the API by feeding it bad enough input, but that's probably true with every API. When used properly it will work.</p>
<p>Having that said, you usually don't u... |
Is it necessary to learn about Code Access Security (CAS)? <p>Is it necessary to learn about Code Access Security (CAS) for desktop application development in C#.</p>
| <p>Thatâs a pretty broad question to ask, and the answer depends on a number of things. The two most important factors, however, are your target environment your method of deployment.</p>
<p>Most consumer software is installed with an installer (MSI) and gets full-trust on the target machine. If this is your environ... |
Is there a way to programatically close a menuitem in WPF <p>I have a menu in wpf that has an input box and a button on it. Once the user clicks the button I need to close the menu.</p>
<p>Is there a way to do this?</p>
<pre><code> <Menu x:Name="MainMenu">
<MenuItem Header="Main">
... | <p>Get hold of the <code>MenuItem</code> and do:</p>
<pre><code>_menuItem.IsSubmenuOpen = false;
</code></pre>
<p>Easy way to get hold of it:</p>
<pre><code><Button x:Name="_button" Tag="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type MenuItem}, AncestorLevel=2}"/>
</code></pre>
<p>... |
InnoDB "The Table is Full" error <p>I have a MySQL InnoDB table on a RedHat Enterprise Linux 4 server, and after trying to import a database previously backed up using <code>mysqldump</code> I got a "the table is full" error. </p>
<p>The table currently has 463,062 rows in it, and the <code>ibdata1</code> file on disk... | <p>Check that the disk the InnoDB data file is stored on isn't full</p>
|
Constructor arguments problem ActionScript 3 <p>I have a custom class defined in Actionscript and I want to make an instance of it in the main document of Flash application. However, after calling the constructor with one argument, Flash gives me this error:</p>
<pre><code>Error #1063: Argument count mismatch on coa.a... | <p>Apologies, I can't comment yet, or I'd put this in a comment.</p>
<p>Are you sure that:</p>
<p>var menu1:MovieClip = new MenuItem(3);</p>
<p>is the only place that you're constructing a new MenuItem? You don't by any chance have the MenuItem class attached to some instances on the stage?</p>
<p>I changed your co... |
Most Efficient/Elegant Address Validation <p>I made this small location class so that I can better handle address information which I am going to be sending off in requests to the Google Maps API. One thing I have left to do is some validation to make sure that the address has enough information to return a result back... | <p>In terms of required items, your rules really boil down to:</p>
<p>A valid address must have either a ZIP code or both a city and state.</p>
<p>As far as I can see, everything that satisfies that rule should be OK. Your validation code can be as simple as:</p>
<pre><code>Public Function isValid() As Boolean
... |
Random numbers from physical sources on the Internet <p>What are the addresses of some websites that offers random numbers from physical sources? I'm looking both for free services and services that cost money.</p>
| <p>I have been using <a href="http://random.org/" rel="nofollow">http://www.random.org/</a>, and i like it. Generates random numbers from atmospheric noise, and also is capable of generate:</p>
<ul>
<li>coin flips</li>
<li>dice rolling</li>
<li>card shuffling</li>
</ul>
<p>among others, take a look at it.</p>
|
Setting dropdown values with nullable types <p>I've written a small utility function for our base page, it works fine in most cases, but if it's called in the form <code>SetDropDownValue(dropdown, Nothing, True)</code> I have to specify the type T.</p>
<p>Since the compiler only requires a type specified when the type... | <p>If the value is Nothing then it doesn't really matter what the type <em>would</em> be, right? So I'd write another method:</p>
<pre><code>Protected Sub ClearDropDownValue(ByVal target As DropDownList, ByVal bindFirst As Boolean)
SetDropDownValue(target, CType(Nothing, Nullable(Of Integer)), bindFirst)
End Sub
<... |
Threads in Spring <p>I have a Web application using spring and hibernate and struts (it runs on Tomcat)</p>
<p>The call sequence is something like this...</p>
<p>Struts action calls spring service bean which in turn calls Spring DAO bean. The DAO implementation is a Hibernate implementation.</p>
<p><strong>The quest... | <p>Spring doesn't spawn the threads. Tomcat does. Spring is just creating and wiring up the objects for you.</p>
<p>Each request from the browser is processed in one request. It is Tomcat that handles the request. It is Tomcat that creates the thread to process the request.</p>
<p>Assuming you have just created a sin... |
Handling authentication with multiple membership providers <p>I have a web app using custom membership providers to access admin and inventory pages, each in a separate folder for different users from different database tables (hence the custom membership providers).</p>
<p>There are other pages in the root and other ... | <p>You could have a web.config file in each of your protected folders, and each referencing its own login page and membership providers. This would be much simpler than trying to decide which provider to use on a single form.</p>
|
Getting position of PhysX wheel <p>I'm using the NxWheelShape to simulate wheels on my car. When I render the wheel model, I use shape->getGlobalPose() to get a 4x4 matrix and render the wheel there. However this gives me the position of the shape, not where the casted ray hits other geomnetry, so even if the car behav... | <p>Found it. Should have used shape->getContact(MyContactDesc); MyContactDesc.contactPosition is how far along Y- the ray hit something.</p>
|
Is normalizing a person's name going too far? <p>You usually normalize a database to avoid data redundancy. It's easy to see in a table full of names that there is plenty of redundancy. If your goal is to create a catalog of the names of every person on the planet (good luck), I can see how normalizing names could be b... | <p>Yes, it's an overkill.</p>
<p>People don't change their names from <code>Bill</code> to <code>Joe</code> all at once.</p>
|
Beginners' guide for setting up Emacs with gcc/gdb? <p>I looked around the GNU emacs material and didn't find anything helpful.</p>
<p>Does anyone know of a good tutorial for setting up emacs, to basically turn it into an IDE? I'm looking for interfacing with gcc/gdb/make, etc...</p>
| <p>Like other answers mentioned, <code>M-x compile</code>, <code>M-x gdb</code> will get you going. While debugging, I'd also suggest <code>gdb-many-windows-mode</code>, which makes Emacs look a bit closer to IDE when debugging.</p>
<p>Besides that and to get closer to "IDE-like features", you can look at:</p>
<ul>
<... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.