instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I'm trying to implement paging using row-based limiting (for example: <code>setFirstResult(5)</code> and <code>setMaxResults(10)</code>) on a Hibernate Criteria query that has joins to other tables.</p>
<p>Understandably, data is getting cut off randomly; and the reason for that is explained <a href="https://develo... | <p>You can achieve the desired result by requesting a list of distinct ids instead of a list of distinct hydrated objects.</p>
<p>Simply add this to your criteria:</p>
<pre><code>criteria.setProjection(Projections.distinct(Projections.property("id")));
</code></pre>
<p>Now you'll get the correct number of results ac... | <p><code>NullPointerException</code> in some cases!
Without <code>criteria.setProjection(Projections.distinct(Projections.property("id")))</code>
all query goes well!
This solution is bad!</p>
<p>Another way is use SQLQuery. In my case following code works fine:</p>
<pre><code>List result = getSession().createSQLQuer... | 38,519 |
<p>The use of XSLT (XML Stylesheet Language Transform) has never seen the same popularity of many of the other languages that came out during the internet boom. While it is in use, and in some cases by large successful companies (i.e. Blizzard Entertainment), it has never seemed to reach mainstream. Why do you think ... | <p>One problem is that XSLT <em>looks</em> complicated. Any developer should be able to pick up the language constructs as there are analogs in most other languages. The problem is that the constructs and data all look exactly the same which makes it difficult to distinguish between the two which makes XSLT more diff... | <p>xslt is great for xml to xml, when you have data that is already escaped and a clear definition of inputs and outputs. using it for things like xml2html to me just seems like such a headache, and with nearly any dynamic language and css the output is a lot easier to implement with style.</p>
| 10,288 |
<p>How do you test the usability of the user interfaces of your applications - be they web or desktop? Do you just throw it all together and then tweak it based on user experience once the application is live? Or do you pass it to a specific usability team for testing prior to release?</p>
<p>We are a small software... | <p>I like <a href="http://friendfeed.com/paul" rel="noreferrer">Paul Buchheit's</a> answer on this from startup school. The short version of what he said listen to your users. Listen does not mean obey your users. Take in the data filter out all the bad advice and iteratively clean up the site. Lather, rinse, repeat. <... | <p>I'm a strong believer in what I call 3-martini usability testing. When designing a system, imagine that the person who will be using it has just had 3 martinis. </p>
<p>Before handing over the system to colleagues (other programmers, quality assurance, tech support) or usability testers, an informal test with a cou... | 3,880 |
<p>I have an ASP.NET web service which does some heavy lifting, like say,some file operations, or generating Excel Sheets from a bunch of crystal reports. I don't want to be blocked by calling this web service, so i want to make the web service call asynchronous. Also, I want to call this web service from a web page, a... | <p>Write a separate method on the server that you can query by passing the ID of the job that has been scheduled and which returns an approximate value between 0-100 (or 0.0 and 1.0, or whatever) of how far along it is.</p>
<p>E.g. in REST-style, you could make a GET request to <code>http://yourserver.com/app/jobstatu... | <p>Make the web service to return some sort of task ID or session ID. Make another web method to query with that ID, which returns the information needed (% completion, list of files, whatever). Poll this method at some interval from the client.</p>
<p>Use a database to store the process information, if you do this in... | 16,409 |
<p>I have made a bunch of changes to a number of files in a project. Every commit (usually at the file level) was accompanied by a comment of what was changed. </p>
<p>Is there a way to get a list from CVS of these comments on changes since the last tagged version?</p>
<p>Bonus if I can do this via the eclipse CVS pl... | <p>The options for the cvs log command are available <a href="http://www.cvsnt.org/manual/html/log.html" rel="noreferrer">here</a>. Specifically, to get all the commits since a specific tag (lets call it VERSION_1_0)</p>
<pre><code>cvs log -rVERSION_1_0:
</code></pre>
<p>If your goal is to have a command that works w... | <p>I know you have already "solved" your problem, but I had the same problem and here is how I quickly got all of the comments out of cvs from a given revision until the latest:</p>
<pre>$ mkdir ~/repo
$ cd ~/repo
$ mkdir cvs
$ cd cvs
$ scp -pr geek@avoid.cvs.org:/cvs/CVSROOT .
$ mkdir -p my/favorite
$ cd my/favorite
... | 31,488 |
<p>Im trying to generate views in unit tests but i can't get around the missing VirtualPathProvider. Most viewengines use the VirtualPathProviderViewEngine base class that gets the provider from the current HostingEnvironment.</p>
<pre><code>protected VirtualPathProvider VirtualPathProvider {
get {
if (_vp... | <p>There are features coming in VS Team System 2010 for the Acceptance Testing which would be appropriate for what you are trying to do. As mentioned by Gregory A Beamer Unit tests for MVC are done to the controller. You can also test the Model depending on how you implement your model. </p>
<p>This is where there ... | <p>I tried to do this as well. Unfortunately, it is not just the VirtualPathProvider (VPP) that is the problem. The VPP is used to map the view or partial view to a physical path to determine the existance of the file. Unfortunately, the ViewContext ends up with the virtualpath, not the physical path, so when the vi... | 42,023 |
<p>I'm building a caching system and I want it to be ready for distributed caching a la memcached. What I'm looking to do is to convert a traditional Hashtable/Dictionary of (string -> object) and to allow per-item expiration to be handled by the Cache itself, in the way that the System.Web.Caching.Cache can do.</p>
... | <p>The most important thing is to make sure that your application is easy to port, follow normal DI/IOC (Dependency injection/Inversion of control) principles. So code that depends on the cache should not</p>
<ul>
<li>Get a reference to the cache themself</li>
<li>Reference a Dictionary<,> object</li>
</ul>
<p>Ins... | <p>This might be helpful
<a href="http://www.codeplex.com/memcachedproviders" rel="nofollow noreferrer">Memcached Providers</a></p>
| 38,479 |
<p>Can Spirit (part of Boost C++ library) be used to parse out binary data coming from a stream? For example, can it be used to parse data coming from a socket into structures, bytes, and individual bit flags? Thanks!</p>
| <p>Boost Spirit allows for a parser to be defined using <a href="http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form" rel="nofollow noreferrer">Extended Backus–Naur Form (EBNF)</a> syntax with <a href="http://en.wikipedia.org/wiki/Template_metaprogramming" rel="nofollow noreferrer">template meta-programming<... | <p>Spirit2, just released, has facilities for parsing binary. <a href="http://www.boost.org/doc/libs/1_41_0/libs/spirit/doc/html/spirit/qi/reference/binary.html" rel="nofollow noreferrer">Check out this</a>.</p>
| 36,200 |
<p>I am using .NET remoting to retrieve periodic status updates from a Windows service into a 'controller' application which is used to display some live stats about what the service is doing.</p>
<p>The resulting network traffic is huge - many times the size of the data for the updates - so clearly I have implemented... | <p>There is an Empower program that Microsoft has available. It gives you several Premium subscriptions for cheap, with the catch that you have to be an ISV working towards an actual product.</p>
<p><a href="https://partner.microsoft.com/global/program/40066412" rel="nofollow noreferrer">This</a> (Not available anymor... | <p>Many MVP's have gift subscriptions that they can give away, so it pays off to be visible in the community.</p>
<p>Speak at your local user group, start (or participate) in an open source project, start a blog... just generally get your name out there.</p>
<p>Eventually you'll get one (or an MVP :)).</p>
<p>What I... | 6,396 |
<p>We have a query that selects rows depending on the value of another, ie. the max. I don't think that really makes much sense, so here is the query:</p>
<pre><code>var deatched = DetachedCriteria.For<Enquiry>("e2")
.SetProjection(Projections.Alias(Projections.Max("Property"), "maxProperty"))
.Add(Restri... | <p>For aggregations it is better to use SQL and not HQL.Use Nhibernate just for main Entities and their relations (very maintainable design) .Stored procedures are a better place to these aggregations and functions because they are data dependent and not object dependent</p>
| <p>I think this must work:</p>
<pre><code>(from e in NHibernateSession().Query<Enquiry>()
where e.Property == (
(
from e2 NHibernateSession().Query<Enquiry>()
where e2.EnqueryCode == e.EnquiryCode
select e2.Property).Max()
)
select e
).ToList<Enquiry>()
</code>... | 46,491 |
<p>I'm starting to code up my own window manager, and was wondering how to use the xorg api to get from raw image data ( such as the data given by libpng ), into an Xorg Pixmap or something drawable by Xorg?</p>
| <p>XCreatePixmapFromBitmapData should do just that. Remember that you need to feed in data of the same bit depth as your xserver is using.</p>
| <p>There's a little dance with XCreateImage, XCreatePixmap and XCopyArea you have to do. It goes a little like this:</p>
<pre><code>struct Image img = get_pixels_and_geometry_from_libpng("filename.png");
XImage *img = XCreateImage(/*5000 paremeters*/);
Pixmap pixmap = XCreatePixmap(dpy, img.width, img.height, 24);
XPu... | 45,063 |
<p>I am from a c# background and am converting a vb.net windows forms app to c#.
I have a windows form called associateForm.
In code the developer references associate form like so:-</p>
<pre><code>Private Sub NotifyIcon1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles... | <p>VB.Net for .Net 2.0 and later has something called default form instances. When you define a form, you get an automatic instance of the form with the same name as the type.</p>
| <p>Joel is correct. This feature exists because VB.NET emulates the VB6 method of being able to refer to a default instance of a form through it's name. </p>
<p>When you convert this to C# you need to provide global access to a a single instance named associateForm. There is a chance that something is preserved in bet... | 43,862 |
<p>I have an ASP.net page. When I am closing the webpage I need to clear the session variables.</p>
<p>How to to handle this I need to maintain the timeout to 20 minutes.
If he closes and login for any number of times in the 20 minutes timed out time</p>
<p>Is there any possiblity for clearing the ASP.net session id<... | <p>[EDIT] As others have suggested, your session should time out eventually, but if you want to close the session before the timeout (for example to clean up large session objects) AND have javascript available to you...</p>
<p>You can do this with an <code>window.onbeforeunload</code> handler that posts back to a sig... | <p>Hello Try This javascript function</p>
<pre><code>function ConfirmClose()
{
if (event.clientY < 0)
{
/* Your asynchronouse request to the page and call that function*/
}
}
/*now call this method on event of javascript*/
</code></pre>
<p>i didn'try this but it just came out from mind </p>
| 36,505 |
<p>I'm interested in hearing your opinions in which is the best way of implementing a social activity stream (Facebook is the most famous example). Problems/challenges involved are:</p>
<ul>
<li>Different types of activities (posting, commenting ..)</li>
<li>Different types of objects (post, comment, photo ..)</li>
<l... | <p>I have created such system and I took this approach:</p>
<p>Database table with the following columns: id, userId, type, data, time.</p>
<ul>
<li><strong>userId</strong> is the user who generated the activity</li>
<li><strong>type</strong> is the type of the activity (i.e. Wrote blog post, added photo, commented o... | <p>I think <a href="http://plurk.com" rel="nofollow noreferrer">Plurk's</a> approach is interesting: they supply your entire timeline in a format that looks a lot like Google Finance's stock charts.</p>
<p>It may be worth looking at <a href="http://ning.com" rel="nofollow noreferrer">Ning</a> to see how a social netwo... | 24,715 |
<p>using jython</p>
<p>I have a situation where emails come in with different attachments. Certain file types I process others I ignore and dont write to file.
I am caught in a rather nasty situation, because sometimes people send an email as an attachment, and that attached email has legal attachments. </p>
<p>What ... | <p>The problem with existing suggestions is the walk method. This recursively, depth-first, walks the entire tree, including children.</p>
<p>Look at the source of the walk method, and adapt it to skip the recursive part. A cursory reading suggests:</p>
<pre><code>if msg.is_multipart():
for part in msg.get_payloa... | <p>What about the example named "<a href="http://docs.python.org/library/email-examples.html" rel="nofollow noreferrer">Here’s an example of how to unpack a MIME message like the one above, into a directory of files</a>"? It looks close from what you want.</p>
<pre><code>import email
...
msg = email.message_from_file(... | 41,369 |
<p>I'm looking to have text display vertically, first letter at the bottom, last letter at the top, within a JLabel. Is this possible?</p>
| <p>I found this page: <a href="http://www.java2s.com/Tutorial/Java/0240__Swing/VerticalLabelUI.htm" rel="noreferrer">http://www.java2s.com/Tutorial/Java/0240__Swing/VerticalLabelUI.htm</a> when I needed to do that.</p>
<p>I don't know if you want the letters 'standing' on each other or all rotated on their side.</p>
... | <p>You can also use the SwingX API</p>
<p>Bottom to top :</p>
<pre><code>JXLabel label = new JXLabel("MY TEXT");
label.setTextRotation(3 * Math.PI / 2);
</code></pre>
<p>Top to bottom :</p>
<pre><code>JXLabel label = new JXLabel("MY TEXT");
label.setTextRotation(Math.PI / 2);
</code></pre>
| 11,824 |
<p>I find myself doing 2 things quite often in JS, at the moment using jQuery:</p>
<p>The first is the populating of an HTML element, which might look like:</p>
<pre><code>$.get('http://www.example.com/get_result.php', { id: 1 }, function (data) {
$('#elementId').html(data);
});
</code></pre>
<p>The second is po... | <p>Here's a quick jQuery plugin I wrote that makes your first example more re-usable:</p>
<pre><code>(function ($) {
$.fn.populateWith = function(sUrl, oData, fCallback) {
if (!oData) oData = false;
if (!fCallback) fCallback = false;
$(this).load(sUrl, oData, fCallback);
};
})(jQuery);
... | <p>For filling an element with the results of an AJAH call, check out the <a href="http://docs.jquery.com/Ajax/load#urldatacallback" rel="nofollow noreferrer">load method</a>.</p>
<p>I'm not aware of an existing plugin to specifically load JSON data into a select list, but it would be straightforward enough to write o... | 47,743 |
<p>Now that <code>LINQ</code> to <code>SQL</code> is a little more mature, I'd like to know of any techniques people are using to create an <strong>n-tiered solution</strong> using the technology, because it does not seem that obvious to me.</p>
| <p>LINQ to SQL doesn't really have a n-tier story that I've seen, since the objects that it creates are created in the class with the rest of it, you don't really have an assembly that you can nicely reference through something like Web Services, etc.</p>
<p>The only way I'd really consider it is using the datacontext... | <blockquote>
<p>Seriously speaking, LINQ to SQL had it's support for n-tier architecture see DataContext.Update method</p>
</blockquote>
<p>Some of what I've read suggests that the business logic wraps the DataContext - in other words you wrap the update in the way that you suggest. </p>
<p>The way i traditionally... | 5,888 |
<p>Joining an existing team with a large codebase already in place can be daunting. What's the best approach;</p>
<ul>
<li>Broad; try to get a general overview of how everything links together, from the code</li>
<li>Narrow; focus on small sections of code at a time, understanding how they work fully</li>
<li>Pick a f... | <p>Start with some small task if possible, debug the code around your problem.
Stepping through code in debug mode is the easiest way to learn how something works. </p>
| <p>(shameless marketing ahead)</p>
<p>You should check out <a href="http://www.nwiresoftware.com/" rel="nofollow noreferrer">nWire</a>. It is an Eclipse plugin for navigating and visualizing large codebases. Many of our customers use it to break-in new developers by printing out visualizations of the major flows.</p>
| 26,434 |
<p>I have a UI widget that needs to be put in an IFRAME both for performance reasons and so we can syndicate it out to affiliate sites easily. The UI for the widget includes tool-tips that display over the top of other page content. See screenshot below or <strong><a href="http://www.bookabach.co.nz/" rel="noreferrer">... | <p>No it's not possible. Ignoring any historical reasons, nowadays it would be considered a security vulnerability -- eg. many sites put untrusted content into iframes (the iframe source being a different origin so cannot modify the parent frame, per the same origin policy).</p>
<p>If such untrusted content had a mec... | <p>As far as I know it cannot be done. Why not use an XHR request and populate a div instead?</p>
| 21,272 |
<p>Following advice I read elsewhere, I have covered my (heated) print bed with blue painter's tape, and before each print I apply an Elmer's purple washable glue stick to improve bed adhesion.</p>
<p>After the print finishes and I remove the part from the bed, the bottom is covered with a white residue. I'm fairly ce... | <p>Elmer's Purple Gluestick is pretty much based on PVA with a water-indicator. It is a water-soluble material. Tossing the piece into a water bin and brushing it with a toothbrush should remove everything.</p>
| <p>I have two different makes of masking tape. The print stick so well to one of them that I end up ripping the tape up to get it off and the bottom of the print has the tape suck to it. The other roll was the complete opposite, nothing would stick to it. I ended up using the non-stick tape and applied a diluted (30% P... | 1,293 |
<p>How can I detect if another host is using the same MAC address as the current host, e.g. because the other host is spoofing?</p>
<p>I'm working in an embedded environment, so looking for answers on a protocol level, rather than “use such and such a tool”.</p>
<p><strong>Edit</strong>: RARP does <em>not</em> solve ... | <p>This question is too interesting to put down! After several false starts I started thinking about the essential components of the problem and scoured the RFCs for advice. <strong>I haven't found a definitive answer,</strong> but here's my thought process, in the hope that it helps:</p>
<ul>
<li><p>The original qu... | <p>Two hosts using same MAC address on a single network segment would probably make switches go nuts and you could probably detect it by having an extremely unreliable network connection (as the switches would send some portion of packets that belong to your host to the second one, depending on which one of you sent th... | 34,944 |
<p>Recently, at work we bought a Guider II printer from FlashForge.
When we try to print models using a high resolution or models with a too high printing time, the feeder gets clogged. And the feeder is too hot. We have concluded that the feeder is getting clogged because the high temperature softens the PLA.</p>
<p>... | <p>The symptoms you describe hint to heat creep. Heat creep is the gradual increase in temperature of the cold end assembly (cooling fins and heat break). This gradual temperature increase leads to too high filament temperatures and as such premature filament softening. In combination with (large) retraction settings, ... | <p>If the temperature is too high it can charr the plastic, causing jams. There are many reasons for that. If the temperature you have selected is not too high (<200C), then it might be the thermistor not correctly reading the temperature. If you can measure the hot end temperature, that will give definitive answer ... | 1,201 |
<p>I'm possibly just stupid, but I'm trying to find a user in Active Directory from C#, using the Login name ("domain\user").</p>
<p>My "Skeleton" AD Search Functionality looks like this usually:</p>
<pre><code>de = new DirectoryEntry(string.Format("LDAP://{0}", ADSearchBase), null, null, AuthenticationTypes.Secure);... | <p>You need to set a filter (DirectorySearcher.Filter) something like:</p>
<p>"(&(objectCategory=person)(objectClass=user)(sAMAccountName={0}))"</p>
<p>Note that you only specify the username (without the domain) for the property sAMAccountName. To search for domain\user, first locate the naming context for the ... | <p>Logon Name(Pre-Windows 2000)</p>
<pre><code>"(&(objectCategory=person)(objectClass=user)(!sAMAccountType=805306370)(sAMAccountName=John))"
</code></pre>
<p>Logon Name(Windows 2000 and above)</p>
<pre><code>"(&(objectCategory=person)(objectClass=user)(!sAMAccountType=805306370)(userPrincipalName=John))"
</... | 19,506 |
<p>How do I call MySQL stored procedures from Perl? Stored procedure functionality is fairly new to MySQL and the MySQL modules for Perl don't seem to have caught up yet.</p>
| <p>There's an example in the <a href="http://search.cpan.org/dist/DBD-mysql/lib/DBD/mysql.pm#MULTIPLE_RESULT_SETS" rel="nofollow noreferrer">section on Multiple result sets in the DBD::mysql docs</a>.</p>
| <p><em>Hi, similar to above but using SQL exec. I could not get the CALL command to work. You will need to fill in anything that is within square brackets and remove the square brackets.</em> </p>
<pre>
use DBI;
#START: SET UP DATABASE AND CONNECT
my $host = '*[server]*\\*[database]*';
my $database ... | 8,968 |
<p>How do I get started?</p>
| <p>I have found the easiest way to achieve this by using Clojure.
Here is the example code:
<pre><code>
(ns example
(:require [clojure.contrib.sql :as sql])
(:import [java.sql Types]))</p>
<p>(def devdb {:classname "oracle.jdbc.driver.OracleDriver"
:subprotocol "oracle"
:subname "thin:user... | <p>You'll need an interface to the Oracle SQL database. As Bob pointed out, Allegro CL has such an interface.</p>
<p><a href="http://clisp.cons.org/impnotes/oracle.html" rel="nofollow noreferrer">GNU CLISP apparently comes with an interface to the database as well.</a></p>
| 9,207 |
<p>I have two tables in a DataSet in .NET. I want to join them on an ID column. Then I want a DataGridView to display two columns from the first table and one column from the second table.</p>
<p>If it makes it easier, the relation between the two tables is one-to-one.</p>
<p>Can it be done?</p>
| <p>Well, is it read only? In .NET 3.5 / C# 3.0 you could probably use a LINQ join and an anonymous output type pretty easily:</p>
<pre><code> DataTable left = new DataTable
{
Columns = { {"PK", typeof(int)}, {"Name", typeof(string)}},
Rows = {{1,"abc"},{2,"def"}}
}, right... | <p>Why not to use the designer?
You place both tables in the dataset, you establish the relationship, and change the Fill/Get methods, to something like this (with the "inner join"):</p>
<blockquote>
<p>SELECT Productos.idProducto,
Productos.Nombre, Precios.Precio,
Tiendas.idTienda,
Zonas.Zona,Productos... | 40,208 |
<p>I've looked at <a href="http://en.wikipedia.org/wiki/Strategy_pattern" rel="noreferrer">this explanation on Wikipedia</a>, specifically the C++ sample, and fail to recognize the difference between just defining 3 classes, creating instances and calling them, and that example. What I saw was just placing two other cl... | <p>The point is to separate algorithms into classes that can be plugged in at runtime. For instance, let's say you have an application that includes a clock. There are many different ways that you can draw a clock, but for the most part the underlying functionality is the same. So you can create a clock display interfa... | <p>Strategy pattern works on simple idea i.e. "Favor Composition over Inheritance" so that strategy/algorithm can be changed at run time. To illustrate let's take an example where in we need to encrypt different messages based on its type e.g. MailMessage, ChatMessage etc.</p>
<pre><code>class CEncryptor
{
virtual... | 20,708 |
<p>What is the best way (performance wise) to paginate results in SQL Server 2000, 2005, 2008, 2012 if you also want to get the total number of results (before paginating)?</p>
| <p>Getting the total number of results and paginating are two different operations. For the sake of this example, let's assume that the query you're dealing with is</p>
<pre><code>SELECT * FROM Orders WHERE OrderDate >= '1980-01-01' ORDER BY OrderDate
</code></pre>
<p>In this case, you would determine the total nu... | <p>You didn't specify the language nor which driver you are using. Therefore I'm describing it abstractly.</p>
<ul>
<li>Create a scrollable resultset / dataset. This required a primary on the table(s)</li>
<li>jump to the end</li>
<li>request the row count </li>
<li>jump to the start of the page</li>
<li>scroll throug... | 13,450 |
<h3>What are some methods of utilising Eclipse for Dependency Management?</h3>
| <p>I really like the <a href="http://maven.apache.org/eclipse-plugin.html" rel="noreferrer">The Maven Integration for Eclipse (m2eclipse, Eclipse m2e)</a>. I use it purely for the dependency management feature. It's great not having to go out and download a bunch of new jars new each time I set up a project. </p>
| <p>Another option is ivy. Ivy has eclipse integration as well.</p>
<p>A comparison of maven and ivy can be found here:
<a href="http://ant.apache.org/ivy/m2comparison.html" rel="nofollow noreferrer">http://ant.apache.org/ivy/m2comparison.html</a></p>
| 17,222 |
<p>Is there a way to pass a password to ssh automatically. I would like to automatically ssh to a server <b>without</b> using public key authentication or expect scripts, by somehow getting ssh to read the password from stdin or a file.</p>
<p>The reason it has to be that way is that I would like to backup my files to... | <blockquote>
<p>expect is out of the question because I would like to run it as a cron job,
and since cron jobs don't run under a terminal the combination of expect/ssh
just doesn't work</p>
</blockquote>
<p>You can run expect scripts from cron, at least you can with expect libraries like "pexpect" for Python. I... | <p>You have misunderstood how public key authentication works. You don't need access to your remote home directory, simply put the local public key in the remote <code>authorized_keys</code> file. Have a google around, there's plenty of guides.</p>
| 34,087 |
<p>I have a table in a database that represents dates textually (i.e. "2008-11-09") and I would like to replace them with the UNIX timestamp. However, I don't think that MySQL is capable of doing the conversion on its own, so I'd like to write a little script to do the conversion. The way I can think to do it involves ... | <p>Does this not do it?</p>
<pre><code>UPDATE
MyTable
SET
MyTimeStamp = UNIX_TIMESTAMP(MyDateTime);
</code></pre>
| <p>If for some reason you do have to iterate (the other answers cover the situation where you don't), I can think of two ways to do it (these aren't MySQL-specific):</p>
<ol>
<li><p>Add a column to the table that's an auto-assigned number. Use that as the PK for your updates, then drop the column afterwards (or just k... | 34,831 |
<p>Question for anyone who's used Mechanical Turk: Is it possible to take an HTML template created on Mechanical Turk's website, and then create more HITs based on that template from the command line tools or API? </p>
<hr>
<p>According to the API docs, it's not possible to create new HTML and add it...from the API. ... | <p>You could post a job on Mechanical Turk to have a person take your template and insert your data into it for each HIT you want to create.</p>
<p>(yes, this is at least half sarcasm)</p>
| <p>As far as I know, I haven't seen a way to use manually created questions from the API.</p>
<p>If you're planning on doing programmatic access, it may be easier to use the API in its entirety (i.e., specify your questions via XML and create HITs from that question):</p>
<p><a href="http://www.codeplex.com/MTurkDotN... | 40,662 |
<p>Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7.</p>
| <p>There is no (exactly correct) solution which will run in a constant amount of time, since 1/7 is an infinite decimal in base 5. One simple solution would be to use rejection sampling, e.g.:</p>
<pre><code>
int i;
do
{
i = 5 * (rand5() - 1) + rand5(); // i is now uniformly random between 1 and 25
} while(i > 21)... | <p>solution in php</p>
<pre><code><?php
function random_5(){
return rand(1,5);
}
function random_7(){
$total = 0;
for($i=0;$i<7;$i++){
$total += random_5();
}
return ($total%7)+1;
}
echo random_7();
?>
</code></pre>
| 16,665 |
<p>In Java, one can declare a variable parameterised by an "unknown" generic type, which looks like this:</p>
<pre><code>Foo<?> x;
</code></pre>
<p>Is there an equivalent construct to this question-mark, in C#?</p>
| <p>The short answer is no. There isn't an equivalent feature in C#.</p>
<p>A workaround, from <a href="http://www.25hoursaday.com/CsharpVsJava.html#generics" rel="noreferrer">C# from a Java developer's perspective</a> by Dare Obasanjo:</p>
<p>In certain cases, one may need create a method that can operate on data str... | <p>No, there isn't really the same concept in C#. You would need to refer to a base class of Foo (maybe a non-generic Foo), or make the method you're working in generic itself (so that you can refer to Foo, and let the caller of your method determine what T is).</p>
<p>Hope that helps.</p>
| 14,233 |
<p>I've followed the steps outlined in <a href="http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx" rel="noreferrer">http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx</a> to enable source debug... | <p>This is broken in the latest GDR, Microsoft needs to fix it</p>
| <p>Debugging didn't work for me when I first followed those steps. I deleted symbol directory and removed all settings from Options -> Debugging -> Symbols and it worked.</p>
<ul>
<li>Uncheck "Enable Just My Code"</li>
<li>Check "Enable .NET Framework source stepping"</li>
<li>Check "Enable source server support"</li>... | 48,880 |
<p>What is the difference between <code>#include</code> and <code>#import</code> in C++?</p>
| <p><strong>Import in VC++:</strong> <code>#import</code> is for type libraries or .tlbs (COM stuff).</p>
<p>The content of the type library is converted into C++ classes, mostly describing the COM interfaces for you automatically, and then it is included into your file.</p>
<p>The <code>#import</code> directive was in... | <p><em>import</em> was also one of the keywords associated with <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2073.pdf#search=%22n2073%20c%2B%2B%22" rel="nofollow noreferrer">n2073, Modules in C++</a>, proposed to the language committee by Daveed Vandevoorde in September 2006. I'm not enough of a la... | 20,762 |
<p>I have a small project that require a storage (I choose SQLite) and I got good result with the <a href="http://sqlite.phxsoftware.com/" rel="noreferrer">ADO DLL for .Net for Sqlite</a>.</p>
<p>After the Install, I noticed that it contain a SQLLinq.dll. Before investigating too much effort, and because I haven't see ... | <p>I've recently discovered <a href="http://code.google.com/p/dblinq2007/" rel="noreferrer">DBLinq</a>, which supports SQLite among other DB:</p>
| <p>Since DBLinq is no longer maintained, I kept searching and found <a href="https://stackoverflow.com/a/22563861/316760">this answer</a> which sort of unclearly points to a solution using Linq to Sql, Entity Framework, and SQLite. The <a href="http://www.bricelam.net/2012/10/entity-framework-on-sqlite.html" rel="nofol... | 31,110 |
<p>I'm invoking <a href="http://msdn.microsoft.com/en-us/library/ms995760.aspx" rel="nofollow noreferrer">one of SharePoint's web service APIs</a> that returns a CAML fragment. I've searched the interweb far and wide but I've been unable to figure out how to make this CAML fragment to render as "normal" HTML that I can... | <p>The CAML is still XML and as mentioned, XSLT will be able to render it as HTML. The actual gnraly nested OR/AND structure of CAML is a whole nother issue. </p>
<p>That would require unrolling the CAML structure and displaying it in a way that normal people understand.</p>
<p>Unfortunately, the XSLT language is uns... | <p>You could send the CAML through an XSLT stylesheet to generate HTML or XHTML.</p>
<p><strong>Edit:</strong></p>
<p>Considering your first question (why SharePoint returns CAML from some of its web services)... who knows? It may be there to support authoring tools such as SharePoint designer. But it seems clear f... | 31,336 |
<p>I have a scrolling div with Three linkbuttons and three differents divs. I need to apply CSS to active linkbutton as soon as button is clicked.The codes used by me are:</p>
<pre><code>protected void btnNetwork_Click(object sender, EventArgs e)
{
this.btnForecast.CssClass = "li_1";
this.btnBlog.... | <p>Instead of using server side event use client side javascript event. Try:</p>
<pre><code>$get('btnId').setAttribute("class", "some_class_name");
</code></pre>
| <p>Simple example:</p>
<ul>
<li>take one button and one label</li>
<li>create one stylesheet and add class style1 as:</li>
</ul>
<p></p>
<pre><code>body
{
}
.style1
{
color: #000080;
}
</code></pre>
<ul>
<li>write this simple code in button click event</li>
</ul>
<p></p>
<pre><code>protected void Button1_C... | 40,078 |
<p>Is there a (cross-platform) way to get a C FILE* handle from a C++ std::fstream ?</p>
<p>The reason I ask is because my C++ library accepts fstreams and in one particular function I'd like to use a C library that accepts a FILE*.</p>
| <p>The short answer is no.</p>
<p>The reason, is because the <code>std::fstream</code> is not required to use a <code>FILE*</code> as part of its implementation. So even if you manage to extract file descriptor from the <code>std::fstream</code> object and manually build a FILE object, then you will have other problem... | <p>I ran in that problem when I was faced with <code>isatty()</code> only working on a file descriptor.</p>
<p>In newer versions of the C++ standard library (at least since C++11), the solution proposed by alfC does not work anymore because that one class was changed to a new class.</p>
<p>The old method will still wor... | 13,474 |
<p>Is there a PHP function to find out the name of the caller function in a given function?</p>
| <p>See <a href="http://php.net/manual/en/function.debug-backtrace.php" rel="noreferrer">debug_backtrace</a> - this can trace your call stack all the way to the top.</p>
<p>Here's how you'd get your caller:</p>
<pre><code>$trace = debug_backtrace();
$caller = $trace[1];
echo "Called by {$caller['function']}";
if (iss... | <p>This should work:</p>
<pre><code>$caller = next(debug_backtrace())['function'];
</code></pre>
| 23,107 |
<p>I was using Codeplex and tried connecting to their source control using Team Explorer, with no joy. </p>
<p>I also tried connecting with HTTPS or HTTP, using the server name and the project name. As I do not have a user account on Codeplex I could not login.</p>
<p>I am just trying to check out some code without c... | <p>I think you have to use the <a href="http://www.codeplex.com/CodePlexClient" rel="nofollow noreferrer">CodePlex Source Control Client</a>. In includes cpc.exe which supports the anonymous access features of CodePlex TFS servers for non-coordinator/developer access. But according to the site:</p>
<blockquote>
<p>T... | <p>I think it's not possible with Team Explorer. But you can with <a href="http://www.codeplex.com/CodePlexClient" rel="nofollow noreferrer">CodePlex Source Control Client</a> or <a href="http://www.codeplex.com/CodePlex/Wiki/View.aspx?title=Using%20TortoiseSVN%20with%20CodePlex&referringTitle=Source%20control%20cl... | 5,839 |
<p>Is there any good example to give the difference between a <code>struct</code> and a <code>union</code>?
Basically I know that <code>struct</code> uses all the memory of its member and <code>union</code> uses the largest members memory space. Is there any other OS level difference? </p>
| <p>With a union, you're only supposed to use one of the elements, because they're all stored at the same spot. This makes it useful when you want to store something that could be one of several types. A struct, on the other hand, has a separate memory location for each of its elements and they all can be used at once.<... | <blockquote>
<p>Is there any good example to give the difference between a struct and a union?</p>
</blockquote>
<p>Real-life example from embedded system application would be the following. It only uses <code>union</code> but it clearly shows the functionality of <code>union</code>.</p>
<p>Write function for I2C commu... | 45,088 |
<p>I'm actually developing a Web Service in Java using Axis 2.
I designed my service as a POJO (Plain Old Java Object) with public method throwing exceptions :</p>
<pre><code>public class MyService {
public Object myMethod() throws MyException {
[...]
}
}
</code></pre>
<p>I then generated the WSDL using... | <p>I don't really think there is a problem. Your Client calls a method on the server. That method results in an exception. Axis transforms this exception to something which can be send to the client to indicate the error.</p>
<p>All exceptions, as far as I know, are wrapped into an AxisFault which is then transmitted ... | <p>Have you tried using Axis2 with Lady4j, it solved this issue for us.</p>
| 23,301 |
<p>What are some good links for diving into Haskell and functional programming in general?</p>
| <p><a href="http://book.realworldhaskell.org/read/" rel="nofollow noreferrer">Real World Haskell</a> is pretty good for a start.</p>
| <p>An oldie but a goodie: "<a href="http://www.cs.kent.ac.uk/people/staff/sjt/craft2e/" rel="nofollow noreferrer">Haskell: The Craft of Functional Programming</a>"</p>
| 49,523 |
<p><strong>The original question is below, but I changed the title because I think it will be easier to find others with the same doubt. In the end, a XHTML document is a XML document.</strong></p>
<p>It's a beginner question, but I would like to know which do you think is the best library for parsing XHTML documents ... | <p>You could use <a href="http://nl3.php.net/simplexml" rel="nofollow noreferrer">SimpleXML</a>, which is included in a default PHP install. This extensions offers easy object-oriented access to XML-structures.</p>
<p>There's also <a href="http://nl2.php.net/domxml" rel="nofollow noreferrer">DOM XML</a>. A "downside" ... | <p>It's been a long time (2 years or more) since I worked with XML parsing in PHP, but I always had good, usable results from the <a href="http://pear.php.net/package/XML_Parser" rel="nofollow noreferrer">XML_Parser Pear package</a>. Having said that, I have had minimal exposure to PHP5, so I don't really know if ther... | 30,643 |
<p>I am just getting started with Grails. How do I add Java libraries to my Grails project? I added the Smack library jar to the lib folder of my Grails project, but I still cannot import any of its packages into my Java or Groovy classes. I am using the Netbeans IDE. Any help would be appreciated..</p>
<p>Buzzy</p>
| <p>This is a know bug in NetBeans: <a href="http://www.netbeans.org/issues/show_bug.cgi?id=144243" rel="nofollow noreferrer">http://www.netbeans.org/issues/show_bug.cgi?id=144243</a></p>
<p>Maybe you can help the devolpers to fix it by adding a comment to this issue in the NetBeans bug tracker.</p>
| <p>The issue still remains in NetBeans 6.5 (Build 200811100001), so the IDE will not do any code completion and formats the code that is referencing classes in the JAR as erroneous.</p>
<p>I have not tried NetBeans 6.7. </p>
| 37,564 |
<p>In Java, what are the performance and resource implications of using</p>
<pre><code>System.currentTimeMillis()
</code></pre>
<p>vs. </p>
<pre><code>new Date()
</code></pre>
<p>vs. </p>
<pre><code>Calendar.getInstance().getTime()
</code></pre>
<p>As I understand it, <code>System.currentTimeMillis()</code> is ... | <p><code>System.currentTimeMillis()</code> is obviously the most <strong>efficient</strong> since it does not even create an object, but <code>new Date()</code> is really just a thin wrapper about a long, so it is not far behind. <code>Calendar</code>, on the other hand, is relatively slow and very complex, since it ha... | <p><code>System.currentTimeMillis()</code> is obviously the fastest because it's only one method call and no garbage collector is required.</p>
| 48,052 |
<p>There are a few <a href="http://www.simple-talk.com/sql/sql-server-2005/practical-sql-server-2005-clr-assemblies/" rel="noreferrer">tutorials</a> on the web that describe consuming a Web Service using SQL Server 2005's CLR integration. For the most, the process seems pretty convoluted. I've run into several issues i... | <p>I think you have answered your own question, I personally find that anything calling a WebService is more than likley better suited to exist OUTSIDE of SQL Server. The complications, elevated trust levels, and as you mentioned overall convoluted process makes it a hard to document and hard to maintain solution.</p>... | <p>I have been doing clr procedures which calls webservices both on Exchange and AD and I agree to the posts above. It works, but we quickly ran into out-of-memory issues because of the special way memory is handled in CLR inside sql server. As you can imagine performance is ok for small queries but does not scale at a... | 21,722 |
<p>My normal work flow to create a new repository with subversion is to create a new repos, do a checkout of the repos root, create my branches tags and trunk folders and place in the trunk my initial files. Then I do a commit of this "initial import", delete the checked out repos from my hard drive and do a checkout o... | <p>There is - it's called an "in-place import", and it's covered in the Subversion FAQ here:</p>
<p><a href="http://subversion.tigris.org/faq.html#in-place-import" rel="noreferrer">http://subversion.tigris.org/faq.html#in-place-import</a></p>
<p>What you're really doing is creating a new empty project in the reposito... | <p>If you've checked out a single folder, copied your files into it, run <code>svn add</code> and <code>svn commit</code>; you shouldn't need to delete the files and re-checkout.</p>
<p>Use the files in place: once they've been committed as you describe, they're ready to be worked on.</p>
| 20,817 |
<p>I see this all the time in Ruby:</p>
<pre><code>require File.dirname(__FILE__) + "/../../config/environment"
</code></pre>
<p>What does <code>__FILE__</code> mean?</p>
| <p>It is a reference to the current file name. In the file <code>foo.rb</code>, <code>__FILE__</code> would be interpreted as <code>"foo.rb"</code>.</p>
<p><strong>Edit:</strong> Ruby 1.9.2 and 1.9.3 appear to behave a little differently from what Luke Bayes said in <a href="https://stackoverflow.com/questions/224379/... | <p>In Ruby, the Windows version anyways, I just checked and <code>__FILE__</code> does not contain the full path to the file. Instead it contains the path to the file relative to where it's being executed from. </p>
<p>In PHP <code>__FILE__</code> is the full path (which in my opinion is preferable). This is why, in o... | 27,718 |
<p>My Firefox 3.0.4 does not display non-existing images at all, or it displays the image alt as plain text (if available).<br/>
This way I would have no idea that there is supposed to be an image there.</p>
<p>Does anyone know if there is a way to make it work like IE/Opera? (ie. display a box even if the image file ... | <p>There is a setting in about:config that is supposed to do just this: <code>browser.display.show_image_placeholders</code>. However, it doesn't do anything on its own.</p>
<p>You need to <a href="http://blog.doxmart.com/2009/08/11/a-quick-tip-on-enabling-broken-image-placeholders-in-firefox-3-and-beyond/" rel="nofol... | <p>As far as i know there is no plugin, Images should have a width and height specified like so:</p>
<pre><code><img src='...' width='100' height='100' alt='...'></img>
or
<img src='...' alt='...' style='width:100px; height:100px;'></img>
</code></pre>
<p>Then firefox will reserve the appropia... | 39,020 |
<p>Is there a C# equivalent for the VB.NET <code>FormatNumber</code> function? </p>
<p>I.e.:</p>
<pre><code>JSArrayString += "^" + (String)FormatNumber(inv.RRP * oCountry.ExchangeRate, 2);
</code></pre>
| <p>In both C# and VB.NET you can use either the <a href="http://www.java2s.com/Code/CSharp/Development-Class/UseToStringtoformatvalues.htm" rel="nofollow noreferrer">.ToString()</a> function or the <a href="http://www.java2s.com/Code/CSharp/Development-Class/UseStringFormattoformatavalue.htm" rel="nofollow noreferrer">... | <p>While I would recommend using ToString in this case, always keep in mind you can use ANY VB.Net function or class from C# just by referencing Microsoft.VisalBasic.dll.</p>
| 7,205 |
<p>Does anyone know any implementation of a templated cache of objects?</p>
<ul>
<li>You use a key to find object (the same as in std::map<>)</li>
<li>You specify a maximum number of objects that can be in the cache at the same time</li>
<li>There are facilities to create an object not found in the cache</li>
<li>T... | <p>You can use the <a href="http://www.boost.org/doc/libs/1_60_0/libs/multi_index/doc/index.html" rel="nofollow">Boost.MultiIndex</a> library.
It is easy to implement a <a href="http://www.boost.org/doc/libs/1_60_0/libs/multi_index/doc/examples.html#example9" rel="nofollow">MRU cache</a>.</p>
| <p>In an application I can hardly imagine it would speed/boost up performance to store objects that apparently can be re-created (hip: since they can be automatically discarded, when the cache tops).
A sw cache would require memory-fetching through associativism code, surely slower then memory allocation and constructo... | 14,960 |
<p>I'm trying to write a TCustomDBGrid descendant that's designed to feel like a TListBox. One of the things I want to change is the Options property's defaults. TCustomDBGrid defines Options as:</p>
<pre><code>property Options: TDBGridOptions read FOptions write SetOptions
default [dgEditing, dgTitles, dgIndicato... | <p>Don't specify the type. Then you can change the default. And remember that you also have to set the Options property to this default in the constructor. The code below does not actually set the default, it just lets it know to not stream the property value when the value is like that.</p>
<pre><code>property Option... | <p>That would not work in a runtime created dbgrid...
See this (from Delphi Language Guide on BDS 2006):</p>
<hr>
<p><em>Property values are not automatically initialized to the default value. That is, the default directive controls only when property values are saved to the form file, but not the initial value of th... | 43,963 |
<p>I'm using <code>int</code> as an example, but this applies to any value type in .Net</p>
<p>In .Net 1 the following would throw a compiler exception:</p>
<pre><code>int i = SomeFunctionThatReturnsInt();
if( i == null ) //compiler exception here
</code></pre>
<p>Now (in .Net 2 or 3.5) that exception has gone.</p>... | <p>I don't think this is a compiler problem <em>per se</em>; an integer value is never null, but the idea of equating them isn't invalid; it's a valid function that always returns false. And the compiler knows; the code</p>
<pre><code>bool oneIsNull = 1 == null;
</code></pre>
<p>compiles, but gives a compiler warning... | <p>The warning is new (3.5 I think) - the error is the same as if I'd done <code>1 == 2</code>, which it's smart enough to spot as never true.</p>
<p>I suspect that with full 3.5 optimisations the whole statement will just be stripped out, as it's pretty smart with never true evaluations.</p>
<p>While I might want <c... | 8,809 |
<p>How do I pass a parameter from a page's useBean in JSP to a servlet in Java? I have some data in a form that gets passed no problem with a submit button, but no way to send anything else. Please help? Here is my code:</p>
<pre><code><input name = "deleteGameButton" type = "submit" value = "Delete"
onclick = "su... | <p>You kind of mess things here.</p>
<p>onclick() is Javascript and executed on client side. It has no (direct) way to update session-scoped bean. That bean is left on server-side, and was used when the HTML page was <strong>generated</strong>. To pass parameters back to servlet you need to use good old form fields, a... | <p>Hi try with the next tag:</p>
<pre><code><jsp:useBean id = "userBean" scope = "session" class = "org.project.User"/>
<jsp:setProperty name="beanName" property="propertyname" value="value"/>
</jsp:useBean>
</code></pre>
<p>more <a href="http://java.sun.com/products/jsp/tags/syntaxref.fm13.html" r... | 28,976 |
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the
best way to do this?
I wrote a delete script (hack), but since there is so much data is
timeout's out after a few hundred records. </p>
| <p>I am currently deleting the entities by their key, and it seems to be faster.</p>
<pre><code>from google.appengine.ext import db
class bulkdelete(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
try:
while True:
q = db.GqlQu... | <p>In javascript, the following will delete all the entries for on page:</p>
<pre><code>document.getElementById("allkeys").checked=true;
checkAllEntities();
document.getElementById("delete_button").setAttribute("onclick","");
document.getElementById("delete_button").click();
</code></pre>
<p>given that you are on the... | 13,414 |
<p>I'm looking for a way to programatically change features ("Programs and Features" -> "Turn Windows Features on or off") in Windows Vista (and newer Redmond OS, e.g. Server 2008).</p>
<p>Ideal solution would be in the form of a Powershell script (Get-Features, Set-Features), however any pointers to MSDN/other docume... | <p>I just found an extension that works for Windows 7. "PowerShell module to Add/Remove Windows 7 features" - <a href="https://psclientmanager.codeplex.com/" rel="nofollow">https://psclientmanager.codeplex.com/</a></p>
| <p>There's unfortunately not a set of cmdlets, yet, nor is there anything in WMI or any other easily-accessible area. Interestingly, Server Core's script-based role management features will only work on Server Core :). Windows 7 may bring some relief in this regard - but it also might not. In the meantime, you're prett... | 43,844 |
<p>I want a true deep copy. In Java, this was easy, but how do you do it in C#?</p>
| <h3>Important Note</h3>
<p><a href="https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.formatters.binary.binaryformatter?view=net-5.0" rel="noreferrer">BinaryFormatter</a> has been deprecated, and will no longer be available in .NET after November 2023. See <a href="https://github.com/dotnet/des... | <pre><code> public static object CopyObject(object input)
{
if (input != null)
{
object result = Activator.CreateInstance(input.GetType());
foreach (FieldInfo field in input.GetType().GetFields(Consts.AppConsts.FullBindingList))
{
if (field.Fiel... | 15,733 |
<p>I used the jQuery Form plugin for asynchronous form submission. For forms that contain files, it copies the form to a hidden iframe, submits it, and copies back the iframe's contents. The problem is that I can't figure out how to find what HTTP status code was returned by the server. For example, if the server retur... | <p>You can't get page headers by JS, but you can distinguish error from success:
Try something like this:</p>
<pre><code><script type="text/javascript">
var uploadStarted = false;
function OnUploadStart(){
uploadStarted = true;
}
function OnUploadComplete(state,message){ ... | <p>You can't retrieving HTTP status code from loaded "iframe" directly.
But when an http error occured, the server will returned nothing to the "iframe".
So the iframe has not content.
you can check the iframe body, when the body of iframe is blank, use ajax with the same url to get the response from server. Then you c... | 5,569 |
<p>Does windows have any decent sampling (eg. non-instrumenting) profilers available? Preferably something akin to Shark on MacOS, although i am willing to accept that i am going to have to pay for such a profiler on windows.</p>
<p>I've tried the profiler in VS Team Suite and was not overly impressed, and was wonder... | <p><a href="http://www.intel.com/cd/software/products/asmo-na/eng/239144.htm" rel="noreferrer">Intel VTune</a> is good and is non-instrumenting. We evaluated a whole bunch of profilers for Windows, and this was the best for working with driver code (though it does unmanaged user level code as well). A particular streng... | <p>I'm not sure what a non-instrumenting profiler is, but I can say for .NET I love RedGate's ANTS Profiler. Version 3 beats the MS version for ease of use and Version 4, which allows arbitrary time slices, makes MS look like a joke.</p>
| 20,524 |
<p>I'm having a weird issue with Visual Studio 2008. Every time I fire it up, the solution explorer is about an inch wide. It's like it can't remember it's layout settings.</p>
<p>Every un-docked window is in the position I place it. But if I dock a window, it's position is saved, but it's size will be reset to very-n... | <p>I had the same problem. It turned out that if the VS window was non-maximized, it was really
small. So after making the non-maximized wider, the problem disappeared.</p>
| <p>Maybe you're closing Visual Studio while some other instance is still alive. The settings of the last instance that is closed is the one that will be applied.</p>
| 3,097 |
<p>I always believed that when it came to software for a platform the parties were referred to as such:</p>
<blockquote>
<p>First-party: The owner/creator of the
platform</p>
<p>Second-party: The user of the platform</p>
<p>Third-party: A developer who is not
the first-party.</p>
</blockquote>
<p>Now... | <p>I think the notion goes back to commercial arrangements. The first and second parties are in a direct producer-purchaser relationship. The third-party parties are those other than the first party that the second party is dealing with. (Note that grammatical person doesn't quite fit, but it is a cute idea. It work... | <p>I agree, I always assumed it was a pun or extension of standard English grammar: <a href="http://en.wikipedia.org/wiki/First-person_narrative" rel="nofollow noreferrer">first person</a>, second person, and third person.</p>
| 34,608 |
<p>I have the following layout for my test suite:</p>
<p>TestSuite1.cmd:</p>
<ol>
<li>Run my program</li>
<li>Check its return result</li>
<li>If the return result is not 0, convert the error to textual output and abort the script. If it succeeds, write out success.</li>
</ol>
<p>In my single .cmd file, I call my p... | <p>Assuming they won't interfere with each other by writing to the same files,etc:</p>
<p>test1.cmd</p>
<pre><code>:: intercept sub-calls.
if "%1"=="test2" then goto :test2
:: start sub-calls.
start test1.cmd test2 1
start test1.cmd test2 2
start test1.cmd test2 3
:: wait for sub-calls to complete.
:loop1
... | <p>try the command <strong>start</strong>, it spawns a new command prompt and you can send along any commands you want it to run.</p>
<p>I'd use this to spawn batch files that run the tests and then appends to a output.txt using >> as such:</p>
<pre><code>testthingie.cmd >> output.txt
</code></pre>
| 16,096 |
<p>I have an Events list in sharepoint and need to disallow users from having the ability to create meeting workspaces in the new event form. Shy of customizing the new event form (which breaks attachment support), how can this be done?</p>
| <p>By default, in order for users to create a meeting workspace, they will need to be an administrator or Site Owner (specifically they will need the Create Sites permission). If you don't give them this permission, they won't be able to create a meeting workspace.</p>
<p>This will disallow the user to create any sit... | <p>I don't think there is a supported way of doing this. One option is to edit the WEBTEMP.XML file in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML\WEBTEMP.XML (make a backup first of course). Comment out the lines as follows:</p>
<pre><code> <!-- <Template Name="M... | 14,449 |
<p>When I use link_to :method=>:delete, what rails has generated is a javascript click, which is not nice if you do come across situation your client just have javascript disabled. That seems a bad idea to me. Any chance to get around this?</p>
| <p>What it generates is a form with method="delete", your best bet is to make the form yourself, the only thing is that the submit button won't be a link, but a button.</p>
<p>You should not, by any mean, try to do it with a basic <code><a href=""></code>, because a disruptive action (create, update, delete) sho... | <p>If you need it to work without JavaScript use <code>button_to</code>:</p>
<p><code><%= button_to 'Delete', @item, :method => :delete %></code></p>
<p>From the doc:</p>
<blockquote>
<p>Generates a form containing a single button that submits to the URL
created by the set of +options+. This is the safe... | 49,851 |
<p>I have a set of core, complicated JavaScript data structures/classes that I'd like to be able to use both in the browser as JavaScript and run on the desktop with .NET 3.5. Is it possible to compile web-friendly JavaScript into assemblies that my C# code can access?</p>
<ul>
<li>Managed JScript - Is there a compil... | <p>JScript.Net is actually mostly EMCAScript3 compliant. As long as you treat your code as a processing library (only have it do crunching, etc - use callbacks to interact with the program), you should be fine.
I'm doing something similar, using javascript as my core parsing library, and then using it within python, d... | <p>How about another option:</p>
<ul>
<li>Host the javascript application inside your desktop app via winforms' WebBrowser control?</li>
</ul>
<p>Is this possible?</p>
<p>You can also access the DOM from WebBrowser control but not everything you want is fully supported.</p>
| 34,204 |
<p>Given a pretty basic source tree structure like the following:</p>
<pre>
trunk -------
QA |--------
Stage |-------
Prod |------
</pre>
<p>And an environment which mirrors that (Dev, QA, Staging and Production servers) - how do you all manage automated or manual code promotion? Do you use a CI se... | <p>You want absolutely no possibility of the production code not being identical to the one QA tested, so you should use binaries.</p>
<p>You should also tag the sources used to create each build, so if needed you can reproduce the build in a dev environment. At least if you make a mistake at this point, the conseque... | <p>We make use of CI at the dev stage, and use daily builds that are promoted. These daily builds, if successful, are tagged in SVN so that we don't need to keep a seperate copy of the binaries. Any third party libraries referenced are also included so that a tag is an exact source copy of what is compiled.</p>
| 18,282 |
<p>I'd like to automate data entry into Excel spreadsheets. User data will exist on a web site, and when the user requests it, that data will need to be injected into an Excel spreadsheet. The complication is that the format of the Excel spreadsheet can vary significantly between users - it'll be user defined.</p>
<p>... | <p>jXLS is maybe an option. You define an XLS file as a template and then you merge your data. </p>
<p>Quick overview <a href="http://www.rgagnon.com/javadetails/java-0516.html" rel="nofollow noreferrer">here</a></p>
<p><a href="http://jxls.sourceforge.net/" rel="nofollow noreferrer">http://jxls.sourceforge.net/</a>... | <p>You might want to look into a third party library called <a href="http://www.aspose.com/categories/file-format-components/aspose.cells-for-.net-and-java/default.aspx" rel="nofollow noreferrer">Aspose.Cells</a>. It is available for Java and .Net and allows very granular control of Excel documents. The great thing a... | 49,244 |
<p>I test my app only on local cassini web server, and I get strange thing.</p>
<p>One Index page works right in default manner, second shows 404, but when use full version Controller/Index - works normal. Only difference I found is that in first sample there is no slash in the end, and in second slash exists, but lin... | <p>Can you show us your routes? Or even better: Try to use Phil Haack's excellent (and essential) Route Debugger. It will tell you which route(s) are hit for a given request, or if no route is hit at all.</p>
<p><a href="http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx" rel="noreferrer">http://haacked.c... | <p>if you could post your routings we could help you better, but for now I'd suggest you to debug it using the <a href="http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx" rel="nofollow noreferrer">Routing Debugger</a>.</p>
| 45,074 |
<p>I'm trying to change default firstDayOfWeek for java.util.Calendar from SUNDAY to MONDAY. Is it possible to achieve this through JVM configuration instead of adding this piece of code?</p>
<pre><code>cal.setFirstDayOfWeek(Calendar.MONDAY);
</code></pre>
| <p>The first day of the week is derived from the current locale. If you don't set the locale of the calendar (<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html#getInstance(java.util.Locale)" rel="noreferrer">Calendar.getInstance(Locale)</a>, or <a href="http://java.sun.com/j2se/1.5.0/docs/api/jav... | <p>Have you tried to invoke the JVM with a different locale? But you should be careful with side effects...</p>
| 33,852 |
<p>I'm writing a custom JSP tag using the JSP 2 tag files. Inside my tag I would like to know which page called the tag in order to construct URLs. Is this possible with out passing it through an attribute?</p>
| <p>Turns out that the request object actually is available, but only in the EL portion of a tag. So this would work:</p>
<pre><code><form action="${pageContext.request.requestURI}">
</code></pre>
<p>But not this:</p>
<pre><code><form action="<%=request.requestURI%>">
</code></pre>
<p>Or this:</p>
... | <p>The request object is available in the tag. It doesn't matter if you use a class or a tag file. In tag files, it is available in Java scriptlets as well as in EL.
However, it is available as a ServletRequest object and not an HttpServletRequest object (in EL the class of the object doesn't matter, but it does in scr... | 36,184 |
<p>I have a list control in GTK+ (a <code>gtk.TreeView</code> with one column), with "find-as-you type" enabled (so typing any text will open a small search field for searching through the list entries). Now, if the user enters some search text like "abc", should I search only for entries <em>starting</em> with "abc", ... | <p>As Omer Kooheji said, the correct answer depends a lot on <em>what</em> the listbox contains.
However, on the basis of the <a href="http://en.wikipedia.org/wiki/Principle_of_least_astonishment" rel="nofollow noreferrer">Principle of least astonishment</a>, I would recommend matching at the start of an entry; that's ... | <p>As a user, I appreciate a "contains" search rather than a "starts with". Sometimes you can't remember exactly what you're looking for and it's more helpful to suggest things that are similar to your search query rather than using it as a straight filter.</p>
<p>There are times when there are multiple way to list s... | 14,855 |
<p>This question is about the difference between ReadWrite and NonStrictReadWrite cache concurrency strategies for NHibernate's second level cache.</p>
<p>As I understand it, the difference between these two strategies is relevant when you have a distributed <em>replicated</em> cache - nonstrict won't guarantee that o... | <p>What you assume is right, in a single target/thread environment there's little difference. However if you look at the cache providers there is a bit going on even in a multi-threaded scenario. </p>
<p>How an object is re-cached from it's modified state is different in the non-strict. For example, if your object i... | <p>I have created a post <a href="http://anirbanchowdhury.wordpress.com/2012/07/23/hibernate-second-level-cache-ehcache/" rel="nofollow">here</a> explaining the differences. Please have a look and feel free to comment.</p>
| 13,444 |
<p>If I am posting a question about a query against an Oracle database, what should I include in my question so that people have a chance to answer me? How should I get this information?</p>
<p>Simply providing the poorly performing query may not be enough.</p>
| <p>Ideally, get the full query plan using DBMS_XPLAN.DISPLAY_CURSOR using the sql_id and child_cursor_id from v$sql. Failing that (ie on older versions), try v$sql_plan and include filter and access predicates. EXPLAIN PLAN is fine if it actually shows the plan that was used.</p>
<p>DB version and edition (Express/Sta... | <p>The query plan is always useful</p>
| 37,473 |
<p>I'm having troubles with HttpWebRequest/HttpWebResponse and cookies/CookieContainer/CookieCollection.
The thing is, if the web server does not send/use a "path" in the cookie, Cookie.Path equals the path-part of the request URI instead of "/" or being empty in my application.
Therefore, those cookies do not work for... | <p>Ah, I see what you mean. Generally what browsers <em>really</em> do is take the folder containing the document as the path; for ‘/login.php’ that would be ‘/’ so it would effectively work across the whole domain. ‘/potato/login.php’ would be limited to ‘/potato/’; anything with trailing path-info parts (eg. ‘/login.... | <p>That's the way cookies work. ‘Proper’ web browsers do exactly the same, as originally specified in the ancient Netscape cookies doc: <a href="http://cgi.netscape.com/newsref/std/cookie_spec.html" rel="nofollow noreferrer">http://cgi.netscape.com/newsref/std/cookie_spec.html</a></p>
<p>Web apps must effectively <em>... | 37,356 |
<p>I am having trouble deploying an ASP.NET MVC app to IIS7. </p>
<p>I have an MVC project created with ASP.NET MVC Beta 1. It consists of nothing more than the default template unmodified. </p>
<p>The app runs just fine within VS2008, but when I publish it to a local IIS7 website (<a href="http://localhost" rel="nof... | <p>Does IIS run ok with the default IIS7 site?</p>
<p>Are you receiving any Event Viewer messages?</p>
| <p>Please make sure that you are running under IIS 7.0 Integrated mode. If you need to run it under IIS 7.0 Classic mode, you need to perform several actions to make the routes work. Please refer the following blog posts;</p>
<p><a href="http://www.tugberkugurlu.com/47" rel="nofollow">http://www.tugberkugurlu.com/arch... | 26,278 |
<p>I currently trying to find a solution, how to ensure that a test fails if an exception occurs in a thread which is spawn by the test method.</p>
<p>I DON'T want to start a discussion about more than one thread in a unit test. => "unit test".Replace("unit","integration");</p>
<p>I already read a lot of threads in s... | <p>The reason that exceptions on non-test threads (i.e. other spawned threads) do not cause tests to fail is that NUnit is configured by default to use <a href="http://msdn.microsoft.com/en-us/library/ms228965.aspx" rel="nofollow noreferrer">legacyUnhandledExceptionPolicy</a> which is a .Net process level setting which... | <p>I solved the problem by creating an addin for nunit, which "installs" an ITestDecorator.</p>
| 45,936 |
<p>I know that it is possible (in theory) to create a new type at run-time, but is it possible to modify a method body of an existing type at run-time? My plan (if I can get this to work) is to tag up methods with a custom attribute, and then at run-time search for methods with the attribute, and insert some of my own ... | <p><a href="http://www.postsharp.org/" rel="noreferrer">PostSharp</a> which is an aftercompiler, does something similar to what you describe, using attributes to mark injection points in the code, only difference is that it does it at compile time. </p>
<p>But you can also do it at runtime not by changing method bodie... | <p>Are you planning to do this for arbitrary types? I would suppose not given that you are going to decorate the methods with an attribute.</p>
<p>Given that, I would think the better approach would be to define abstract methods in a super class for your types. A method on the super class can house the boiler-plate ... | 30,953 |
<p>How can I set cron to run certain commands every one and a half hours?</p>
| <p>That's not possible with a single expression in normal <code>cron</code>.</p>
<p>The best you could do without modifying the code is:</p>
<pre><code>0 0,3,6,9,12,15,18,21 * * * [cmd]
30 1,4,7,10,13,16,19,22 * * * [cmd]
</code></pre>
<p>These <em>might</em> be compressible, depending on the version of cron you have ... | <p>added the following to my crontab and is working</p>
<pre><code>15 */1 * * * root /usr/bin/some_script.sh >> /tmp/something.log
</code></pre>
| 30,757 |
<p>I have a file that I want to include in Python but the included file is fairly long and it'd be much neater to be able to split them into several files but then I have to use several include statements.</p>
<p>Is there some way to group together several files and include them all at once?</p>
| <ol>
<li>Put files in one folder. </li>
<li>Add __init__.py file to the folder. Do necessary imports in __init__.py</li>
<li><p>Replace multiple imports by one:</p>
<p>import folder_name </p></li>
</ol>
<p>See <a href="http://docs.python.org/tut/node8.html#SECTION008400000000000000000... | <p>Yes, take a look at the "6.4 Packages" section in <a href="http://docs.python.org/tut/node8.html" rel="nofollow noreferrer">http://docs.python.org/tut/node8.html</a>:</p>
<p>Basically, you can place a bunch of files into a directory and add an __init__.py file to the directory. If the directory is in your PYTHONPA... | 7,641 |
<p>The database type is PostGres 8.3.</p>
<p>If I wrote: </p>
<pre><code>SELECT field1, field2, field3, count(*)
FROM table1
GROUP BY field1, field2, field3 having count(*) > 1;
</code></pre>
<p>I have some rows that have a count over 1. How can I take out the duplicate (I do still want 1 row for each of them in... | <p>This is one of many reasons that all tables should have a primary key (not necessarily an ID number or IDENTITY, but a combination of one or more columns that uniquely identifies a row and which has its uniqueness enforced in the database).</p>
<p>Your best bet is something like this:</p>
<pre><code>SELECT field1,... | <p>One possible answer is:</p>
<pre><code>CREATE <temporary table> (<correct structure for table being cleaned>);
BEGIN WORK; -- if needed
INSERT INTO <temporary table> SELECT DISTINCT * FROM <source table>;
DELETE FROM <source table>
INSERT INTO <source table> SELECT * FROM <t... | 30,174 |
<p>I've been exploring the details of Django for about a week now and like what I see. However I've come upon some.. negativity in relation to fine-grained control of permissions to the CRUD interface.</p>
<p>What I'm writing is an Intranet client management web-app. The organisation is about 6 tiers, and I need to re... | <p>If I read your updated requirements correctly, I don't think Django's existing auth system will be sufficient. It sounds like you need a full-on ACL system.</p>
<p>This subject has come up a number of times. Try googling on django+acl.</p>
<p>Random samplings ...</p>
<p>There was a Summer of Code project a couple... | <p>You may also want to have a look at the granular-permissions monkeypatch:
<a href="http://code.google.com/p/django-granular-permissions/" rel="nofollow noreferrer">http://code.google.com/p/django-granular-permissions/</a></p>
<p>It adds row-level permissions to django's permission system.</p>
| 28,718 |
<p>I have a method that creates a MessageDigest (a hash) from a file, and I need to do this to a lot of files (>= 100,000). How big should I make the buffer used to read from the files to maximize performance?</p>
<p>Most everyone is familiar with the basic code (which I'll repeat here just in case):</p>
<pre><code>M... | <p>Optimum buffer size is related to a number of things: file system block size, CPU cache size and cache latency.</p>
<p>Most file systems are configured to use block sizes of 4096 or 8192. In theory, if you configure your buffer size so you are reading a few bytes more than the disk block, the operations with the ... | <p>1024 is appropriate for a wide variety of circumstances, although in practice you may see better performance with a larger or smaller buffer size. </p>
<p>This would depend on a number of factors including file system block
size and CPU hardware.</p>
<p>It is also common to choose a power of 2 for the buffer size,... | 29,309 |
<p>How do you write the syntax for a While loop?</p>
<h2>C<code>#</code></h2>
<pre><code>int i = 0;
while (i != 10)
{
Console.WriteLine(i);
i++;
}
</code></pre>
<h2>VB.Net</h2>
<pre><code>Dim i As Integer = 0
While i <> 10
Console.WriteLine(i)
i += 1
End While
</code></pre>
<h2>PHP</h2>
... | <p>In PHP a while loop will look like this:</p>
<pre><code><?php
while(CONDITION)
{
//Do something here.
}
?>
</code></pre>
<p>A real world example of this might look something like this</p>
<pre><code><?php
//MySQL query stuff here
$result = mysql_query($sql, $link) or die("Opps");
while($row = mysql_fetch... | <h2>TCL</h2>
<pre><code>set i 0
while {$i != 10} {
puts $i
incr i
}
</code></pre>
<p>C++, C, JavaScript, Java and a myriad of other C-like languages all look exactly the same as C#, except in the way that they write the output to the console, or possibly the way you create the variable <code>i</code>. Answer... | 6,384 |
<p>If I create a J# Application is there any way I can execute it on JVM as well</p>
| <p>No, J# programs are designed to run on the .NET platform. See the <a href="http://msdn.microsoft.com/en-nz/vjsharp/bb188604.aspx" rel="noreferrer">J# FAQ</a>.</p>
| <p>Yes - sort of. If the Java you write will compile using javac then you can have one source base and compile for both J# and Java. We do that for our reporting engine. If you do this on .net 40, you need <a href="http://blogs.windwardreports.com/davidt/2011/02/calling-j-code-from-net-40.html" rel="nofollow">Calling J... | 20,007 |
<p>Could you provide an example of accessing the Eclipse Abstract Syntax Tree programmatically for a given piece of code?</p>
<p>eg getting the AST for:</p>
<hr>
<h2>Class1.java</h2>
<pre><code>package parseable;
public class Class1 {
/**
* @param args
*/
public static void main(String[] args) {
System.out.... | <p>It is not an <em>exact</em> answer, that may give you a place where to start:</p>
<p>As said in this <a href="https://stackoverflow.com/questions/160382/extract-all-string-from-a-java-project#161145">question</a>, </p>
<p>A full example is available in this <a href="http://www.eclipse.org/articles/article.php?file... | <pre><code>// get an ICompilationUnit by some means
// you might drill down from an IJavaProject, for instance
ICompilationUnit iunit = ...
// create a new parser for the latest Java Language Spec
ASTParser parser = ASTParser.newParser(AST.JLS3);
// tell the parser you are going to pass it some code where the type l... | 23,957 |
<p>Given an array of characters which forms a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.</p>
<p>Example input and output:</p>
<pre><code>>>> reverse_words("this is a string")
'string a is this'
</code></pre>
<p>It should be O(N) time and O(1) spa... | <p>A solution in C/C++:</p>
<pre class="lang-cpp prettyprint-override"><code>void swap(char* str, int i, int j){
char t = str[i];
str[i] = str[j];
str[j] = t;
}
void reverse_string(char* str, int length){
for(int i=0; i<length/2; i++){
swap(str, i, length-i-1);
}
}
void reverse_words(ch... | <p>Push each word onto a stack. Pop all the words off the stack.</p>
| 6,963 |
<p>I'm interested in using API spying/hijacking to implement some core features of a project I'm working on. It's been mentioned <a href="https://stackoverflow.com/questions/60641/how-to-replace-winapi-functions-calls-in-the-ms-vc-project-with-my-own-implemen">in this question</a> as well, but that wasn't really on top... | <p>I implemented <a href="http://www.geocities.com/SiliconValley/1741/downloads/" rel="nofollow noreferrer">syringe.dll</a> (L-GPL) instead of MS Detours (we did not like the license requirements or huge payment for x64 support) it works fantastically well, I ported it from Win32 to Win64, we have been using in our off... | <p>I've been using standard IAT hooking techniques for a few years now and it works well has been nice and stable and ported to x64 with no problems. The main problems I've had have been more to do with how I inject the hooks in the first place, it took a fair while to work out how best to suspend managed processes at ... | 11,741 |
<p>This isn't legal:</p>
<pre><code>public class MyBaseClass
{
public MyBaseClass() {}
public MyBaseClass(object arg) {}
}
public void ThisIsANoNo<T>() where T : MyBaseClass
{
T foo = new T("whoops!");
}
</code></pre>
<p>In order to do this, you have to do some reflection on the type object for T or you... | <p>Nope. If you weren't passing in parameters, then you could constrain your type param to require a parameterless constructor. But, if you need to pass arguments you are out of luck.</p>
| <p>I can see that not working.</p>
<p>But what is stopping you from doing this?</p>
<pre><code>public void ThisIsANoNo<T>() where T : MyBaseClass
{
MyBaseClass foo = new MyBaseClass("whoops!");
}
</code></pre>
<p>Since everything is going to inherit from MyBaseClass they will al be MyBaseClass, right?</p>
<... | 12,213 |
<p>Welcome!
I very enjoyed programming artificial intelligence in my studies - neural networks, expert machines and other. But in work I develop mainly web applications. </p>
<p>And now I think about returning to such programming, maybe in hobby, or maybe in work. Are there areas where AI is commonly used in applicati... | <p>I recently started reading the book <a href="https://rads.stackoverflow.com/amzn/click/com/0596529325" rel="noreferrer" rel="nofollow noreferrer">Programming Collective Intelligence</a>. It's an excellent book which discusses exactly what you are looking for - using AI techniques in web applications.</p>
<p>The boo... | <p>Outside of games, I've seen very few commercial uses of AI. </p>
<p>It could, in theory, be very useful in industrial robotics and imaging, but those fields also tend to be very conservative, and uncomfortable with non-deterministic algorithms. </p>
<p>You might want to research what iRobot does, but even them use... | 42,227 |
<p>Just what the title says, I need to change the password for an existing sql server login and I want to do it via sql script.</p>
| <p>ALTER LOGIN</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms189828.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms189828.aspx</a></p>
| <pre><code>alter login mylogin with password = 'mylogin'
</code></pre>
| 8,106 |
<p>Winform on CF is a bit heavy, initialising a lot of windows handles takes serious time and memory. Another issue is the lack of inbuilt double buffering and lack of control you have over the UI rendering means that during processor intensive operations the UI might leave the user staring at a half rendered screen. N... | <p>I ran across this the other day, which might be helpful at least as a starting point: <a href="http://fluid.codeplex.com/" rel="nofollow noreferrer">Fuild - Windows Mobile .NET Touch Controls</a>. The look and feel is nice, but there is no design time support. I don't know too much about memory footprint, etc but ev... | <p>Actually, you can override the paint event.</p>
<p>And the idea is that you offload long-running operations to a separate thread. That's no different from any other event-driven framework, really. <em>Anything</em> that relies on a handling a Paint event is going to be susceptible to that.</p>
<p>Also, there's n... | 5,322 |
<p>I am using Eclipse 3.3.2 with the Flex Builder Plugin (3.0.194161) and the Flex SDK 3.2. Recently the intellisense has started forgetting about everything in the flash.* package EXCEPT flash.errors.*</p>
<p>The code still compiles, but attempting to automatically resolve something (CTRL+SPACE) removes any of the fl... | <p>I was able to work around the problem by adding the following SWC to my library path: FLEX_SDK\libs\player\10\playerglobal.swc</p>
<p>It looks like the problem is caused by {targetPlayerMajorVersion} no longer resolving, though I have no idea how that happened.</p>
<p><strong>Edit:</strong> Known bug, as described... | <p>Upgrade to <a href="http://www.adobe.com/devnet/flex/articles/sdk32_fb302.html" rel="nofollow noreferrer">Flex Builder 3.0.2</a>. I've noticed that older versions of Flex Builder don't like Flash Player 10's new playerglobal.swc.</p>
| 42,249 |
<p>I need a way to get the elapsed time (wall-clock time) since a program started, in a way that is resilient to users meddling with the system clock.</p>
<p>On windows, the non standard clock() implementation doesn't do the trick, as it appears to work just by calculating the difference with the time sampled at start... | <p>I guess you can always start some kind of timer. For example under Linux a thread
that would have a loop like this :</p>
<pre><code>static void timer_thread(void * arg)
{
struct timespec delay;
unsigned int msecond_delay = ((app_state_t*)arg)->msecond_delay;
delay.tv_sec = 0;
de... | <p>If you have a network connection, you can always acquire the time from an NTP server. This will obviously not be affected in any the local clock.</p>
| 24,485 |
<p>I'm kind of like stuck trying to implement YUI autocomplete textbox. here's the code:</p>
<pre><code><div id="myAutoComplete">
<input id="myInput" type="text" />
<div id="myContainer"></div>
</div>
<script type="text/javascript">
YAHOO.example.BasicRemote = function() {
oDS = ... | <p>@Kriss -- Could you post a link to the page where you're having trouble? It's hard to debug XHR autocomplete without seeing what's coming back from the server and seeing the whole context of the page.</p>
<p>@Adam -- jQuery is excellent, yes, but YUI's widgets are all uniformly well-documented and uniformly licens... | <p>To be honest, and I know this isn't the most helpful answer... you should look into using jQuery these days as it has totally blown YUI out of the water in terms of ease-of-use, syntax and community following.</p>
<p>Then you could toddle onto <a href="http://plugins.jquery.com" rel="nofollow noreferrer">http://plu... | 46,462 |
<p>I wanted to write a small <a href="http://en.wikipedia.org/wiki/Rapid_Serial_Visual_Presentation" rel="nofollow noreferrer">Rapid Serial Visual Presentation (RSVP)</a> program for my mobile device but I realized that there are some patent issues associated with that technique (<a href="http://www.freepatentsonline.c... | <p>You really need to consult an attorney for something like this.</p>
| <p>I have no money for an attorney.</p>
<p>No attorneys on stackoverflow.com? </p>
<p>;-)</p>
| 25,808 |
<p>In a spring configuration, what is the difference between using name vs id? I'm aware that XML restricts the "id" attribute to be unique in a document and limits the characters for using in the id. But otherwise when declaring a bean, what is the difference between using the "name" attribute vs the "id" attribut... | <p>It turns out that FindControl does work: </p>
<pre><code>CType(MyListView.FindControl("litTotal"), Literal).Text = GetTheSum()
</code></pre>
<p>I'd still like to know if there might be a better way though.</p>
| <p>You can't reference the control in the code-behind because it's in the LayoutTemplate. Maybe with FindControl, but I haven't tried that yet.</p>
| 26,061 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.