instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Yes we're talking about ASCII codes. My appologies I'm not the Delphi dev here.</p>
| <p>For Delphi 7, I'd get <a href="http://www.soft-gems.net/index.php/libs/unicode-library" rel="nofollow noreferrer">the free Unicode Library by Mike Lischke</a> who is the author of Virtual Treeview.</p>
<p>The libary includes a lot of conversion functions to go to and from Unicode, so you can use the ones that make ... | <p>It depends what your definition of conversion is. If you want to map the 127 lowest characters to the Unicode equivalent, you can use an explicit cast. But this creates garbage if the string contains higher characters.</p>
<p>If you want mappings like ë -> e and û -> u, you can write your own code. But be aware tha... | 39,243 |
<blockquote>
<p>Unit testing is, roughly speaking, testing bits of your code in isolation with test code. The immediate advantages that come to mind are:</p>
<ul>
<li>Running the tests becomes automate-able and repeatable</li>
<li>You can test at a much more granular level than point-and-click testing via a GUI</li>
</... | <p>Ok here's some best practices from some one who doesn't unit test as much as he should...cough.</p>
<ol>
<li>Make sure your tests test <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=35578" rel="noreferrer" title="one">one</a>
thing and one thing only.</li>
<li>Write unit tests as you go. Preferably <a h... | <p>NUnit is a good tool for any of the .NET languages.</p>
<p>Unit tests can be used in a number of ways: </p>
<ol>
<li>Test Logic</li>
<li>Increase separation of code units. If you can't fully test a function or section of code, then the parts that make it up are too interdependant.</li>
<li>Drive development, some... | 3,755 |
<p>While debugging a Linux app, I found a pointer with the suspicious value 0x7c7c7c7c. Does that particular value indicate anything?</p>
<p>(I ask because I know from my MSVC days that in a debug build, values like 0xcdcdcdcd or 0xdddddddd would be stored into heap blocks that were uninitialized, freed, or otherwise... | <p>I don't recognize that magic number, and neither does <a href="http://en.wikipedia.org/wiki/Magic_number_(programming)" rel="nofollow noreferrer">Wikipedia</a>. I would guess that some code in your program (or in a library you're using) is using <code>memset()</code> and hitting your pointer. Have you grepped your... | <p>0x7c7c = 01111100 01111100 in binary. That could be one of those "most difficult to read" bit patterns that format utilities fill unused space on hard drives with.</p>
| 46,904 |
<p>I have a big load of documents, text-files, that I want to search for relevant content. I've seen a searching tool, can't remeber where, that implemented a nice method as I describe in my requirement below.</p>
<p>My requirement is as follows:</p>
<ul>
<li>I need an optimised search function: I supply this search ... | <p>What you're talking about is known as an <a href="http://en.wikipedia.org/wiki/Inverted_index" rel="nofollow noreferrer">inverted index</a> or posting list, and operates similary to what you propose and what Mecki proposes. There's a lot of literature about inverted indexes out there; the Wikipedia article is a good... | <p>Not sure about the syntax (this is sql server syntax), but:</p>
<pre><code>-- N is the number of elements in the list
SELECT idDoc, COUNT(1)
FROM Word_Docs wd INNER JOIN Words w on w.idWord = wd.idWord
WHERE w.Word IN ('word1', ..., 'wordN')
GROUP BY wd.idDoc
HAVING COUNT(1) = N
</code></pre>
<p>That is, without ... | 17,821 |
<p>Using qsort in C we pass in a comparison function e.g.</p>
<pre><code>int cmp(const void*, const void*);
</code></pre>
<p>the protoype of qsort expects a <code>int (* )(const void* , const void*)</code> so we call:</p>
<pre><code>qsort(..., cmp);
</code></pre>
<p>but it is equally valid to call:</p>
<pre><code>... | <p>Whether you feel uncomfortable or not doesn't change the fact that C is not considered a type-safe language. Case in point:</p>
<pre><code>int main()
{
int integer = 0xFFFFFF;
void (*functionPointer)() = (void(*)())integer;
functionPointer();
return 0;
}
</code></pre>
<p>This is completely valid... | <p>It's not so much a sense of discomfort as a distaste for valid-yet-conflicting syntax options. Either <code>cmp</code> is pointer, and should be treated consistently as such, or it's some other type--which, IMHO is syntactically misleading.</p>
<p>Going a bit further, I'd also require a call either to dereference... | 32,263 |
<p>I have these two <code>CREATE TABLE</code> statements: </p>
<pre><code>CREATE TABLE GUEST (
id int(15) not null auto_increment PRIMARY KEY,
GuestName char(25) not null
);
CREATE TABLE PAYMENT (
id int(15) not null auto_increment
Foreign Key(id) references GUEST(id),
BillNr int(15) not null
);
</code></pr... | <p>The answer to your question is almost the same as the answer to <a href="https://stackoverflow.com/questions/236668/foreign-keys-in-mysql#236677">this one</a> . </p>
<p>You need to specify in the table containing the foreign key the name of the table containing the primary key, and the name of the primary key field... | <p>There should be space between <code>int(15)</code> and <code>not null</code></p>
| 29,626 |
<p>I'm trying to do a simple test php script for sessions. Basically it increments a counter (stored in <code>$_SESSION</code>) every time you refresh that page. That works, but I'm trying to have a link to destroy the session which reloads the page with the <code>?destroy=1</code> parameter. I've tried a couple of if ... | <p>I think you put</p>
<pre><code>$_POST['destroy']
</code></pre>
<p>Instead of</p>
<pre><code>$_GET['destroy']
</code></pre>
<p>You need to use a form if you'd like to use a $_POST variable. $_GET variables are stored in the URL.</p>
| <blockquote>
<p>I know I'm doing something silly (I'm a php newbie) but I can't seem to find what it is...</p>
</blockquote>
<p>that is how you are going to learn a lot ;) enjoy it ...</p>
| 3,750 |
<p>We are porting an app which formerly used Openbase 7 to now use MySQL 5.0.</p>
<p>OB 7 did have quite badly defined (i.e. undocumented) behavior regarding case-sensitivity. We only found this out now when trying the same queries with MySQL.</p>
<p>It appears that OB 7 treats lookups using "=" differently from thos... | <p>Another idea .. does MySQL offer something like User Defined Functions? You could then write a UDF-version of like that is case insesitive (ci_like or so) and change all like's to ci_like. Probably easier to do than regexing a call to lower in ..</p>
| <p>These two articles talk about case sensitivity in mysql:</p>
<ul>
<li><a href="http://dev.mysql.com/doc/refman/5.1/en/case-sensitivity.html" rel="nofollow noreferrer">Case Sensitive mysql</a></li>
<li><a href="http://dev.mysql.com/doc/refman/5.1/en/case-sensitivity.html" rel="nofollow noreferrer">mySql docs "Case S... | 49,460 |
<p>Newbie question...</p>
<p>If I have a file that is in the root of the web app. How do I programmaticaly query the path of that file? ie, what directory it is in?</p>
| <pre><code>System.Web.HttpServerUtility.MapPath( "~/filename.ext" );
</code></pre>
<p>will give you the physical (disk) path, which you would use with System.IO methods and such.</p>
<pre><code>System.Web.Hosting.VirtualPathUtility.ToAbsolute( "~/filename.ext" );
</code></pre>
<p>will give you the "absolute" virtual... | <p>was close to what I was wanting..... except that didn't seem to compile or wasn't valid in the context I was calling it.</p>
<p>However I found what I needed with System.Web.HttpRuntime.AppDomainAppPath</p>
| 25,908 |
<p>So I get that most of you are frowning at me for not currently using any source control. I want to, I really do, now that I've spent some time reading the questions / answers here. I am a hobby programmer and really don't do much more than tinker, but I've been bitten a couple of times now not having the 'time m... | <p>Eric Sink has a great <a href="http://www.ericsink.com/scm/source_control.html" rel="noreferrer">series of posts</a> on source control basics. His company (Sourcegear) makes a source control tool called Vault, but the how-to is generally pretty system agnostic.</p>
| <p>If you are using Subversion, you check out your files <em>once</em> . Then, whenever you have made big changes (or are going to lunch or whatever), you <em>commit</em> them to the server. That way you can keep your old work flow by pressing F5, but every time you <em>commit</em> you save a copy of all the files in t... | 9,265 |
<p>I'm working on an app that takes data from our DB and outputs an xml file using the FOR XML AUTO, ELEMENTS on the end of the generated query, followed by an XSLT to transform it the way we want. However in a particular case where we are generating some data using an sql scalar function, it always puts that element ... | <p>I would try to get rid of the sub query parts "(SELECT..." and do regular joins, like:</p>
<pre><code>SELECT table1.column1, table1.column2, ..., envelope.column21, ...
FROM table1 LEFT JOIN envelope on table1.column1 = envelope.column1 ...
WHERE envelope.column21 = 8
FOR XML AUTO, ELEMENTS
</code></pre>
<p>To... | <p>I would try to get rid of the sub query parts "(SELECT..." and do regular joins, like:</p>
<pre><code>SELECT table1.column1, table1.column2, ..., envelope.column21, ...
FROM table1 LEFT JOIN envelope on table1.column1 = envelope.column1 ...
WHERE envelope.column21 = 8
FOR XML AUTO, ELEMENTS
</code></pre>
<p>To... | 33,259 |
<p>So, I got ZF MVC site and want to force SSL connection on everything under my /checkout/
I tried using mod_rewrite for that, so my .htaccess would look like this:</p>
<pre><code>RewriteEngine on
RewriteRule (\/checkout.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R]
RewriteRule !\.(js|ico|gif|jpg|png|css|swf|xml|avi|f... | <p>Tim Lytle's answer is mostly there.</p>
<p>I'd change it be a little more strict in checking HTTPS and the flags need a delimiter.</p>
<pre><code>RewriteCond %{HTTPS} !^on$
RewriteRule ^/checkout/? https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteRule !\.(js|ico|gif|jpg|png|css|swf|xml|avi|flv|mov|mp3|wav)$ index... | <p>This may help you, add the RewriteCond to only apply when the connection is not SSL, then add the 'L' option to your redirect rule so rewrite processing stops at that point (so the last rule doesn't override the SSL redirect).</p>
<pre><code>RewriteCond %{HTTPS} !on
RewriteRule (\/checkout.*)$ https://%{HTTP_HOST}%... | 49,802 |
<p>I'm trying to use the Stream.BeginWrite Async I/O API in .NET for a high-throughput situation with many short messages. As such, a scatter/gather API will reduce the number of context switches (and CPU usage) tremendously. Does this API use the LPBUFFERS Win32 API at all? Is there an alternative API for Scatter/Gath... | <p>Looking at the .net sources, the accepted answer seems to be wrong.</p>
<p><code>SocketAsyncEventArgs</code> has a <a href="https://msdn.microsoft.com/en-us/library/system.net.sockets.socketasynceventargs.bufferlist%28v=vs.90%29.aspx" rel="nofollow"><code>BufferList</code></a> attribute. When that is used, instead ... | <p>There is no way to do socket scatter/gather I/O in .NET. According to a MSFT blog post, there may be a similar API in .NET 4.5 (whatever that is...)</p>
| 14,014 |
<p>I know the mantra is that the database is always the long pole in the tent anytime a page is being generated server-side.</p>
<p>But there's also a good bit of file i/o going on on a web server. Scripted code is replete with include/require statements. Moreover, its typically a practice to store templated html outs... | <p>10 years ago, disks were so much faster than processors that you didn't have to worry about it so much. You'd run out of CPU (or saturate your NIC) before disk became an issue. Nowadays, CPUs and gigabit NICs could make disk the bottleneck, <strong>BUT</strong>....</p>
<p>Most non-database disk usage is so easily... | <p>I would say that file IO speed only becomes an issue if you are serving tons of static content. When you are processing data, and executing code to render the pages, the time to read the page itself from disk is negligible. File I/O is important in cases where the static files you are serving up are unable to fit ... | 18,822 |
<p>Short of cutting and pasting, is there a way to sort the methods in my classes in Visual Studio 2008? I like orderly code.</p>
| <p>This is a free plug-in that does what you are asking: <a href="http://www.visualstudiogallery.com/ExtensionDetails.aspx?ExtensionID=800978aa-2aac-4440-8bdf-6d1a76a5c23c" rel="nofollow noreferrer">http://www.visualstudiogallery.com/ExtensionDetails.aspx?ExtensionID=800978aa-2aac-4440-8bdf-6d1a76a5c23c</a></p>
<h3>Up... | <p>Resharper will do a good job in a limited way. It depends on how much you want. For example, it wont go and reorder your overrides in an asp.net page based on lifecycle, or anything like that, but it will keep properties, fields, methods and what not clearly grouped</p>
<p>EDIT: By the eway i was refering to auto r... | 19,332 |
<p>I recently saw <a href="https://www.youtube.com/watch?v=TpvNEZCvk84" rel="noreferrer">this</a> video of super-swellable polymer and felt inspired. Printing a swellable structure would be sort of interesting. However, sodium polyacrylate isn't a printable material. Does anyone know of a material that is? Preferably, ... | <p>To print with 2 extruders simultaneously you need a firmware that supports that. Luckily, there is a firmware called Sailfish that is able to do that. The feature you are looking for is called <code>Ditto</code> printing.</p>
<p>Sailfish firmware is found <a href="http://www.sailfishfirmware.com" rel="nofollow nore... | <p>If you want a ditto printing is not mandatory to have a specific firmware (or g-code), you only need to add extruder to your end effector and - because of electrical power requirements - add further stepper driver for further stepper motor.
Please note that the maximum footprint of your printed object is less than ... | 913 |
<p>I've got an interesting design question. I'm designing the security side of our project, to allow us to have different versions of the program for different costs and also to allow Manager-type users to grant or deny access to parts of the program to other users. Its going to web-based and hosted on our servers.</... | <p>If it's only going to be Allow/Deny, then a simple linking table between Users and Resources would work fine. If there is an entry keyed to the User-Resource in the linking table, allow access.</p>
<pre><code>UserResources
-------------
UserId FK->Users
ResourceId FK->Resources
</code></pre>
<p>and the sql ... | <p>B. It allows for much better checks whether the data is complete (for example, when you add an allowable/deniable feature).</p>
<p>Also, table size should only be a consideration for tables that you know will contain many records (as in, 100,000+). You even taking the time to type the table size consideration into ... | 4,338 |
<p>I am coding a program that reads data directly from user input and was wondering how could I (without loops) read all data until EOF from standard input. I was considering using <code>cin.get( input, '\0' )</code> but <code>'\0'</code> is not really the EOF character, that just reads until EOF or <code>'\0'</code>, ... | <p>The only way you can read a variable amount of data from <code>stdin</code> is using loops. I've always found that the <a href="http://en.cppreference.com/w/cpp/string/basic_string/getline" rel="noreferrer"><code>std::getline()</code></a> function works very well:</p>
<pre><code>std::string line;
while (std::getlin... | <pre><code>while(std::cin) {
// do something
}
</code></pre>
| 24,682 |
<p>I'm looking for a Ruby's equivalent of <a href="http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html" rel="nofollow noreferrer">Code Like a Pythonista: Idiomatic Python</a></p>
<p>Desirable features:</p>
<ul>
<li>easy to read</li>
<li>single document which covers all topics: tips, tricks, guidelin... | <p><a href="http://blog.angelbob.com/posts/244" rel="noreferrer">Ruby Idioms (originally from RubyGarden)</a> is my usual reference for idioms. It's clearly organized and fairly complete. As the author says, these are from RubyGarden, which <a href="http://web.archive.org/web/20071016094753/www.rubygarden.org/Ruby/pa... | <p>An executable guide to understanding Ruby's closures, <a href="http://innig.net/software/ruby/closures-in-ruby.rb" rel="nofollow noreferrer">closures-in-ruby.rb</a>.</p>
| 11,138 |
<p>For those who did not know, linking to off-site content in answers is a no-go at SE sites unless you provide context. From <a href="https://3dprinting.stackexchange.com/help/how-to-answer">help</a>:</p>
<blockquote>
<p><strong>Provide context for links</strong><br>Links to external resources are encouraged,
but... | <p><em>Copied from chat</em></p>
<hr>
<p>I agree about the posting of the entire configuration file or G-code in a question is too big to fit, etc. What is really needed, and I've thought this for a long time, is a SE sanctioned version of PasteBin [functionality]. A persistent scrapbook/scratchpad site internal to S... | <p>A possibility is to allow off-site content for the OP to post. Once the problem is spotted, the one answering the question could update the question with relevant parts of the off-site content, or copy the relevant parts into the answer.</p>
| 63 |
<p>We have been looking at g++ versions 3.2.3 and 4.2.4. With 4.2.4, the performance improvements on some of our code base is significant.</p>
<p>I've tried searching the <a href="http://gcc.gnu.org/bugzilla/" rel="nofollow noreferrer">gcc buzilla database</a> to find hints as to what bugs may have had such a dramati... | <p>In my experience, 3.4 is where the performance basically peaked; 4.2 is actually slower than 3.4 on my project, with 4.3 being the first to roughly equal 3.4's performance. 4.4 is slightly faster than 3.4.</p>
<p>There are a specific few cases I've found where older versions of gcc did some unbelievably retarded t... | <p>Streams were very slow in 3.3 and got much faster in 3.4. (<a href="http://gcc.gnu.org/ml/libstdc++/2004-06/msg00272.html" rel="nofollow noreferrer">message on gcc mailing list</a>)
I bet other things improved too.</p>
| 14,580 |
<p>While designing a table my colleague here says that I should avoid identity column as it is specific to SQL Server and MS Access, But I differ with his views as it makes my coding simpler. </p>
<p>Should I use identity column or not? If not what is best way to create the identity columns from application code?</p>
| <p>You can't completely divorce an application from the database vendor. If you do you won't be able to take advantages of whatever features your database provides you.</p>
<p>I'd say use the identity column. If you move over to Oracle (for example), you can use a Sequence. Hardly a big change.</p>
<p>I don't know wh... | <p>As far as i am aware, every slightly serious RDBMS has some sort of unique numbering scheme per table.</p>
<ol>
<li>Access and SQL Server have identity columns</li>
<li>MySQL has auto increment columns</li>
<li>PostgreSQL has sequences</li>
<li>sqlite has an implicit ROWID column</li>
<li>Oracle has some sort of se... | 22,547 |
<p>Is there any Oracle database ( around version 10 ) front end that we can use in Linux, free or open source?</p>
<p>I am currently using Ubuntu 8.10 and if possible I just want it to need the thin JDBC to connect to oracle and not the whole (huge) client of oracle installed in it.</p>
| <p>I use <a href="http://www.oracle.com/technology/products/database/sql_developer/index.html" rel="nofollow noreferrer">Oracle SQL Developer</a> which is similar to TOAD (which is not free). SQL Developer is free and supported by Oracle. Make sure you get the latest version as they're improving it all the time. It ... | <p>Pretty much any JDBC tool will be able to talk compentantly to Oracle.</p>
<p>I've used SQuirrel SQL Client, SQL Workbench, DbVisualizer (free edition).
There's even plug-ins for jEdit that can talk to a database.</p>
| 46,282 |
<p>I'm having a problem writing Norwegian characters into an XML file using C#. I have a string variable containing some Norwegian text (with letters like æøå). </p>
<p>I'm writing the XML using an XmlTextWriter, writing the contents to a MemoryStream like this:</p>
<pre><code>MemoryStream stream = new MemoryStream()... | <p>Why are you writing the XML first to a MemoryStream and then writing that to the actual file stream? That's pretty inefficient. If you write directly to the FileStream it should work. </p>
<p>If you still want to do the double write, for whatever reason, do one of two things. Either</p>
<ol>
<li><p>Make sure that ... | <p>After investigating, this is that worked best for me:</p>
<pre><code>var doc = new XDocument(new XDeclaration("1.0", "ISO-8859-1", ""));
using (XmlWriter writer = doc.CreateWriter()){
writer.WriteStartDocument();
writer.WriteStartElement("Root");
writer.WriteElementString... | 16,851 |
<p>I've never been so good at design because there are so many different possibilities and they all have pros and cons and I'm never sure which to go with. Anyway, here's my problem, I have a need for many different loosly related classes to have validation. However, some of these classes will need extra information to... | <p>what about this : </p>
<pre><code>interface Validatable {
void validate(Validator v);
}
class Object1 implements Validatable{
void validate(Validator v){
v.foo
v.bar
}
}
class Object1Converse implements Validator{
//....
}
class Object2 implements Validatable{
void validate(Validator v){
//do ... | <p>Perhaps the <a href="http://commons.apache.org/validator/" rel="nofollow noreferrer">apache commons validator</a> project would be useful here - either directly or as a model for how to attack your problem. They effectively have a parallel set of objects that do the validation - so there is no interface on the obje... | 22,011 |
<p>Which component is best to use for receiving HTTP requests in Delphi application?</p>
| <p><a href="http://www.indyproject.org" rel="noreferrer">Indy</a> is the way to go. but you need a server component, not a client one. <a href="http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdHTTPServer.html" rel="noreferrer">TIDHTTPServer</a> should fit the bill</p>
| <p>I've been playing around with HTTP components before, and I've also implemented IInternetProtocol to integrate with Internet Explorer and build ISAPI extensions to integrate with IIS.
I've started <a href="http://xxm.sourceforge.net/" rel="nofollow noreferrer">http://xxm.sourceforge.net/</a> to open-source this, and... | 32,841 |
<p>My new project is targeting an embedded ARM processor. I have a build system that uses a cross-compiler running on an Ubuntu linux box. I like to use unit testing as much as possible, but I'm a little bit confused about how to proceed with this setup.</p>
<p>I can't see how to run unit tests on the ARM device its... | <p>With embedded device it depends on what interfaces (hardware) you have.</p>
<p>For example the motion control cards I deal with uses a command line interface. The IDE they ship uses it as it primary method of interacting with the cards. It works the same way regardless if I am using PCI, IDE, Serial, or Ethernet. <... | <p>In ten-plus years in the embedded industry, I've seen it done quite a few ways. At my current company:</p>
<ul>
<li>one of our products has enough horsepower (and space) to run tests on the target board. It's somewhat slow, and we can't stick all the python on the box we'd like, but it works well.</li>
<li>one of... | 33,797 |
<p>I know that the JVM can do some pretty serious optimizations at runtime, especially in -server mode. Of course, it takes a little while for the JVM to settle down and reach peak performance. Is there any way to take a snapshot of those optimizations so they can be applied immediately the next time you run your app?<... | <p>Basically not yet with Sun's VM, but they have it in mind.</p>
<p>See various postings/comments under here:</p>
<p><a href="http://blogs.oracle.com/fatcatair/category/Java" rel="nofollow noreferrer">http://blogs.oracle.com/fatcatair/category/Java</a></p>
<p>(Sorry: I can't find quite the right one about retaining... | <p>Perhaps this might help: <a href="http://wikis.sun.com/display/HotSpotInternals/PrintAssembly" rel="nofollow noreferrer"><a href="http://wikis.sun.com/display/HotSpotInternals/PrintAssembly" rel="nofollow noreferrer">http://wikis.sun.com/display/HotSpotInternals/PrintAssembly</a></a>.</p>
| 48,839 |
<p>Can someone please let me know how do I implement "Did you mean" feature in Lucene.net?</p>
<p>Thanks!</p>
| <p>You should look into the <a href="https://svn.apache.org/repos/asf/lucene/lucene.net/trunk/C%23/contrib/SpellChecker.Net/" rel="nofollow noreferrer">SpellChecker</a> module in the contrib dir. It's a port of Java lucene's <a href="https://lucene.apache.org/core/6_3_0/suggest/index.html?org/apache/lucene/search/spell... | <p>Take a look at google code project called semanticvectors.
There's a decent amount of discussion on the Lucene mailing lists for doing functionality like what you're after using it - however it is written in java.</p>
<p>You will probably have to parse and use some machine learning algorithms on your search logs to... | 45,294 |
<p>I am currently refactoring an application that prints its status to the console window. At the moment I am doing something like this:</p>
<pre><code> Console.Write("Print some status.....")
//some code
Console.WriteLine("Done!")
</code></pre>
<p>Now while this works fine, all the logic is hidden between consol... | <p>Take a look at Log4Net, it handles everything, but might be an overkill for your app, no idea. However knowing Log4Net will likely help you down the road someday so maybe this is a good chance too learn it.</p>
| <p>Why not use a Logger object that write errors into a text file? You could come with some "priority" error messages such as: Logger.print(new priority("important"), "blabla");
This way, you could find in your file the exact time and all the message you want. </p>
<p>If you absolutely want the console, you could use... | 36,374 |
<p>My first instinct is to say each key is an object, and has a hash code, which is what is used to determine if a duplicate is being inserted. However, I can't find anything to back that up for sure. Can someone provide a link that says that, or provide the real answer here? Thanks!</p>
| <p>The <code>Map</code> interface specifies that if two keys are <code>null</code> they are duplicates, otherwise if there's a key <code>k</code> such that <code>key.equals(k)</code>, then there is a duplicate. See the contains or get method here:</p>
<p><a href="http://java.sun.com/javase/6/docs/api/java/util/Map.ht... | <p>Careful on an edge case here. Null keys are not always duplicates. In fact, null keys turn out to be out to cause much frustration inbetween Map implementations (see my post on <a href="http://scanningcrew.blogspot.com/2008/12/consistency.html" rel="nofollow noreferrer">Consistency</a>).</p>
<p>For example null key... | 47,619 |
<p>I am using the jQuery library to implement drag and drop. </p>
<p>How do I get at the element that is being dragged when it is dropped?</p>
<p>I want to get the id of the image inside the div. The following element is dragged:</p>
<pre><code><div class="block">
<asp:Image ID="Image9" AlternateText="1... | <p>Is it not the ui.draggable?</p>
<p>If you go here (in Firefox and assuming you have firebug) and look in the firebug console youll see I am doing a console.dir of the ui.draggable object which is the div being dragged</p>
<p><a href="http://jsbin.com/ixizi" rel="noreferrer">http://jsbin.com/ixizi</a></p>
<p>There... | <p><strong>How to manipulate clone object in any jquery ui operation ?</strong></p>
<p>Just target ui outer html and use normal html jquery selectors</p>
<pre><code>var target_ui_object_html=$(ui.item.context).attr("your attributes");
</code></pre>
<blockquote>
<p>attributes => id ,class ,rel,alt ,title or custom ... | 24,034 |
<p>Here is my code, which takes two version identifiers in the form "1, 5, 0, 4" or "1.5.0.4" and determines which is the newer version.</p>
<p>Suggestions or improvements, please!</p>
<pre><code> /// <summary>
/// Compares two specified version strings and returns an integer that
/// indicates thei... | <p>The <a href="http://msdn.microsoft.com/en-us/library/system.version.aspx" rel="nofollow noreferrer">System.Version</a> class does not support versions with commas in it, so the solution presented by <a href="https://stackoverflow.com/questions/30494#30510">Darren Kopp</a> is not sufficient.</p>
<p>Here is a version... | <p>If you can assume that each place in the version string will only be one number (or at least the last 3, you can just remove the commas or periods and compare...which would be a lot faster...not as robust, but you don't always need that.</p>
<pre><code>public static int CompareVersions(string strA, string strB)
{
... | 5,036 |
<p>I'm writing a WCF service and want to expose some custom configuration elements (e.g. Custom ConfigurationSection and ConnectionStringSettings) so that I can modify the service's configuration. </p>
<p>One of my custom configuration elements inherits from <code>System.Configuration.ConfigurationElementCollection</c... | <p>Just hit this issue today. It was confusing because the problem came up moving a project from machine to machine. This article seems relevant:</p>
<p><a href="http://blogs.msdn.com/youssefm/archive/2009/08/10/serializing-plain-old-clr-objects-poco-types-with-datacontractserializer.aspx" rel="nofollow noreferrer">... | <p>Ok, well in the end I had to re-architect my solution. I found the SerializableConfigurationSection most beneficial. It's in the patterns and practices EnterpriseLibrary. So rather than trying to pass my Custom Configuration Sections through WCF, I perform the seralization/deserialization manually and pass the confi... | 31,132 |
<p>Can we call functions using function pointer? if yes how?</p>
| <p>Yes. Trivial example:</p>
<pre><code>
// Functions that will be executed via pointer.
int add(int i, int j) { return i+j; }
int subtract(int i, int j) {return i-j; }
// Enum selects one of the functions
typedef enum {
ADD,
SUBTRACT
} OP;
// Calculate the sum or difference of two ints.
int math(int i, int j, ... | <p>Yes. An example: </p>
<p>Before code...</p>
<pre>
typedef int ( _stdcall *FilterTypeTranslatorType )
(
int TypeOfImportRecord,
PMAType *PMA
);
FilterTypeTranslatorType FilterTypeTranslator = {NULL};
</pre>
<p>Now in the code...</p>
<pre>
PMAType *PMA;
HANDLE hFilterDll;
// assume ... | 31,466 |
<p>Is there a way to create a <code>JButton</code> with your own button graphic and not just with an image inside the button? </p>
<p>If not, is there another way to create a custom <code>JButton</code> in java?</p>
| <p>When I was first learning Java we had to make Yahtzee and I thought it would be cool to create custom Swing components and containers instead of just drawing everything on one <code>JPanel</code>. The benefit of extending <code>Swing</code> components, of course, is to have the ability to add support for keyboard s... | <p>I haven't done SWING development since my early CS classes but if it wasn't built in you could just inherit <code>javax.swing.AbstractButton</code> and create your own. Should be pretty simple to wire something together with their existing framework.</p>
| 2,436 |
<p>I was wondering about implementing my own sessions (more for an exercise than anything else) for a GAE app I'm working ... at first I was thinking of using the datastore to store the session data. However, every time something needs to be added to the session 'bucket', it would require saving to the datastore. Obvio... | <p>I suggest checking out (and contributing to) these three implementations of appengine sessions before rolling out your own:</p>
<ul>
<li><a href="http://code.google.com/p/app-engine-patch/" rel="nofollow noreferrer">app-engine-patch</a></li>
<li><a href="http://gaeutilities.appspot.com/" rel="nofollow noreferrer">g... | <p>If you use web2py (version 1.46 or latter) sessions are on by default on GAE.
This achieved by the following three lines of web2py code at the top of the scaffoling model:</p>
<pre><code>from gluon.contrib.gql import *
db=GQLDB()
session.connect(request,response,db=db)
</code></pre>
<p>Here is a sample action th... | 29,152 |
<p>I have a just one table mapped in a datacontext. Here's the property and attribute on the column of interest:</p>
<pre><code>[Column(Storage="_CustomerNumber", DbType="VarChar(25)")]
public string CustomerNumber
{
</code></pre>
<p>This column is, in fact, a varchar(25) and has an index.</p>
<p>I've got some simp... | <p>Here's the way I solve this problem now-a-days. This converts the parameters to the desired type and then runs the query. It generates the same sql as originally generated, just with different parameter types.</p>
<pre><code>DbCommand myCommand = myDataContext.GetCommand(query);
foreach (DbParameter dbParameter ... | <p>Here's what I've got as a possible work around. I'm interested in seeing other solutions as well:</p>
<pre><code>List<IQueryable<Customer>> myQueries =
myList.Select(s => myDC.Customers.Where(c => c.CustomerNumber == s)).ToList();
IQueryable<Customers> myQuery = myQueries.First();
fore... | 39,939 |
<p>I am using <code>DirectoryInfo.GetDirectories()</code> recursively to find the all the sub-directories under a given path.
However, I want to exclude the System folders and there is no clear way for that.
In FindFirstFile/FindNextFile things were clearer with the attributes.</p>
| <p>@rslite is right, .NET doesn't give such filtering out-of-box, but it's not hard to implement:</p>
<pre><code>static IEnumerable<string> GetNonSystemDirs(string path)
{
var dirs = from d in Directory.GetDirectories(path)
let inf = new DirectoryInfo(d)
where (inf.Attributes &a... | <p>You'd probably have to loop through the results and reject those with the attributes that you don't want (use the Attributes property).</p>
| 12,601 |
<p>I need to replace the contents of a node in an XElement hierarchy when the element name and all the attribute names and values match an input element. (If there is no match, the new element can be added.)</p>
<p>For example, if my data looks like this:</p>
<pre><code><root>
<thing1 a1="a" a2="b">one&... | <p>This will match any given element with exact tag name and attribute name/value pairs:</p>
<pre><code>public static void ReplaceOrAdd(this XElement source, XElement node)
{
var q = from x in source.Elements()
where x.Name == node.Name
&& x.Attributes().All(a =>node.Attributes()... | <p>You can do an XPathSelectElement with the path (don't quote me, been to the bar; will clean up in the morn) /root/thing2[@a1='a' and @a2='b'] and then take .LastOrDefault() (XPathSelectElement is an extension method in system.Linq.Xml).</p>
<p>That will get you the node you wish to change. I'm not sure how you wan... | 18,832 |
<p>A project I'm working on supposed to authenticate users agains AD. I've never worked with AD before, neither did I work in organizations that use AD, so here's my stupid question: in case if AD involved, who manages roles, groups and users for application? Is it my responsibility to provide an UI for site admin to a... | <p>I don't think you should supply a Gui for active directory. Most organization that use active directory manage it with the standard active directory tools.</p>
<p>If you want to handle the case of small shops. Then make the groups internal to the application DB. You will still be able to use the active directory us... | <p>This really depends on who owns the AD, and who is going to be responsible for managing user accounts. If this AD is isolated from your coporate domain, and you want your support or sales, or other business person to manage the accounts then by all means create them an admin tool.</p>
<p>If your trying to tie into ... | 47,609 |
<p>I am completely new to programming - my interest lies in PHP & MySql for building a dynamic web application for Military Band Administration purposes. i.e. General info and social networking for members + added functionality for the management team to communicate effectively.</p>
<p>OK so the question - as I le... | <p><a href="http://www.wikipedia.org/" rel="nofollow noreferrer">Wikipedia</a> is probably your best resource for general information on programming terminology. A large segment of their community overlaps with the programming community, so tech-related pages are normally very accurate, educational, and up to date. S... | <p>I'm not sure if there's one book that'll teach you "The Fundamentals of Programming." The only way I know of learning all these things is simply <b>practice</b>. Get a PHP tutorial and start building things. Always keep your mind open to learning new things. When you find a better way to do something than a likely v... | 26,365 |
<p>I've generated a certificate request, submitted it to the Microsoft Certificate Services program. It issues the certificate. I downloaded it to conf/ssl/server.cert</p>
<p>I configured it in apache to using </p>
<pre><code>SSLCertificateFile conf/ssl/server.cert
SSLCertificateKeyFile conf/ssl/server.key
</code></p... | <p>Sounds like your cert isn't allowed to be used for a server. IIRC, you can view the certificate in a browser and look for Usage or some such language, and it should say SSL Server (possibly among other things).</p>
| <p>You need to make sure that the issued certificate has "Server Authentication" specified as one of the permitted uses in the extended key usage extension. The easiest way to do this (and only way on Win2k3 Standard) is to use the Web Server certificate template.</p>
<p>You need to use the Certificate Services MMC sn... | 47,575 |
<p>Do you know of a [free] library for graphing or charting, similar to Zedgraph, but that works for developing on windows mobile 6?</p>
| <p>A basic, free chart API is <a href="http://www.codeproject.com/KB/mobile/pocketbargraph.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/mobile/pocketbargraph.aspx</a></p>
<p>If web access and bandwidth are not a problem, <a href="http://code.google.com/apis/chart/" rel="nofollow noreferrer">http://cod... | <p>I once used a listbox to create a (horizontal) bar graph. I needed to catch a paint event for the listbox items to be able to draw the bars. Not easy, but free if your time is free...</p>
| 36,483 |
<p>I am looking for validation framework and while I am already using NHibernate I am thinking of using NHibernate.validator from contrib project however I also look at MS Validation Block which seem to be robust but i am not yet get into detail of each one yet so I wonder has anyone had step into these two frameworks ... | <p>NHibernate Validator does not require you to use NHibernate for persistence. Usage can be as simple as:</p>
<pre><code>var engine = new ValidatorEngine();
InvalidValue[] errors = engine.Validate(someModelObjectWithAttributes);
foreach(var error in errors)
{
Console.WriteLine(error.Message);
}
</code></pre>
<p... | <p>How about D) None of the above.
I remember evaluating this last year and decided on going with Spring.NET's validation framework.</p>
<p>If your using NHibernate your probably want to use Spring.NET's facilities for using NHibernate as well.</p>
| 18,564 |
<p>We have an Sqlite DB on our Linux/PHP production webserver. What is the best way to manage it remotely? I've found some server wrappers are available and some applications claim to offer remote access methods. Any suggestions?</p>
| <p>SSH in and use the SQLite command-line client.</p>
<p>But...why are you using SQLite on a <em>production</em> webserver!? Even the SQLite website advises against this!</p>
| <p>SSH in and use the SQLite command-line client.</p>
<p>But...why are you using SQLite on a <em>production</em> webserver!? Even the SQLite website advises against this!</p>
| 23,035 |
<p>I have written the following simple test in trying to learn Castle Windsor's Fluent Interface:</p>
<pre><code>using NUnit.Framework;
using Castle.Windsor;
using System.Collections;
using Castle.MicroKernel.Registration;
namespace WindsorSample {
public class MyComponent : IMyComponent {
public MyCompon... | <p>Is the assembly in the Global Assembly Cache (GAC) or any place the might be overriding the assembly that you think is being loaded? This is usually the result of an incorrect assembly being loaded, for me it means I usually have something in the GAC overriding the version I have in bin/Debug.</p>
| <p>I just resolved this by running the iisreset command using the command prompt...
Always the first thing I do when I get such errors.</p>
| 15,175 |
<p>A legacy embedded system is implemented using a cooperative multi-tasking scheduler. </p>
<p>The system essentially works along the following lines:</p>
<ul>
<li>Task A does work</li>
<li>When Task A is done, it yields the processor.</li>
<li>Task B gets the processor and does work.</li>
<li>Task B yields<br>
...... | <p>While VxWorks is a priority based OS, it is possible to implement this type of cooperative multi-tasking.</p>
<p>Simply put all the tasks at the <strong>same</strong> priority.<br>
In your code, where you do your <em>yield</em>, simply insert a 'taskDelay(0);'</p>
<p>Note that you have to make sure the kernel time... | <p>This isn't specific to VxWorks, but the system you have described is a variant of Round Robin Scheduling (I'm assuming you are using priority queues, otherwise it is just Round Robin Scheduling).</p>
<p>The <a href="http://en.wikipedia.org/wiki/Round-robin_scheduling" rel="nofollow noreferrer">wiki article</a> prov... | 17,243 |
<p>Is it possible for a JPA entity class to contain two embedded (<code>@Embedded</code>) fields? An example would be:</p>
<pre><code>@Entity
public class Person {
@Embedded
public Address home;
@Embedded
public Address work;
}
public class Address {
public String street;
...
}
</code></pre>
... | <p>If you want to have the same embeddable object type twice in the same entity, the column name defaulting will not work: at least one of the columns will have to be explicit. Hibernate goes beyond the EJB3 spec and allows you to enhance the defaulting mechanism through the NamingStrategy. DefaultComponentSafeNamingSt... | <p>In case you are using hibernate you can also use a different naming scheme which adds unique prefixes to columns for identical embedded fields. See <a href="https://stackoverflow.com/questions/3046677/automatically-add-a-prefix-to-column-names-for-embeddable-classes/43018343#43018343">Automatically Add a Prefix to C... | 42,982 |
<p>Ok</p>
<p>I'm working on a little project at the moment, the Report expects an int but the ReportParameter class only lets me have a value that's a string or a string[]</p>
<p>How can I pass an int?</p>
<p>thanks</p>
<p>dan</p>
| <p>You can call the method <code>GetReportParameters()</code> which will return a <code>ReportParameter[]</code> array. If you iterate through each parameter and look at its Type property it will indicate if it is an <code>int</code>. The Type property is an <code>enum</code> of type <code>ParameterTypeEnum</code> and ... | <p>I would try:</p>
<pre><code>var rp = new ReportParameter("IntValue", intValue.ToString());
report.SetParameters(new ReportParameter[]{rp});
</code></pre>
| 28,918 |
<p>Assuming Visual C/C++ 6, I have a complex data structure of 22399 elements that looks like this:</p>
<pre><code>{
{ "(SAME", "AS", "U+4E18)", "HILLOCK", "OR", "MOUND"},
{ "TO", "LICK;", {1, 1, 0}, "TASTE,", "A", "MAT,", "BAMBOO", "BARK"},
{ "(J)", "NON-STANDARD", "FORM", "OF", "U+559C", ",", {1, 1, 0}, "LIKE,", "LO... | <p>I just read your new posts and re-read the original post, and I think I just fully understood the goal here. Sorry it took so long, I'm kind of slow.</p>
<p>To paraphrase the question, on line 4 of the original example:</p>
<pre><code>{ "(AN", "ANCIENT", {1, 2, 2}, {1, 2, 3}, "U+4E94)", "FIVE"},
</code></pre>
<p... | <p>The saga is not over yet it seems. I eventually ended up turning everything into a ragged array of <code>int</code>. But with that is lost the idea of items in a line which the self-referential mechanism behind the triplets was depending on.</p>
<p>Am now looking into using <a href="http://rapideuphoria.com" rel="n... | 23,791 |
<p>I've been reading the legacy code,which invloves in the customized memory pooling system, then I found that the code uses _aligned_malloc. I wonder what is this function and when do I have to use it. </p>
<hr>
<p>Thanks all of you. </p>
<p>I did read MSDN but what I wanted was the answer like "An example of a rea... | <p>This function is useful when the alignment of your memory allocation is important to you.</p>
<p>Alignment means that the numerical value of the pointer returned must be evenly divisible by a certain number, ie. <code>((unsigned int)ptr) % alignment</code> should evaluate to 0.</p>
<p>An example of a reason for wa... | <p>Have you checked the MSDN documentation?
You can find the respective entry
<a href="http://msdn.microsoft.com/en-us/library/8z34s9c6(VS.80).aspx" rel="nofollow noreferrer">here</a>.</p>
| 15,279 |
<p>My client wants to send email announcements and reports for customers. Now. The python-side code doesn't seem too hard but there's the rest of the story.</p>
<p>What do I require in order to send such emails that won't end up getting blocked by email servers and clients?</p>
| <p>Your program makes an SMTP connection to a sendmail server. If you own that server, you control it's configuration. Nothing will be blocked going out.</p>
<p>Spam, however, is spam. Your client may think their email is golden, but their customers may think it's spam. Oh well.</p>
<p>First, you have to make you... | <p>There's no sure fire way, as email filters can do as they wish, but a few recommendations:</p>
<ul>
<li>Use a real SMTP server, usually your client's (Authenticating if needs be). By real I mean one that's in real usage not a special one to send your emails only.</li>
<li>Send from a real account able to receive re... | 30,056 |
<p>I'm involved in creating a web based business solution. The idea is that the customers will use it, get their business processes and information into one place and also receive added business value by inter-system communication. In short they will use it as a core tool in their daily work and will depend highly upon... | <p>I too make web apps in my personal time and job so I can understand why you ask the above questions. While at work none of the above issues are discussed, I pay a lot of attention to these things in my personal work. I can't answer all your questions, but for the ones I can, I will say this:</p>
<p>How would you mo... | <blockquote>
<p>The system needs to be reachable
through the Internet. What should we
think about when deciding on how to
host it? (i.e. do we need our web host
to have multiple physical paths
connecting them to the Internet and
similar questions.)</p>
</blockquote>
<p>If you want 99% uptime, then yes yo... | 28,416 |
<p>I m just starting using gwt and so far so good, however after reading some sample code I wonder is it necesary to have a high level of test coverage? (I can see that most code is declarative and then add some attributes I can see the sense in checking so me particular attributes are there but not all)</p>
<p>Also i... | <p>I think you asked a pretty broad question, which is part of the reason why you didn't get a reply for a while.</p>
<p>Compared to traditional AJAX web development, one could argue a GWT application requires less testing. Because the GWT team has worked so hard to make sure that its widgets work consistently across... | <p>I think you asked a pretty broad question, which is part of the reason why you didn't get a reply for a while.</p>
<p>Compared to traditional AJAX web development, one could argue a GWT application requires less testing. Because the GWT team has worked so hard to make sure that its widgets work consistently across... | 28,385 |
<p>How is it possible to read/write to the Windows registry using Java?</p>
| <p>I know this question is old, but it is the first search result on google to "java read/write to registry". Recently I found this amazing piece of code which:</p>
<ul>
<li>Can read/write to ANY part of the registry. </li>
<li>DOES NOT USE JNI.</li>
<li>DOES NOT USE ANY 3rd PARTY/EXTERNAL APPLICATIONS TO WORK.</li>
... | <p>I prefer using <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/preferences/overview.html" rel="nofollow">java.util.prefs.Preferences</a> class.</p>
<p>A simple example would be </p>
<pre><code>// Write Operation
Preferences p = Preferences.userRoot();
p.put("key","value");
// also there are variou... | 8,766 |
<p>I have a "span" element inside a "table" "td" element. The span tag has a Title.</p>
<p>I want to get the title of that span tag and pull it out to make it the "mouseover" tip for the "td" element.</p>
<p>For example:</p>
<p>I want to turn this:</p>
<pre><code><td>
<a href="#"><span id="test"... | <p>Based on your edit, you might check out jQuery's DOM traversal methods: <a href="http://docs.jquery.com/Traversing" rel="noreferrer">http://docs.jquery.com/Traversing</a></p>
<p>Something along these lines (not tested, I don't claim it's syntactically correct, just general ideas here)...</p>
<pre><code>$("td").eac... | <p>With jQuery:</p>
<pre><code>$('#test').attr('title')
</code></pre>
| 19,984 |
<p>Basically, I'm trying to create an object of unique objects, a set. I had the brilliant idea of just using a JavaScript object with objects for the property names. Such as,</p>
<pre><code>set[obj] = true;
</code></pre>
<p>This works, up to a point. It works great with string and numbers, but with other objects, th... | <p>JavaScript objects can only use strings as keys (anything else is converted to a string).</p>
<p>You could, alternatively, maintain an array which indexes the objects in question, and use its index string as a reference to the object. Something like this:</p>
<pre><code>var ObjectReference = [];
ObjectReference.pu... | <p>If you truly want set behavior (I'm going by Java knowledge), then you will be hard pressed to find a solution in JavaScript. Most developers will recommend a unique key to represent each object, but this is unlike set, in that you can get two identical objects each with a unique key. The Java API does the work of c... | 23,676 |
<p>I have a large text template which needs tokenized sections replaced by other text. The tokens look something like this: ##USERNAME##. My first instinct is just to use String.Replace(), but is there a better, more efficient way or is Replace() already optimized for this?</p>
| <p><a href="http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.replace.aspx" rel="noreferrer" title="MSDN">System.Text.RegularExpressions.Regex.Replace()</a> is what you seek - IF your tokens are odd enough that you need a regex to find them.</p>
<p><a href="http://blogs.msdn.com/debuggingtoo... | <p>This is an ideal use of Regular Expressions. Check out <a href="http://regular-expressions.info" rel="nofollow noreferrer">this helpful website</a>, the <a href="http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx" rel="nofollow noreferrer">.Net Regular Expressions class</a>, and this v... | 4,063 |
<p>The problem is following: I want to automate the way my emacs starts.
It has to be split in two buffers and the slime-repl has to be started in the smallest (bottom) buffer. Plus, I want my file to be opened in the bigger (upper) buffer.
In my .emacs there are lines:</p>
<pre><code>(slime)
...
(split-window-vertica... | <p>Instead of <code>switch-to-buffer</code>, use function <code>pop-to-buffer</code>.</p>
<blockquote>
<p><code>(pop-to-buffer BUFFER-OR-NAME &optional OTHER-WINDOW NORECORD)</code></p>
<p>Select buffer <code>BUFFER-OR-NAME</code> in some window, preferably a different one.</p>
</blockquote>
| <p>Try:</p>
<pre><code>(other-window 1)
(find-file "g:/Private/pa/pa2.lsp")
</code></pre>
<p>instead of your last two lines.</p>
| 22,855 |
<p>I have a generic list, i.e. <code>List<myclass></code>. Here <code>myclass</code> contains two string properties. </p>
<p>How can I assign a datasource to the list collection?</p>
| <p>Mirmal, I guess English is not your first language, this question is not very clear. I think that what you are asking is given a list of your class how do you then bind that list to something (a listbox or combobox etc)</p>
<p>Here is a simple code snippet of how to do this...</p>
<pre><code>private void button2_C... | <p>You got it the other way around. Databound objects like grids and the like could set generic lists as their data source.</p>
<p>You have to either manually populate your list or use a technology that populates it for you (e.g., LINQ to SQL, NHibernate)</p>
| 17,785 |
<p>I know the rule-of-thumb to read declarations right-to-left and I was fairly sure I knew what was going on until a colleague told me that:</p>
<pre><code>const MyStructure** ppMyStruct;
</code></pre>
<p>means "ppMyStruct is <strong>a pointer to a const pointer to a (mutable) MyStructure</strong>" (in C++).</p>
<p... | <p>Your colleague is wrong. That is a (non-const) pointer to a (non-const) pointer to a const MyStructure. In both C and C++.</p>
| <pre><code>void Foo( int * ptr,
int const * ptrToConst,
int * const constPtr,
int const * const constPtrToConst )
{
*ptr = 0; // OK: modifies the pointee
ptr = 0; // OK: modifies the pointer
*ptrToConst = 0; // Error! Cannot modify the pointee
ptrT... | 43,659 |
<p>What if a Java allow both static and dynamic types. That might allow the best of both worlds. i.e.:</p>
<pre><code>String str = "Hello";
var temp = str;
temp = 10;
temp = temp * 5;
</code></pre>
<ol>
<li>Would that be possible?</li>
<li>Would that be beneficial?</li>
<li>Do any languages currently support both and... | <p>C# has a "var" keyword used in the manner you describe, but it ends up being a strongly typed variable based on the types of values that type checking suggests will go into it.</p>
| <p>Dynamic typed variables just have type <strong>Universal</strong>, such that every other type is a subtype of <strong>Universal</strong>. Any language where all types inherit from such a universal type (such as Java modulo unboxed values) already have this capability. As for usefulness - depends on what you're doi... | 12,454 |
<p>The LinearGradientBrush in .net (or even in GDI+ as a whole?) seems to have a severe bug: Sometimes, it introduces artifacts. (See <a href="http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.languages.csharp/2007-01/msg01592.html" rel="nofollow noreferrer">here</a> or <a href="http://www.experts-exch... | <p>I have noticed this as well when using gradient brushes. The only effective workaround I have is to always create the gradient brush rectangle 1 pixel bigger on all edges than the area that is going to be painted with it. That protects you against the issue on all four edges. The downside is that the colors used at ... | <p>I experienced artifacts too in my C++ code. What solved the problem is setting a non-default SmoothingMode for the Graphics object. Please note that all non-default smoothing modes use coordinate system, which is bound to the center of a pixel. Thus, you have to correctly convert your rectangle from GDI to GDI+ coor... | 13,532 |
<p>Total newbie question but this is driving me mad!
I'm trying this:</p>
<pre><code>myInt = [myFloat integerValue];
</code></pre>
<p>but I get an error saying essentially integerValue doesn't work on floats. </p>
<p>How do I do it?</p>
| <p>I'm pretty sure C-style casting syntax works in Objective C, so try that, too:</p>
<pre><code>int myInt = (int) myFloat;
</code></pre>
<p>It might silence a compiler warning, at least.</p>
| <p>In support of unwind, remember that Objective-C is a superset of C, rather than a completely new language.</p>
<p>Anything you can do in regular old ANSI C can be done in Objective-C.</p>
| 36,461 |
<p>For reference, this would be for Visual Studio 2008 with a fair amount of WinForms working with the VS Designer.</p>
<p>Given the same price bracket, would there be certain specs you look for in a development rig vs what one would get for a gaming machine?</p>
<p>Edit: The reason I ask is on my laptop that I can r... | <p>Any new video card you could buy today would be more than adequate for non-3D software development. In fact whatever integrated video came with your system is fine. The only exception would be for multiple monitor support, in that case you would need to get an extra $50 video card since most (all?) motherboards only... | <p>Any 100 buck graphics card will do fine for software development, although that's probably about what you'd need to see Aero graphics effects on Vista.</p>
| 32,528 |
<p>I am implementing a validation class in classic ASP. How should the validation class interface with my other classes? </p>
<p>My current setup:
The User class's set methods call the appropriate validation method in the validation class. Any errors that occur are stored in User.mError. For example, here's my set met... | <p>You should try the validation concept used in ajaxed (which is an AJAX library for classic ASP - <a href="http://www.webdevbros.net/ajaxed/" rel="nofollow noreferrer">www.webdevbros.net/ajaxed/</a>). Unfortunately the validator will be officialy released in version 2.0 but its already available in <a href="http://co... | <p>I would suggest looking at Validator related classes provided by .net framework.</p>
<p>In your case, you can have a Validator Class (EmailValidator to be specific), which could have a method named Validate which takes a string, returns a boolean</p>
<p>You could also pass ErrorMessage as one of the parameters of ... | 39,447 |
<p>I have a <a href="http://en.wikipedia.org/wiki/Bluehost" rel="noreferrer">Bluehost</a> account where I can run Python scripts as CGI. I guess it's the simplest CGI, because to run I have to define the following in <code>.htaccess</code>:</p>
<pre><code>Options +ExecCGI
AddType text/html py
AddHandler cgi-script .py... | <p><strong>How WSGI, CGI, and the frameworks are all connected?</strong></p>
<p>Apache listens on port 80. It gets an HTTP request. It parses the request to find a way to respond. Apache has a LOT of choices for responding. One way to respond is to use CGI to run a script. Another way to respond is to simply ser... | <p>It's a simple abstraction layer for Python, akin to what the Servlet spec is for Java. Whereas CGI is really low level and just dumps stuff into the process environment and standard in/out, the above two specs model the http request and response as constructs in the language. My impression however is that in Pytho... | 26,965 |
<p>Having the window handle for an open application, I'm able to use the GetWindowText function to retrieve the text from the title bar of the app. I would like to take this a step farther and retrieve the icon associated with the same app. </p>
<p>How might I go about doing this? I looked through what I thought wo... | <pre><code>Icon ico = Icon.ExtractAssociatedIcon(theProcess.MainModule.FileName);
</code></pre>
<p><a href="https://stackoverflow.com/questions/203456/how-can-i-get-the-icon-from-the-executable-file-only-having-an-instance-of-its#203490">From TheSoftwareJedi</a></p>
<p>Initially this appears to be an exact duplicate ... | <p>You could do the following:</p>
<pre><code>[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
static extern IntPtr LoadIcon(IntPtr hInstance, IntPtr lpIconName);
[DllImport("user32.dll", EntryPoint = "GetClassLong")]
static ex... | 39,073 |
<p>One of those classic programming interview questions...</p>
<p>You are given two marbles, and told that they will break when dropped from some certain height (and presumably suffer no damage if dropped from below that height). You’re then taken to a 100 story building (presumably higher than the certain height), an... | <p>The interesting thing here is how you can do it in the least amount of drops possible. Going to the 50th floor and dropping the first would be disastrous if the breaking floor is the 49th, resulting in us having to do 50 drops. We should drop the first marble at floor n, where n is the max amount of drops required. ... | <p>First thing I would do is use the dead simple algorithm that starts at floor 1 drops the marble one floor at a time until it reaches 100 or the marble breaks.</p>
<p>Then I'd ask why should I spend time optimizing it until somone can show that it will be a problem. Too many times people get all hung up on finding t... | 2,826 |
<p>Is there a programatic way from java to force a file deletion on windows even if the file is locked by some process? I cannot kill the process that locks the file.</p>
| <p>you can go through JNI. But the whole point of locking was NOT to allow for deletion from another process.</p>
<p>So, unless you're running Windows 9x, this might be impossible to do.</p>
<p>That said, if you're aware of a way to do it using WIN32, then you might be able to do it in java using JNI.</p>
| <p>I am not an expert on windows, but I do not know of a way in OR OUT of Java to reliably force the deletion of a file that is currently open to a process while the process continues to run.</p>
| 21,238 |
<p><em>Please note: In each step I describe below I'm logged in as the same domain user account.</em></p>
<p>I have a web application that controls a service on a remote machine (via <a href="http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspx" rel="nofollow noreferrer">ServiceControl... | <p>Your scenario is delegation and not impersonation. Delegation is hard to achieve and it depends on many thing that are done right.</p>
<p>A place to start would be <a href="http://support.microsoft.com/kb/907272" rel="nofollow noreferrer">Kerberos authentication and troubleshooting delegation issues</a></p>
<p><a ... | <p>"ANOTHER weird thing about this is that if I'm debugging from my local machine/connecting to the remote server, it works every time! But I'm NOT debugging, it fails every time!"</p>
<p>That's a clear indication that you have permission issues. When you run in the debugger you're running as the logged on user, when... | 41,674 |
<p>In what order are the following parameters tested (in C++)?</p>
<pre><code>if (a || b && c)
{
}
</code></pre>
<p>I've just seen this code in our application and I hate it, I want to add some brackets to just clarify the ordering. But I don't want to add the brackets until I know I'm adding them in the righ... | <p>From <a href="http://www.difranco.net/compsci/C_Operator_Precedence_Table.htm" rel="nofollow noreferrer">here</a>:</p>
<pre><code>a || (b && c)
</code></pre>
<p>This is the default precedence.</p>
| <p>I'm not sure but it should be easy for you to find out.</p>
<p>Just create a small program with a statement that prints out the truth value of:
(true || false && true)</p>
<p>If the result is true, then the || has higher precedence than &&, if it is falase, it's the other way around.</p>
| 13,920 |
<p>I created an html helper </p>
<pre><code>Html.BreadCrumb(IDictionary<string, string> crumbs)
</code></pre>
<p>Where the first string is the label and the second string is the URL.
The helper creates the html required (an unordered list, some classes for first element, current element, last element, dead elem... | <p>BTW we have a naming pattern in ASP.NET MVC for the various rendering techniques.</p>
<p>Helpers that return a string of what they are should be named what they are. For example, Url.Action() and Html.TextBox() return those exact items. Thus, these helpers should be used with the <%= %> syntax.</p>
<p>Helpers t... | <p>I don't think you will have any performance problems as long as the size of the HTML pages you produce is reasonable. And when you really start to create pages of megabytes in size, then you should ask yourself, why are you creating such huge HTML files?</p>
| 32,238 |
<p>Currently I'm trying to erase a sequence of iterators from a set, however GCC's standard library seems to be broken because std::set::erase(iterator) should return the an iterator (next iterator), however in GCC it returns void (which is standard?)</p>
<p>Anyways I want to write:</p>
<pre><code>myIter = mySet.eras... | <p>There is no problem with </p>
<pre><code>mySet.erase(myIter++);
</code></pre>
<p>The order of operation is well-defined: myIter is copied into myTempIter, myIter is incremented, and myTempIter is then given to the erase method.</p>
<p><strong>For Greg and Mark</strong>: no, there is no way operator++ can perform ... | <p>First, reread the standard and you'll see that the prototype of the set::erase method is:</p>
<pre><code>void erase(iterator position);
</code></pre>
<p>However, the associative containers in the STL are "stable", as erasing an element do not affect the iterators on the other elements. This means that the followin... | 19,478 |
<p>We have a button that saves asynchronously using AjaxToolKit/C#/.NET. I'm getting this in my Error Console:</p>
<pre><code>Error: [Exception... "'Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException:
An unknown error occurred while processing the request on the s... | <p>Things to check:</p>
<ol>
<li>Reboot (oldie but goodie, and doesn't always go without saying)</li>
<li>OS version (you did this)</li>
<li>Web browser (you did this)</li>
<li>Web browser settings (you covered this by trying multiple browsers)</li>
<li>Network connectivity and <a href="http://en.wikipedia.org/wiki/Ho... | <p>It is not the error of Ajax, Somewhere your code has error.remove Ajax and then check,u will come to know What is exact error.</p>
<p>Ajit</p>
| 48,174 |
<p>In Perl, a conditional can be expressed either as</p>
<pre><code>if (condition) { do something }
</code></pre>
<p>or as</p>
<pre><code>(condition) and do { do something }
</code></pre>
<p>Interestingly, the second way seems to be about 10% faster. Does anyone know why?</p>
| <p>I've deparsed it, and it really shouldn't be faster. The opcode tree for the first is</p>
<pre><code>LISTOP (0x8177a18) leave [1]
OP (0x8176590) enter
COP (0x8177a40) nextstate
LISTOP (0x8177b20) scope
OP (0x81779b8) null [174]
UNOP (0x8177c40) dofile
SVOP (0x8177b58) c... | <p>It also could depend on the version of Perl. Which you haven't mentioned. And the difference is not enough to worry about anyway. So use whatever makes more sense.</p>
| 11,419 |
<p><strong>Short version</strong></p>
<p>If I split my users into shards, how do I offer a "user search"? Obviously, I don't want every search to hit every shard.</p>
<p><strong>Long version</strong></p>
<p>By shard, I mean have multiple databases where each contains a fraction of the total data. For (a naive) exa... | <p>There is no magic bullet. </p>
<p>Searching each shard in succession is out of the question, obviously, due to the incredibly high latency you will incur.</p>
<p>So you want to search in parallel, if you have to.</p>
<p>There are two realistic options, and you already listed them -- indexing, and parallelized se... | <p>RDBMs are not good tool for textual search. You will be much better off looking at <a href="http://lucene.apache.org/solr/" rel="nofollow">Solr</a>. Performance difference between Solr and database will be in the order of magnitude of 100X. </p>
| 32,548 |
<p>This question has been discussed in two blog posts (<a href="http://dow.ngra.de/2008/10/27/when-systemcurrenttimemillis-is-too-slow/" rel="nofollow noreferrer">http://dow.ngra.de/2008/10/27/when-systemcurrenttimemillis-is-too-slow/</a>, <a href="http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking... | <p>Within the java memory model? No, you are not ok. </p>
<p>I've seen a number of attempts to head towards a very 'soft flush' approach like this, but without an explicit fence, you're definitely playing with fire.</p>
<p>The 'happens before' semantics in </p>
<p><a href="http://java.sun.com/docs/books/jls/third_ed... | <p>Well, I don't think it is.</p>
<p>The first if-statement: </p>
<pre><code>if (counter == HeartBeatThread.counter)
return;
</code></pre>
<p>Does not access any volatile field and is not synchronized. So you might read stale data forever and never get to the point of accessing the volatile field.</p>
<p>Quoti... | 34,477 |
<p>I have a huge dictionary of blank values in a variable called current like so:</p>
<pre><code>struct movieuser {blah blah blah}
Dictionary<movieuser, float> questions = new Dictionary<movieuser, float>();
</code></pre>
<p>So I am looping through this dictionary and need to fill in the "answers", like s... | <p>Matt's answer, getting the keys first, separately is the right way to go. Yes, there'll be some redundancy - but it will work. I'd take a working program which is easy to debug and maintain over an efficient program which either won't work or is hard to maintain any day. </p>
<p>Don't forget that if you make <code>... | <p>store the dictionary keys in a temporary collection then loop over the temp collection and use the key value as your indexer parameter. This should get you around the exception.</p>
| 42,407 |
<p>I'm used to doing all my coding in one C file. However, I'm working on a project large enough that it becomes impractical to do so. I've been #including them together but I've run into cases where I'm #including some files multiple times, etc. I've heard of .h files, but I'm not sure what their function is (or why h... | <p>You should regard .h files as <strong>interface files</strong> of your .c file. Every .c file represents a module with a certain amount of functionality. If functions in a .c file are used by other modules (i.e. other .c files) put the function prototype in the .h interface file. By including the interface file in y... | <p>The .h files should be used to define the prototypes for your functions. This is necessary so you can include the prototypes that you need in your C-file without declaring every function that you need all in one file. </p>
<p>For instance, when you <code>#include <stdio.h></code>, this provides the prototype... | 7,026 |
<p>I know that the JBoss Application Server has the JMX-Console as a GUI for administration. My question is, is there a similar admin tool using the command line? Does this tool come with the application server, and can it report on the status of various services under the control of the server?</p>
| <p>You might want to have a look at twiddle.sh 'A JMX client to 'twiddle' with a remote JBoss server.' </p>
| <p>If you are using JBoss Application Server 6, you can find a command line tool called Twiddle in the <em>bin</em> folder of your installation. You can find more information in JBoss wiki: <a href="http://community.jboss.org/wiki/Twiddle" rel="nofollow">http://community.jboss.org/wiki/Twiddle</a></p>
| 24,615 |
<p>SVN keyword substition gives is not pretty. E.g.,</p>
<blockquote>
<p>Last updated: $Date$ by $Author$</p>
</blockquote>
<p>yields</p>
<blockquote>
<p>Last updated: $Date: 2008-09-22
14:38:43 -0400 (Mon, 22 Sep 2008) $ by
$Author: cconway $"</p>
</blockquote>
<p>Does anybody have a Javascript snippet tha... | <p>Errr.. This feels a bit like me doing your job for you :), but here goes:</p>
<pre><code>function formatSvnString(string){
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
var re = /\$Date: (\d{4})-(\d\d)-(\d\d).*?\$Author: (\S+) \$/
return string.replac... | <p>Some JavaScript libraries provide templating functionality.</p>
<p>Prototype - <a href="http://www.prototypejs.org/api/template" rel="nofollow noreferrer">http://www.prototypejs.org/api/template</a><br>
Ext JS - <a href="http://extjs.com/deploy/dev/docs/?class=Ext.DomHelper" rel="nofollow noreferrer">http://extjs.c... | 14,219 |
<p>I'm developing my first Word 2007 addin, and I've added an OfficeRibbon to my project. In a button-click handler, I'd like a reference to either the current <code>Word.Document</code> or <code>Word.Application</code>.</p>
<p>I'm trying to get a reference via the <code>OfficeRibbon.Context</code> property, which the... | <p>I also encountered this problem while creating an Excel 2007 AddIn using VS2008 SP1. The workaround I used was to store the Application in an <code>internal static</code> property in the main AddIn class and then reference it in the event handler in my ribbon:</p>
<pre><code>public partial class ThisAddIn
{
in... | <p>While I dont know much about changes in Office 2007 word object model, here is my explanation using VBA knowledge.</p>
<p>Application is a globally available object.
Also, Application.ActiveDocument should get you handle to the current document.</p>
<p>Speculating: How are you trying to add the ribbon?</p>
| 31,555 |
<p>Hi I get an System.InvalidProgramException while trying to run the Example Project called "C# Example.WorkItemBrowser".
The Exception also apears when I try to execute these lines:</p>
<pre><code>TeamFoundationServer tfserver = new TeamFoundationServer("http://localhost:8085");
tfserver.EnsureAuthenticated();
WorkI... | <p>This solved my problem: <a href="http://blogs.msdn.com/b/jianges/archive/2008/03/28/tfs-sdk-will-cause-invalidprogramexception-while-running-as-64-bit.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/b/jianges/archive/2008/03/28/tfs-sdk-will-cause-invalidprogramexception-while-running-as-64-bit.aspx</a></p>
| <p>I just a very similar question <a href="https://stackoverflow.com/questions/1015648/how-do-i-distribute-a-service-that-uses-the-team-foundation-server-api">here</a>. </p>
<p>Turns out, you have to have Team Explorer installed on the machine you are executing this code on. Are you deploying this to another machine... | 21,529 |
<p>I've been given a prototype/mockup of a grid written in html and javascript (via ExtJS) that I now need to implement within an ASP.net web application. Does anyone have any pointers as to how to pass data to the grid (to a GroupingStore, specifically). </p>
<p>I'd rather not have a proliferation of web services or ... | <p>I believe a service that simply returns json structures for your pages is the best option, nicely abstracted and reusable across the application rather than page methods.</p>
| <p>I believe a service that simply returns json structures for your pages is the best option, nicely abstracted and reusable across the application rather than page methods.</p>
| 27,260 |
<p><strong>Scenario:</strong> C# apps uses SQL2000. It excecute 3 stored procs within a try catch in the app. In the catch the error is suppressed. Due to some legalities, the c# code cannot be changed and implemented. </p>
<p><strong>Q:</strong> How do I trap the actual SQL error in the stored proc into a log file or... | <p><code>@@ERROR</code> is reset to 0 when you check it. Why? Because it reflects the status of the last statement executed.</p>
<pre><code>IF @@ERROR <> 0 ...
</code></pre>
<p>is a statement, and that statement succeeds, causing <code>@@ERROR</code> to be set to 0.</p>
<p>The proper way to examine and opera... | <p>Didn't try it myself but I guess you can monitor the errors with <strong>Sql Server Profiler</strong>.</p>
| 16,703 |
<p>I have not seen much support for Grails to develop facebook apps.I was just wondering if people around are developing facebook apps on grails </p>
| <p>Jozef Dransfield:
<a href="http://www.grassr.com/wordpress/?cat=8" rel="nofollow noreferrer">http://www.grassr.com/wordpress/?cat=8</a></p>
| <p>I helped out a startup in San Francisco that are using Grails with facebook apps.
So yes, it's happening. There is even a grails plugin for facebook integration (at the time I'm writing this is woefully incomplete, but looks like it's having work done so check up on it again soon).</p>
| 10,751 |
<p>I'm making modifications to a members-based site whose owner wants to be able to track time spent on site (login/logout) for all users in a DB backend. Login is easy; there's one point of entry (the login form) and as a result, logins can be thrown in the database as soon as they happen.</p>
<p>Logouts, however, a... | <p>The web is not built to allow accurate tracking of logout events. You just aren't guaranteed to get notice from the browser when the user quits, so under normal circumstances the best you can hope for is to trap the session timeout event, and that event might not fire until 20 minutes after the user abandoned the p... | <p>I've had good success with using timer in javascript to ping the server. In my case the site requires javascript so this is not an issue. I also use this mechanism to perform a check which prevents a single account from being logged in from two different machines so there is more compelling reasons to do this hack.<... | 43,315 |
<p>I'm making a simple tool that will get a string of MySQL commands and run it (on several DB servers sequentially). I trust the users to be sensible, but mistakes happen, and I'm looking for a way to prevent basic typos:</p>
<p>Is there a way to validate, at runtime, (relatively simple) MySQL queries to see if they'... | <p>Not without knowledge of the schema (for example, is 'x' a table?) and writing a SQL parser. Your MySQL query tool should be able to do that kind of validation (intellisense if you like) but I know from first hand experience, most of the (free) MySQL tools are abysmal.</p>
<p>'Preparing' the query would do what yo... | <p>You can temporarily create a stored procedure with your code and unique name.
Then you can drop it immediately. Transactions can't rollback SP creation.
But be careful, because it just syntax validation, so it doesn't check if an object (in your query) exists or not.</p>
| 49,490 |
<p>Well basically I'm finishing school in mid December so I'm just brushing up my resume and I'm wondering if there's a way to use custom fonts (in this case Calibri and Cambria) in a PDF file and make them render correctly on all computers.</p>
<p>Thanks in advance!</p>
<p><strong>EDIT:</strong> I'm using MS Word 20... | <p>PDFs don't store text and fonts like other documents, they actually convert the font to vectors, that way no matter what font you use, the document displays exactly as expected. This is why searching for text inside the PDF is such a problem for 3rd party PDF Readers and why even Adobe themselves use to distribute ... | <p>theoretically speaking, on technical side, embedding/not embedding ability, regarding the fonts, is settled with a special flag in font file (ttf or opentype or type1)</p>
<p>you can view this special embedding flag with any font <strong>editor</strong> program (I recommend</p>
<p><strong>FontCreator</strong> (by ... | 34,023 |
<p>I'm currently trying to read text from a file and append it to a element in my html page using the DOM and Javascript. I can't get the text to format though. I've tried using innerHtml but isn't formating at all( no line breaks ).</p>
<p>Here is the javascript:</p>
<pre><code>http = new XMLHttpRequest();
http.open... | <p>You might have luck wrapping the text in a <code><pre></code> tag. What's in the response? If it's XML, you might want to use <code>responseXML</code>.</p>
<pre><code>http = new XMLHttpRequest();
http.open("GET",FILE,false);
http.send();
document.getElementById("tbody").appendChild(http.responseXML);
<... | <p>innerHTML takes (and parses) and html string, so what should result is a DOM tree similar to</p>
<p>(assuming )</p>
<pre><code><tbody>{responseText}</tbody>
</code></pre>
<p>But without knowing what type of content is in the response text it's difficult to know the exact cause of your problem.</p>
| 45,327 |
<p>In our place we're split between using mysqli and PDO for stuff like prepared statements and transaction support. Some projects use one, some the other. There is little realistic likelihood of us ever moving to another RDBMS.</p>
<p>I prefer PDO for the single reason that it allows named parameters for prepared sta... | <p>Well, you could argue with the object oriented aspect, the prepared statements, the fact that it becomes a standard, etc. But I know that most of the time, convincing somebody works better with a killer feature. So there it is:</p>
<p>A really nice thing with PDO is you can fetch the data, injecting it automaticall... | <p>There's one thing to keep in mind.</p>
<p>Mysqli does not support fetch_assoc() function which would return the columns with keys representing column names. Of course it's possible to write your own function to do that, it's not even very long, but I had <strong>really</strong> hard time writing it (for non-believe... | 3,450 |
<p>We're seeing the error message ORA-00936 Missing Expression for the following SQL:</p>
<p>Note that this is just a cut-down version of a much bigger SQL so rewriting it to a inner join or similar is not really in the scope of this:</p>
<p>This is the SQL that fails:</p>
<pre><code>select (select count(*) from gt_... | <p>That should work, assuming the column names are not ambiguous (and even if they were that would lead to a different error). I ran an equivalent statement and got a result without error:</p>
<pre><code>SQL> select (select count(*) from emp2 where empdeptno = deptno)
2 from dept
3 where deptno=10
4 /
(S... | <p>That should work, assuming the column names are not ambiguous (and even if they were that would lead to a different error). I ran an equivalent statement and got a result without error:</p>
<pre><code>SQL> select (select count(*) from emp2 where empdeptno = deptno)
2 from dept
3 where deptno=10
4 /
(S... | 31,078 |
<p>I am using a nested html unordered list styled as a drop down. When the a tag within the inner lists list item is clicked it trigger some javascript which is supposed to set the value of a hidden field to the text for the link that was clicked.</p>
<p>The javascript seems to work - I used an alert to read the value... | <p>I would do this: First, remove the <code>runat='server'</code> attribute from the hidden field (inside body):</p>
<pre><code><input type="hidden" id="accomodationAnswer" />
</code></pre>
<p>Now, on the server, where you want to read that value, do this:</p>
<pre><code>string accomodationAnswer = Request.For... | <p>Try this</p>
<p>if you are using .net 4.0 then in page header.</p>
<p>Language="C#" AutoEventWireup="true" CodeFile="Page.cs" Inherits="Page"</p>
<p>Alongwith this write:</p>
<pre><code>ClientIDMode="Static"
</code></pre>
<p>It helps in not changing the server side control id at runtime</p>
<p>Now</p>
<p></p>... | 42,964 |
<p>What is the best way to implement connection pooling in hsqldb, without compromising on the speed?</p>
| <p>Hibernate gets connections from a <code>DataSource</code>, uses them and closes them. You need a connection pool or it will be very inefficient, consuming a lot of resources both on your app and on the DBMS, regardless of the database server you use.</p>
<p>You should try out <em>commons-dbcp</em> from Apache-Jakart... | <p>If you used Hibernate's own connection pooler, you could consider using <a href="http://sourceforge.net/projects/c3p0" rel="nofollow noreferrer">c3p0</a>? (If you're already using c3p0, I can't help further) I haven't used HSQLDB myself but I think that could be worth trying.</p>
| 33,221 |
<p>How do I make it so <code>mailto:</code> links will be registered with my program?</p>
<p>How would I then handle that event in my program?</p>
<p>Most of the solutions I found from a quick Google search are how to do this manually, but I need to do this automatically for users of my program if they click a button, ... | <p><em>@Dillie-O: Your answer put me in the right direction (I should have expected it to just be a registry change) and I got this working. But I'm going to mark this as the answer because I'm going to put some additional information that I found while working on this.</em></p>
<p>The solution to this question really ... | <p>From what I've seen, there are a few registry keys that set the default mail client. One of them is:</p>
<p>System Key: <code>[HKEY_CLASSES_ROOT\mailto\shell\open\command]</code></p>
<p>Value Name: <code>(Default)</code></p>
<p>Data Type: <code>REG_SZ</code> (String Value)</p>
<p>Value Data: <code>Mail program comma... | 2,272 |
<p>Background: In my job, we use SVN, C# and VisualStudio. Part of my task regularly involves global renames. Often I end up with a broken build after renaming something and then merging in changes.</p>
<p>The question: is there a solution out there that can look at my changes, notice the global rename and then apply ... | <p>There is a commercial tool for exactly that use case called <a href="https://www.semanticmerge.com/" rel="nofollow noreferrer">Semantic Merge</a>. They provide a 15-day free trial, open source projects may use it for free (<a href="https://users.semanticmerge.com/Checkout" rel="nofollow noreferrer">contact the suppo... | <p>Assuming at least VS 2005 and the global rename is a variable/property/function, there is a Refactor - Rename right-click menu option you could use. By design it propagates the name change in your entire solution.</p>
| 16,368 |
<p>Many languages have standard repositories where people donate useful libraries that they want others to have access to. For instance Perl has CPAN, PHP has PEAR, Ruby has RubyGems, and so on. What is the best option for JavaScript?</p>
<p>I ask because a few months ago I ported <a href="http://search.cpan.org/~mi... | <p>AFAIK, there is no central JavaScript repository, but you might have success promoting it on <a href="http://snipplr.com/" rel="nofollow noreferrer">Snipplr</a> or as a project on <a href="http://code.google.com/" rel="nofollow noreferrer">Google Code</a>.</p>
| <p>You could start a project on SourceForge to contain useful snippets of code like this (or google for snippets to find one).</p>
| 12,498 |
<p>I need to pause for maybe 500 miliseconds before I submit a form. Here is what I have so far:</p>
<pre><code> $(".rowqty input").bind("keyup", function() { $("#ViewCartPage form").animate({ opacity: 1.0 }, 3000).submit() });
</code></pre>
<p>so when someone changes the quantity of the input field it submits the f... | <p>Give this a shot:</p>
<pre><code>$(".rowqty input").bind("keyup", function() { setTimeout("$('#ViewCartPage form').submit()", 500 });
</code></pre>
| <pre><code>setTimeout(function () {$("#formID").submit()},1000);
</code></pre>
<p>it works for me (no quotes)</p>
| 33,228 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.