instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I want to tune a production SQL server. After making adjustments (such as changing the degree of parallelism) I want to know if it helped or hurt query execution times.</p>
<p>This seems like an obvious performance counter, but for the last half hour I've been searching Google and the counter list in perfmon, and ... | <p>I don't believe there is a PerfMon but there is a report within SQL Server Management Studio:</p>
<p>Right click on the database, select <strong>Reports > Standard Reports > Object Execution Statistics</strong>. This will give you several very good statistics about what's running within the database, how long it's ... | <p>Average over what time and for which queries? You need to further define what you mean by "average" or it has no meaning, which is probably why it's not a simple performance counter.</p>
<p>You could capture this information by running a trace, capturing that to a table, and then you could slice and dice the execut... | 19,843 |
<p>I am attempting to get a DropDownList to AutoPostBack via an UpdatePanel when the selected item is changed. I'm going a little stir-crazy as to why this isn't working.</p>
<p>Does anyone have any quick ideas?</p>
<p>ASPX page:</p>
<pre><code><asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always"... | <p>I was able to get it to work with what you posted. This is the code I used... Basically what you had but I am throwing an exception.</p>
<pre><code> <asp:ScriptManager ID="smMain" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always" ChildrenAsTriggers="true" > ... | <p>Rather than using AutoPostBack="true" set the DropList as a trigger in the update panel.</p>
| 44,318 |
<p>How does the comma operator work in C++?</p>
<p>For instance, if I do:</p>
<pre><code>a = b, c;
</code></pre>
<p>Does a end up equaling b or c? </p>
<p>(Yes, I know this is easy to test - just documenting on here for someone to find the answer quickly.)</p>
<p><strong>Update:</strong> This question has expos... | <p>It would be equal to <code>b</code>.</p>
<p>The comma operator has a lower precedence than assignment.</p>
| <p><strong>First things first:</strong> Comma is actually not an operator, for the compiler it is just a token which gets a meaning <em>in context</em> with other tokens.</p>
<h2>What does this mean and why bother?</h2>
<p><strong>Example 1:</strong></p>
<p>To understand the difference between the meaning of the sam... | 7,774 |
<p>I have a blogengine.net install that requires privatization.</p>
<p>I'm doing research work at the moment, but I have to keep my blog/journal private until certain conditions are met.</p>
<p>How can I privatize my blogEngine.net install so that readers must log in to read my posts?</p>
| <p>I use this extension. Just save the file as RequireLogin.cs in your App_Code\Extensions folder and make sure the extension is activated.</p>
<pre><code>using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControl... | <p>I would think it's possible to do this in the web config file by doing something like the following:</p>
<pre><code><system.web>
<authorization>
<allow roles="Admin" />
<deny users="*" />
</authorization>
</system.web>
</code></pre>
| 3,806 |
<p>I used to have a Tests folders in my main project where a unit test had this line of code:</p>
<pre><code>Foo foo = new Foo(Environment.CurrentDirectory + @"\XML\FooData.xml" );
</code></pre>
<p>I have an XML directory in the Foo project that has a FooData.xml</p>
<p>In the post build event of my projects i have ... | <p>Rather than having a post-build step, can you not just make it a "content" item in Visual Studio, telling it to copy it to the target directory? I usually either do that, or make it an embedded resource and use streams and Assembly.GetManifestResourceStream. </p>
| <p>You can also put the full path of the xml in your test modules app.config</p>
| 45,050 |
<p>In a <a href="https://stackoverflow.com/questions/190524/mapping-computed-properties-in-linq-to-sql-to-actuall-sql-statements">previous question</a> I asked how to make "Computed properties" in a linq to sql object. The answer supplied there was sufficient for that specific case but now I've hit a similar snag in an... | <p>The problem is that CurrentStep is a normal method. Hence, the Expression contains a call to that method, and naturally SQL cannot execute arbitrary .NET methods.</p>
<p>You will need to represent the code as an Expression. I have one in depth example here: <a href="http://www.atrevido.net/blog/2007/09/06/Complicat... | <p>Check out <a href="/questions/209924/switch-statement-in-linq#210051">my answer</a> to "<a href="/questions/209924/switch-statement-in-linq">switch statement in linq</a>" and see if that points you in the right direction... </p>
<p>The technique i demonstrate there is the one that got me past the scary "no translat... | 25,476 |
<p>I need to use one logical PGM based multicast address in application while enable such application "seamlessly" running across several different geo-locations (i.e. think US/Europe/Australia).</p>
<p>Application is quite throughput (several million biz. messages a day) and latency demanding whith a lot of small but... | <p>Try this:</p>
<pre><code>Image img = new Image();
img.Source = new BitmapImage(new Uri(@"c:\icons\A.png"));
mnuA.Icon = img;
</code></pre>
| <p>Might be a long shot, but try something like:</p>
<blockquote>
<p>Uri u = new Uri(...); mnuA.Icon = new
BitmapImage(u);</p>
</blockquote>
<p>What it seems its happening is that your icon is getting converted to a string.</p>
| 46,212 |
<p>I have a private const int defined in a C# class. I want compilation to fail with an error if the value of this int mod 3 != 0. How can I accomplish this?</p>
| <p>Timothy Khouri almost got it. It should be this:</p>
<pre><code>int compilerError = 1 / (MY_CONST % 3 == 0 ? 1 : 0);
</code></pre>
| <p>Try this:</p>
<pre><code>if (MY_CONST % 3 != 0) { int compilerError = 1 / 0; }
</code></pre>
| 30,897 |
<p>I'm trying to populate a DataTable, to build a LocalReport, using the following:<br></p>
<pre><code>MySqlCommand cmd = new MySqlCommand();
cmd.Connection = new MySqlConnection(Properties.Settings.Default.dbConnectionString);
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT ... LEFT JOIN ... WHERE ...";... | <p>After fiddling around quite a bit I found that the <code>DataTable.Load</code> method expects a primary key column in the underlying data. If you read the documentation carefully, this becomes obvious, although it is not stated very explicitly.</p>
<p>If you have a column named "id" it seems to use that (w... | <p>Not sure why you're missing the row in the datatable, is it possible you need to close the reader? In any case, here is how I normally load reports and it works every time...</p>
<pre><code> Dim deals As New DealsProvider()
Dim adapter As New ReportingDataTableAdapters.ReportDealsAdapter
Dim ... | 28,399 |
<p>I've noticed for quite a long time that strange domains such like jsev.com, cssxx.com appered in my firefox status bar from time to time, I always wonder why so many web pages contains resources from these strange domains. I googled it, but found nothing. I guess it's some kind of virus which infect the servers and ... | <p>This happens if you are using one of Princeton university's CoDeeN project proxy servers. CoDeeN is an academic testbed content distribution network. When you browse a web page using CoDeeN proxy it injects some HTML code to the site's original HTML and redirects requests sent to pseudo adresses to the project's ser... | <p>That could very well be the case, as this does kinda look like some shady code. What if you use a different computer, does the source look the same?</p>
| 25,796 |
<p>I have a stored procedure that consists of a single select query used to insert into another table based on some minor math that is done to the arguments in the procedure. Can I generate the plan used for this query by referencing the procedure somehow, or do I have to copy and paste the query and create bind varia... | <p>Use <a href="http://68.142.116.68/docs/cd/B19306_01/server.102/b14211/sqltrace.htm#i4640" rel="nofollow noreferrer">SQL Trace and TKPROF</a>. For example, open SQL*Plus, and then issue the following code:-</p>
<pre><code>alter session set tracefile_identifier = 'something-unique'
alter session set sql_trace = true;... | <p>From what I understand, this was done on purpose. The idea is that individual queries within the procedure are considered separately by the optimizer, so EXPLAIN PLAN doesn't make sense against a stored proc, which could contain multiple queries/statements.</p>
<p>The current answer is NO, you can't run it against ... | 14,928 |
<p>I need to programmatically get a list of running applications as shown in the "Applications" tab inside the Windows Task Manager using PowerShell or VBScript.</p>
<p>All I could find so far is how to list processes using VBScript and WMI.</p>
| <p>This gets you close in PowerShell:</p>
<pre><code>get-process | where-object {$_.mainwindowhandle -ne 0} | select-object name, mainwindowtitle
</code></pre>
<p>Or the shorter version:</p>
<pre><code>gps | ? {$_.mainwindowhandle -ne 0} | select name, mainwindowtitle
</code></pre>
| <p>stahler's answer converted to PowerShell:</p>
<p>$word = new-object -com 'word.application'</p>
<p>$word.tasks | ? {$_.visible} | select name</p>
<p>$word.quit()</p>
| 23,215 |
<p>I am building an Entity Framework model for a subset of the Pubs database from microsoft. I am only interested and publishers and books, not publishers and employees, but there is a foreign key constraint between the publishers and emoloyees tables. When I remove the employees entity from my model, the model won't v... | <p>Not sure what I'm missing here, but your <code>filesize</code> being -1 seems to be your problem. The <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLResponse_Class/Reference/Reference.html#//apple_ref/occ/instm/NSURLResponse/expectedContentLength" rel="noreferrer">API docs... | <p>In your code, filesize appears to be an NSNumber object (!). So</p>
<p><code>
NSLog(@"filesize: %d", self.filesize);
</code></p>
<p>and</p>
<p><code>
NSLog(@"content-length: %d bytes", self.filesize);
</code></p>
<p>will likely report something like the address (id) of that object (or something else). This i... | 40,317 |
<p>I have a listbox that is databound to a Collection of objects. The listbox is configured to display an identifier property of each object. I would like to show a tooltip with information specific to the item within the listbox that is being hovered over rather than one tooltip for the listbox as a whole.</p>
<p>I... | <p>There are two main sub-problems one must solve in order to solve this problem:</p>
<ol>
<li>Determine which item is being hovered over</li>
<li>Get the MouseHover event to fire when the user has hovered over one item, then moved the cursor within the listbox and hovered over another item.</li>
</ol>
<p>The first p... | <p>Using title attribute, we can set tool tip for each list items in a list box.</p>
<p>Loop this for all the items in a list box.</p>
<pre><code>ListItem li = new ListItem("text","key");
li.Attributes.Add("title","tool tip text");
</code></pre>
<p>Hope this helps.</p>
| 23,401 |
<p>What kind of optimization patterns can be used to improve the performance of the garbage collector? </p>
<p>My reason for asking is that I do a lot of embedded software using the Compact Framework. On slow devices the garbage collection can become a problem, and I would like to reduce the times the garbage collecto... | <p>The key is to understand how the CF GC works for allocations. It's a simple mark-and-sweep, non-generational GC with specific algorithms for what will trigger a GC, and what will cause compaction and/or pitching after collection. There is almost nothing you can do at an app level to control the GC (the only method... | <p>I heard a <a href="http://www.dotnetrocks.com/default.aspx?showNum=360" rel="nofollow noreferrer">.NET Rocks</a> show on <a href="http://www.microsoft.com/downloads/details.aspx?familyid=3a1c93fa-7462-47d0-8e56-8dd34c6292f0&displaylang=en" rel="nofollow noreferrer">Rotor 2.0</a>. If you are really hardcore, you... | 20,542 |
<p>I once had the task of determining the following performance parameters from inside a running application:</p>
<ul>
<li>Total virtual memory available</li>
<li>Virtual memory currently used</li>
<li>Virtual memory currently used by my process<hr></li>
<li>Total RAM available</li>
<li>RAM currently used</li>
<li>RAM ... | <h2>Windows</h2>
<p>Some of the above values are easily available from the appropriate Win32 API, I just list them here for completeness. Others, however, need to be obtained from the Performance Data Helper library (PDH), which is a bit "unintuitive" and takes a lot of painful trial and error to get to work.... | <p>I used this following code in my C++ project and it worked fine:</p>
<pre><code>static HANDLE self;
static int numProcessors;
SYSTEM_INFO sysInfo;
double percent;
numProcessors = sysInfo.dwNumberOfProcessors;
//Getting system times information
FILETIME SysidleTime;
FILETIME SyskernelTime;
FILETIME SysuserTime; ... | 8,874 |
<p>I don't remember whether I was dreaming or not but I seem to recall there being a function which allowed something like,</p>
<pre><code>foo in iter_attr(array of python objects, attribute name)</code></pre>
<p>I've looked over the docs but this kind of thing doesn't fall under any obvious listed headers</p>
| <p>Using a list comprehension would build a temporary list, which could eat all your memory if the sequence being searched is large. Even if the sequence is not large, building the list means iterating over the whole of the sequence before <code>in</code> could start its search.</p>
<p>The temporary list can be avoidi... | <p>I think:</p>
<pre><code>#!/bin/python
bar in dict(Foo)
</code></pre>
<p>Is what you are thinking of. When trying to see if a certain key exists within a dictionary in python (python's version of a hash table) there are two ways to check. First is the <strong><code>has_key()</code></strong> method attached to the... | 2,310 |
<p>Although somewhat related to <a href="https://stackoverflow.com/questions/4409/is-the-desktop-app-dead">this question</a>, I have what I think is a different take on it.</p>
<p>Is a desktop app that has no connections to the "cloud" dead? I believe that some things are going to continue to be on the machine (operat... | <p>10 years or more ago this would have been, "Are non-internet applications dead?"</p>
<p>There's things the cloud does better than desktop applications, and in those places I'm sure non-cloud applications will become increasingly rare. But there's plenty of applications where you might not want to use the cloud, th... | <p>I personally will never leave my stuff on the web under someone else's control. All of my photos and e-mails I keep on local hard drives that I control. </p>
<p>I prefer to make my own stuff available to me through the web on my own hardware. The only way to have reasonable performance and be productive when off... | 7,576 |
<p>I have the following code:</p>
<pre><code>Dim obj As New Access.Application
obj.OpenCurrentDatabase (CurrentProject.Path & "\Working.mdb")
obj.Run "Routine"
obj.CloseCurrentDatabase
Set obj = Nothing
</code></pre>
<p>The problem I'm experimenting is a pop-up that tells me Access can't set the focus on the othe... | <p>You could use <a href="http://msdn.microsoft.com/en-us/library/system.string.split.aspx" rel="noreferrer" title="String.Split method msdn reference">String.Split method</a>.</p>
<pre><code>class ExampleClass
{
public ExampleClass()
{
string exampleString = "there is a cat";
// Split string o... | <p>If you are using C# 3.5 you could write an extension method to System.String that does the splitting you need. You then can then use syntax:</p>
<pre><code>string.SplitByMyTokens();
</code></pre>
<p>More info and a useful example from MS here <a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx" rel="nof... | 9,581 |
<p>I'm returning to c++ after being away for a bit and trying to dust off the old melon. </p>
<p>In Java Iterator is an interface to a container having methods: <code>hasNext()</code>, <code>next()</code> and <code>remove()</code>. The presence of <code>hasNext()</code> means it <strong>has the concept of a limit</str... | <p>Yes, there is a large conceptual difference. C++ utilizes different "classes" of iterators. Some are used for random access (unlike Java), some are used for forward access (like java). While even others are used for writing data (for use with, say, <code>transform</code>). </p>
<p>See the iterators concept in the <... | <p>Iterators are only equivalent to pointers in the trivial case of iterating over the contents of an array in sequence. An iterator could be supplying objects from any number of other sources: from a database, from a file, from the network, from some other calculation, etc.</p>
| 8,026 |
<p>I am trying to use <a href="http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx" rel="nofollow noreferrer">ShellExecute</a> to open a file in Excel. I was reading about the function on MSDN forums, and I found the folowing information about the handle, which is the first parameter: </p>
<p>"hwnd [in] A han... | <p>It is <a href="http://www.oehive.org/node/521" rel="nofollow noreferrer">usually 0</a></p>
<blockquote>
<p>hwnd : parent window that will receive a possible messagebox. This parameter is usually 0.</p>
</blockquote>
<p>It refers to the top-level window: the window you are opening does not have any parent, and is... | <p>Is there any specific reason, you are using ShellExecute?</p>
<p>You can open an xls file using [System.Diagnostics.]Process.Start [name of the file]<br>
I apologize, I didn't look at tags & assume that you are using .net</p>
| 40,734 |
<p>I have a <a href="https://www.monoprice.com/product?c_id=107&cp_id=10724&cs_id=1072403&p_id=21711" rel="nofollow noreferrer">Monoprice Select Mini V2</a> and I’ve recently been having issues with little strings that are thick and sturdy sticking off of models:</p>
<p><a href="https://i.stack.imgur.com/x... | <p>The Monoprice Select Mini V2 uses a Bowden style extrusion system. Bowden extruders compress the filament in the tube where the gap between the filament and inner tube diameter allow for the filament to buckle slightly and compress causing a pressure build-up in the hotend. Without retraction this implies that the f... | <p>The Monoprice Select Mini V2 uses a Bowden style extrusion system. Bowden extruders compress the filament in the tube where the gap between the filament and inner tube diameter allow for the filament to buckle slightly and compress causing a pressure build-up in the hotend. Without retraction this implies that the f... | 1,049 |
<p>I am working with a device that requires me to generate a 16 bit CRC.</p>
<p>The datasheet for the device says it needs the following CRC Definition:</p>
<pre>
CRC Type Length Polynomial Direction Preset Residue
CRC-CCITT 16 bits x16 + x12 + x5 + 1 Forward FFFF (16) 1D0F (16)
</pre... | <p>You initialize the CRC register with the <strong><em>preset</em></strong> before feeding in your message.</p>
<p>The <strong><em>residue</em></strong> is what should be left in the CRC register after feeding through a message, plus its correct CRC.</p>
<p>If you just want to send a message, you won't see the resid... | <p>The difference is in what the algorithm does with the two values. I just looked at a CRC algorithm myself and it looks pretty simple.</p>
<p>Preset is the value it starts with and residue is XOR'd with the value at the end.</p>
<p>Now, the <b>reason</b> for choosing particular values for preset and residue, that ... | 29,910 |
<p>I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a specific question regarding Actions. Most of the pages have exactly one Action, and the processExecute() methods are hideous monsters (very long and tons of nested if statements based on request parameters).</p>
<p>Given that Actions are an ... | <p>My way of dealing with this would be:</p>
<ul>
<li>dont do 'everything at once'</li>
<li>whenever you change anything, leave it better than you found it
<ul>
<li>replacing conditionals with separate Action implementations is one step. </li>
<li>Better yet: Make your implementations separate from the Action classes... | <p>Tough problem but typical of early web app development.</p>
<p>First things first you need to start thinking about which logic constitutes business behavior, which logic constitutes "flow" (i.e. what the user sees), and which logic gets the content for what he sees.</p>
<p>You don't have to go down the route of fa... | 25,715 |
<p>When you are developing a web-based application and you want to allow richly formatted text from the user you have to make a choice about how to allow that input. Many different markup languages have been created because it is arguably more difficult to sanitize HTML.</p>
<p>What are the advantages and disadvantag... | <p>Markdown, BBCode, Textile, MediaWiki markup are all basically the same general concept, so I would really just lump this into two categories: HTML, and plain text markup.</p>
<h3>HTML</h3>
<p>The deal with HTML is the content is already in a "presentable" form for web content. That's great, saves processin... | <p>"Many different markup languages have been created because it is arguably more difficult to sanitize HTML."</p>
<p>Really? How is it difficult? There are functions to remove potentially dangerous attributes or tags and validate the HTML before you enter it in database or file. Can you give me examples of how it is ... | 44,585 |
<p>I am looking to do this in C/C++. I came across <a href="http://www.swig.org/Doc1.3/Varargs.html" rel="nofollow noreferrer"><strong>Variable Length Arguments</strong></a>, but this suggests a solution with Python and C using <a href="http://sourceware.org/libffi/" rel="nofollow noreferrer">libffi</a>.</p>
<p>Now, if... | <p>The problem is that you cannot use 'printf' with <em>va_args</em>. You must use <strong>vprintf</strong> if you are using variable argument lists. <em>vprint</em>, <em>vsprintf</em>, <em>vfprintf</em>, etc. (there are also 'safe' versions in Microsoft's C runtime that will prevent buffer overruns, etc.)</p>
<p>Yo... | <p>How do you mean a pure C/C++ solution?</p>
<p>The rest parameter (...) is supported cross platform in the C runtime.</p>
<p><em><a href="https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/va-arg-va-copy-va-end-va-start" rel="nofollow noreferrer">va_arg, va_copy, va_end, va_start</a></em></p>
| 6,267 |
<p>I have just found a static nested interface in our code-base.</p>
<pre><code>class Foo {
public static interface Bar {
/* snip */
}
/* snip */
}
</code></pre>
<p>I have never seen this before. The original developer is out of reach. Therefore I have to ask SO:</p>
<p>What are the semantics beh... | <p>The static keyword in the above example is redundant (a nested interface is automatically "static") and can be removed with no effect on semantics; I would recommend it be removed. The same goes for "public" on interface methods and "public final" on interface fields - the modifiers are redundant and just add clutte... | <p>Static means that any class part of the package(project) can acces it without using a pointer. This can be usefull or hindering depending on the situation.</p>
<p>The perfect example of the usefullnes of "static" methods is the Math class. All methods in Math are static. This means you don't have to go out of your ... | 9,716 |
<p>I have a view that has a list of jobs in it, with data like who they're assigned to and the stage they are in. I need to write a stored procedure that returns how many jobs each person has at each stage.</p>
<p>So far I have this (simplified):</p>
<pre><code>DECLARE @ResultTable table
(
StaffName nvarchar(100),... | <p>You could just check for existence and use the appropriate command. I believe this really does use a cursor behind the scenes, but it's the best you'll likely get: </p>
<pre><code>IF (EXISTS (SELECT * FROM MyTable WHERE StaffName = @StaffName))
begin
UPDATE MyTable SET ... WHERE StaffName = @StaffName
end
else... | <p>The following query on your result table should combine the rows again. This is assuming that InStage1 and InStage2 are never both '1'.</p>
<pre><code>select distinct(rt1.StaffName), rt2.Stage1Count, rt3.Stage2Count
from @ResultTable rt1
left join @ResultTable rt2 on rt1.StaffName=rt2.StaffName and rt2.Stage1Count ... | 3,957 |
<p>I have a CompositeControl that contains a DropDownList.</p>
<p>I have set the AutoPostBack property of the DropDownList to true.</p>
<p>On the page, I have:</p>
<pre><code><asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>
<MyControl:Control ID="CustomControl" runat="se... | <p>Ok so this may not be the best answer, but I think the problem you're having it that the UpdatePanel just can't see the child control's event. Good news is, it's easy to fix. Say you have a control (CatchMyEvent, which by the way is a crazy clever name) and it has a DropDownList on it. Now you want the parent pag... | <p>I made the following at the end of the BuildControlHierarchy:</p>
<pre><code> ...
if (DesignMode || Page == null) return;
var sm = ScriptManager.GetCurrent(Page);
if (sm == null)
{
throw new MissingFieldException("The ScriptManager is needed on the page!");
... | 27,897 |
<p>I'm working on a idea where my a:link have one state (blue, no underline etc) with a a:hover being white. I want my <strong>visited links to have the same state</strong> as <code>a:link</code> and <code>a:hover</code>. Is this possible? supported in most common browsers?</p>
| <pre><code>a, a:link, a:hover, a:visited, a:active {text-decoration: none; color: blue;}
</code></pre>
<p>should work on all CSS-enabled browsers, although this is a <a href="http://www.useit.com/alertbox/20040503.html" rel="noreferrer">bad idea</a> (currently offline, <a href="http://209.85.129.132/search?q=cache:WLL... | <p>Here's how you can style the a tags (normal and visited) and style the hover separately.</p>
<pre><code>a
{
color:#6c7492;
font-weight:bold;
text-decoration:none;
}
a:hover
{
border-bottom:1px solid #6c7492;
}
</code></pre>
| 38,986 |
<p>I have two properties files that are not the same and I need to find the differences. The second file is sorted by key.</p>
<p>Is there a tool that can help me with it? From what I've seen every merge tool cares very much about the order.</p>
| <p>I've done it in bash on Linux by sorting both files and then merge them. If you are on Windows you could install Cygwin for running Linux programs.</p>
<p>However, I think you are best served by creating a small program to do it, probably takes you less time than learning to use Cygwin.</p>
<p>Edit: You could look... | <p>Sort one or both files.</p>
<p>Then run "diff".</p>
| 46,373 |
<p>Is anyone working on or know if there exists a SQL 2k8 Dialect for NHibernate? </p>
| <p>I am assuming the plugin here is the NPAPI plugin (e.g. Flash). Under X11, QtWebKit search several common directories for the plugin. For the complete list, see <a href="http://doc.qt.digia.com/4.5/qtwebkit.html#netscape-plugin-support" rel="nofollow noreferrer">the documentation on Netscape plugin support</a>.</p>
... | <p>Have you tried putting in the <em>standard library directories</em>? It should be picked up by the <strong>linker</strong> if it's in one of those directories.</p>
<p>For example:</p>
<pre><code>/lib/
/usr/lib/
/usr/share/lib/
/usr/local/lib/
</code></pre>
| 3,940 |
<p>Question: Is there an easy way (library function) to perform a bitwise AND or OR on numbers larger than 32-bit in ActionScript? </p>
<p>From the docs:
"Bitwise operators internally manipulate floating-point numbers to change them into 32-bit integers. The exact operation performed depends on the operator, but all ... | <p>I think your most straightforward option is to break the masks, and if possible the data being masked, into two pieces. You're butting up against a feature gap, so no point in being tricky if you can help it. And if you don't need real BigNum support, best not to even consider it.</p>
| <p>According to <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=03_Language_and_Syntax_11.html" rel="nofollow noreferrer">http://livedocs.adobe.com/flex/3/html/help.html?content=03_Language_and_Syntax_11.html</a>, there are no 64-bit integers (signed or unsigned)...only 32-bit.</p>
<p>The Number type,... | 32,565 |
<p>Basically, something similar to System.Xml.XmlWriter - A streaming XML Writer that doesn't incur much of a memory overhead. So that rules out xml.dom and xml.dom.minidom. Suggestions?</p>
| <p>I think you'll find XMLGenerator from xml.sax.saxutils is the closest thing to what you want.</p>
<pre>
import time
from xml.sax.saxutils import XMLGenerator
from xml.sax.xmlreader import AttributesNSImpl
LOG_LEVELS = ['DEBUG', 'WARNING', 'ERROR']
class xml_logger:
def __init__(self, output, encoding):
... | <p><strong>xml.etree.cElementTree</strong>, included in the default distribution of CPython since 2.5. Lightning fast for both reading and writing XML.</p>
| 11,931 |
<p>which would you recommend?
which is faster, reliable?
apache mod_python or nginx/lighttpd FastCGI?</p>
| <p>I've done both, and Apache/mod_python tended to be easier to work with and more stable. But these days I've jumped over to Apache/mod_wsgi, which is everything I've ever wanted and more:</p>
<ul>
<li>Easy management of daemon processes.</li>
<li>As a result, <strong>much</strong> better process isolation (running m... | <p>Personally I've had it working with FastCGI for some time now (6 months or so) and the response times 'seem' quicker when loading a page that way vs mod___python. The critical reason for me though is that I couldn't see an obvious way to do multiple sites from the same apache / mod_python install whereas FastCGI was... | 30,420 |
<p>XAML allows you to specify an attribute value using a string that contains curly braces. Here is an example that creates a <em>Binding</em> instance and assigns it to the <em>Text</em> property of the <em>TextBox</em> element.</p>
<pre><code><TextBox Text="{Binding ElementName=Foo, Path=Bar}"/>
</code></pre>
... | <p>take a look at markupextensions
<a href="http://blogs.msdn.com/wpfsdk/archive/2007/03/22/blogpost-text-creatingasimplecustommarkupextension.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/wpfsdk/archive/2007/03/22/blogpost-text-creatingasimplecustommarkupextension.aspx</a></p>
| <p>take a look at markupextensions
<a href="http://blogs.msdn.com/wpfsdk/archive/2007/03/22/blogpost-text-creatingasimplecustommarkupextension.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/wpfsdk/archive/2007/03/22/blogpost-text-creatingasimplecustommarkupextension.aspx</a></p>
| 13,933 |
<p>I'm loading data from my database, and exporting to an Excel file via a method I found on this site: <a href="http://www.appservnetwork.com/modules.php?name=News&file=article&sid=8" rel="noreferrer">http://www.appservnetwork.com/modules.php?name=News&file=article&sid=8</a></p>
<p>It works, but what ... | <p>I have written Excel spreadsheets from PHP 5 using the <a href="http://pear.php.net/package/Spreadsheet_Excel_Writer/" rel="noreferrer"><code>PEAR :: Package :: Spreadsheet_Excel_Writer</code></a> classes. You can do a lot with this package.</p>
| <p>The TinyButStrong template system (www.tinybutstrong.com) has an optional plugin that allows you to write to excel templates. </p>
<p>I've used this a great deal. It's particularly neat in that you can set up the page to write to either HTML or Excel depending on a flag - so typically my reports offer 'display on... | 35,381 |
<p>Are there any other ways to avoid LazyInitializationExceptions in a Hibernate web application besides using the OpenSessionInView pattern? Are there any downsides to using OpenSessionInView?</p>
| <p>When working on our web applications, we usually decide beforehand which objects/fields will be needed in the view pages and make sure that all the objecs are properly initialized from the model before dispatching to the view.</p>
<p>This can be accomplished in (at least) three ways:</p>
<ol>
<li><a href="http://... | <p>The Oracle Java tutorials point out that "Enterprise beans support transactions, the mechanisms that manage the concurrent access of shared objects." So, in order to handle the Lazy Fetch issues I create a Stateless Java Session Bean and then get all of the sub classes I need before returning from the method. Oracle... | 26,520 |
<p>I am writing a custom ant task that extends Task. I am using the log() method in the task. What I want to do is use a unit test while deveoping the task, but I don't know how to set up a context for the task to run in to initialise the task as if it were running in ant.</p>
<p>This is the custom Task:</p>
<pre><co... | <p>Or better yet, decouple the task object itself from the logic (lets call it TaskImpl) inside the task - so that you can pass in your own dependencies (e.g., the logger). Then, instead of testing the task object, you test TaskImpl -> which you can pass in the logger, and any other weird bits and pieces it might need ... | <p>Ant has a handy class called BuildFileTest that extends the JUnit TestCase class. You can use it to test the behaviour of individual targets in a build file. Using this would take care of all the annoying context.</p>
<p>There's a <a href="http://ant.apache.org/manual/tutorial-writing-tasks.html#TestingTasks" rel... | 21,955 |
<p>I am looking for an easy way to get the SID for the current Windows user account. I know I can do it through WMI, but I don't want to go that route.</p>
<p>Apologies to everybody that answered in C# for not specifying it's C++. :-)</p>
| <p>In Win32, call <a href="http://msdn.microsoft.com/en-us/library/aa446671.aspx" rel="nofollow noreferrer">GetTokenInformation</a>, passing a token handle and the <code>TokenUser</code> constant. It will fill in a <a href="http://msdn.microsoft.com/en-us/library/aa379634.aspx" rel="nofollow noreferrer">TOKEN_USER</a> ... | <p>You didn't specify what language you want. But if you're up for C# this article offers both the WMI method as well as a faster (while more verbose) method utilizing the Win32 API.</p>
<p><a href="http://www.codeproject.com/KB/cs/processownersid.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/proces... | 31,279 |
<p>I am trying to print my first test but my Creality Ender 3 starts printing near the front edge and within 10 seconds is printing in front of the tray (off onto my table). I really think it should be starting the print in the middle and then never going so close to the edge and even over it</p>
<p>What can I do?</p... | <p>When a print is not printing on the build platform, you either:</p>
<ol>
<li><p>Have the incorrect settings in the slicer (e.g. Ultimaker Cura, <a href="https://3dprinting.stackexchange.com/a/6450/5740">a common mistake is that the "origin at center" option is active</a>), or</p></li>
<li><p>Have the center of the ... | <p>When a print is not printing on the build platform, you either:</p>
<ol>
<li><p>Have the incorrect settings in the slicer (e.g. Ultimaker Cura, <a href="https://3dprinting.stackexchange.com/a/6450/5740">a common mistake is that the "origin at center" option is active</a>), or</p></li>
<li><p>Have the center of the ... | 1,115 |
<p>Two main ways to deploy a J2EE/Java Web app (in a very simplistic sense):</p>
<h2>Deploy assembled artifacts to production box</h2>
<p>Here, we create the <code>.war</code> (or whatever) elsewhere, configure it for production (possibly creating numerous artifacts for numerous boxes) and place the resulting artifac... | <p>I'm firmly against building on the production box, because it means you're using a different build than you tested with. It also means every deployment machine has a different JAR/WAR file. If nothing else, do a unified build just so that when bug tracking you won't have to worry about inconsistencies between serv... | <p>If you are asking this question relative to configuration management, then your answer needs to be based on what you consider to be a managed artifact. From a CM perspective, it is an unacceptable situation to have some collection of source files work in one environment and not in another. CM is sensitive to environ... | 17,127 |
<p>Are there any handy general items you put in your .procmailrc file?</p>
| <p>Many mailers prefix a mail's subject with "Re: " when replying, if that prefix isn't already there. German Outlook instead prefixes with "AW: " (for "AntWort") if that prefix isn't already there. Unfortunately, these two behaviours clash, resulting in mail subjects like "Re: AW: Re: AW: Re: AW: Re: AW: Lunch". So... | <p>To stop weird russian and chinese spams, I use this procmail configuration. </p>
<pre><code>UNREADABLE='[^?"]*big5|iso-2022-jp|ISO-2022-KR|euc-kr|gb2312|ks_c_5601-1987'
:0:
* ^Content-Type:.*multipart
* B ?? $ ^Content-Type:.*^?.*charset="?($UNREADABLE)
spam-unreadable
</code></pre>
| 2,993 |
<p>I'm running Emacs 22.1.1 and IPython 0.9.1 on OS X and I'd like to be able to run lines/methods/snippets of Python code from my current buffer on demand inside an IPython interpreter.</p>
<p>What do I need to do to get this working?</p>
| <p>also ipython wont load with the official python.el being used with emacs 23.1.1</p>
| <p>python-mode.el supports IPython natively.</p>
<p>Just make sure shebang doesn't point to another interpreter. </p>
<p>In this case:</p>
<ul>
<li>either call a command with ending "-ipython", which will override shebang</li>
<li>customize "ipython" as default interpreter and set `py-force-py-shell-name-p'. This mi... | 43,883 |
<p>I am designing a game to be played in the browser.</p>
<p>Game is a space theme and I need to generate a map of the "Galaxy".</p>
<p>The basic idea of the map is here:</p>
<p><a href="http://www.oglehq.com/map.png" rel="nofollow noreferrer">game map http://www.oglehq.com/map.png</a></p>
<p>The map is a grid, wit... | <p>There are two very nice browser-based vector / javascript-manipulable graphics packages which, together, are virtually universal: SVG and VML. They generally produce high-quality vector-based images with low bandwidth.</p>
<p><a href="http://en.wikipedia.org/wiki/Scalable_Vector_Graphics" rel="nofollow noreferrer"... | <p>As long as links have a maximum length that's not too long, then you don't have too many different possible images for each cell. You need to come up with an ordering on the kinds of image cells. For example, an integer where each bit indicates the presense or absence of an image component.</p>
<pre><code>Bit 0 : H... | 13,262 |
<p>We'd like a trace in our application logs of these exceptions - by default Java just outputs them to the console.</p>
| <p>There is a distinction between uncaught exceptions in the EDT and outside the EDT.</p>
<p><a href="https://stackoverflow.com/questions/75218/how-can-i-detect-when-an-exceptions-been-thrown-globally-in-java#75439">Another question has a solution for both</a> but if you want just the EDT portion chewed up...</p>
<pr... | <p>There are two ways:</p>
<ol>
<li>/* Install a Thread.UncaughtExceptionHandler on the EDT */</li>
<li>Set a system property:
System.setProperty("sun.awt.exception.handler",MyExceptionHandler.class.getName());</li>
</ol>
<p>I don't know if the latter works on non-SUN jvms.</p>
<p>--</p>
<p>Indeed, the first is not... | 12,130 |
<p>Is there an easy way to convert a string that contains this:</p>
<pre><code>Date: Wed, 5 Nov 2008 13:12:12 -0500 (EST)
</code></pre>
<p>into a string that contains this:</p>
<pre><code>20081105_131212
</code></pre>
<p><strong>UPDATE:</strong><br>
I ended up using date.tryparse which is similar to tryParseExact e... | <p>Even better than <code>Date.Parse</code> in this case would be <code>Date.TryParseExact()</code>. That would let you tell the framework what format you expect and return a boolean rather than throwing an exception if the parse fails.</p>
<p>Then use <code>.ToString("yyyyMMdd_HHmmss")</code> to get the desired new ... | <p><code>Format(date, "yyyyMMdd_HHmmss")</code></p>
<p>More help on <a href="http://msdn.microsoft.com/en-us/library/59bz1f0h(VS.71).aspx" rel="nofollow noreferrer">format</a> function.</p>
| 33,900 |
<p>Is it possible to create an HTML email signature for <strong>Outlook 2003</strong> or above that doesn't reference external images?</p>
<p>That is, using those special "cid" reference but embed the image itself in the signature and not on the file system or network.</p>
<p>This is for an web application that gener... | <p>If you reference the image using a <code>file:///</code> URI Outlook will automatically change it into a <code>cid:</code> URI and add the image as an attachment on insertion.</p>
<p>BTW: What has this got to do with programming?</p>
<p><strong>EDIT</strong>: OK, considering your update to the question: I'm afraid... | <p>If the image is small enough, then you might be able to do something with a <a href="http://en.wikipedia.org/wiki/Data_Uri" rel="nofollow noreferrer">data URI</a>.</p>
| 44,536 |
<p>If I have no connection to internet, does that mean I can't start <strong>IDLE</strong> (which comes with <strong>python 3.0</strong>)?</p>
| <p>IDLE displays a warning message about firewall programs because it connects to the interpreter over the loopback interface, but that interface is always "connected" and doesn't require you to be on the Internet.</p>
<p>If IDLE isn't working for you with Python 3.0, you might consult <a href="http://bugs.python.org/... | <p>IDLE does not need to be connected to the internet.</p>
<p>Consult python support if you have problems: <a href="http://www.python.org/about/help/" rel="nofollow">Python help page</a></p>
| 23,065 |
<p>I have a table with one field that can point to a foreign key in one of 3 other tables based on what the descriminator value is (Project, TimeKeep, or CostCenter. Usually this is implemented with subclasses, and I am wondering if what I have below will work. <strong>Note the subclass name is the same as the parent... | <p>Discriminators are used for storing class hierarchies in a single table. What you have there is a single class with multiple meanings. </p>
<p><a href="http://docs.jboss.org/hibernate/core/3.5/reference/en-US/html/mapping.html#mapping-declaration-discriminator" rel="nofollow noreferrer">http://docs.jboss.org/hiber... | <p>AFAIK, you can reuse Java class names for subclass mappings if you use entity-names.</p>
<p>Try the mapping below. Here the super class mapping itself is abstract. The subclasses use the same Java class and an entity-name for each subclass. You might need to put entity-name to the super class mapping. However, I wo... | 21,064 |
<p>Is it necessary for setter methods to have one argument? Usually setter methods accept one argument as the value of a certain property of an Object. What if I want to test first the validity which depends on another argument which is a boolean, if true, validate first, else just set the value.</p>
<p>I am getting t... | <p>It is necessary specifically in the java bean framework model, but it s not mandatory in general.</p>
<p>You can have setter with no argument when they are meant to "swith" a value.</p>
<pre><code>void setCheck()
</code></pre>
<p>could for instance be meant to set the "check" boolean attribute to true.</p>
<p>So... | <p>In the book "Effective Java 2nd Edition" by Joshua Bloch (ISBN-13: 978-0-321-35668-0) saids that it's best to use the builder pattern than the bean convention for objects creations.<br></p>
<p>For instance (bean pattern):</p>
<pre><code>NutritionFacts cocaCola = new NutritionFacts();
cocaCola.setServingSize(240);
... | 39,249 |
<p>Our users have created MS-Excel spreadsheets which over time have evolved into fairly complex applications. They run their part of the business with them. But, never having been exposed to software development discipline, these spreadsheets are brittle, single point of failure, solutions.</p>
<p>Our development g... | <p>There are tools that could convert the data, but trying to converting the formulas would cause the design to be inefficient at best and unusable at worst. The difference between spreadsheets and an Oracle database are similar to the differences between a home gardener and a farmer. Both are useful on their level a... | <p>You can find tools to migrate the data, but other than that you wouldn't find a tool to automatically do this, you would have to do it all manually.</p>
<p>Even directly copying what was there would not make sense, you were using very limited tools (Excel), you would need to re-analyze the requirements, and possibl... | 28,968 |
<p>In SQL Server I have a <code>DATETIME</code> column which includes a time element.</p>
<p>Example: </p>
<pre><code>'14 AUG 2008 14:23:019'
</code></pre>
<p>What is the <strong>best</strong> method to only select the records for a particular day, ignoring the time part?</p>
<p>Example: (Not safe, as it does no... | <p>Technique 1:</p>
<pre><code> DECLARE @p_date DATETIME
SET @p_date = CONVERT( DATETIME, '14 AUG 2008', 106 )
SELECT *
FROM table1
WHERE column_datetime >= @p_date
AND column_datetime < DATEADD(d, 1, @p_date)
</code></pre>
<p>The advantage of this is that it will use any index on 'column_da... | <p>In sqlserver</p>
<pre><code>DECLARE @p_date DATE
SELECT *
FROM table1
WHERE column_dateTime=@p_date
</code></pre>
<p>In C#
Pass the short string of date value using ToShortDateString() function.
sample:
DateVariable.ToShortDateString();</p>
| 3,200 |
<p>Can someone explain the mechanics of a jump table and why is would be needed in embedded systems?</p>
| <p>A jump table can be either an array of pointers to functions or an array of machine code jump instructions. If you have a relatively static set of functions (such as system calls or virtual functions for a class) then you can create this table once and call the functions using a simple index into the array. This w... | <p>Jump tables, more often known as a Branch table, are usually used only by the machine.</p>
<p>The compiler creates a list of all labels in a assembly program and links all labels to a a memory location. A jump table pretty much is a reference card to where, a function or variable or what ever the label maybe, is st... | 7,039 |
<p>I have a simple piece of code:</p>
<pre><code>public string GenerateRandomString()
{
string randomString = string.Empty;
Random r = new Random();
for (int i = 0; i < length; i++)
randomString += chars[r.Next(chars.Length)];
return randomStr... | <p>This is happening, because the calls happen very close to each other (during the same milli-second), then the Random constructor will seed the Random object with the same value (it uses date & time by default).</p>
<p>So, there are two solutions, actually.</p>
<p><strong>1. Provide your own seed value</strong>... | <p>The default constructor for Random (the one you're using) seeds the generator with a value based on the current time. If the time in milliseconds doesn't change between the first and second call of the function, it would use the same random seed.</p>
<p>My suggestion is to use a static Random object and only initi... | 49,260 |
<p>I have the following XAML: </p>
<pre><code><TextBlock Text="{Binding ElementName=EditListBox, Path=SelectedItems.Count}" Margin="0,0,5,0"/>
<TextBlock Text="items selected">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
... | <p>The DataTrigger is firing but the Text field for your second TextBlock is hard-coded as "items selected" so it won't be able to change. To see it firing, you can remove Text="items selected".</p>
<p>Your problem is a good candidate for using a <strong>ValueConverter</strong> instead of <strong>DataTrigger</strong>.... | <p>The DataTrigger is firing but the Text field for your second TextBlock is hard-coded as "items selected" so it won't be able to change. To see it firing, you can remove Text="items selected".</p>
<p>Your problem is a good candidate for using a <strong>ValueConverter</strong> instead of <strong>DataTrigger</strong>.... | 11,984 |
<p>I've recently heard about the <a href="http://msdn.microsoft.com/en-us/library/bb204633(VS.85).aspx" rel="nofollow noreferrer">CaptureStackBackTrace</a> function by reading <a href="https://stackoverflow.com/questions/105659/how-can-one-grab-a-stack-trace-in-c">this post</a>. I cannot find it in any of my Visual St... | <p>Did you update your Windows SDK to the most recent version? Since this is a Windows API function, it should be included there.</p>
| <p>Did you update your Windows SDK to the most recent version? Since this is a Windows API function, it should be included there.</p>
| 26,005 |
<p>I have made a C# application and I am trying to figure out if I can tap into build events of cctray (cruise control tray)? I don't want to re-invent the wheel, I just want to know when my builds fail or succeed (on a client machine) so than my custom C# application may execute a specific set of routines.</p>
| <p>You could add the CruiseControl remote library as a refrence and create an instance of CruiseManagerFactory and this line will get you the status of all the projects. ServerUri is a string in the format of tcp://ServerName:Port/CruiseManager.rem</p>
<pre><code>ProjectStatus[] currentStatuses = managerFactory.GetCr... | <p>Any reason why you can't use your build tool to do that?<br>
e.g. in <a href="http://nant.sourceforge.net/" rel="nofollow noreferrer">Nant</a>, you can specify the target to be executed when the build fails or succeeds by using <a href="http://nant.sourceforge.net/release/0.85/help/fundamentals/properties.html#built... | 46,717 |
<p>We're using SQL Server 2005 in a project. The users of the system have the ability to search some objects by using 'keywords'. The way we implement this is by creating a full-text catalog for the significant columns in each table that may contain these 'keywords' and then using CONTAINS to search for the keywords th... | <p>These "small words" are considered "noise words" by the full text index. You can customize the list of noise words. This <a href="http://arcanecode.wordpress.com/2008/05/29/creating-and-customizing-noise-words-in-sql-server-2005-full-text-search/" rel="nofollow noreferrer">blog post</a> provides more details. You ne... | <p>I knew about the noise words file, but I'm not why your "Terminator 2" example is still giving you issues. You might want to try asking this on the <a href="http://forums.microsoft.com/Forums/ShowForum.aspx?ForumID=93&SiteID=1" rel="nofollow noreferrer">MSDN Database Engine forum</a> where people that specialize... | 9,707 |
<p>When you have a query or stored procedure that needs performance tuning, what are some of the first things you try?</p>
| <p>Here is the handy-dandy list of things I always give to someone asking me about optimisation.<br>
We mainly use Sybase, but most of the advice will apply across the board. </p>
<p>SQL Server, for example, comes with a host of performance monitoring / tuning bits, but if you don't have anything like that (and maybe... | <p>Don't prefix Stored Procedure names with "sp_" because system procedures all start with "sp_", and SQL Server will have to search harder to find your procedure when it gets called.</p>
| 3,933 |
<p>How would I go about this?</p>
<p>I have a mostly static site, which is being hosted on a cheap web-host, which only allows FTP access to the hosting. The site is tracked in git. I am using OS X.</p>
<p>I would like to upload a new version of the site by simply doing <code>cap deploy</code></p>
| <p>We use capistrano to deploy our site which is written in PHP.</p>
<p>From memory (I'm not at work right now) we overload deploy and used rsync to sync over sftp. Something like this:</p>
<pre class="lang-rb prettyprint-override"><code>desc "Sync"
namespace :deploy do
desc "Sync remote by default"
task :defaul... | <p>I've not tried it with capistrano, but in my own shell scripts, I've always used weex</p>
<p>(<a href="http://weex.sourceforge.net/" rel="nofollow noreferrer">http://weex.sourceforge.net/</a>)</p>
<p>to deploy sites over FTP. Imagine you could hack it up with capistrano too.</p>
<p>It keeps a local cache of the s... | 42,428 |
<p>I have a PHP script that processes file uploads. The script tries to organise the files that are uploaded and may create new folders to move the files into if needed. These files will be below the www root directory (ie, a web browser will be able to access them).</p>
<p>My question is, what permissions should I se... | <p>Your webserver needs read and write permission in those folders, execute permission should be revoked (assuming UNIX-like systems). If not, a user could upload a script and have it executed by sending a HTTP request for it.</p>
<p>But IMO the whole concept is a potential security hole. Better store the files in a f... | <p>to answer it specifically 766 (no execute permissions) would be the loosest you would want to use. On the other end 700 would allow no one but the web user to mess with the file.
But really it all depends you were doing with the files that would determine the best result.</p>
| 37,027 |
<p>How do I convert a datetime or date object into a POSIX timestamp in python? There are methods to create a datetime object out of a timestamp, but I don't seem to find any obvious ways to do the operation the opposite way.</p>
| <pre><code>import time, datetime
d = datetime.datetime.now()
print time.mktime(d.timetuple())
</code></pre>
| <p>Best conversion from posix/epoch to datetime timestamp and the reverse:</p>
<pre><code>this_time = datetime.datetime.utcnow() # datetime.datetime type
epoch_time = this_time.timestamp() # posix time or epoch time
this_time = datetime.datetime.fromtimestamp(epoch_time)
</code></pre>
| 31,820 |
<p>I have a FlowDocument in a standard WPF application window where I have some text, and in this text some hyperlinks and buttons.</p>
<p>The problem is, if I put this FlowDocument inside anything <strong>except</strong> a <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.flowdocumentpageviewer.... | <p>I'm using a FlowDocumentScrollViewer for my about box:</p>
<pre><code><FlowDocumentScrollViewer VerticalScrollBarVisibility="Auto">
<FlowDocument>
<Paragraph>
<!-- ... -->
</code></pre>
<p>I don't have any of the controls or issues you mention.</p>
| <p>I am wondering whether you expecing some thing like this?</p>
<pre><code><TextBlock>
<Hyperlink>
<Run Text="Test link"/>
</Hyperlink >
</code></pre>
<p></p>
<pre><code></TextBlock>
</code></pre>
| 10,605 |
<p>As in subject... is there a way of looking at an empty table schema without inserting any rows and issuing a SELECT?</p>
| <p>Are you looking for <a href="http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/core/r0002019.htm" rel="nofollow noreferrer">DESCRIBE</a>?</p>
<p><code>db2 describe table user1.department</code> </p>
<pre><code>Table: USER1.DEPARTMENT
Column Type Type
name ... | <p>Looking at your <a href="https://stackoverflow.com/questions/153920/php-unixodbc-db2-describe-token-not-valid">other question</a>, DESCRIBE may not work. I believe there is a system table that stores all of the field information.</p>
<p>Perhaps <a href="http://www.code400.com/ffd.php" rel="nofollow noreferrer">this... | 18,569 |
<p>I did this tests and the results seems the count function scale linearly. I have another function relying strongly in the efficiency to know if there are any data, so I would like to know how to replace this select count(*) with another more efficient (maybe constant?) query or data structure.</p>
<blockquote>
<p... | <p>select true from table limit 1;</p>
| <p>You may find <a href="http://wiki.postgresql.org/wiki/Slow_Counting" rel="nofollow noreferrer">this</a> useful.</p>
| 28,980 |
<p><em>Overview</em></p>
<p>I'm working on some Emergency Services reporting and mapping application for California (kind of weird, considering the fires there, right now...). We need to map demographic and emergency data for an internal govt unit.</p>
<p>What we have are <em>all</em> the streets, cities and neighbor... | <p>As @Oddthinking noted in a comment, your problems started at:</p>
<blockquote>
<p>So I changed the table to be more normalised by making the Neighborhood, City and State fields a foreign key to their own new table (eg. lookups) .. and those two fields are now NULLABLE.</p>
<p>So .. that all works fine. except when I... | <p>Is this an OLTP system and reporting system or only a reporting system? If it's only a reporting system, you can denormalize the data in a data warehouse fashion (with snowflake dimensions or not for the hierachies of geographic jurisdictions) and you'll find the reporting to be easier.</p>
<p>I would start from t... | 38,117 |
<p>The Microsoft unit testing framework has suddenly gone on strike.</p>
<p>When I try to run tests in VS2008, I get a dialog with the message "VSTestHost.exe has stopped working".</p>
<p>I have Visual Studio Team System 2008 (version 9.0.30729.1 SP) running on Vista with all updates applied. </p>
<p>The "Problem re... | <p>This is usually due to something wrong in the code like an endless loop, or a circular reference. </p>
<p>I had the same issue and realized that it was my code that was messing up, and the test framework was simply protecting itself against my code by shutting itself down.</p>
<p>The key for me was that the same t... | <p>Have you tried running a repair on Visual Studio or even resetting back to factory settings?</p>
<p>To reset to factory settings, run devenv /ResetSettings from the run window.</p>
| 28,948 |
<p>I've tried these, and they did not work (Access opens, but it does not wait:</p>
<pre><code>start "C:\program files\Microsoft Office\Office\MSACCESS.EXE" filename.mdb
start /WAIT "C:\program files\Microsoft Office\Office\MSACCESS.EXE" filename.mdb
start /W "C:\program files\Microsoft Office\Office\MSACCESS.EXE" f... | <pre><code>start /WAIT msaccess.exe filename.mdb
</code></pre>
<p>does the trick.</p>
<p>I don't know why adding the full path makes it fail.</p>
| <pre><code>PATH="C:\Program Files\Microsoft Office\OFFICE11\; C:\Windows\Command"
START /WAIT MSACCESS.exe "path to mdb file" /X "name of macro"
</code></pre>
| 21,237 |
<p>Is there a framework equivalent to Guice (<a href="http://code.google.com/p/google-guice" rel="noreferrer">http://code.google.com/p/google-guice</a>) for Python?</p>
| <p>I haven't used it, but the <a href="http://springpython.webfactional.com/" rel="noreferrer">Spring Python</a> framework is based on Spring and implements <a href="http://static.springsource.org/spring-python/1.2.x/sphinx/html/objects.html" rel="noreferrer">Inversion of Control</a>.</p>
<p>There also appears to be a... | <p>If you prefer a really tiny solution there's a little function, it is just a dependency setter. </p>
<p><a href="https://github.com/liuggio/Ultra-Lightweight-Dependency-Injector-Python" rel="nofollow">https://github.com/liuggio/Ultra-Lightweight-Dependency-Injector-Python</a></p>
| 18,895 |
<p>So I bought a Lulzbot Mini a couple months ago and finally downloaded Ultimaker's version of Cura... Boy... have I been missing out...</p>
<p>One feature Ultimaker Cura implemented that I've been looking for is a "pause at z-height" feature ("post-processing tool"). I'm building prototypes of an electronics device,... | <p>There is an option to directly insert extra commands at a specific Z height, no need to enter them manually.</p>
<p>That said, it is a bad idea to turn off the heated bed while printing, because this will often detach the object from the bed completely (that's kind of the point of having the heated bed in the first... | <p>Discharge the battery entirely, then there is no danger of ignition if the membrane breaks. The battery cells are usually protected by Kapton tape (LiPo) or maybe even metal (LiIon). Both will withstand the temperature of 240°C. The downside is that the cells are damaged after a deep discharge. You should discard th... | 883 |
<p>Curious what is recognized as a solid algorithm/approach for judging the strength of a directed acyclic graph - particularly the strength of certain nodes. The main question I have about this can be boiled down to the following two graphs:</p>
<p><img src="https://farm4.static.flickr.com/3055/2893003041_0e9c6dc251... | <p>This really depends on what you mean by strength. Because of the versatility of the DAG in representing information, you could be discussing anything from a multiple-outcome control flow to argument clauses of non-adverbial discourse connectives or even the full set of dependencies between different words in a sent... | <p>Okay, the practical application is sports teams. Each node is a team, each link is a victory over another team. Assume there are no circular victory paths, like A->B->C->A. The objective is to get a power ranking that doesn't conflict with the graph, and ranks the teams in order of a team's strength. The site in... | 17,471 |
<p>Anyone have suggestions for deployment methods for Perl modules to a share nothing cluster?</p>
<p>Our current method is very manual.</p>
<ol>
<li>Take down half the cluster</li>
<li>Copy Perl modules ( CPAN style modules ) to downed cluster members</li>
<li>ssh to each member and run <code>perl Makefile.pl; make ... | <p>Take one node offline, install Perl, and then use it to reimage the other nodes.</p>
<p>At least, that's how I imagine you'd want to install software in a shared-nothing cluster. Perl is just the application you happen to be installing.</p>
| <p>I am not sure exactly what a share nothing cluster is, but if it uses some base *nix system like Fedora, Mandriva, or Ubuntu. Many of the perl modules are precompiled for specific architectures. You can easily run these.</p>
<p>If these systems are of the same arch you can do as someone else said and just copy the ... | 15,944 |
<p>I have been doing a lot of research on this lately, but have yet to get a really good solid answer. I read somewhere that a new Function() object is created when the JavaScript engine comes across a function statement, which would lead me to believe it could be a child of an object (thus becoming one). So I emailed ... | <p>Your understanding is wrong:</p>
<pre><code>myFunction().myProperty; // myFunction has no properties
</code></pre>
<p>The reason it does not work is because ".myProperty" is applied to the returned value of "myFunction()", not to the object "myFunction". To wit:</p>
<pre><code>$ js
js> function a() { this.b=1;... | <p>JavaScript is based on the ECMA script. Its specification uses the prototyping model for it to be OOP. How ever, ECMA script does not enforce strict data types.
The object needs to be instantiated for the same reason that ECMA script requires a 'new' call which will allocate memory for the property, Otherwise it wil... | 48,650 |
<p>I'm having some trouble figuring out how to use more than one left outer join using LINQ to SQL. I understand how to use one left outer join. I'm using VB.NET. Below is my SQL syntax.</p>
<p><strong>T-SQL</strong></p>
<pre><code>SELECT
o.OrderNumber,
v.VendorName,
s.StatusName
FROM
Orders o
LEFT... | <p>This may be cleaner (<strong>you dont need all the <code>into</code> statements</strong>):</p>
<pre><code>var query =
from order in dc.Orders
from vendor
in dc.Vendors
.Where(v => v.Id == order.VendorId)
.DefaultIfEmpty()
from status
in dc.Status
.Where(s => s.Id... | <p>I am using this linq query for my application. if this match your requirement you can refer this. here i have joined(Left outer join) with 3 tables. </p>
<pre><code> Dim result = (From csL In contractEntity.CSLogin.Where(Function(cs) cs.Login = login AndAlso cs.Password = password).DefaultIfEmpty
... | 33,551 |
<p>Given a Generic List of objects that contain a member variable that is a string, what is the best way to get the object that contains the string with the longest length?</p>
<p>ie.
assuming val1 is the string I'm comparing:</p>
<pre><code>0 : { val1 = "a" }
1 : { val1 = "aa" }
2 : { val1 = "aba" }
3 : { val1 = ... | <p>Sorry, I'll try again. You can use the following aggregation:</p>
<pre><code>Dim result = elements.Aggregate(Function(a, b) If(a.val1.Length > b.val1.Length, a, b))
</code></pre>
| <p>You could also use an order-by:</p>
<pre><code>var x = myStringArray.OrderBy(s => s.Length).Last();
</code></pre>
| 31,375 |
<p>I've got two ASP.Net applications residing in two different folders on my server:</p>
<ul>
<li><code>/Foo</code> <-- this is the standard unsecure application</li>
<li><code>/Secure</code> <-- this is a separate application that requires SSL by IIS</li>
</ul>
<p>The problem is that by default, the <code>ASP.... | <p>In .Net 2.0 and above, you can set the "cookieName" attribute of the "sessionState" XML element in your web.config to different values for each of your applications. That will keep them from using the same session ID.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/h6bb9cz9.aspx" rel="noreferrer">Here's th... | <p>Sounds like they are just in separate virtual directories, but are still in the same Application Pool. If you really want the applications to be separate, try creating another application pool for your /secure app.</p>
| 38,795 |
<p>Personally, I find the range of functionality provided by java.util.Iterator to be fairly pathetic. At a minimum, I'd like to have methods such as:</p>
<ul>
<li>peek() returns next element without moving the iterator forward</li>
<li>previous() returns the previous element</li>
</ul>
<p>Though there are lots of ot... | <p>You can get <code>previous()</code> easily by just using a <code>java.util.ListIterator</code>.</p>
<p>Peek at that point is easily implemented by doing a </p>
<pre><code>public <T> T peek(ListIterator<T> iter) throws NoSuchElementException {
T obj = iter.next();
iter.previous();
return obj... | <p>I haven't ever run into an issue where I've needed a peek(); Iterator has worked just fine for me. I'm curious how you're using iterators that you feel you need this added functionality.</p>
| 23,384 |
<p>Does anyone have any data on how to interface with a Compris POS? I have a Compris POS, and I need to grab data from the database. I can't get information from NCR regarding the underlying data format, and I was wondering if anyone had reverse engineered the device, or had any documentation on the device.</p>
| <p>What kind of DB? Can you post the structure?</p>
<p>I work with a POS software company and I'm quite sure I could deconstruct it rather easily...</p>
| <p>There are various tools such as pludump.exe, prtme.exe etc that you may already have which can provide extracts as text. These can then be imported into Excel.</p>
| 18,134 |
<p>I need to store my class A objects in some data structure.
In addition, i would like them to be automatically sorted according to a key, which is in my case an embedded object of another class B. </p>
<p>Thus I decided to use a STL priority queue.</p>
<p>However it is possible that the 2 or more objects B to have ... | <blockquote>
<p>Does the STL priority queue allow duplicate keys??</p>
</blockquote>
<p>Yes.</p>
<blockquote>
<p>If it does what should I consider </p>
</blockquote>
<p>That the order between equal elements may change arbitrarily.</p>
<blockquote>
<p>and which predicate should I use?</p>
</blockquote>
<p>Tha... | <p>Konrad has a great answer, to add to that. You should know that priority_queue doesn't necessarily have great performance. According to this page <a href="http://www.cs.brown.edu/~jwicks/libstdc++/html_user/classstd_1_1priority__queue.html" rel="nofollow noreferrer">http://www.cs.brown.edu/~jwicks/libstdc++/html_use... | 31,314 |
<pre><code>Double out = otherTypes.someMethod(c, c2);
assertEquals((Double)-1.0D, out);
</code></pre>
<p>I get error "Double cannot be resolved" (the Double in assertEquals), is there any way to hack around it except extracting variable?</p>
<p>Is this bug in Java or just very usefull feature that wont be fix?</p>
| <p>One important note: Because of the way floating point numbers work, you should never compare two doubles (or floating point numbers generally spoken) for equality directly, always compare if their difference is within a specified delta: <code>abs(double1 - double2) < delta</code>. </p>
<p>JUnit has an <code>asse... | <p>My suggestion when you want to check if two doubles are exactly the same:</p>
<pre><code>assertEquals(Double.doubleToLongBits(-1.0), Double.doubleToLongBits(out));
</code></pre>
| 27,761 |
<p>I always hear that using "lastInsertId" (or mysql_insert_id() if you're not using PDO) is evil. In case of triggers it obviously is, because it could return something that's totally not the last ID that your INSERT created.</p>
<pre><code>$DB->exec("INSERT INTO example (column1) VALUES ('test')");
// Usually ret... | <p>If you go the route of ADOdb (<a href="http://adodb.sourceforge.net/" rel="nofollow noreferrer">http://adodb.sourceforge.net/</a>), then you can create the insert ID <em>before hand</em> and explicitly specific the ID when inserting. This can be implemented portably (ADOdb supports a ton of different databases...) a... | <p>You could try this:</p>
<pre><code>$sql = "SELECT id FROM files ORDER BY id DESC LIMIT 1";
$PS = $DB -> prepare($sql);
$PS -> execute();
$result = $PS -> fetch();
</code></pre>
| 36,940 |
<p>Other than Notepad++, what text editor do you use to program in Windows? </p>
| <p>Another vote for <strong>gvim</strong> (<a href="http://www.vim.org/about.php" rel="nofollow noreferrer">about</a>, <a href="http://www.vim.org/download.php#pc" rel="nofollow noreferrer">download</a>). I think once you learn the keystrokes to control it, you won't want to use anything else.</p>
<p>Plus, there is th... | <p>No <a href="http://www.eclipse.org/" rel="nofollow noreferrer">Eclipse</a> in the list !!!</p>
| 3,498 |
<p>We are using shared hosting and the follow features are disabled.</p>
<pre><code>file_uploads = Off
allow_url_fopen = Off
allow_url_include = Off
</code></pre>
<p>We are unable to change hosting and need to figure out some workarounds. The hosting co is also not able/willing to enable these features. </p>
<p>Fo... | <p>Since you're looking to retrieve remote content the easiest way will be to write the functionality to fetch the content yourself with something like curl (<a href="http://php.net/curl" rel="nofollow noreferrer">php.net/curl</a>)</p>
| <p>Have you tried something like this:
<a href="http://www.humanumbrella.com/2007/12/08/how-to-download-a-remote-file-in-php-and-then-save-it/" rel="nofollow noreferrer">http://www.humanumbrella.com/2007/12/08/how-to-download-a-remote-file-in-php-and-then-save-it/</a></p>
| 40,424 |
<p>I'm used to writing classes like this:</p>
<pre><code>public class foo {
private string mBar = "bar";
public string Bar {
get { return mBar; }
set { mBar = value; }
}
//... other methods, no constructor ...
}
</code></pre>
<p>Converting Bar to an auto-property seems convenient and concise, but how ... | <p>Update - the answer below was written before C# 6 came along. In C# 6 you can write:</p>
<pre><code>public class Foo
{
public string Bar { get; set; } = "bar";
}
</code></pre>
<p>You can <em>also</em> write read-only automatically-implemented properties, which are only writable in the constructor (but ... | <p>In the default constructor (and any non-default ones if you have any too of course):</p>
<pre><code>public foo() {
Bar = "bar";
}
</code></pre>
<p>This is no less performant that your original code I believe, since this is what happens behind the scenes anyway.</p>
| 20,426 |
<p>We generate web pages that should always be printed in landscape mode. Web browser print dialogs default to portrait, so for every print job the user has to manually select landscape. It's minor, but would be nice for the user if we can remove this unnecessary step. </p>
<p>Thanks in advance to all respondents.</p... | <p>A quick Google indicates that it's not really supported. There's more than a few folks out there trying to <a href="http://www.daniweb.com/forums/showthread.php?t=14877&page=2&highlight=javascript+print+landscape" rel="nofollow noreferrer">hack</a> <a href="http://home.tampabay.rr.com/bmerkey/examples/landsc... | <p>I was looking to do this same thing and found <a href="http://edacio.us/forum/comments.php?DiscussionID=39" rel="nofollow noreferrer">this</a> article. It looks particularly "hacky" and as the author points out, may invoke an active x warning in IE. Seems like a losing proposition to confuse the user with an active ... | 5,785 |
<p>I'm looking for a graph algorithm with some unusual properties.</p>
<p>Each edge in the graph is either an "up" edge or a "down" edge.</p>
<p>A valid path can go an indefinite number of "up"'s followed by an indefinite number of "down"'s, or vice versa. However it cannot change direction more than once.</p>
<p>E.... | <p>Assuming you don't have any heuristics, a variation of <a href="http://en.wikipedia.org/wiki/Dijkstra's_algorithm" rel="nofollow noreferrer">dijkstra's algorithm</a> should suffice pretty well. Every time you consider a new edge, store information about its "ancestors". Then, check for the invariant (only one di... | <p>If you have a standard graph search function, say <code>Graph.shortest(from, to)</code> in a library, you can loop and minimize, in C#/pseudocode: </p>
<pre><code>[ (fst.shortest(A, C) + nxt.shortest(C, B))
for C in nodes , (fst, nxt) in [(up, down), (down, up)] ].reduce(min)
</code></pre>
<p>If you need to r... | 7,623 |
<p>I'm writing a Perl script and I've come to a point where I need to parse a Java source file line by line checking for references to a fully qualified Java class name. I know the class I'm looking for up front; also the fully qualified name of the source file that is being searched (based on its path). </p>
<p>For e... | <p>You also need to skip quoted strings (you can't even skip comments correctly if you don't also deal with quoted strings).</p>
<p>I'd probably write a fairly simple, efficient, and incomplete tokenizer very similar to the one I wrote in <a href="http://perlmonks.org/?node_id=566467" rel="nofollow noreferrer">node 56... | <p>If you are feeling adventurous enough you could have a look at <a href="http://search.cpan.org/dist/Parse-RecDescent/" rel="nofollow noreferrer">Parse::RecDescent</a>.</p>
| 15,984 |
<p>Can't get to my site. Apache gives the following error message: </p>
<blockquote>
<p>[Fri Sep 05 08:47:42 2008] [error] (OS 10060)A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.... | <p>Can you connect to the proxied host (10.10.10.1) directly? Is it functioning normally?</p>
| <p><a href="http://www.checkupdown.com/status/E503.html" rel="nofollow noreferrer">http://www.checkupdown.com/status/E503.html</a></p>
<blockquote>
<p>Your Web server is effectively 'closed for repair'. It is still functioning minimally because it can at least respond with a 503 status code, but full service is impo... | 6,774 |
<p>I'm creating a multi-tenancy web site which hosts pages for clients. The first segment of the URL will be a string which identifies the client, defined in Global.asax using the following URL routing scheme:</p>
<pre><code>"{client}/{controller}/{action}/{id}"
</code></pre>
<p>This works fine, with URLs such as /fo... | <p>I think the main issue is that if you're going to piggyback on the built-in ASP.NET FormsAuthentication class (and there's no good reason you shouldn't), something at the end of the day is going to call <code>FormsAuthentication.RedirectToLoginPage()</code> which is going to look at the one configured URL. There's o... | <p>Still, if one decides to use the built-in ASP.NET FormsAuthentication, one can overide <code>Application_AuthenticateRequest</code> in <code>Global.asax.cs</code> as follows:</p>
<pre><code>protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
string url = Request.RawUrl;
if (url.Con... | 46,554 |
<p>I'm not a newbie since I've been programming on and off since 1983, but I only have real experience with scripting languages like Applescript, ARexx, HyperTalk and Bash.</p>
<p>I write scripts to automate data entry, batch process images and convert file formats. I dabble at Processing, Ruby and Python.</p>
<p>Mos... | <p>Yes. Anything longer than zero lines can be unit tested - usually to good effect.</p>
| <p>The only time you need to write unit tests is when you care that the output of your program is correct, and will continue to be correct in the future.</p>
<p>If correctness of your code is not important, then it is not necessary to unit test.</p>
| 24,388 |
<p>I've noticed a lot of talk about asp.net MVC lately, but I haven't come across a clear or compelling description of when, where or why I would want to use it over WebForms.</p>
<p>Let's say I wanted to build a small web application that allows a person to advertise some items online. The website will have 4 use cas... | <blockquote>
<ul>
<li>What are the fundamental differences between the two models?</li>
</ul>
</blockquote>
<p>WebForms try to mimic WinForms development by allowing you to reuse lots of pre-made controls, and by faking web application state via the hidden _VIEWSTATE mechanism.</p>
<p>MVC is a pattern designed ... | <ol>
<li>The biggest difference between ASPNET MVC and is WebForms is the lifecycle of an page, no difficult(unnecessary) postbacks, clean coding, enz.</li>
<li>There are no rules for that</li>
<li>???</li>
<li>REST-full website, Separation of logic</li>
<li>Design-time support, can't use third-party webcontrols</li>
<... | 39,714 |
<p>If I have a <code>UIView</code> (or <code>UIView</code> subclass) that is visible, how can I tell if it's currently being shown on the screen (as opposed to, for example, being in a section of a scroll view that is currently off-screen)?</p>
<p>To maybe give you a better idea of what I mean, <code>UITableView</code... | <p>Not tried any of this yet. But <code>CGRectIntersectsRect()</code>, <code>-[UIView convertRect:to(from)View]</code> and <code>-[UIScrollView contentOffset]</code> seem to be your basic building blocks here.</p>
| <p>I recently had to check whether my view was onscreen. This worked for me:</p>
<pre><code>CGRect viewFrame = self.view.frame;
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
// We may have received messages while this tableview is offscreen
if (CGRectIntersectsRect(viewFrame, appFrame)) {
// Do work... | 17,200 |
<p>What tool would you recommend to detect <strong>Java package cyclic dependencies</strong>,
knowing that the goal is to <em>list explicitly the specific classes involved in the detected 'across-packages cycle'</em>?</p>
<p>I know about <a href="http://classycle.sourceforge.net/" rel="noreferrer">classycle</a> and <a... | <p>Findbugs can detect circular class dependencies and has an Eclipse plugin too.</p>
<p><a href="http://findbugs.sourceforge.net/" rel="nofollow noreferrer">http://findbugs.sourceforge.net/</a></p>
| <p>One tool which does this is the software <a href="http://www.software-tomography.com/" rel="nofollow noreferrer">tomograph</a>. It is commercial and the UI sucks :o</p>
| 8,765 |
<p>I sometimes notice programs that crash on my computer with the error: "pure virtual function call".</p>
<p>How do these programs even compile when an object cannot be created of an abstract class?</p>
| <p>They can result if you try to make a virtual function call from a constructor or destructor. Since you can't make a virtual function call from a constructor or destructor (the derived class object hasn't been constructed or has already been destroyed), it calls the base class version, which in the case of a pure vi... | <p>Here is a sneaky way for it to happen. I had this essentially happen to me today.</p>
<pre><code>class A
{
A *pThis;
public:
A()
: pThis(this)
{
}
void callFoo()
{
pThis->foo(); // call through the pThis ptr which was initialized in the constructor
}
virtual void foo() = 0;
};
class B... | 12,478 |
<p>I am writing a stored procedure where I have an input parameter called <em>my_size</em> that is an <em>INTEGER</em>. I want to be able to use it in a <code>LIMIT</code> clause in a <code>SELECT</code> statement. Apparently this is not supported, is there a way to work around this?</p>
<pre><code># I want something ... | <p>A search turned up <a href="http://bugs.mysql.com/bug.php?id=8094" rel="noreferrer">this article</a>. I've pasted the relevant text below.</p>
<blockquote>
<p>Here's a forum post showing an example of prepared statements letting
you assign a variable value to the limit clause:</p>
<p><a href="http://forum... | <p>I've faced the same problem using MySql 5.0 and wrote a procedure with the help of @ENargit's answer:</p>
<pre><code>CREATE PROCEDURE SOME_PROCEDURE_NAME(IN _length INT, IN _start INT)
BEGIN
SET _start = (SELECT COALESCE(_start, 0));
SET _length = (SELECT COALESCE(_length, 999999)); -- USING ~0 GIVES OUT OF... | 30,413 |
<p>Since I didn't do a good job writing the last question, and most of the answers were good, but not at all in the direction I intended for the question to go in, I deleted it and remade it as this question.</p>
<p>I'm a solo developer on my own projects, generally very small things, but I have a few ideas that might... | <p>Even if you don't need process to promote good communication between team members, process can help you compensate for the fact that you aren't as superhuman as you thought you were when you were 18 :) The type and amount of 'paperwork' you decide to do depends on your own strengths and weaknesses. Bad memory? Wr... | <p>Follow your heart.</p>
| 15,062 |
<p>I have a swf that is run from C:/ in the browser instead of a server (long story) and that swf loads a video that it located at ../../videos/video in relation to that swf.</p>
<p>Problem is, When I run it in Flex, everything is cool. Running locally, it can't find the file (not a security error) and is throwing a ... | <p>Flex Builder has a file that it adds all of your bin directories to in order to allow the debug player to get around the local security restrictions.</p>
<p>Here's a <a href="http://viconflex.blogspot.com/2008/08/why-no-sandbox-violation-running-from.html" rel="nofollow noreferrer">blog post on the subject</a>.</p>... | <p>I would suggest getting HTTPFOX for Firefox which is a sniffer. Then you can see what is failing. In my own search I found that FLV's are always relative to the SWF, even when loaded on the WEB. Every asset that I have loaded is relative to the index.html file except for FLV's which always remain relative to the ... | 24,357 |
<p>I'm working on a home project that involves comparing images to a database of images (using a quadrant - or so - histogram approach). I wanted to know what my options are in regards to web cams or other image capture devices that:</p>
<ul>
<li>Are easy to work with with the
Windows SDK (particularly
<a href="http:... | <p>Use the ScriptManager server control:</p>
<pre><code> <asp:ScriptManager ID="myScriptManager" runat="server">
<Scripts>
<asp:ScriptReference Path = "~/javascript/actions.js" />
<asp:ScriptReference Path = "~/javascript/jquery/jquery-1.2.6.min.js" />
</Scripts>
&... | <p>As per <a href="http://weblogs.asp.net/scottgu/archive/2006/12/19/tip-trick-how-to-run-a-root-site-with-the-local-web-server-using-vs-2005-sp1.aspx" rel="nofollow noreferrer">ScottGu</a>,</p>
<p>One tip to take advantage of is the relative path fix-up support provided by the head runat="server" control. You can us... | 22,231 |
<p>When I try to login to this site using my yahoo openid, it takes me to the yahoo site, I click "continue" meaning that i <em>want</em> to send my authentication details to stackoverflow.com and stackoverflow.com gives me the following error underneath the login text field:</p>
<p>Unable to log in with your OpenID p... | <pre><code>public string UserDefinedField
{
get { return _userDefinedField; }
set { SetField(value); ChangedFields.Add(Fields.UserDefinedField); }
}
// Call this from internal methods and use the public property for other cases
internal string SetField(string userValue)
{
_userDefinedField = userValue;
}
<... | <p>This isn't exactly what you're asking, but in a case like that, I would use an internal method to set the value directly.</p>
<pre><code>...
internal void SetUserDefinedField(string val) {
_userDefinedField = val;
}
...
</code></pre>
| 26,201 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.