instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I'm developing an HTML newsletter system using PHP & PEAR. It sends out the emails fine.</p>
<p>However I cannot force Apple Mail to reload images from the server. I have tried:</p>
<ul>
<li>Restarting Mail</li>
<li>Clear ~/Library/MailDownloads </li>
<li>Clear ~/Library/Cache/Mail</li>
<li>Empty Safari cache<... | <p>You could use <a href="http://www.titanium.free.fr/" rel="nofollow noreferrer">OnyX</a> to clear all apps cache and also tune up other aspects of the OS.</p>
| <p>I spent some time playing with this today and was able to duplicate the problem easily. The image in mail <strong>doesn't change</strong> - whichever picture shows when you first look at the email seems to stay with that message no matter how many times you change the image on the server. Even when I forward the me... | 48,508 |
<p>By convention our DB only alows the use of stored procedures for INSERT, UPDATE and DELETE. For some tables / types there is no DELETE stored procedure, because it is not allowed to delete rows. (You can only update the status of such a type to "deleted"). e.g. a customer may be marked as deleted but is never really... | <p>Implement a partial class for each such entity and implement the OnValidate partial method. It takes a ChangeAction as a parameter. When the ChangeAction is ChangeAction.Delete, throw an exception that indicates that the operation is disallowed (IllegalOperationException, maybe).</p>
| <p>The deletion API is not generated, by which I mean an option on a generated table cannot remove the ability to mark an item as deleted. <code>DeleteOnSubmit</code> is part of the <code>Table<TEntity></code> class.</p>
<p>If it is always an error to delete an entity, <code>OnValidate</code> should throw an <co... | 37,408 |
<p>So for viewing a current object's state at runtime, I really like what the Visual Studio Immediate window gives me. Just doing a simple</p>
<pre><code>? objectname
</code></pre>
<p>Will give me a nicely formatted 'dump' of the object. </p>
<p><strong>Is there an easy way to do this in code, so I can do somethin... | <p>You could base something on the ObjectDumper code that ships with the <a href="http://code.msdn.microsoft.com/csharpsamples/Release/ProjectReleases.aspx?ReleaseId=8" rel="noreferrer">Linq samples</a>.<br>
Have also a look at the answer of this <a href="https://stackoverflow.com/questions/852181/c-printing-all-proper... | <p>I found a library called <a href="https://github.com/drewburlingame/ObjectPrinter" rel="nofollow">ObjectPrinter</a> which allows to easily dump objects and collections to strings (and more). It does exactly what I needed.</p>
| 47,018 |
<p>I am developing sharepoint (MOSS) project in Virtual PC. Unfortunately virtual PC can utilize only one core of my quad core machine. Are there any tips & tricks which can speed my development process?</p>
| <p>Things that we used to do before we moved to Hyper-V...</p>
<p>Don't allocate too much RAM to the VPC, it will start to use the paging file too much.</p>
<p>Make sure that the virtual hard drives and virtual memory files for the VPC are excluded from your antivirus program.</p>
<p>Defrag the VPC, then defrag the ... | <p>Did you activate hardware virtualization extension in both your BIOS and VPC settings ?<br>
Did you give your VM enough memory (I usually set around 2GB). </p>
<p>You may also switch to Win2008 + HyperV which is more powerful.</p>
| 44,627 |
<p>When using a Silverlight-enabled WCF service, where is the best place to instantiate the service and to call the CloseAsync() method?</p>
<p>Should you say, instantiate an instance each time you need to make a call to the service, or is it better to just instantiate an instance as a variable of the UserControl that... | <p>You're better off just having an instance variable for the service. Creating and destroying the service for each call creates a lot of unnecessary overhead. Just create the variable and call the methods, no need to open it since this will be <a href="http://blogs.msdn.com/silverlight_sdk/archive/2008/06/04/breaking-... | <p>In the case of 2 parallel event handlers in your SL client, you can do the following approach to make sure only one gets invoked:
Assume, we have a global client variable, App.Client, which is being used by everything in the app.
Now, control 1 needs to react on MyOperationCompleted, as does control 2.
Each control ... | 35,234 |
<p>What is the best way to encode URL strings such that they are rfc2396 compliant and to decode a rfc2396 compliant string such that for example %20 is replaced with a space character?</p>
<p>edit:
URLEncoder and URLDecoder classes do <strong>not</strong> encode/decode rfc2396 compliant URLs, they encode to a MIME ty... | <p>Use the URI class as follows:</p>
<pre><code>URI uri = new URI("http", "//www.someurl.com/has spaces in url", null);
URL url = uri.toURL();
</code></pre>
<p>or if you want a String:</p>
<pre><code>String urlString = uri.toASCIIString();</code></pre>
| <p>Use <a href="http://java.sun.com/javase/6/docs/api/java/net/URLEncoder.html" rel="nofollow noreferrer">java.net.URLEncoder</a> and <a href="http://java.sun.com/javase/6/docs/api/java/net/URLDecoder.html" rel="nofollow noreferrer">java.net.URLDecoder</a>.</p>
| 39,182 |
<p>Is there any way to show two editing windows in visual studio? I would like to look at two source files at the same time but I must be missing the option to do that.</p>
| <p>Another easy option is to open two documents, then just click and drag the tab for one of the documents and drop it on the document itself. This will display a menu that lets you move the document to a new vertical or horizontal tab group.</p>
<p>I find this to be the easiest and quickest way to do this.</p>
<p>Yo... | <p>In visual Studio 2015 right click tab part where file name is written and select vertical split or horizontal split.</p>
| 37,585 |
<p>How do I limit the types of HTML that a user can input into a textbox? I'm running a small forum using some custom software that I'm beta testing, but I need to know how to limit the HTML input. Any suggestions?</p>
| <p>i'd suggest a slightly alternative approach:</p>
<ul>
<li>don't filter incoming user data (beyond prevention of sql injection). user data should be kept as pure as possible.</li>
<li>filter all outgoing data from the database, this is where things like tag stripping, etc.. should happen</li>
</ul>
<p>keeping user ... | <p>Once the text is submitted, you could strip any/all tags that don't match your predefined set using a regex in PHP.</p>
<p>It would look something like the following: </p>
<pre><code>find open tag (<)
if contents != allowed tag, remove tag (from <..>)
</code></pre>
| 19,222 |
<p>Is there a good way to determine if a person has a popup blocker enabled? I need to maintain a web application that unfortunately has tons of popups throughout it and I need to check if the user has popup blockers enabled.</p>
<p>The only way I've found to do this is to open a window from javascript, check to see i... | <p>Read <a href="http://www.visitor-stats.com/articles/detect-popup-blocker.php" rel="nofollow noreferrer">Detect a popup blocker using Javascript</a>:</p>
<p>Basically you check if the 'window.open' method returns a handle to a newly-opened window.</p>
<p>Looks like this:</p>
<pre><code>var mine = window.open('',''... | <p>Popups that are opened in response to an action by a user—such as clicking a link—shouldn't be blocked by popup blockers.</p>
| 31,126 |
<p>I have read a book whose title is "Oracle PL SQL Programming" (2nd ed.) by Steven Feuerstein & Bill Pribyl. On page 99, there is a point suggested that </p>
<p><strong>Do not "SELECT COUNT(*)" from a table unless you really need to know the total number of "hits." If you only need to know whether there is more ... | <p>There are a number of reasons why developers might perform select COUNT(*) from a table in a PL/SQL program:</p>
<h1>1) They genuinely need to know how many rows there are in the table.</h1>
<p>In this case there is no choice: select COUNT(*) and wait for the result. This will be pretty fast on many tables, but c... | <p>SQL Server:</p>
<pre><code>if 2 = (
select count(*) from (
select top 2 * from (
select T = 1 union
select T = 2 union
select T = 3 ) t) t)
print 'At least two'
</code></pre>
<p>Also, don't ever use cursors. If you think you really really need them, beat yourself... | 38,095 |
<p>There's an annoying "feature" when using Eclipse PDE on Mac OS X: the font size of the runtime IDE is not the same as the true IDE. If you're developing a plug-in and you launch an Eclipse instance to test it (from within Eclipse), you will notice that the spawned instance looks very different from the original runn... | <p>Found the answer. </p>
<p>You need to add the following VM argument to your launch configuration:
-Dorg.eclipse.swt.internal.carbon.smallFonts</p>
<p>I opened a defect about it. Hopefully it will be fixed.</p>
| <p>Eclipse saves its preferences on a per-workspace base. You probably don't use the same workspace for both eclipse instances. Threfore you'd need to set the preferences for the spawn once or copy it to the spawn-workspace from your original one.</p>
<p>Now you've got the default settings and that is probably not wha... | 43,238 |
<p>I want to change member of structure under double pointer. Do you know how?</p>
<p>Example code</p>
<pre><code>typedef struct {
int member;
} Ttype;
void changeMember(Ttype **foo) {
//I don`t know how to do it
//maybe
*foo->member = 1;
}
</code></pre>
| <p>Try</p>
<pre><code>(*foo)->member = 1;
</code></pre>
<p>You need to explicitly use the * first. Otherwise it's an attempt to dereference member.</p>
| <p>maybe (*foo)->member = 1 (if it's dynamically allocated)</p>
| 45,112 |
<p>I'd like to find the base url of my application, so I can automatically reference other files in my application tree...</p>
<p>So given a file config.php in the base of my application, if a file in a subdirectory includes it, knows what to prefix a url with. </p>
<pre><code>application/config.php
application/admin... | <p>I use the following in a homebrew framework... Put this in a file in the root folder of your application and simply include it.</p>
<pre><code>define('ABSPATH', str_replace('\\', '/', dirname(__FILE__)) . '/');
$tempPath1 = explode('/', str_replace('\\', '/', dirname($_SERVER['SCRIPT_FILENAME'])));
$tempPath2 = ex... | <p>One solution would be to use relative paths for everything, that way it does not matter where the app is installed. For example, to get to your style sheet, use this:</p>
<pre><code>../css/style.css
</code></pre>
| 21,282 |
<p>How can you allow a PHP script to write to a file with high-security restrictions, such as only allowing a single user to write to it?</p>
<p>The difficulty seems to be that a PHP script is running as a low-permissions user (maybe apache, or www, or nobody?), and even if I <code>chown</code> apache the_writable_fil... | <p>Unfortunately, in shared hosts that use <strong>mod_php, there is no way to restrict access</strong> to secure files to your web app and login user.</p>
<p>The solution is to <strong>run your web app as your login user</strong>. When you do that, UNIX file permissions can correctly lock everyone else out. There are... | <p>Sure, <code>chgrp apache the_writable_file</code> and <code>chmod g+w the_writable_file</code>. After that, only your secure user and the apache user will be able to write to the file. Since the apache user is typically forbidden from logging in, you only have to worry about web users writing to your secure file u... | 5,417 |
<p>I would like create my own collection that has all the attributes of python list and also knows how to save/load itself into/from a database. Also I want to make the load implicit and lazy, as in it doesn't happen at the point of creation of the list, but waits until its first used.</p>
<p>Is there a single<code>_... | <p>No, there isn't.</p>
| <p>There isn't a single method. You have to redefine quite a lot of them. MutableSequence seems to be the modern way of doing it. Here is a version that works with Python 2.4+::</p>
<pre><code>class LazyList(list):
"""List populated on first use."""
def __new__(cls, fill_iter):
class LazyList(list):
... | 29,842 |
<p>I was wondering if there was some kind of J tool in the java swing library that opens up a file browser window and allows a user to choose a file. Then the ouput of the file would be the absolute path of the chosen file.</p>
<p>Thanks in advance,</p>
| <p>You can use the <a href="http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JFileChooser.html" rel="noreferrer">JFileChooser</a> class, check <a href="http://www.java2s.com/Code/Java/Swing-JFC/DemonstrationofFiledialogboxes.htm" rel="noreferrer">this example</a>.</p>
| <p>In WebStart and the new 6u10 PlugIn you can use the FileOpenService, even without security permissions. For obvious reasons, you only get the file contents, not the file path.</p>
| 35,820 |
<pre><code>boolean a = false, b = true;
if ( a && b ) { ... };
</code></pre>
<p>In most languages, <code>b</code> will not get evaluated because <code>a</code> is false so <code>a && b</code> cannot be true. My question is, wouldn't short circuiting be slower in terms of architecture? In a pipeline, do... | <p>Short circuit evaluation is translated into branches in assembly language in the same way if statements are (branches are basically a goto), which means it is not going to be any slower than if statements.</p>
<p>Branches don't typically stall the pipeline, but the processor will guess whether the branch is taken o... | <p>Depending upon the context, it can also be called "Guarding".</p>
<p>And I've seen it in just about every language I've worked in - which pushes close to a dozen.</p>
| 11,472 |
<p>What are the advantages/disadvantages between MS VS C++ 6.0 and MSVS C++ 2008? </p>
<p>The main reason for asking such a question is that there are still many decent programmers that prefer using the older version instead of the newest version.</p>
<p>Is there any reason the might prefer the older over the new?</p... | <p>Advantages of Visual Studio 2008 over Visual C++ 6.0:</p>
<ul>
<li>Much more standards compliant C++ compiler, with better template handling</li>
<li>Support for x64 / mobile / XBOX targets </li>
<li>Improved STL implementation</li>
<li>Support for C++0x TR1 (smart pointers, regular expressions, etc)</li>
<li>Secu... | <p>Visual C++ 2008 is much more standards compliant (Visual Studio 6 doesn't support the C++ standard set in 1998).</p>
| 8,778 |
<p>As above. Usually at work someone else does the database design, and when I do personal projects they're small enough to not really require more than five or six tables, but I'm about to start a personal project that I think will probably require around eleven or twelve tables and I'd like something to help me desig... | <p><a href="http://dev.mysql.com/workbench/" rel="noreferrer">MySQL Workbench</a>, while a little buggy, has been invaluable to me since I discovered it.</p>
<p><a href="http://office.microsoft.com/en-us/visio/default.aspx" rel="noreferrer">Visio</a> has a good visual database designer, but it can't export the result ... | <p>Perhaps it is possible to take a different approach and design the domain objects for your application, and let the database be created for you.</p>
<p>This design pattern is called "data persistence" and there are several tools people use, like Hibernate (or NHibernate, being the .net alternative), or xpodatasourc... | 27,164 |
<p>I'm looking for ActiveX components that can easily: </p>
<ul>
<li>get and send emails via SMTP and POP3</li>
<li>strip out and save attachments.</li>
<li>Convert RTF (Outlook emails) to HTML</li>
<li>Sanitize HTML.</li>
</ul>
<p>What components would you recommend? What components do you use?</p>
| <p>Sendong and receiving email is simple with CDOSYS. And RTF isn't really that complex a format to handle.
But I think Chilkat SMTP/POP# ActiveX component is something you migth want to look into. </p>
| <p>seanyboy, I can help you out here, but before you look at commerical solutions, there are a couple things you need to understand. </p>
<p>First, there are hundreds, or thousands of controls out there to do what you want.</p>
<p>But, you have to consider HOW you are going to use them. I used to work for an Anti-v... | 28,877 |
<p>A longwinded question - please bear with me!</p>
<p>I want to programatically create an XML document with namespaces and schemas. Something like</p>
<pre><code><myroot
xmlns="http://www.someurl.com/ns/myroot"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.so... | <p>It's because when you call <code>foo(@_)</code>, the prototype for <code>foo()</code> forces the first parameter (which is an array) to be converted into a scalar (which is the number of elements in <code>@_</code>).</p>
<p>See answers to my previous question asking "<a href="https://stackoverflow.com/questions/297... | <p>get rid of <code>($;@)</code> after your function names and it works fine.</p>
| 43,465 |
<p>The heated bed output on my printer recently stopped working. I have an output for a second hotend. How can I reprogram this output as a heated bed output? The board is a <a href="http://www.geeetech.com/wiki/index.php/GT2560" rel="nofollow noreferrer">Geeetech GT2560 rev A+</a>.</p>
| <p><em>Although it appears to be a RAMPS compatible board as described in <a href="/a/11477">this <strong>now deleted</strong> answer</a>, <strong>it is not using a RAMPS pin configuration</strong>.</em> </p>
<hr>
<p>To fix this in the firmware, this requires an upload of newly configured firmware to the board. See e... | <p>If you want to use Extruder heater and thermistor 2 as a hotbed driver, then you will need to get an external mosfet, since I doubt that the extruder heater mosfet will be able to handle the required current. Then in your slicer, just remap the bed from BED to E2</p>
| 1,524 |
<p>I am aware of this command:
<code>cvs log -N -w<userid> -d"1 day ago"</code></p>
<p>Unfortunately this generates a formatted report with lots of newlines in it, such that the file-path, the file-version, and the comment-text are all on separate lines. Therefore it is difficult to scan it for all occurrences o... | <p>The <code>-w</code> options seems to work better with the <code>-S</code> option. Otherwise there are additional results which don't seem related to the userid. Perhaps someone can explain it.</p>
<pre><code>cvs log -N -S -w<userid> -d"1 day ago"
</code></pre>
<p>With that I have been getting reasonable su... | <p>This might be way overkill, but you could use <a href="http://www.kernel.org/pub/software/scm/git/docs/git-cvsimport.html" rel="nofollow noreferrer">git-cvsimport</a> to import the CVS history to a Git repository and search it using Git's tools. Not only can you search for text within commit messages, but you can al... | 14,405 |
<p>In the application that I am working on, the logging facility makes use of <code>sprintf</code> to format the text that gets written to file. So, something like:</p>
<pre><code>char buffer[512];
sprintf(buffer, ... );
</code></pre>
<p>This sometimes causes problems when the message that gets sent in becomes too bi... | <p>No you can't use <code>sprintf()</code> to allocate enough memory. Alternatives include:</p>
<ul>
<li>use <code>snprintf()</code> to truncate the message - does not fully resolve your problem, but prevent the buffer overflow issue</li>
<li>double (or triple or ...) the buffer - unless you're in a constrained enviro... | <p>With the vanilla version of sprintf, there is no way to prevent the data from overwriting the passed in buffer. This is true regardless of wether the memory was manually allocated or allocated on the stack. </p>
<p>In order to prevent the buffer from being overwritten you'll need to use one of the more secure ver... | 37,673 |
<p>I'm creating a <code>Path</code> in <em>Silverlight</em>, and adding elements to it on mouse events. But, although the elements are there in memory, the screen doesn't get updated until something else causes a screen repaint to happen.</p>
<p>Here's the relevant code - I'm responding to a mouse event, and I keep a ... | <p>I needed something very similar but drawing on the new Silverlight VE Map Control. Your code above worked fine without any fiddling other properties to 'force a redraw'. Code here for your reference:</p>
<pre><code>using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Microsof... | <p>What kind of element is your layout root? I copied your code and used a Canvas as the layout root and it works great in both IE and Firefox. </p>
<pre><code><UserControl x:Class="SilverlightTesting.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.... | 31,079 |
<p>I have a TreeView control in my WinForms .NET application that has multiple levels of childnodes that have childnodes with more childnodes, with no defined depth. When a user selects any parent node (not necessarily at the root level), how can I get a list of all the nodes beneith that parent node?</p>
<p>For examp... | <p>Use recursion</p>
<pre><code>Function GetChildren(parentNode as TreeNode) as List(Of String)
Dim nodes as List(Of String) = New List(Of String)
GetAllChildren(parentNode, nodes)
return nodes
End Function
Sub GetAllChildren(parentNode as TreeNode, nodes as List(Of String))
For Each childNode as TreeNode in ... | <p>in .Net WindowsForm TreeView has <code>Find()</code> method with the optional flag <code>'searchAllChildren'</code>.</p>
<p>in asp.net instead there isn't.
to have the same result i use this (similar to Keith answer, but in input i use the TreeView)</p>
<pre><code>public static IEnumerable<TreeNode> Descendant... | 21,357 |
<p>If its dead, is there a successor?</p>
<h5>For those who didn't know:</h5>
<p>The Network News Transfer Protocol or NNTP is an Internet application protocol used primarily for reading and posting Usenet articles (aka netnews), as well as transferring news among news servers.</p>
| <p>NNTP isn't dead. It just smells funny.</p>
<p>Sadly, these days if you want to follow 10 different forums then you need to have 10 different accounts and learn 10 different UIs. I like being able to pick the newsreader that I like and have the same interface for all of my newsgroups. OpenID may bring some of thi... | <p>The only true NNTP Replacement could be Mailing lists. Not any web-based forum.</p>
| 32,967 |
<p>When adding new properties to classes, I find myself typing the same things over and over in xcode:</p>
<ol>
<li><code>add TYPE *NAME;</code> (in .h interface)</li>
<li><code>add @property (nonatomic, retain) TYPE *NAME;</code> (in .h)</li>
<li><code>add @synthesize NAME;</code> (in .m)</li>
<li><code>add [NAME rel... | <p>That sounds about right. IIRC, the Objective-C 2.0 doc says you might be able to leave out step #1, but otherwise I don't know of any shortcuts.</p>
<p>You could probably write a user script to do so within Xcode. See <a href="http://www.mactech.com/articles/mactech/Vol.23/23.01/2301XCode/index.html" rel="nofollo... | <p>You could look at Andrew Pang's <a href="http://realmacforge.com/svn/trunk/RMModelObject/README.txt" rel="nofollow noreferrer">RMModelObject</a> - I haven't used it, but it acts as a object base class that simplifies model creation.</p>
<p>I haven't used it, but here's some of what's highlighted in the readme:</p>
... | 13,671 |
<p>I find myself running scripts and copy-pasting the output of these runs into emails or into some other documents. Is there a way such that I can make the copy-to-clipboard step a part of the script itself? Most of my scripts are either Perl or bat files and I work on Windows. </p>
<p>Thanks.</p>
| <p>There's a <a href="http://www.labnol.org/software/tutorials/copy-dos-command-line-output-clipboard-clip-exe/2506/" rel="noreferrer">utility called clip.exe</a> that you can use. Just pipe the output of your script or any other command into clip.exe (First, put it on your path somewhere. If you don't have a usual pla... | <p>Not sure about the clipboard but you can pipe the output to a text file but doing something like this:</p>
<pre><code>somescript.bat > output.txt
</code></pre>
| 39,601 |
<p>I'm looking for best practices for establishing connections between Oracle 8 and Visual Studio 2005 applications. The target would be a Windows Forms application written in C# that hits the database once a second to monitor tables looking for their last inserted record. I'm considering using "Application settings" t... | <p>Based on my experience with Oracle 10g....</p>
<p>I recommend using the Oracle data provider (ODP.Net) and not using the Microsoft for Oracle data provider based on my experience with Oracle 10g. Microsoft's has not been updated in years and does not support everything in Oracle 10g, so I would definitely check int... | <p>I would warn against building an architecture like you're suggesting. Opening a new connection to the database to poll for changes every second is an expensive operation. It gets worse if you're trying to scale this Windows Form application beyond a few users.</p>
<p>Instead, you should look into the built-in Oracl... | 28,583 |
<p>How do you stop the "Default SMTP Virtual Server" from sending bounce messages for email addresses that you don't have?</p>
<p>i.e. I'm using IIS' SMTP server to handle my email and if an email is sent unknown at mydomain.com a bounce email with 'address not known' (or something like that) is sent back to the sende... | <p>I found this <a href="http://isorecorder.alexfeinman.com/catchall.htm" rel="nofollow noreferrer">article</a> which has a script you can run to configure a catch-all account on your server. All emails which would generate a NDR will instead be directed to this account. Sorry, I haven't tested it. The article above... | <p>This isn't an IIS failure. The SMTP server receiving the message is looking for a valid email address, and when it doesn't find one, sends an email back to your email address saying that there isn't one there. The only way to have it silently fail is by putting the from address as a bogus email like no-reply@compan... | 8,384 |
<p>We want to include data visualization in our desktop GUI (mostly timelines and graphs; clickable, draggable). We want to restrict to open-source, non-copyleft C++ libraries that allow commercial use and are portable across many platforms. Which library can I use? Our GUI is based on WxWidgets.</p>
| <p>there is <a href="http://www.vtk.org/" rel="nofollow noreferrer">VTK</a>.</p>
<p>And if data visualization is your thing, have a look at <a href="http://www.opendx.org/highlights.php" rel="nofollow noreferrer">opendx</a> too.</p>
| <p>I think this question would be easier to answer if you also stated which other GUI components you use. Perhaps that limits the choice of available libraries. Since you're C++ and cross-platform, maybe wxWindows? Would be good not to have to guess.</p>
| 25,976 |
<p>I found the ad on this site to Krypton controls (<a href="https://github.com/ComponentFactory/Krypton" rel="nofollow noreferrer">and here's another one!</a>) and was wondering if any of you using vs.net 05 or 08 are using them and how that's working out. If you're answering, please specify which parts you're using (... | <p>I have been using the <strong>Krypton Controls ToolKit for over 3 years</strong> with <strong>Visual Studio 2005 and 2008</strong> in <strong>.NET 2.0, 3.0, 3.5, and 3.5 SP1</strong>. I have <strong>only used the free ToolKit</strong> and not the Ribbon or Tab controls. I have used it <strong>only in C</strong>#.<... | <p>I'm using it. It's quite okay.</p>
| 9,183 |
<p>In many places in our code we have collections of objects, from which we need to create a comma-separated list. The type of collection varies: it may be a DataTable from which we need a certain column, or a List<Customer>, etc.</p>
<p>Now we loop through the collection and use string concatenation, for exampl... | <pre><code>string.Join(", ", Array.ConvertAll(somelist.ToArray(), i => i.ToString()))
</code></pre>
| <p>Here's my favorite answer adapted to the question,
and corrected Convert to ConvertAll:</p>
<pre><code>string text = string.Join(", ", Array.ConvertAll(table.Rows.ToArray(), i => i["title"]));
</code></pre>
| 42,812 |
<p>How do I assign a method's output to a textbox value without code behind?</p>
<pre><code><%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Public TextFromString As String =... | <p>There's a couple of different expression types in .ASPX files. There's:</p>
<pre><code><%= TextFromMethod %>
</code></pre>
<p>which simply reserves a literal control, and outputs the text at render time.</p>
<p>and then there's:</p>
<pre><code><%# TextFromMethod %>
</code></pre>
<p>which is a databi... | <p>Have you tried using an HTML control instead of the server control? Does it also cause a compilation error?</p>
<pre><code><input type="text" id="TextBox4" runat="server" value="<%=TextFromString%>" />
</code></pre>
| 5,665 |
<p>One of the tenets of SOA is: "Services Are Autonomous".
I have 2 services. Service A depends on Service B. Service A cannot serve clients unless Service B is up and running. Do I violate the tenet here?</p>
<p>Or if autonomous must mean "decoupled", do I satisfy the tenet if I have a failsafe (say another instan... | <p>See this post on <a href="http://sendhil.spaces.live.com/blog/cns!30862CF919BD131A!449.entry" rel="noreferrer">SOA Tenets</a>. Also see <a href="http://blogs.msdn.com/richardt/archive/2005/05/20/420650.aspx" rel="noreferrer">The Fractal Constellation of Autonomous Services</a>.</p>
<p>"Services should be deployed,... | <p>Your autonomy is only <em>improved</em> by having a back up service. What if both services B and C go down? Then your service goes down. You can improve your autonomy (and your performance) even further by caching results from the external services. That way, if B and C go down, you can still service <em>some</e... | 31,740 |
<p>I have a Tapestry application that is serving its page as UTF-8. That is, server responses have header:</p>
<pre><code>Content-type: text/html;charset=UTF-8
</code></pre>
<p>Now within this application there is a single page that should be served with ISO-8859-1 encoding. That is, server response should have this ... | <p>Have you considered a Filter? Maybe not as elegant as something within Tapestry, but using a plain Filter, that registers the url mapping(s) of interest. One of its init parameters would be the encoding your after. Example:</p>
<pre><code>public class EncodingFilter implements Filter {
private String encoding;
p... | <p>The filter suggestion is good. You can also mix servlets with Tapestry. For instance, we have servlets for serving displaying XML documents and dynamically generated Excel files. Just make sure that correctly set the mappings in web.xml so that that the servlets do not go through Tapestry.</p>
| 18,530 |
<p>I just saw <a href="http://ayende.com/Blog/archive/2008/10/09/first-steps-with-post-sharp.aspx" rel="noreferrer">Ayende's post</a> today about PostSharp. I downloaded the code and tried it out, and I thought it was the coolest, most easy to use way to handle AOP that I've seen. </p>
<p>In his post, Ayende says that... | <p>Weaving refers to the process of injecting functionality into an existing program. This can be done conceptually at a number of levels:</p>
<ul>
<li>Source code weaving would inject source code lines before the code is compiled</li>
<li>IL weaving (for .NET) adds the code as IL instructions in the assembly</li>
<l... | <p>Might help if you Google MSIL Injection instead. This link is from <a href="http://www.sharpcrafters.com/aop.net/msil-injection" rel="nofollow noreferrer">PostSharp</a> and it explains it well.</p>
<p>My company has recently bought a product called dynaTrace for performance diagnosis. It uses MSIL injection to in... | 22,963 |
<p>Each of my clients can have many todo items and every todo item has a due date.</p>
<p>What would be the query for discovering the next undone todo item by due date for each file? In the event that a client has more than one todo, the one with the lowest id is the correct one.</p>
<p>Assuming the following minima... | <p>I haven't tested this yet, so you may have to tweak it:</p>
<pre><code>SELECT
TD1.client_id,
TD1.id,
TD1.description,
TD1.timestamp_due
FROM
Todos TD1
LEFT OUTER JOIN Todos TD2 ON
TD2.client_id = TD1.client_id AND
TD2.timestamp_completed IS NULL AND
(
TD2.timestamp_due < T... | <p>The following should get you close, first get the min time for each client, then lookup the client/todo information</p>
<pre><code>SELECT
C.Id,
C.Name,
T.Id
T.Description,
T.timestamp_due
FROM
{
SELECT
client_id,
MIN(timestamp_due) AS "DueDate"
FROM todos
WHERE timest... | 30,648 |
<p>I'm looking for a framework to generate Java source files.</p>
<p>Something like the following API:</p>
<pre><code>X clazz = Something.createClass("package name", "class name");
clazz.addSuperInterface("interface name");
clazz.addMethod("method name", returnType, argumentTypes, ...);
File targetDir = ...;
clazz.g... | <p>Sun provides an API called CodeModel for generating Java source files using an API. It's not the easiest thing to get information on, but it's there and it works extremely well.</p>
<p>The easiest way to get hold of it is as part of the JAXB 2 RI - the XJC schema-to-java generator uses CodeModel to generate its ja... | <p>It really depends on what you are trying to do. Code generation is a topic within itself. Without a specific use-case, I suggest looking at velocity code generation/template library. Also, if you are doing the code generation offline, I would suggest using something like ArgoUML to go from UML diagram/Object mode... | 14,759 |
<p>I am trying to uncompress some data created in VB6 using the zlib API.</p>
<p>I have read this is possible with the qUncompress function:
<a href="http://doc.trolltech.com/4.4/qbytearray.html#qUncompress" rel="nofollow noreferrer">http://doc.trolltech.com/4.4/qbytearray.html#qUncompress</a></p>
<p>I have read the ... | <p>I haven't used VB6 in <em>ages</em>, so I hope this is approximately correct. I <em>think</em> that vb6 used () for array indexing. If I got anything wrong, please let me know.</p>
<p>Looking at the qUncompress docs, you should have put your data in your QByteArray starting at byte 5 (I'm going to assume that you... | <p>It looks like you want a C chunk of code that uncompresses some zlib compressed data.
In that case is it possible for you to actually use zlib and just feed the zlib data to it. The zlib homepage: <a href="http://www.zlib.net/" rel="nofollow noreferrer">http://www.zlib.net/</a>.</p>
<p>If I got it wrong, could you ... | 21,408 |
<p>I've got a large amount of data (a couple gigs) I need to write to a zip file in Python. I can't load it all into memory at once to pass to the .writestr method of ZipFile, and I really don't want to feed it all out to disk using temporary files and then read it back.</p>
<p>Is there a way to feed a generator or a... | <p>The only solution is to rewrite the method it uses for zipping files to read from a buffer. It would be trivial to add this to the standard libraries; I'm kind of amazed it hasn't been done yet. I gather there's a lot of agreement the entire interface needs to be overhauled, and that seems to be blocking any incre... | <p>The gzip library will take a file-like object for compression.</p>
<pre><code>class GzipFile([filename [,mode [,compresslevel [,fileobj]]]])
</code></pre>
<p>You still need to provide a nominal filename for inclusion in the zip file, but you can pass your data-source to the fileobj.</p>
<p><em>(This answer differ... | 38,041 |
<p>I have this in my installer and I need to change the name of the ini file.</p>
<pre><code>[INI]
Filename: {app}\bin\old.ini; Section: Data; Key: key; String: Value;
</code></pre>
<p>If I just change the filename it will create another ini file and I'll lose the data.</p>
<p>Is there some easy way to rename this i... | <p>I think you should use RenameFile() in [CODE] section instead, since you know where the ini file is.</p>
| <p>I think you should use RenameFile() in [CODE] section instead, since you know where the ini file is.</p>
| 40,941 |
<p>Javascript</p>
<p>I have code that will hide various sections in a MS CRM form based on the value of a Picklist. The code executes in the onChange event of the Picklist. It hides the section by referencing a field in the section and then navigating up the DOM using the ParentElement syntax, as such:</p>
<p>crmFo... | <p>Take a look at the following post. it uses section position instead of parentElement.
<a href="http://mscrm4ever.blogspot.com/2008/08/show-hide-crm-form-section.html" rel="nofollow noreferrer">http://mscrm4ever.blogspot.com/2008/08/show-hide-crm-form-section.html</a></p>
| <p>Sorry, buy can you clean up the question? You say it works with 1 exception when the section has a read-only field.
Is that the field you are trying to work with in your example? Or can you work with any field in the section, but if there is one read only in the section it fails?
What is the exception (doesn't work,... | 44,604 |
<p>I am writing a C library that reads a file into memory. It skips the first 54 bytes of the file (header) and then reads the remainder as data. I use fseek to determine the length of the file, and then use fread to read in the file.</p>
<p>The loop runs once and then ends because the EOF is reached (no errors). At t... | <p>perhaps it's a binary mode issue. Try opening the file with <code>"r+b"</code> as the mode.</p>
<p><strong>EDIT</strong>: as noted in a comment <code>"rb"</code> is likely a better match to your original intent since <code>"r+b"</code> will open it for read/write and <code>"rb"</code> is read-only.</p>
| <p>A solution, based on the previous answers:</p>
<pre><code> size_t bytesRead = 0;
BYTE* localBuffer = new BYTE[bytesTotal];
fseek(stream,headerLen,SEEK_SET);
while(!feof(stream) && !ferror(stream)) {
size_t result = fread(localBuffer+bytesRead,sizeof(BYTE),bytesTotal-
bytes... | 19,824 |
<p>EDIT: I've tagged this C in a hope to get more response. It's more the theory I'm interested in than a specific language implementation. So if you're a C coder please treat the following PHP as pseudo-code and feel free to respond with an answer written in C.</p>
<p>I am trying to speed up a PHP CLI script by hav... | <p>There is no syscall to get a list of child pids, but <code>ps</code> can do it for you.</p>
<p><code>--ppid</code> switch will list all children for you process so you just need to count number of lines outputted by <code>ps</code>.</p>
<p>Alternatively you can maintain your own counter that you will increment on ... | <p>man 2 setrlimit</p>
<p>That's going to be per-user which <em>may</em> be what you want anyway.</p>
| 43,619 |
<p>I ported a Delphi 6 application to Delphi 2007 and it uses BDE to connect to
an Oracle 9i database. I am getting an</p>
<blockquote>
<p>ORA-01426: numeric overflow exception</p>
</blockquote>
<p>When I execute a stored procedure. This happens randomly and if I
re-run the stored procedure through the application ... | <p>Showing a code example could make this easier, but here are a couple of hunches: </p>
<ol>
<li><p>Are the data coming from another source (like Excel) that does not have explicit data types? Mixed or ambiguous data may be causing BDE to assign the wrong data type to a field that then is incompatible with the datab... | <p>Does the D6 version of the app use the same version of BDE, Oracle, and the database? If so, then it's probably something about the data being passed (either content or mechanism). </p>
<p>Not knowing what those data are, nor how they are passed, makes it pretty hard to diagnose.</p>
| 45,738 |
<p>I need to create some windows service which will execute every N period of time.<br>
The question is:<br>
Which timer control should I use: <code>System.Timers.Timer</code> or <code>System.Threading.Timer</code> one? Does it influence on something? </p>
<p>I am asking because I heard many evidences to non correct ... | <p>Both <a href="http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx" rel="noreferrer"><code>System.Timers.Timer</code></a> and <a href="http://msdn.microsoft.com/en-us/library/system.threading.timer.aspx" rel="noreferrer"><code>System.Threading.Timer</code></a> will work for services.</p>
<p>The timers y... | <p>I know this thread is a little old but it came in handy for a specific scenario I had and I thought it worth while to note that there is another reason why <code>System.Threading.Timer</code> might be a good approach.
When you have to periodically execute a Job that might take a long time and you want to ensure tha... | 30,623 |
<p>What is the difference between</p>
<pre><code>char str1[32] = "\0";
</code></pre>
<p>and </p>
<pre><code>char str2[32] = "";
</code></pre>
| <p>Since you already declared the sizes, the two declarations are exactly equal. However, if you do not specify the sizes, you can see that the first declaration makes a larger string:</p>
<pre><code>char a[] = "a\0";
char b[] = "a";
printf("%i %i\n", sizeof(a), sizeof(b));
</code></pre>
<p>prints</p>
<pre><code>3 ... | <p>Unless I'm mistaken, the first will initialize 2 chars to 0 (the '\0' and the terminator that's always there, and leave the rest untouched, and the last will initialize only 1 char (the terminator).</p>
| 7,221 |
<p>I'm creating a C# dll, which is going to be used by others developers in WinForms. For some reasons, I want to detect, if methods from this library, are called from Main (GUI) Thread and warn developer he has done such a thing (ie. in log file). Is there any reasonable way to detect calling method from main thread?
... | <p>An easy solution in this case is to declare a static control in the library assembly that is created on the Main UI thread. If you want to detect if the library is called from the main thread, then use the following</p>
<pre><code>if (MyLibraryControl.InvokeRequired)
//do your thing here
</code></pre>
| <p>The simplest option (if you have a form/control handy) is to check InvokeRequired.</p>
<p>In the absence if that, you could try using <code>SynchronizationContext</code> to simulate a Post or Send, checking what thread that happens on? Calling Send or Post will switch to the UI thread.</p>
| 27,877 |
<p>Assuming we always use a Sun JVM (say, 1.5+), is it always safe to cast a Graphics reference to Graphics2D? </p>
<p>I haven't seen it cause any problems yet and, to my understanding, the Graphics class is legacy code but the Java designers didn't want to change the interfaces for Swing and AWT classes in order to ... | <p>According to the discussion <a href="https://community.oracle.com/thread/1350311?db=5" rel="nofollow noreferrer">here</a>, it <strong>is always safe to cast from <code>Graphics</code> to <code>Graphics2D</code></strong>. However I am not able to quickly find the official Sun statement on this.</p>
<blockquote>
<p... | <p>The <a href="http://java.sun.com/docs/books/tutorial/2d/overview/rendering.html" rel="noreferrer">2D Graphics Trail</a> says:</p>
<blockquote>
<p>To employ Java 2D API features in the application, cast the Graphics object passed into a component’s rendering method to a Graphics2D object. For example:</p>
</blockq... | 21,632 |
<p>I have a page (page1.html) which references a css file (style1.css)</p>
<p>All is good.</p>
<p>I need Page1.html to additionally reference Style2.css
However when I add the reference, some stuff on Page1.html screws up.</p>
<p>How can I determine what it is about Style2.css that is causing this problem?
Some diff... | <p><a href="http://getfirebug.com/" rel="nofollow noreferrer">Firebug</a> shows you which rules are being overridden, and from which stylesheet the rules come from. </p>
<p>Just select the problem elements and it will show you the rules applied to it. You can then toggle them on/off the see the effect.</p>
| <p>All good answers.... I am loathed to pick a correct one this time.</p>
<p>Just to add to the mix... A colleague recommended the Web Developer Toolbar for FF. </p>
<p>I used CSS\View Style Info and then clicked the stuff that was strange... I quickly found a rule from the new stylesheet which was radically altering... | 27,898 |
<p>I have a GridView that allows editing the values in every column, in every row, all the time. The user enters in all their changes, clicks Save once and all changes are commited.</p>
<p>The user must also be able to click the New button, have a new row appear in the GridView (yep, it has to show up in the actual G... | <p>Just off my head I can think of two options. The first is to cache the original results that you are binding into the grid and when you need to add another row you add a datarow to the datatabale that you are binding to and then bind this to the grid. If there are changes in the grid then you need to update the da... | <p>You could dynamically add the new row via javascript, and on the save command look for newly added rows. That is fairly common.</p>
| 34,425 |
<p>A simple application is written in CF 2.0. It's single-threaded as far as I'm concerned.</p>
<p>Two parts of the application are of interest: an event handler that handles "Barcode scanned" event raised by a class that represents PDA's barcode scanner (provided by manufacturer), and an event handler for Windows.For... | <p>The Windows.Forms timer is going to happen on the UI thread via a call to PostMessage. That is a guarantee. How the "barcode scanned" even comes in is completely up to the developer of the library that's giving you the event. You should certainly <strong>not</strong> assume that it's going to run in the same cont... | <p>Pretty much every barcode scanning component i've worked with runs off a background thread, so i'd look at that more closely.</p>
| 48,769 |
<p>Four 2D points in an array. I need to sort them in clockwise order. I think it can be done with just one swap operation but I have not been able to put this down formally.</p>
<p><strike>Edit: The four points are a convex polygon in my case.</strike></p>
<p>Edit: The four points are the vertices of a convex polygo... | <p>If you want to take a more mathematical perspective, we can consider the permutations of 4 points</p>
<p>In our case there are 4 permutations that are in clockwise order</p>
<pre><code>A B C D
B C D A
C D A B
D A B C
</code></pre>
<p>All other possible permutations can be converted to one of these forms with 0 or... | <p>Wedge’s Answer is correct.</p>
<p>To implement it easily, I think the same way as smacl: you need to find the boundary’s center and translate your points to that center.</p>
<p>Like this:</p>
<pre><code>centerPonintX = Min(x) + ( (Max(x) – Min(x)) / 2 )
centerPonintY = Min(y) + ( (Max(y) – Min(y)) / 2 )
</cod... | 30,005 |
<p>I have in Word ‘hello’ and when I paste it I get 018hello 019 so the apostrophes turn into these strange characters.</p>
<p>The type of web application should not matter as the behaviour is different depending on the workstation I use.</p>
<p>I checked with Notepad, Excel and Wordpad and this issue does not occur,... | <p>The quotation marks in word are not the "regular" quotation marks. Word automatically replaces quotations as you type them with fancy ones called "smart quotes". Since your browser does not understand smart quotes it replaces them.</p>
| <p>This is known as the Word "smart quotes" feature. There should be a place to turn it off somewhere in the Word settings.</p>
<p>More information can be found at the <a href="http://en.wikipedia.org/wiki/Quotation_mark_glyphs" rel="nofollow noreferrer">Quotation mark glyphs</a> Wikipedia article.</p>
| 31,864 |
<p>Although I'm specifically interested in web application information, I would also be somewhat curious about desktop application development as well. This question is driven by my work on my personal website as well as my job, where I have developed a few features, but left it to others to integrate into the look and... | <p>Usually, each operating System has user Interface Guidelines. For Windows, have a <a href="http://blogs.msdn.com/acoat/archive/2006/09/27/773148.aspx" rel="nofollow noreferrer">look here</a>. (Edit: The links in that post are broken. But a Search for "<a href="http://search.msdn.microsoft.com/Default.aspx?query... | <p>As for desktop applications: Whatever you do, do not use hand-picked colors. Stick with the named system colors such as "Window Background", "Menu Text", etc. Otherwise, people relying on OS accessibility features will be locked with your color choices (unable to choose a high-contrast theme, for instance) and to pe... | 2,721 |
<p>I ran across this and was wondering if someone could explain why this works in VB.NET when I would expect it should fail, just like it does in C#</p>
<pre><code>//The C# Version
struct Person {
public string name;
}
...
Person someone = null; //Nope! Can't do that!!
Person? someoneElse = null; //No problem, ju... | <p>If I remember correctly, 'Nothing' in VB means "the default value". For a value type, that's the default value, for a reference type, that would be null. Thus, assigning nothing to a struct, is no problem at all.</p>
| <p>Because a Structure is made up of possibly several different Types (not a single value Type, but a possible composite of several different types), to ask if it is "Nothing" would break the logic of the use of "Nothing". Nothing tests differently depending on the type that you're testing and therefore a complex type... | 38,993 |
<p>We used the "undocumented" xp_fileexist stored procedure for years in SQL Server 2000 and had no trouble with it. In 2005, it seems that they modified the behavior slightly to always return a 0 if the executing user account is not a sysadmin. It also seems to return a zero if the SQL Server service is running under ... | <p>Maybe a CLR stored procedure is what you are looking for. These are generally used when you need to interact with the system in some way.</p>
| <p>I still believe that a CLR procedure might be the best bet. So, I'm accepting that answer. However, either I'm not that bright or it's extremely difficult to implement. Our SQL Server service is running under a local account because, according to Mircosoft, that's the only way to get an iSeries linked server working... | 3,735 |
<p>What is the best choice for a Python GUI application to display large number of thumbnails, e.g. 10000 or more? For performance reasons such thumbnail control must support virtual items, i.e. request application for those thumbnails only which are currently visible to user. </p>
| <p>In <a href="http://wxpython.org/" rel="nofollow noreferrer">wxPython</a> you can use <a href="http://docs.wxwidgets.org/stable/wx_wxgrid.html#wxgrid" rel="nofollow noreferrer">wxGrid</a> for this as it supports virtual mode and custom cell renderers.</p>
<p><a href="http://docs.wxwidgets.org/stable/wx_wxgridtableba... | <p>If you had to resort to writing your own, I've had good results using the Python Imaging Library to create thumbnails in the past.
<a href="http://www.pythonware.com/products/pil/" rel="nofollow noreferrer">http://www.pythonware.com/products/pil/</a></p>
| 26,430 |
<p>My Printrbot simple metal's extruder is jammed and I need to heat it up to unjam it. Unfortunately, the printer does't want to connect to my laptop regardless of the program I'm using (Repetier-Host or Cura 15). </p>
<p>Is there a way to use a micro SD card to heat up the printer hotend but not print anything?</p>
| <p>Sure there is. As you use Cura, you can grab any G-code file (you already have) and use it to set hotend temperature (delete the actual printing part from the file) to get something like this:</p>
<pre><code>;FLAVOR:Marlin
;TIME:102
;Filament used: 0.0573674m
;Layer height: 0.2
;Generated with Cura_SteamEngine 3.3.... | <p>I heated it up and was able to extract some plastic that had gotten jammed in the hot ends opening. </p>
<p>I heated up the hotend by commenting out all the other lines of code in Cura's start and end G-code tabs (must have missed some because the printer moved. I would just unplug the printer when it stopped movin... | 893 |
<p>I am wondering if there are any alternatives to using the Expand key word when performing an LINQ to ADO.net Data Services query. The expand method does get me the data I am interested in, but it requires me to know all of the sub-objects that I am going to be working with in advance. My absolute preference would ... | <p>Loading sub-objects via ADO.net Data Services seem to have two choices:</p>
<h2>Eager Loading</h2>
<p>Accomplished by .Expand("[MemberVariableName]") on the LINQ to Data Services example</p>
<pre><code>var me = (from m in ctx.Member.Expand("MailingAddress")
where m.MemberID == 10000
... | <p>With LINQ to Entities you can also use the <a href="http://msdn.microsoft.com/en-us/library/bb896272.aspx" rel="nofollow noreferrer">Include method</a>. You can apply this to me after it's declared but before it's executed, e.g.:</p>
<pre><code>me = me.Include("MailingAddress");
</code></pre>
| 21,387 |
<p>I need to reformat a text file into a PDF. Using Perl, I am modifying an existing PostScript template file based on what is in the text file. Sometimes this text file will be long enough to require a two page PDF.</p>
<p>Can I create a two page PDF file from one .ps file using GhostScript? If so, what tells GhostSc... | <p>PostScript doesn't directly have the concept of text flows or page breaks. The <a href="http://www.tailrecursive.org/postscript/operators.html" rel="nofollow noreferrer">showpage</a> operator renders the page to the device, clears the page and starts a new one. PS to PDF conversion will create a new page in the PD... | <p>I would guess it depends on what's in your PostScript template. A PostScript file is a computer program, and page breaks are determined by the logic in the PostScript. If the two-page format is substantially the same as the one-page format, you could have your Perl script split the data up, then create two single-pa... | 39,996 |
<p>I use <em>lazy connection</em> to connect to my DB within my DB object. This basically means that it doesn't call mysql_connect() until the first query is handed to it, and it subsequently skips reconnecting from then on after.</p>
<p>Now I have a method in my DB class called <code>disconnectFromDB()</code> which p... | <p>As far as I know, unless you are using persistent connections, your MySQL connection will be closed at the end of the page execution.</p>
<p>Therefore, you calling disconnect will add nothing and because you do the lazy connection, may cause a second connection to be created if you or another developer makes a mist... | <p>The basic unit of execution presumably is an entire script. What you first of all are wanting to apply resources (i.e. the database) to, efficiently and effectively, is the entirety of a single script.</p>
<p>However, PHP, Apache/IIS/whatever, have lives of their own; and they are capable of using the connections y... | 43,606 |
<p>I am using SourceForge for some Open Source projects and I want to automate the deployment of releases to the SourceForge File Release System. I use Maven for my builds and the standard SFTP deployment mechanism doesn't seem to work unless you do some manual preparation work. I have come across some old postings on ... | <p>I'm not able to test this to confirm, but I believe it is possible without writing any plugins.</p>
<p>You can <a href="http://sourceforge.net/apps/trac/sourceforge/wiki/SCP" rel="noreferrer">deploy to SourceForge using SCP</a>, and the maven-deploy-plugin can be configured to <a href="http://maven.apache.org/plugi... | <p>The Maven SourceForge plug-in does not work with Maven 2. Also I believe this plug-in uses FTP which is no longer supported.</p>
| 3,722 |
<p>What does the expression "Turing Complete" mean? </p>
<p>Can you give a simple explanation, without going into too many theoretical details?</p>
| <p>Here's the briefest explanation:</p>
<p>A Turing Complete system means a system in which a program can be written that will find an answer (although with no guarantees regarding runtime or memory).</p>
<p>So, if somebody says "my new thing is Turing Complete" that means in principle (although often not in ... | <p>As <a href="https://stackoverflow.com/questions/7284/what-is-turing-complete/878771#878771">Waylon Flinn said</a>:</p>
<blockquote>
<p>Turing Complete means that it is at least as powerful as a Turing Machine.</p>
</blockquote>
<p>I believe this is incorrect, a system is Turing complete if it's exactly as powerf... | 2,893 |
<p>I have a java webapp that has to be deployed on either Win or Linux machines. I now want to add log4j for logging and I'd like to use a relative path for the log file as I don't want to change the file path on every deployment. The container will most likely be Tomcat but not necessarily.</p>
<p>What's the best way... | <p>Tomcat sets a catalina.home system property. You can use this in your log4j properties file. Something like this:</p>
<pre><code>log4j.rootCategory=DEBUG,errorfile
log4j.appender.errorfile.File=${catalina.home}/logs/LogFilename.log
</code></pre>
<p>On Debian (including Ubuntu), <code>${catalina.home}</code> wil... | <p>My suggestion is the log file should always be logged above the root context of the webApp, so in case we redeploy the webApp, we don't want to override the existing log files.</p>
| 26,648 |
<p>I did see the question about setting the proxy for the JVM but what I want to ask is how one can utilize the proxy that is already configured (on Windows).</p>
<p>Here is a demonstration of my issue: </p>
<blockquote>
<blockquote>
<ol>
<li>Go to your Control Panel->Java and set a proxy address. </li>
... | <p>It is possible to detect the proxy using the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/ProxySelector.html" rel="noreferrer">ProxySelector</a> class and assign the system proxy by assigning environment variables with the <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#setPropert... | <p><strong>UPDATE:</strong> you need to have the System Property <strong>java.net.useSystemProxies</strong> set to <strong>true</strong> for my solution below to work.</p>
<p>If you use <code>java.net.URL.openStream()</code> to get an <code>InputStream</code> for the web resource content you automatically get the same... | 49,219 |
<p>How does a stack overflow occur and what are the best ways to make sure it doesn't happen, or ways to prevent one, particularly on web servers, but other examples would be interesting as well?</p>
| <h2>Stack</h2>
<p>A stack, in this context, is the last in, first out buffer you place data while your program runs. Last in, first out (LIFO) means that the last thing you put in is always the first thing you get back out - if you push 2 items on the stack, 'A' and then 'B', then the first thing you pop off the stac... | <p>Considering this was tagged with "hacking", I suspect the "stack overflow" he's referring to is a call stack overflow, rather than a higher level stack overflow such as those referenced in most other answers here. It doesn't really apply to any managed or interpreted environments such as .NET, Java, Python, Perl, PH... | 4,577 |
<p>How do I get the reference to a folder for storing per-user-per-application settings when writing an Objective-C Cocoa app in Xcode?</p>
<p>In .NET I would use the <code>Environment.SpecialFolder</code> enumeration:</p>
<pre><code>Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
</code></pre>
... | <p>In Mac OSX application preferences are stored automatically through NSUserDefaults, which saves them to a .plist file <code>~/Library/Preferences/</code>. You shouldn't need to do anything with this file, NSUserDefaults will handle everything for you.</p>
<p>If you have a data file in a non-document based applicati... | <p>For most stuff, you should just use the NSUserDefaults API which takes care of persisting settings on disk for you.</p>
| 46,907 |
<p>Is it OK (or even recommended/good practice) to <code>#include</code> a <code>.c</code> file in another <code>.c</code> file?</p>
| <p>Used properly, this can be a useful technique.</p>
<p>Say you have a complex, performance critical subsystem with a fairly small public interface and a lot of non-reusable implementation code. The code runs to several thousand lines, a hundred or so private functions and quite a bit of private data. If you work wit... | <p>you should add header like this</p>
<pre><code>#include <another.c>
</code></pre>
<p>note : both file should placed in same place</p>
<p>i use this in codevison AVR for ATMEGA micro controllers and work truly but its not work in normal C language file</p>
| 28,800 |
<p>Which programming language(s) were used to code Windows Vista?</p>
| <p>Well, the Windows kernel is still almost entirely C. However, there are different aspects that use C++, say some parts of the shell and so forth. The core is C. Other languages, perhaps even .NET might be used in some corners for certain applications but C is the OS language of choice in Windows.</p>
| <p>Vista operating system arrived in numerous variants for use in places like England and Kandohar as stated in the rules for the use of Vista and its definition. Some were coded in something like RCODE for home computing and others may have been coded in COMAL, VBAS or ICODE for computers based on a Commodore (CBM) 63... | 49,927 |
<p>I am planning to create a web app that allows users to downgrade their visual studio project files. However, It seems Google App Engine accepts files uploading and flat file storing on the Google Server through <code>db.TextProperty</code> and <code>db.BlobProperty</code>.</p>
<p>I'll be glad anyone can provide cod... | <p>Here is a complete, working file. I pulled the original from the Google site and modified it to make it slightly more real world.</p>
<p>A few things to notice:</p>
<ol>
<li>This code uses the <a href="http://code.google.com/appengine/docs/python/blobstore/" rel="noreferrer">BlobStore API</a></li>
<li><p>The purp... | <p>There's no flat file storing in Google App Engine. Everything has to go in to the <a href="http://code.google.com/appengine/docs/datastore/" rel="nofollow noreferrer">Datastore</a> which is a bit like a relational database but not quite.</p>
<p>You could store the files as <a href="http://code.google.com/appengine... | 10,712 |
<p>If I define a struct in C# using automatic properties like this:</p>
<pre><code>public struct Address
{
public Address(string line1, string line2, string city, string state, string zip)
{
Line1 = line1;
Line2 = line2;
City = city;
State = state;
Zip = zip;
}
... | <p><strong>Note: as of C# 6, this isn't required - but you should be using read-only automatically-implemented properties with C# 6 anyway...</strong></p>
<p><code>this()</code> makes sure that the fields are definitely assigned as far as the compiler is concerned - it sets all fields to their default values. You have... | <p>A property is nothing more than an encapsulation of a <code>Get</code> method and/or a <code>Set</code> method. The CLR has metadata which indicates that particular methods should be regarded as being a properties, meaning compilers should allow some constructs which it would not allow with methods. For example, i... | 34,250 |
<p>Basically I am trying to restart a service from a php web page.</p>
<p>Here is the code:</p>
<pre><code><?php
exec ('/usr/bin/sudo /etc/init.d/portmap restart');
?>
</code></pre>
<p>But, in <code>/var/log/httpd/error_log</code>, I get </p>
<blockquote>
<p>unable to change to sudoers gid: Operation not pe... | <p>The problem is not with sudo at the moment, but with <a href="http://en.wikipedia.org/wiki/Selinux" rel="noreferrer">SELinux</a>, which is (reasonably) set to deny the HTTPD from gaining root privileges.<br>
You will need to either explicitly allow this (you can use <a href="http://fedoraproject.org/wiki/SELinux/aud... | <p>This is probably down to something like trying to execute sudo in a non-interactive shell.</p>
<p>If you do a grep for 'sudo' in your apache users mail log you might find things like this </p>
<blockquote>
<p>sudo: sorry, you must have a tty to run sudo</p>
</blockquote>
| 13,885 |
<p>How do I check if a string represents a numeric value in Python?</p>
<pre><code>def is_number(s):
try:
float(s)
return True
except ValueError:
return False
</code></pre>
<p>The above works, but it seems clunky.</p>
<hr />
<p><sub>If what you are testing comes from user input, it is <e... | <p>For non-negative (unsigned) integers only, use <a href="https://docs.python.org/3/library/stdtypes.html#str.isdigit" rel="noreferrer" title="str.isdigit"><code>isdigit()</code></a>:</p>
<pre><code>>>> a = "03523"
>>> a.isdigit()
True
>>> b = "963spam"
>>> b.isd... | <p>use following it handles all cases:-</p>
<pre><code>import re
a=re.match('((\d+[\.]\d*$)|(\.)\d+$)' , '2.3')
a=re.match('((\d+[\.]\d*$)|(\.)\d+$)' , '2.')
a=re.match('((\d+[\.]\d*$)|(\.)\d+$)' , '.3')
a=re.match('((\d+[\.]\d*$)|(\.)\d+$)' , '2.3sd')
a=re.match('((\d+[\.]\d*$)|(\.)\d+$)' , '2.3')
</code></pre>... | 46,115 |
<p>I'm designing my website and was curious, before I go rip someone else's ideas, what were the salient considerations and questions one should ask in designing a database?</p>
| <p>I think the most important question is, "Why are you doing it (the CMS, not the web site)?" This is very well-trod ground. Unless you have some really innovative ideas and unique insights into how you want it to be done ... and your question suggests that you probably don't ... you would probably be better-served ... | <p>This is just off the top of my head:</p>
<ul>
<li>Content organization should be one of your primary concerns. How are you going to organize all the disparate pieces of content? </li>
<li>Security, and what levels? do you need to only secure the ability to edit any content? certain pieces of content? How about ... | 13,494 |
<p>Many times I have seen Visual Studio solutions which have multiple projects that share source files. These common source files are usually out in a common directory and in the solution explorer their icon shows up with a link arrow in the bottom left.</p>
<p>However, any time I try to add a source file to the proj... | <p>Right click on a project, select <strong>Add->Existing Item->Add as link</strong> (press on small arrow on Add button)</p>
| <p>Thanks @aku!</p>
<p>I knew this could be done, but I didn't know how to do this from Visual Studio. It shows up as a shortcut to the file and the csproj file generates the resulting XML like this:</p>
<pre><code><Compile Include="..\CommonAssemblyInfo.cs">
<Link>CommonAssemblyInfo.cs</Link>
<... | 6,763 |
<p>I have a PHP-generated page which is displaying some data about a set of films. The page is updated using POST. The form only shows films starting with a particular letter. I want to present a set of clickable options at the top of the screen, each of which is a letter. So if you click on "B" it submits the form and... | <p>You can always create a number of submit buttons and give each a different name. Then you test to see which submit was pressed based on what is included in the POST array.</p>
<p>Please note that you can use the <a href="http://www.w3schools.com/TAGS/att_input_type.asp" rel="nofollow noreferrer">image input type</a... | <p>You don't actually need to submit the form as you are not really using it.</p>
<p>Why not just a set of hyperlinks B</p>
| 38,802 |
<p>Are there any sites out there that have been built with asp.net and facebook api? I am looking for some ideas and inspiration for doing some social networking web programming. I did find some asp.net/facebook blog entries but still could not find any site that has successfuly done some work in this area. </p>
| <p>Isn't the framework you create your ideas in pretty much irrelevant? It shouldn't make much difference if a site is made in ASP.Net, or Ruby on Rails, or PHP, or <em>etc etc etc</em>.</p>
<p>Why not look for <em>any</em> successful site using the Facebook API (regardless of implementation)? Or do you want ideas on ... | <p>I found this through google:</p>
<p><a href="http://weblogs.asp.net/mikebosch/archive/2008/08/05/giftlistr-asp-net-mvc-facebook-application.aspx" rel="nofollow noreferrer">Gift List</a></p>
<p>Here are some links that mention a facebook .net wrapper:</p>
<p><a href="http://community.irritatedvowel.com/blogs/pete_... | 34,952 |
<p>I've had nothing but good luck from SO, so why not try again?</p>
<p>I have an application that needs to show a different image based on the season of the year (spring, summer, winter, fall). I have very specific start and end dates for these seasons.</p>
<p>What I would like from you geniuses is a method called... | <p>Seems like just checking the month would do:</p>
<pre><code>private static final String seasons[] = {
"Winter", "Winter", "Spring", "Spring", "Summer", "Summer",
"Summer", "Summer", "Fall", "Fall", "Winter", "Winter"
};
public String getSeason( Date date ) {
return seasons[ date.getMonth() ];
}
// As state... | <p>since in this range all seasons are full months, you can do a switch with the month from your date:</p>
<pre><code>switch (date.getMonth()) {
case Calendar.JANUARY:
case Calendar.FEBRUARY:
return "winter";
case Calendar.MARCH:
return "spring";
//etc
}
</code></pre>
<p>I recommend ... | 22,980 |
<p>This is as much a code maintenance issue as a code issue, but I have a WebForm that no longer checks it CustomValidator. It worked when I last touched the code over a year ago, but it no longer works now that the user has requested some changes ...</p>
<p>The WebForm contains a data-bound drop down with a default "... | <p>I notice a couple of issues</p>
<ul>
<li>I don't think you need a CausesValidation=true if AutoPostBack is set to false</li>
<li>You do not use validation groups, so that cannot be the cause</li>
<li>Why not use a RequiredFieldValidator?</li>
<li>If you want to fire validation on empty fields, set the ValidateEmpty... | <p>Some troubleshooting steps:</p>
<ul>
<li>Is this the only validator on the form? </li>
<li>Is validation enabled on the page? </li>
<li>Is validation enabled for the targeted control? </li>
<li>Is the validator itself enabled?</li>
</ul>
| 35,686 |
<p>Will limiting a query to one result record, improve performance in a large(ish) MySQL table if the table only has one matching result?</p>
<p>for example</p>
<pre><code> select * from people where name = "Re0sless" limit 1
</code></pre>
<p>if there is only one record with that name? and what about if <code>name</... | <p>If the column has </p>
<p><strong>a unique index: no,</strong> it's no faster</p>
<p><strong>a non-unique index: maybe,</strong> because it will prevent sending any additional rows beyond the first matched, if any exist</p>
<p><strong>no index: sometimes</strong></p>
<ul>
<li>if 1 or more rows match the query, <... | <p>I believe the LIMIT is something done after the data set is found and the result set is being built up so I wouldn't expect it to make any difference at all. Making name the primary key will have a significant positive effect though as it will result in an index being made for the column.</p>
| 5,472 |
<p>I've just learned ( yesterday ) to use "exists" instead of "in".</p>
<pre><code> BAD
select * from table where nameid in (
select nameid from othertable where otherdesc = 'SomeDesc' )
GOOD
select * from table t where exists (
select nameid from othertable o where t.nameid = o.nameid ... | <p>It's specific to each DBMS and depends on the query optimizer. Some optimizers detect IN clause and translate it. </p>
<p>In all DBMSes I tested, alias is only valid inside the ( )</p>
<p>BTW, you can rewrite the query as:</p>
<pre><code>select t.*
from table t
join othertable o on t.nameid = o.nameid
and ... | <p>Personally I would use a join, rather than a subquery for this.</p>
<pre><code>SELECT t.*
FROM yourTable t
INNER JOIN otherTable ot
ON (t.nameid = ot.nameid AND ot.otherdesc = 'SomeDesc')
</code></pre>
| 22,896 |
<p>I want to access Microsoft SQL Server Compact Edition databases from Java. How can I do that? I searched for JDBC driver for SQLCE, but I didn't find any.</p>
| <p>According to <a href="http://groups.google.com/group/microsoft.public.sqlserver.jdbcdriver/browse_thread/thread/2ba56d70e6b35ee7" rel="noreferrer">a newsgroup post sent this Tuesday (2008-12-09) by Jimmy Wu@Mircrosoft</a>:</p>
<blockquote>
<p>The Microsoft SQL Server JDBC Driver
does not support connecting to S... | <p>Good tutorial <a href="http://www.herongyang.com/jdbc/sqljdbc-jar-Microsoft-JDBC-Driver.html" rel="nofollow noreferrer">sqljdbc-tut</a></p>
<p>Latest driver (in tech preview) is <a href="http://www.microsoft.com/downloads/details.aspx?familyid=F914793A-6FB4-475F-9537-B8FCB776BEFD&displaylang=en" rel="nofollow n... | 46,725 |
<p>I have a java class:</p>
<blockquote>
<p>it.eng.ancona.view.RuoliView$TabElaborazioneFattureValidazione$ElencoDettaglioElaborazioneFattureValidazione$RigaElencoDettaglioElaborazioneFattureValidazione</p>
</blockquote>
<p>It's so long for multiple inner class.</p>
<p>If I use 1.4.2_07-b05 on Eclipse and I call t... | <p>This could be caused by the maximum path length of Windows. Try moving your Tomcat server to something like C:\TC to see if you still have a problem. Also check if the jar that this class should be in, actually does have it.</p>
| <p>isn't this more a Classpath problem? </p>
<p>Within Eclipse it is fairly easy to get a correct classpath, since it manages its own build directory.</p>
<p>Is the class in your WAR (or autodeploy-folder, or whatever you use to deploy to Tomcat)?</p>
| 17,894 |
<p>I am building an ASP.NET web site where the users may upload photos of themselves. There could be thousands of photos uploaded every day. One thing my boss has asked a few time is if there is any way we could detect if any of the photos are showing too much 'skin' and automatically move flag these as 'Adults Only' b... | <p>Your best bet is to deal with the image in the HSV colour space (see <a href="http://www.cs.rit.edu/~ncs/color/t_convert.html" rel="noreferrer">here</a> for rgb - hsv conversion). The colour of skin is pretty much the same between all races, its just the saturation that changes. By dealing with the image in HSV you ... | <p>I'm afraid I can't help point you in the right direction, but I do remember reading about this being done before. It was in the context of people complaining about baby pictures being caught and flagged mistakenly. If nothing else, I can give you the hope that you don't have to invent the wheel all by yourself... ... | 32,974 |
<p>In our project we have to map one nested structures of beans onto another. (These are actually JAXB mapped Java-Representations of XML documents that, say, represent an incoming order document.) This has to be mapped onto the quite different order document structure of another system.</p>
<p>What are the options to... | <p>Another alternative is <a href="http://mapstruct.org/" rel="nofollow">MapStruct</a> which generates mapping code at build time, resulting in type-safe mappings which don't require any dependencies at runtime (Disclaimer: I'm the author of MapStruct).</p>
| <p>There is an interesting solution that might help you if you are mapping data structures that have many slightly different variants. For example if you are modelling business order structures for different business cases and product variants, and different variants require different combinations of the same attribute... | 48,947 |
<p>Just wondering if there is an easy way to add the functionality to duplicate an existing listing in the admin interface?</p>
<p>In data entry we have run into a situation where a lot of items share generic data with another item, and to save time it would be very nice to quickly duplicate an existing listing and on... | <p>You can <a href="http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_as" rel="noreferrer">save as</a> by just enabling adding this to your ModelAdmin:</p>
<pre><code>save_as = True
</code></pre>
<p>This replaces the "Save and add another" button with a "Save as" button. "S... | <p>You can also apply this method: <a href="https://stackoverflow.com/a/4054256/7995920">https://stackoverflow.com/a/4054256/7995920</a></p>
<p>In my case, with unique constraint in the 'name' field, this action works, and can be requested from any form:</p>
<hr>
<pre><code>def duplicate_jorn(modeladmin, request, qu... | 21,812 |
<p>How do I check to see if a particular value has already been assigned to Smarty and if not assign a (default) value?</p>
<p>Answer:</p>
<pre><code>if ($this->cismarty->get_template_vars('test') === null) {
$this->cismarty->assign('test', 'Default value');
}
</code></pre>
| <p><strong>Smarty 2</strong> </p>
<pre><code>if ($smarty->get_template_vars('foo') === null)
{
$smarty->assign('foo', 'some value');
}
</code></pre>
<p><strong>Smarty 3</strong></p>
<pre><code>if ($smarty->getTemplateVars('foo') === null)
{
$smarty->assign('foo', 'some value');
}
</code></pre>
<... | <p>Pretty sure you can do:</p>
<pre><code>if (!isset($smarty['foo']))
{
$smarty->assign('foo', 'some value');
}
</code></pre>
| 45,568 |
<p>I want to use Visual Studio snippets to generate SQL code, for example we have standard naming conventions for foreign keys etc and it would be great if I could just expand a snippet in my SQL script file. </p>
<p>However as far as I can tell the only languages that are supported by the Snippet manager are C#, VB J... | <p>So, if you have a statement something like the following, you're saying that you get no 'print' result?</p>
<pre>select * from sysobjects
PRINT 'Just selected * from sysobjects'</pre>
<p>If you're using SQL Query Analyzer, you'll see that there are two tabs down at the bottom, one of which is "Messages" and that's... | <p>Do you have variables that are associated with these print statements been output? if so, I have found that if the variable has no value then the print statement will not be ouput.</p>
| 33,678 |
<p>I'm working on a web-application and need to figure out the best way to host it. I'm looking to minimize "Total Cost of Ownership," but it's more important to keep hosting costs low than labor costs in my case.</p>
<p>Potentially, some day, it will grow quite large (in terms of user-base) with heavy traffic but, of... | <p>I would highly recommend going with a VPS account. I've had clients who have spent many thousands of dollars and countless hours trying to get a perfect dedicated hosting environment setup and then never came close to needing it's capacity. </p>
<p>With VPS, as long as you use the virtualization technology that you... | <p>I would buy a dedicated box, from a company like serverpronto, then when you out-grow them move to a colo, which if done properly will be mostly painless.</p>
| 44,179 |
<p>I could swear I've seen the function (or method) that takes a list, like this <code>[3, 7, 19]</code> and makes it into iterable list of tuples, like so: <code>[(0,3), (1,7), (2,19)]</code> to use it instead of:</p>
<pre><code>for i in range(len(name_of_list)):
name_of_list[i] = something
</code></pre>
<p>but ... | <pre><code>>>> a = [3,4,5,6]
>>> for i, val in enumerate(a):
... print i, val
...
0 3
1 4
2 5
3 6
>>>
</code></pre>
| <p>If you have multiple lists, you can do this combining <code>enumerate</code> and <code>zip</code>:</p>
<pre><code>list1 = [1, 2, 3, 4, 5]
list2 = [10, 20, 30, 40, 50]
list3 = [100, 200, 300, 400, 500]
for i, (l1, l2, l3) in enumerate(zip(list1, list2, list3)):
print(i, l1, l2, l3)
</code></pre>
Output:
<pre><... | 15,391 |
<p>I'd like to link to some PDFs in one of my controller views. What's the best practice for accomplishing this? The CakePHP webroot folder contains a ./files/ subfolder, I am confounded by trying to link to it without using "magic" pathnames in my href (e.g. "/path/to/my/webroot/files/myfile.pdf").</p>
<p>What are my... | <pre><code>$html->link('Pdf', '/files/myfile.pdf');
</code></pre>
| <p>or...</p>
<pre><code><a href="<?php echo $html->url('/files/somefile.pdf'); ?>">Link Text</a>
</code></pre>
| 28,921 |
<p>When a user clicks in certain places in my control, I want to change the color of some rows and columns in my grid, then fade it back to the normal color, within say 500ms or so. I haven't decided whether to use Winforms or WPF yet, so advice in either of those technologies would work. Thank you.</p>
<p>Edit: I u... | <p>WPF has very good support for animations. Animations are supported from both xaml and code behind, so you should be able to achieve any look that you are going for.</p>
<p>The MSDN <a href="http://msdn.microsoft.com/en-us/library/ms752312.aspx" rel="nofollow noreferrer">Animation Overview</a> for WPF looks to have ... | <p>At its simplest, a fade effect like this just requires a timer of some sort that gradates the color back towards normal with each tick. The faster the time, the more discrete colors you will display from start to finish, and the smoother the overall effect will be (WPF may have something built-in to do this).</p>
... | 34,927 |
<p>Is it possible via code to programmatically (from .NET for example via SQL query) to ask an Access database if it is corrupt or have tables with corrupt rows in it?</p>
<p>//Andy</p>
| <p>None of the application/database level objects have such an "isCorrupted" property. </p>
<p>Furthermore, corrupted databases do not have a standard behaviour. Depending on the situation, database might not open at all (file is not recognized as a valid mdb file). If it opens, error might occur immediately or when u... | <p>Here is some VBA that can be used to check for an error in previous releases of Access. It may also suit 2007.</p>
<pre><code>Sub CheckForErr(tablename)
Dim rs As dao.Recordset
Dim db As Database
Set db = CurrentDb
Set rs = db.OpenRecordset(tname)
With rs
Do While Not .EOF
For Each fld In rs.Fields
... | 30,379 |
<p>I've been trying to understand the strict aliasing rules as they apply to the char pointer.</p>
<p><a href="http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html#cast_to_char_pointer" rel="nofollow noreferrer">Here</a> this is stated:</p>
<blockquote>
<p>It is always presumed th... | <p>Re @Adam Rosenfield: The union will achieve alignment so long as the supplier of the char* started out doing something similar.</p>
<p>It may be useful to stand back and figure out what this is all about.</p>
<p>The basis for the aliasing rule is the fact that compilers may place values of different simple types o... | <p>Correct, the second example is in violation of the strict aliasing rules, so if you compile with the <code>-fstrict-aliasing</code> flag, there's a chance you may get incorrect object code. The fully correct solution would be to use a union here:</p>
<pre><code>union
{
SocketMsgToRecv msg;
char msgBuff[100];
}... | 32,837 |
<p>I just got Delphi 2009 and have previously read some articles about modifications that might be necessary because of the switch to Unicode strings.
Mostly, it is mentioned that sizeof(char) is not guaranteed to be 1 anymore.
But why would this be interesting regarding string manipulation?</p>
<p>For example, if I u... | <p>With Unicode <em>SizeOf(SomeChar) <> Length(SomeChar)</em>. Essentially the length of a <strong>string</strong> is less then the sum of the size of its <strong>char</strong>s. As long as you don't assume <em>SizeOf(Char) = 1</em>, or <em>SizeOf(SomeString[x]) = 1</em> (since both are <strong>FALSE</strong> now)... | <p>The actual size of a character shouldn't matter, unless you are doing the manipulation at the byte level.</p>
| 15,325 |
<p>Sometimes in our production environment occurs situation when connection between service (which is python program that uses MySQLdb) and mysql server is flacky, some packages are lost, some black magic happens and .execute() of MySQLdb.Cursor object never ends (or take great amount of time to end). </p>
<p>This is ... | <p>if the communication is such a problem, consider writing a 'proxy' that receives your SQL commands over the flaky connection and relays them to the MySQL server on a reliable channel (maybe running on the same box as the MySQL server). This way you have total control over failure detection and retrying.</p>
| <p>You need to analyse exactly what the problem is. MySQL connections should eventually timeout if the server is gone; TCP keepalives are generally enabled. You may be able to tune the OS-level TCP timeouts.</p>
<p>If the database is "flaky", then you definitely need to investigate how. It seems unlikely that the data... | 23,842 |
<p>I"m looking for something (Win API calls or whatever) to notify me when a file becomes available for editing (i.e. no longer in use). Should I set up a timer to check the files on some interval or is there a good way to set up a watch on the file?</p>
| <p>FileSystemWatcher doesn't help, nor does the Win32 FindFirstChangeNotification: they won't tell you when someone releases a file handle.</p>
<p>Your best way is to periodically attempt to open the file with the access you want, handling any errors.</p>
<p>Even if you were notified that a file was available, that w... | <p>I don't know what .NET's System.IO.FileSystemWatcher does, but if you could use that, you could get events when things about a file changes.</p>
| 25,142 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.