instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Is there anything to the process of 3D printing that might make the dice unfair/land on a specific side more frequently? Or will any imperfections be negligible, thus making the dice fair? I'm more concerned about making a d20 than anything else, so focus on that shape if need be.</p>
<hr>
<p>I am using a MakerBot... | <h2>It probably won't be fair.</h2>
<p>Incidentally, I have a decent amount of experience with 3D printing.</p>
<p>It depends heavily on the particular technology that you're using to do the 3D printing, but nearly all forms of printing aren't perfect--depending on the design you make (solid? honeycombed? hollow?), the... | <p>Well it is a bit more complicated than that. Changes are the d20 you buy in the store is a bit more favored as well. Now we are talking statically, it will like one side over the other. As the difference in weight distribution is not drastic if you print it solid, it will not matter. In use you likely will not see i... | 525 |
<p>Refactoring is the process of improving the existing system design without changing its behavior.</p>
<p>Besides Martin Fowler's seminal book "<a href="https://rads.stackoverflow.com/amzn/click/com/0201485672" rel="nofollow noreferrer" rel="nofollow noreferrer">Refactoring - Improving the design of existing code</a... | <p><a href="http://www.refactoring.com/" rel="noreferrer">http://www.refactoring.com/</a> might help you. They have a long list of methods here:</p>
<ul>
<li><a href="http://www.refactoring.com/catalog/index.html" rel="noreferrer">http://www.refactoring.com/catalog/index.html</a></li>
</ul>
<p>Joel's article <a href=... | <p>What is your codebase?</p>
<p>Eclipse has quite good support for Java. But unfortunately limited support for C++ code.</p>
<p><a href="http://www.ibm.com/developerworks/library/l-eclipse.html" rel="nofollow noreferrer">Heres</a> an article from the makers..</p>
| 7,127 |
<p>Should we use Generic Collection to improve safety and performance?</p>
| <p>Of course. Why wouldn't you? More important than the performance, IMO, is the fact that generic APIs are more expressive. That goes for generic APIs in general, not just collections.</p>
<p>EDIT: Just to clarify these a bit:</p>
<ul>
<li><p>Performance characteristics are slightly different between the generic and... | <p>Short answer: yes</p>
<p>Longer answer: There are really no downsides to using generic collections. Compile-time type checking eliminates the posibility of runtime errors from casting. Performance will be greater for built-in types such as integers, since boxing and unboxing are not needed (in contrast to Java gene... | 33,132 |
<p>I am attempting to create a struts2 component using freemarker. I created an <code>ftl</code> file with code like this:</p>
<pre><code><script type="text/javascript" src="${parameters.library?default('')}"></script>
</code></pre>
<p>Which is expecting a parameter named <code>library</code> to be passed... | <p>send the param with single quotes</p>
<pre><code><s:component template="mytemplate.ftl">
<s:param name="library" value="'/scripts/mylibrary.js'"/>
</s:component>
</code></pre>
| <p>I eventually ran across some syntax in the docs that works. I have to refer to the parameter like this:</p>
<pre><code><script type="text/javascript" src="${parameters.get('library')?default('')}">
</script>
</code></pre>
| 35,085 |
<p>I'm using wget to connect to a secure site like this:</p>
<p><code>wget -nc -i inputFile</code></p>
<p>where inputeFile consists of URLs like this:</p>
<p><code><a href="https://clientWebsite.com/TheirPageName.asp?orderValue=1.00&merchantID=36&programmeID=92&ref=foo&Ofaz=0" rel="nofollow noreferre... | <ol>
<li><p>Try forging your UserAgent</p>
<pre><code>-U "Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-GB; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1"
</code></pre></li>
<li><p>Disable Ceritificate Checking ( slow ) </p>
<pre><code>--no-check-certificate
</code></pre></li>
<li><p>Debug whats happening by enabling ve... | <p>Is the certificate on the client site valid? You may want to specify --no-certificate-check if it is a self-signed certificate.</p>
<p><a href="http://www.gnu.org/software/wget/manual/wget.html#HTTPS-_0028SSL_002fTLS_0029-Options" rel="nofollow noreferrer">HTTPS (SSL/TLS) Options for wget</a></p>
| 11,972 |
<p>I'm running Visual Studio 2008 with the stuff-of-nightmares awful MS test framework. Trouble is that it's sending my CPU to 100% (well 25% on a quad-core).</p>
<p>My question is why can't Visual Studio run on more than one core? Surely M$ must have a sufficient handle on threading to get this to work.</p>
| <p>I have VS2008 running on all 4 CPUs. Just set this environment variable / project flag.</p>
<p>/MP</p>
<p>(It can be set in C/C++ Settings, Advanced. In project settings)</p>
<p>Edit: The MP flag can also accept a number, e.g. /MP2 which means it will only run on 2 cores. Leaving it as just /MP means it will run ... | <p>The /MP flag is only for builds, we at least it is according to this <a href="http://msdn.microsoft.com/en-us/library/bb385193.aspx" rel="nofollow noreferrer">msdn</a></p>
<p>Now I would love to be wrong about it, but im pretty sure its just for builds. Which of course is still very useful.</p>
| 7,749 |
<p>I'm about to start a project that requires XML messages to be sent between a couple of servers over HTTPS. A brief summary is this: I have an application in use by clients that will send information to a central server. That server will communicate these XML messages to another company's server. I will also recei... | <p>Are the messages from the foreign server immediate replies to your messages? If not (either side can initiate a message whenever it likes), consider having both ends implement RESTful web services - the XML can be the payload, and https requests are trivially supportable.</p>
<p>Since invoking the web service is ju... | <p>I would start with looking at <a href="http://en.wikipedia.org/wiki/Web_service" rel="nofollow noreferrer">web services</a> to look at the basic theory. Then depending on what sort of technology you are using I would then pick up an intro book on creating webservices in it.</p>
| 33,307 |
<p>I'm trying to define a task that emits (using echo) a message when a target completes execution, regardless of whether that target was successful or not. Specifically, the target executes a task to run some unit tests, and I want to emit a message indicating where the results are available:</p>
<pre><code><tar... | <p>According to the <a href="http://ant.apache.org/manual/Tasks/exec.html" rel="nofollow noreferrer">Ant docs</a>, there are two properties that control whether the build process is stopped or not if the testng task fails: </p>
<blockquote>
<p><strong>haltonfailure</strong> - Stop the build process
if a failure ha... | <p>Although you are showing a fake task called "testng" in your example I presume you are using the junit target.</p>
<p>In this case, it is strange you are seeing these results because the junit target by default does NOT abort execution on a test failure.</p>
<p>There is a way to actually tell ant to stop the build... | 15,604 |
<p>In Emacs, <kbd>C-x o</kbd> takes me to the next window.</p>
<p>What keyboard macro takes me to the previous window in Emacs?</p>
| <p>That'd be <kbd>C-- C-x o</kbd></p>
<p>In other words, <kbd>C-x o</kbd> with an argument of -1. You can specify how many windows to move by inserting a numeric argument between <kbd>C-u</kbd> and the command, as in <kbd>C-u 2 C-x o</kbd>. (<kbd>C--</kbd> is a shortcut for <kbd>C-u - 1</kbd>)</p>
| <pre><code>(global-set-key (kbd "C-x a") 'ace-swap-window)
(global-set-key (kbd "C-x q") 'ace-select-window)
download ace-window from the melpa repo if you don't know how to do that
put this in your .emacs file if you don't have one create it
(package-initialize) ... | 11,637 |
<p>Could somebody tell me wich new dynamic tools analysis for C-code are there like valdgrind?</p>
| <p>You should monitor and be alerted for severity levels 17 to 25. <br></p>
<p>Severity levels from 17 through 19 will require intervention from a DBA, they're not as serious as 20-25 but the DBA needs to be alerted.<br>
17 Insufficient Resources<br>
18 Nonfatal Internal Error Detected<br>
19 Error in Resource<br>
<br... | <blockquote>
<p>What do you always monitor regardless of the database? </p>
</blockquote>
<p>We always turn on hardware alerts for all of our servers, in addition to log alerts. Hardware errors, such as inode errors, can take down servers just as fast as 5xx errors, for example. We've seen customers' PDF export capa... | 43,391 |
<p>You're my last hope stackoverflowers.</p>
| <p>No that is not possible on iphone.</p>
| <p>No.</p>
<p>You need to go through the itunes connect web site for that</p>
| 39,658 |
<p>I need to write the content of a map (key is ID of int, value is of self-defined struct) into a file, and load it from the file later on. Can I do it in MFC with CArchive?</p>
<p>Thank you!</p>
| <p>In MFC, I believe it's easiest to first serialize the size of the map, and then simply iterate through all the elements.</p>
<p>You didn't specify if you use <code>std::map</code> or MFC's <code>CMap</code>, but a version based on <code>std::map</code> could look like this:</p>
<pre><code>void MyClass::Serialize(C... | <p>I don't know much about MFC, but your problem is rather trivially solved using <a href="http://www.boost.org/doc/libs/1_35_0/libs/serialization/doc/index.html" rel="nofollow noreferrer">Boost.Serialization</a></p>
<pre><code>struct MapData {
int m_int;
std::string m_str;
private:
friend class boos... | 32,654 |
<p>With wxWidgets I use the following code:</p>
<pre><code>HWND main_window = ...
...
wxWindow *w = new wxWindow();
wxWindow *window = w->CreateWindowFromHWND(0, (WXHWND) main_window);
</code></pre>
<p>How do I do the same thing in Qt? The <code>HWND</code> is the handle of the window I want as the parent window for ... | <p>Use the create method of QWidget.</p>
<pre><code>HWND main_window = ...
...
QWidget *w = new QWidget();
w->create((WinId)main_window);
</code></pre>
| <p>How about fromWinId <a href="https://doc-snapshots.qt.io/qt6-dev/qwindow.html#fromWinId" rel="nofollow noreferrer">https://doc-snapshots.qt.io/qt6-dev/qwindow.html#fromWinId</a></p>
<p>Creates a local representation of a window created by another process or by using native libraries below Qt.</p>
| 37,497 |
<p>Is there anyway to build a solution to target 64 bit environment in vs2003? My solution is native c++ not visual c++. Any help would be greatly appreciated.</p>
<p>cheers,</p>
<p>RWendi</p>
| <p>This page on 2003's lack of 64-bit targeting seems to address your issue: <a href="http://www.toymaker.info/Games/html/64_bit.html" rel="nofollow noreferrer">http://www.toymaker.info/Games/html/64_bit.html</a>.</p>
<blockquote>
<p>The first step was to set up my development environment for 64 bit development. I use ... | <p>Sounds like a viable solution... going to try it before accepting the answer. votes up!</p>
<p>RWendi</p>
| 21,868 |
<p>I'm using Microsoft.XMLHTTP to get some information from another server from an old ASP/VBScript site. But that other server is restarted fairly often, so I want to check that it's up and running before trying to pull information from it (or avoid my page from giving an HTTP 500 by detecting the problem some other w... | <p>You could try making a ping to the server and check the response.
Take a look at this <a href="http://classicasp.aspfaq.com/general/how-do-i-execute-a-ping-command-from-asp-and-retrieve-the-results.html" rel="nofollow noreferrer">article</a>.</p>
| <p>You could try making a ping to the server and check the response.
Take a look at this <a href="http://classicasp.aspfaq.com/general/how-do-i-execute-a-ping-command-from-asp-and-retrieve-the-results.html" rel="nofollow noreferrer">article</a>.</p>
| 11,660 |
<p>I'm trying to figure out how to write this function:</p>
<pre><code>template <typename Bound>
Bound::result_type callFromAnyList(Bound b, list<any> p)
{
}
</code></pre>
<p>Then, if I had some function:</p>
<pre><code>double myFunc(string s, int i)
{
return -3.0;
}
</code></pre>
<p>I could call it... | <p>As you updated your concerns in the comment sections, here the answer. Just getting the return type of a function is possible:</p>
<pre><code>template<typename>
struct return_of;
template<typename R>
struct return_of<R(*)()> {
typedef R type;
};
template<typename R, typename P1>
struct... | <p>I ended up doing this for now -</p>
<pre><code>void invoke(void (f)(), list<any>& params)
{
f();
}
template <typename R>
void invoke(R (f)(), list<any>& params)
{
params.push_front(f());
}
template <typename T0>
void invoke(void (f)(T0), list<any>& params)
{
T... | 39,434 |
<p>Just that, if you embed an icon:</p>
<pre><code>[Embed(source='icons/checkmark.png')]
private static var CheckMark:Class;
</code></pre>
<p>You end up with a dynamic class. You can pretty easily assign the icon to a button at runtime by calling the setStyle method:</p>
<pre><code>var btn:Button = new Button();
btn... | <p>This is the only answer I could find that seemed close: <a href="http://blog.xsive.co.nz/archives/234" rel="nofollow noreferrer">Dynamic Icons</a> <a href="http://blog.xsive.co.nz/flex_source/button_icon_drawing/ButtonTest.html" rel="nofollow noreferrer">(example with View Source)</a></p>
<p>His solution involves a... | <p>The way I'd solve this is to implement a programmatic skin class that draws the icon itself manually. There's probably more work you'll have to do to ensure the button calculates the correct size as if it has an icon even though it doesn't. You may have to poke through the Button source code to look at how the ref... | 19,380 |
<p>I'm writting a simple prototype front end using a GridView that is populated via function, rather than being linked directly to a SqlServer data source.</p>
<p>So I can delete a row/record from grid/underlying database I am currently</p>
<ol>
<li>Setting the AutoGenerateDeleteButton = true</li>
<li>Displaying the ... | <p>GridView has a DataKeyNames property. When you bind a data source to the grid, you set the DataKeyNames (usually with just one name, your PK field). You don't show the PK, but you can get to it from code-behind.</p>
| <p>Visible=false means don't render on the page. What you want is either to make it a template field and use a HiddenField to hold the value or set the style on the control to "display: none;". This would be the case if the client side code needed access to the value for an Ajax call or something.</p>
<p>Otherwise u... | 25,151 |
<p>Say I wanted to print a plastic credit card like shape (like <a href="https://rads.stackoverflow.com/amzn/click/com/B07193KG7G" rel="nofollow noreferrer" rel="nofollow noreferrer">these</a>), but with a QR code engraved. How could I do that for cheap? You can buy an "ID card printer" for $1,000-1,500 on Amazon, but ... | <p><strong>FDM printer?</strong><br>
If you want to print one, maybe you should outsource it (let it print the tag on both sides), even the most affordable printers are in the \$100 - \$150 price range. If you want a printer and use it also to create ID tags, you could go for an FDM printer. Considering your request of... | <p>One option to create the tag you require can be accomplished with a single extruder and a bit of manual intervention.</p>
<p>I've performed the sequence of steps from a <a href="https://www.thingiverse.com/thing:1973570" rel="nofollow noreferrer">Thingiverse creation</a> that resulted in a box lid for a gift card b... | 1,558 |
<p>I'm wondering if storing the data in viewstate is a good idea for this given problem.
He's a simplified example of what I am trying to achieve, firstly we have a Repeater control:</p>
<pre><code><asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<asp:TextBox id="Name" runat="server" />
&l... | <p>SELECT * FROM <a href="http://msdn.microsoft.com/en-us/library/ms174397(SQL.90).aspx" rel="noreferrer">sys.database_files</a> (SQL 2005+)</p>
<p>SELECT * FROM dbo.sysfiles (SQL 2000)</p>
| <pre><code>SELECT * FROM sys.master_files
</code></pre>
<p>...will give you a basic view of where your database lives. It might not cope too well with filegroups, etc.</p>
| 46,086 |
<p>I'm in the process of setting up a php project, but am not very familiar with how to properly use php's include/require commands. My layout currently looks like this:</p>
<pre><code>/public --apache points into this directory
/public/index.php
/public/blah/page.php
/utils/util1.php -- useful classes/... | <p>Usually, the standard conventions are thus: like @grepsedawk said, you'll want to define a constant that contains the root of your project folder and if you can the root of your includes folder:</p>
<pre><code>define('APP_ROOT', dirname(__FILE__));
define('INCLUDE_ROOT', APP_ROOT . "/includes");
</code></pre>
<p>N... | <p>Why not require it based on it's full path?</p>
<p>For example, /sharedhost/yourdomain.com/apache/www is your document root, so why not use </p>
<pre><code>require('/sharedhost/yourdomain.com/apache/www/dbutils.php');
</code></pre>
<p>This also has the advantage of you being able to store your includes <strong>ou... | 44,048 |
<p>I use Eclipse with "external" projects - i.e. projects created from existing source.</p>
<p>Poking around in the workspace files, I cannot find any reference to these projects. My question is: how does Eclipse keep track of these projects?</p>
<p>I'd like to be able to add such a project to the workspace automatic... | <p>Windows:</p>
<pre><code><workspace>\.metadata\.plugins\org.eclipse.core.resources\.projects\
</code></pre>
<p>Linux / osx:</p>
<pre><code><workspace>/.metadata/.plugins/org.eclipse.core.resources/.projects/
</code></pre>
<p>Your project can exist outside the workspace, but all Eclipse-specific <code>meta... | <p>You can also have several workspaces - so you can connect to one and have set "A" of projects - and then connect to a different set when ever you like. </p>
| 31,263 |
<p>I am sequentially processing a large file and I'd like to keep a large chunk of it in memory, 16gb ram available on a 64 bit system.</p>
<p>A quick and dirty way is to do this, is simply wrap the input stream into a buffered input stream, unfortunately, this only gives me a 2gb buffer. I'd like to have more of it i... | <p>How about letting the OS deal with the buffering of the file? Have you checked what the performance impact of not copying the whole file into JVMs memory is?</p>
<p>EDIT: You could then use either RandomAccessFile or the FileChannel to efficiently read the necessary parts of the file into the JVMs memory.</p>
| <p>I think there are 64 bit JVMs that will support nonstandard limits.</p>
<p>You might try buffering chunks. </p>
| 17,163 |
<p>I'm trying to find a way to list the (static) dependency requirements of a jar file, in terms of which symbols are required at run time.</p>
<p>I can see that the methods exported by classes can be listed using "javap", but there doesn't seem to be an opposite facility to list the 'imports'. Is it possible to do th... | <p>You could use the <a href="http://depfind.sourceforge.net/Manual.html#ShowingOnlyOutboundDependencies" rel="nofollow noreferrer">Outbound dependencies</a> feature of <a href="http://depfind.sourceforge.net/" rel="nofollow noreferrer">DependencyFinder</a>. You can do that entirely in the GUI, or in command line expor... | <p>There's a tool called <a href="http://www.kirkk.com/main/Main/JarAnalyzer" rel="nofollow noreferrer">JarAnalyzer</a> that will give you the dependencies between the jars in a directory. It'll also give you a list of dependencies that don't exist in the directory.</p>
| 4,815 |
<p>I'm running into a common pattern in the code that I'm writing, where I need to wait for all threads in a group to complete, with a timeout. The timeout is supposed to be the time required for <em>all</em> threads to complete, so simply doing <code>Thread.Join(timeout)</code> for each thread won't work, since the po... | <p>I still think using Join is simpler. Record the expected completion time (as Now+timeout), then, in a loop, do </p>
<pre><code>if(!thread.Join(End-now))
throw new NotFinishedInTime();
</code></pre>
| <p>I was tying to figure out how to do this but i could not get any answers from google.
I know this is an old thread but here was my solution:</p>
<p>Use the following class:</p>
<pre><code>class ThreadWaiter
{
private int _numThreads = 0;
private int _spinTime;
public ThreadWaiter(int S... | 32,936 |
<p>I have had thoughts of trying to write a simple crawler that might crawl and produce a list of its findings for our NPO's websites and content.</p>
<p>Does anybody have any thoughts on how to do this? Where do you point the crawler to get started? How does it send back its findings and still keep crawling? How does... | <p>You'll be reinventing the wheel, to be sure. But here's the basics:</p>
<ul>
<li>A list of unvisited URLs - seed this with one or more starting pages</li>
<li>A list of visited URLs - so you don't go around in circles</li>
<li>A set of rules for URLs you're not interested in - so you don't index the whole Internet<... | <p>Use wget, do a recursive web suck, which will dump all the files onto your harddrive, then write another script to go through all the downloaded files and analyze them.</p>
<p>Edit: or maybe curl instead of wget, but I am not familiar with curl, I do not know if it does recursive downloads like wget.</p>
| 12,826 |
<p>I use Vim and Vim plugins for Visual Studio when writing C++. Often, I find myself wanting to search for a string within a function, for example every call to <code>object->public_member.memberfunc()</code>.</p>
<p>I know Vim offers a convenient way to search for a single word, by pressing <code>*</code> and <cod... | <p>Check this Vim tip: <a href="http://vim.wikia.com/wiki/Search_for_visually_selected_text" rel="noreferrer">Search for visually selected text</a></p>
<p>Or you can simply yank the selected text with <strong>y</strong> and go to search mode <strong>/</strong>, then you can paste the last yanked text with <strong>Ctrl... | <p>You can actually select text visually and press * and # to search for the next occurrence... It will work the same, the only caveat is that:</p>
<blockquote>
<p>Whitespace in the selection matches any whitespace, when searching (searching for "hello world" will also find "hello" at the end of a line, with "world"... | 47,401 |
<p>I'm using ReportViewer WinForms, and since it is no easy way to create an coversheet, then I wonder, is it possible to render two reports and have them concatenated?, so they appear as one report?</p>
<p>If I was to print only, then I could execute two reports after each other, but since the user want to see the re... | <p>Do you need to display the 2 reports as 1 in the reportViewer control or would having them both exported to PDF and showing a single PDF containing both reports be satisfactory?</p>
<p>I was looking for that but using the Web ReportViewer and found examples exporting the reports to several PDFs, then concatenating ... | <p>I've created a report that sounds like what you are attempting to do...first to clarify, I'm going to guess your using Crystal Reports within VS2005/2008.</p>
<p>If that's the case, all you need to do in the main report is create an additional section after your section that contains the "Cover Sheet" layout/data. ... | 13,998 |
<p>I have a table in SQL Server that I inherited from a legacy system thats still in production that is structured according to the code below. I created a SP to query the table as described in the code below the table create statement. My issue is that, sporadically, calls from .NET to this SP both through the Enter... | <p>I have seen this happen with indexes that were out of date. It could also be a parameter sniffing problem, where a different query plan is being used for different parameters that come in to the stored procedure.</p>
<p>You should capture the parameters of the slow calls and see if they are the same ones each time... | <p>Sounds like another query is running in the background that has locked the table and your innocent query is simply waiting for it to finish</p>
| 8,210 |
<p>I just started programming Objective-C and, having a background in Java, wonder how people writing Objective-C programs deal with private methods.</p>
<p>I understand there may be several conventions and habits and think about this question as an aggregator of the best techniques people use dealing with private met... | <p>There isn't, as others have already said, such a thing as a private method in Objective-C. However, starting in Objective-C 2.0 (meaning Mac OS X Leopard, iPhone OS 2.0, and later) you can create a category with an empty name (i.e. <code>@interface MyClass ()</code>) called <em>Class Extension</em>. What's unique ab... | <p>As other people said defining private methods in the <code>@implementation</code> block is OK for most purposes.</p>
<p>On the topic of <strong>code organization</strong> - I like to keep them together under <code>pragma mark private</code> for easier navigation in Xcode</p>
<pre><code>@implementation MyClass
// ... | 20,796 |
<p>Is there any convention on how to mark an all metal hotend to distinguish it from a hotend with a PTFE tube in the heatbreak? Once assembled for a German Riprap 3D printer, they look exactly the same on the outside. I'm trying to decide on a way of marking them to indicate the difference.</p>
<p>Hotend with heatsi... | <p>Given your heatbreaks are the same material and external dimensions, it seems that the most practical way to distinguish one from the other would be to mount the all metal heatbreaks in a heat sink that's anodized to some other color than natural aluminum -- red or blue, for instance.</p>
<p>If you can't buy them th... | <p>Usually, the neck of an all-metal heat break would be thinner (as it does not need to contain the PTFE tube, and making it overly thick would conduct heat unneccesarily). This may be observable when one loses track of what is where.
If one needs to see at a glance, I do not think there is a convention.</p>
| 1,971 |
<p>Does anyone know of a way to force a nolock hint on all transactions issued by a certain user? I'd like to provide a login for a support team to query the production system, but I want to protect it by forcing a nolock on everything they do. I'm using SQL Server 2005.</p>
| <p>You could configure your support staff's SQL Management Studio to set the default transaction isolation level to READ UNCOMMITTED (Tools->Options->Query Execution->SQL Server->Advanced). This is functionally the same as having NOLOCK hints on everything.</p>
<p>The downsides are that you'd have to do this for each... | <p>You could create a limited user for the support team, and then either write stored procedures or views with the nolock-hint. Then only give access to those and not direct table select access.</p>
| 8,971 |
<p>I can get both System.Net.Mail and System.Web.Mail to work with GMail, but I can't get them both to work with smtp.att.yahoo.com.</p>
<p>I get the SMTP settings from my own Web.config keys. These settings work when I send using System.Web.Mail, but fail with System.Net.Mail.</p>
<pre><code> <add key="SmtpS... | <p>I've learned the answer. The answer is:</p>
<p>Because System.Net.Mail does not support "implicit" SSL, only "explicit" SSL.</p>
| <p>Gimel's answer is back to front. He says use the new System.<strong>Net</strong>.Mail library, but the problem is that System.<strong>Net</strong>.Mail does not work for SSL on port 465 like System.<strong>Web</strong>.Mail did/does work!</p>
<p>I've beaten my head against this all day and for identical settings Sy... | 20,755 |
<p>I am using a multi-dimensional dynamic array in delphi and am trying to figure this out:</p>
<p>I have 2 seperate values for the first index and second index that are totally seperate of each other.</p>
<p>As new values come I want to grow the array if that new value is outside of either bound.</p>
<p>For new val... | <p>I think you forgot to use the second index on the second dimension;</p>
<p>Your code should probably read like this :</p>
<pre><code>if Length(List) < (x + 1) then
SetLength(List, x + 1);
if Length(List[x]) < (y + 1) then
SetLength(List[x], y + 1);
</code></pre>
<p>Note the use of 'x' as the first dim... | <p><del>@PatrickvL:
Sorry, but that is just plain wrong. Your code does not even compile because it tries to set two dimensions for the single-dimensional element List[x].</del> <em>(PatrickvL updated his code so this part of the answer is no longer valid.)</em></p>
<p>The following code demonstrates multidimensional ... | 19,681 |
<p>I need to test a function that needs to query a page on an external server using urllib.urlopen (it also uses urllib.urlencode). The server could be down, the page could change; I can't rely on it for a test.</p>
<p>What is the best way to control what urllib.urlopen returns?</p>
| <p>Another simple approach is to have your test override urllib's <code>urlopen()</code> function. For example, if your module has</p>
<pre><code>import urllib
def some_function_that_uses_urllib():
...
urllib.urlopen()
...
</code></pre>
<p>You could define your test like this:</p>
<pre><code>import mym... | <p>Adding onto Clint Miller's answer, to do this I had to create a fake class that implements a read method like this:</p>
<pre class="lang-py prettyprint-override"><code>class FakeURL:
def read(foo):
return '{"some":"json_text"}'
</code></pre>
<p>Then to stub out urllib2.open:</p>
<pre class="lang-py pr... | 37,758 |
<p>I have a script to extract certain data from a much bigger table, with one field in particular changing regularly, e.g.</p>
<pre><code>SELECT CASE @Flag WHEN 1 THEN t.field1 WHEN 2 THEN t.field2 WHEN 3
THEN t.field3 END as field,
...[A bunch of other fields]
FROM table t
</code></pre>
<p>However, th... | <p>I think you need to pull <code>@Flag</code> out of the query altogether, and use it to decide which of three separate SELECT statements to run.</p>
| <p>You seem to be focusing your attention on the technology rather than the problem to be solved. Think about one select from the main table for each case - which is how you describe it here, isn't it?</p>
| 30,980 |
<p>When reading data from the Input file I noticed that the ¥ symbom was not being read by the StreamReader. Mozilla Firefox showed the input file type as Western (ISO-8859-1).</p>
<p>After playing around with the encoding parameters I found it worked successfully for the following values:</p>
<pre><code>System.Text.... | <p>Code page 1252 isn't quite the same as ISO-Latin-1. If you want ISO-Latin-1, use <code>Encoding.GetEncoding(28591)</code>. However, I'd expect them to be the same for this code point (U+00A5). UTF-7 is completely different (and almost never what you want to use).</p>
<p><code>Encoding.Default</code> is <em>not</em>... | <p>Are you a software developer? do not forget to read Joel Spolsky's
<a href="http://www.joelonsoftware.com/articles/Unicode.html" rel="nofollow noreferrer"><strong>The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)</strong></a></p>
| 48,449 |
<p>I am trying this in my Form Load Event</p>
<p><pre><code>
cmdCancel.Attributes.Add("onClick", "document.forms[0].reset();return false;")
</pre></code></p>
<p>but it doesn't clear my form. My form is a "ContentPage", part of a masterpage.</p>
<p>Am I missing something?</p>
| <p>Try this:</p>
<pre><code> cmdCancel.Attributes.Add("onClick","document.getElementById('" + this.Page.ClientId + "').reset(); return false;");
</code></pre>
| <p>Shouldn't cancel take you away from the form entry page?
It sounds like you are trying to code "reset", but you are functionally attempting "cancel".</p>
<p>Personally, I always have an event that fires on "cleanup" and does all form cleanup that I need to do (not just for reset form fields).</p>
| 32,584 |
<p>I have my print settings dialed into a real good spot, but there's one obstacle that's preventing them from coming out flawless; somehow, my print has "fuzz" everywhere. Not traditional stringing like you get from filament oozing while travelling from section to section, nor do I mean over-extrusion that c... | <p>That is the print stringing still. Even thought that you have your printer dialed in, the plastic that is still in the nozzle is still grabbing onto your print and pulling out the nozzle just a tad. This, as far as I know, is unavoidable. The best solution that I could think of fixing this (as far as having your pri... | <p>These stringers are common with PETG.
You can reduce them by:</p>
<ol>
<li><p>Increasing retraction reduces the stringers, but too much retraction can cause the filament to jam and stop extruding.</p>
</li>
<li><p>Lowering the extruder temperature will reduce the stringers, but also reduce adhesion between layers. ... | 1,978 |
<p>I have a Pocket PC 2003 solution, consisting of three projects, that was created in Visual Studio 2005. I open the solution in Visual Studio 2008 and two of the projects fail to convert due to errors like the following:</p>
<p>Unable to read the project file 'PDA.vbproj'. D:\PDA.vbproj(121,61): The imported projec... | <blockquote>
<p>Microsoft.CompactFramework.CSharp.targets was not found...</p>
</blockquote>
<p>You may run into an error message like the one above when trying to load a smart device project into Visual Studio after a new Windows 10 build has been installed or when upgrading from Windows 8 to Windows 8.1. This erro... | <p>For projects that search it in framework 2.0 folder you should copy those four files:</p>
<ol>
<li>Microsoft.CompactFramework.VisualBasic.targets,</li>
<li>Microsoft.CompactFramework.CSharp.targets,</li>
<li>Microsoft.CompactFramework.Common.targets,</li>
<li>Microsoft.CompactFramework.Build.Tasks.dll</li>
</ol>
<... | 46,095 |
<p>I wand to construct an MSI which, in its installation process, will deploy itself along with its contained Files/Components, to the TargetDir.</p>
<p>So MyApp.msi contains MyApp.exe and MyAppBootstrapperEmpty.exe (with no resources) in its File Table.</p>
<p>The user launches a MyAppBootstrapperPackaged.exe (conta... | <p>Add an uncompressed medium to your wxs like this:</p>
<pre><code><Media Id='2'/>
</code></pre>
<p>And then create a component with a File element like this:</p>
<pre><code><File Source='/path/to/myinstaller.msi' Compressed='no' DiskId='2' />
</code></pre>
<p>This will make the installer look for a fi... | <p>I'd configure the MSI cache path to a known location.</p>
<p>Then at runtime if you need to "edit" the MSI use VBScript or similar.</p>
<p>But still, I ask WHY!?!</p>
| 11,369 |
<p>I'm interested in using a Reed-Solomon error correction [<a href="http://en.wikipedia.org/wiki/Reed%E2%80%93Solomon_error_correction" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Reed%E2%80%93Solomon_error_correction</a> as a reference] to try to rebuild files from partial bits of a file. I'm doing this as... | <p><a href="http://parchive.sourceforge.net/" rel="nofollow noreferrer">http://parchive.sourceforge.net/</a> is an open-source implementation. So you can at least read the code. I believe they also have docs on the math <a href="http://parchive.sourceforge.net/docs/specifications/parity-volume-spec/article-spec.html" r... | <p>There is ZFEC package for python <a href="http://pypi.python.org/pypi/zfec" rel="nofollow">http://pypi.python.org/pypi/zfec</a> that implements Reed Solomon algorithm for creating and restoring files from parts and does exactly what you want. You can use it without coding - as a command line utility. Its core is a s... | 45,514 |
<p>The <code>__debug__</code> variable is handy in part because it affects every module. If I want to create another variable that works the same way, how would I do it?</p>
<p>The variable (let's be original and call it 'foo') doesn't have to be truly global, in the sense that if I change foo in one module, it is upd... | <p>I don't endorse this solution in any way, shape or form. But if you add a variable to the <code>__builtin__</code> module, it will be accessible as if a global from any other module that includes <code>__builtin__</code> -- which is all of them, by default.</p>
<p>a.py contains</p>
<pre><code>print foo
</code></p... | <p>This sounds like modifying the <code>__builtin__</code> name space. To do it:</p>
<pre><code>import __builtin__
__builtin__.foo = 'some-value'
</code></pre>
<p>Do not use the <code>__builtins__</code> directly (notice the extra "s") - apparently this can be a dictionary or a module. Thanks to ΤΖΩΤΖΙΟΥ for pointi... | 17,228 |
<p>I'm trying to write a Windows cmd script to perform several tasks in series.
However, it always stops after the first command in the script.</p>
<p>The command it stops after is a maven build (not sure if that's relevant).</p>
<p>How do I make it carry on and run each task in turn please?</p>
<p>Installing any so... | <p>When you call another .bat file, I think you need "call" in front of the call:</p>
<pre><code>call otherCommand.bat
</code></pre>
| <p>Note that you don't need semicolons in batch files. And the reason why you need to use call is that mvn itself is a batch file and batch files need to call each other with call, otherwise control does not return to the caller.</p>
| 24,101 |
<p>I have an XML schema that includes multiple addresses:</p>
<pre><code><xs:element name="personal_address" maxOccurs="1">
<!-- address fields go here -->
</xs:element>
<xs:element name="business_address" maxOccurs="1">
<!-- address fields go here -->
</xs:element>
</code></pre... | <p>I think you are on the right tracks. I think its more to do with XML namespaces. Try the following:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/foo"
xmlns:tns="http://www.example.org/foo"
el... | <p>While namespaces help keep schemas organized and prevent conflicts,
it's not the namespace above that allows for the reuse,
it's the placement of the type as an immediate child of the <xs:schema> root
that makes it a global type. (Usable within the namespace w/o the namespace qualifier and from anywhere that ... | 28,140 |
<p>Recently, I've been dealing with an error with accessing MAPI via the .NET framework (as described in <a href="http://blogs.msdn.com/mstehle/archive/2007/10/03/fyi-why-are-mapi-and-cdo-1-21-not-supported-in-managed-net-code.aspx" rel="nofollow noreferrer">this article</a>). I am now left with a series of memory acce... | <p>I'm not entirely sure what you're asking, but i'll give it a shot.</p>
<p>Visual C++ is a pure C/C++ compiler so has none of .NET's memory management, nor any of its runtime -- You have to manually call new and delete.</p>
<p>.NET also provides C++/CLI, which is a slightly modified version of C++ that targets the ... | <p>Unless you are using Managed C++ (which it doesn't sound like you are) then no, the memory is not managed by the CLR.</p>
<p>The recommended method of talking to Exchange in .Net is via WebDAV.</p>
| 4,005 |
<p>for a server based j2ee application, I need to retrieve the number of pages from word documents.. any ideas what works?</p>
| <p>If the documents are modern Word 2007 format you can use direct XML-based manipulation, through <a href="http://msdn.microsoft.com/en-us/library/aa338205.aspx#office2007aboutnewfileformat_developingsolutionsusingtheoffice" rel="nofollow noreferrer">OOXML</a>. This is by far the better long term solution, though I re... | <p>//Open the Word Document </p>
<pre><code>Document doc = new Document("C:\\Temp\\file.doc");
</code></pre>
<p>//Get page count </p>
<pre><code>int pageCount = doc.getPageCount();
</code></pre>
| 36,020 |
<p>I am building a toolchanger CoreXY 3D printer. I am in big trouble to find mic-6 aluminium toolplate in my country. Can you suggest me an alternative to mic-6? In my country, I can find easily 5083, 6082, 7005, etc. I don't think, that theese aluminium plates are suitable as heated bed. The design of the bed is the ... | <p>This is probably caused by too few top layers in combination with a too low infill percentage. Increase skin layers and increase infill percentage.</p>
<p>If you have multiple layers already (at least about 4 for 0.2 mm layer height, for smaller layer heights even more), you might be printing at a too high temperatu... | <p>To combat the bad top layers, I usually use usually 5 top layers for any model of layer height 0.1 to 0.3 mm. I generally don't print with less than 9 % infill for PLA, which I have found sufficient to support even complex geometry on top.</p>
<p>Also, I generally use a mixed setup of layers: the outermost layers I ... | 1,815 |
<p>Is the memory space consumed by one object with 100 attributes the same as that of 100 objects, with one attribute each?</p>
<p>How much memory is allocated for an object?<br>
How much additional space is used when adding an attribute?</p>
| <p><a href="http://mindprod.com/jgloss/sizeof.html" rel="noreferrer">Mindprod</a> points out that this is not a straightforward question to answer:</p>
<blockquote>
<p>A JVM is free to store data any way it pleases internally, big or little endian, with any amount of padding or overhead, though primitives must behav... | <p>The rules about how much memory is consumed depend on the JVM implementation and the CPU architecture (32 bit versus 64 bit for example). </p>
<p>For the detailed rules for the SUN JVM check <a href="http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/5163" rel="nofollow noreferrer">my old blog</a></p>
<p>Regards... | 32,213 |
<p>I recently added <a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-pedantic-1" rel="nofollow noreferrer">-pedantic</a> and <a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-pedantic-errors-1" rel="nofollow noreferrer">-pedantic-errors</a> to my make GCC compile options to he... | <p>Using the <em><a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wsystem-headers" rel="nofollow noreferrer">-Wsystem-headers</a></em> option, GCC will print warning messages associated with system headers, which are normally suppressed. However, you're looking to have GCC basically treat these f... | <p>You could fix the headers and submit a patch to <a href="https://en.wikipedia.org/wiki/FFmpeg" rel="nofollow noreferrer">FFmpeg</a>; compatibility with <a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-pedantic-1" rel="nofollow noreferrer"><code>-pedantic</code></a> is a worthy goal, so I'm sure... | 20,784 |
<p>I'd like to use the camera in my Macbook in a program. I'm fairly language agnostic - C, Java, Python etc are all fine. Could anyone suggest the best place to look for documents or "Hello world" type code?</p>
| <p>The ImageKit framework in Leopard has an <a href="http://developer.apple.com/documentation/GraphicsImaging/Reference/IKImagePicker_Class/IKImagePicker_Reference.html#//apple_ref/occ/cl/IKPictureTaker" rel="nofollow noreferrer"><code>IKPictureTaker</code></a> class that will let you run the standard picture-taking sh... | <p>Quartz Composer is also a pleasant way to capture and work with video, when it's applicable. There's a video input patch.</p>
<p>Quartz Composer is a visual programming environment that integrates into a larger Cocoa program if need be.</p>
<p><a href="http://developer.apple.com/graphicsimaging/quartz/quartzcompo... | 8,165 |
<p>Is there a substitute in emacs for the vi "gf" command?
meaning try to open the file which is under the cursor right now
if a real file name is in fact there.</p>
<p>Thanks</p>
| <p>You want the <code>find-file-at-point</code> function (which is also aliased to <code>ffap</code>). It's not bound to a key by default, but you can use</p>
<pre><code>M-x ffap
</code></pre>
<p>Or, you can put in your <code>.emacs</code> file:</p>
<pre><code>(ffap-bindings)
</code></pre>
<p>This will replace man... | <p>Thanks, it works quite well but somehow the vi (gf) version is
still somewhat smarter. I think it looks at some path variable for search paths.</p>
<p>I made something which is needlessly complicated but works for me (only in linux).
It uses the "locate" command to search for the path under the cursor.
I guess it c... | 32,397 |
<p>I see a lot of people have .NET 2.0 or even 1.1 as a requirement for their projects. In my own workplace there is also lots of skepticism for upgrading to the latest and greatest .NET framework. </p>
<p>As a programmer I feel it is very frustrating working with the older frameworks when you know that you could have... | <p>First, understand the reasons why businesses are slow to upgrade.</p>
<p>Computer systems are not a strategic advantage for most of the companies out there. They are a necessary service function.</p>
<p>Since they are necessary, breaking them can be extremely expensive. Since they are not a strategic advantage, ... | <p>The major problem is that your application will require a certain version of the .NET framework; not that fun for your end users who might have to download an installer of 100 MB or more.</p>
| 49,016 |
<p>Why does the following code not work as I was expecting?</p>
<pre><code><?php
$data = array(
array('Area1', null, null),
array(null, 'Section1', null),
array(null, null, 'Location1'),
array('Area2', null, null),
array(null, 'Section2', null),
array(null, null, 'Location2')
);
$root = arra... | <p>If you modify your code on two lines as follows:</p>
<pre><code>$area = array();
$section = array();
</code></pre>
<p>to this:</p>
<pre><code>unset($area);
$area = array();
unset($section);
$section = array();
</code></pre>
<p>it will work as expected.</p>
<p>In the first version, <code>$area</code> and <code... | <p>This will also works:</p>
<pre><code>$root[$row[0]] = array();
$area =& $root[$row[0]];
</code></pre>
| 6,448 |
<p>What is an external and internal iterator in Java ?</p>
| <h1>External Iterator</h1>
<p>When you get an iterator and step over it, that is an external iterator</p>
<pre><code>for (Iterator iter = var.iterator(); iter.hasNext(); ) {
Object obj = iter.next();
// Operate on obj
}
</code></pre>
<h1>Internal Iterator</h1>
<p>When you pass a function object to a method to r... | <p><strong>External Iterator</strong> :- Using this we have to iterate all element one-by-one and do some operation because programmer does have control on that, its a External Iterator.</p>
<p><strong>Internal Iterator</strong> :- Using this we can iterate according to our condition, Programmer can control over on it... | 27,762 |
<p>I know that tables are for tabular data, but it's so tempting to use them for layout. I can handle DIV's to get a three column layout, but when you got 4 nested DIV's, it get tricky. </p>
<p>Is there a tutorial/reference out there to persuade me to use DIV's for layout?</p>
<p>I want to use DIV's, but I refuse to ... | <p>There's the <a href="http://developer.yahoo.com/yui/grids/" rel="nofollow noreferrer">Yahoo Grid CSS</a> which can do all sorts of things. </p>
<p>But remember: <strong>CSS IS NOT A RELIGION</strong>. If you save hours by using tables instead of css, do so. </p>
<p>One of the corner cases I could never make my min... | <p>This may be unhelpful but I somehow don't understand all these problems related to CSS. If a newspaper designer would try to embed a movie in the ad page, everybody would agree that he's a bit crazy. But still those same people pine after three-column layouts in HTML. HTML is just not apt to handle this kind of layo... | 8,640 |
<p>I've used straight Mongrel, I've used Mongrel clusters behind Apache, I've looked at Thin, and I'm becoming very intrigued by Passenger. I've looked at Nginx, too. I've looked at MRI, Ruby Enterprise Edition, Rubinius, and JRuby. There are a lot of options, each claiming to be the new holy grail.</p>
<p>What is the... | <p>I switched from Mongrel Cluster to Passenger two weeks ago (Debian Linux Server). I didn't look back for a second. Passenger is probably the easiest way to get your new server up and running. Performance and reliability are reasonable too.</p>
<p>Personally, I like to spend my time working on exciting new Rails pro... | <p>I'm hosting my new apps with Apache2 and Passenger on Ubuntu Hardy. Seems like the easiest and best option for most scenarios. I have just joined Slicehost.com for that purpose. They seem to get good reviews and have the most competitive prices of first class hosts.</p>
<p>I can't really endorse them yet because I'... | 35,415 |
<p>I'm currently implementing a raytracer. Since raytracing is extremely computation heavy and since I am going to be looking into CUDA programming anyway, I was wondering if anyone has any experience with combining the two. I can't really tell if the computational models match and I would like to know what to expect. ... | <p>One thing to be very wary of in CUDA is that divergent control flow in your kernel code absolutely KILLS performance, due to the structure of the underlying GPU hardware. GPUs typically have massively data-parallel workloads with highly-coherent control flow (i.e. you have a couple million pixels, each of which (or... | <p>It can certainly be done, has been done, and is a hot topic currently among the raytracing and Cuda gurus. I'd start by perusing <a href="http://www.nvidia.com/object/cuda_home.html" rel="nofollow noreferrer">http://www.nvidia.com/object/cuda_home.html</a></p>
<p>But it's basically a research problem. People who ... | 6,053 |
<p>I'm looking for the fastest way to determine if a <code>long</code> value is a perfect square (i.e. its square root is another integer): </p>
<ol>
<li>I've done it the easy way, by using the built-in <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Math.html#sqrt(double)" rel="norefer... | <p>I figured out a method that works ~35% faster than your 6bits+Carmack+sqrt code, at least with my CPU (x86) and programming language (C/C++). Your results may vary, especially because I don't know how the Java factor will play out.</p>
<p>My approach is threefold:</p>
<ol>
<li>First, filter out obvious answers. Th... | <p>Don't know about fastest, but the simplest is to take the square root in the normal fashion, multiply the result by itself, and see if it matches your original value.</p>
<p>Since we're talking integers here, the fasted would probably involve a collection where you can just make a lookup.</p>
| 37,777 |
<p>Ok, I'm getting my version control processes in order for my web team.</p>
<p>I know ideally each user would have a full working copy of their code on their local machine.</p>
<p>Unfortunately for a lot of our web apps they have additional server specific DB or other system integration requirements that cannot be ... | <p>You may find that the performance of Subversion operations over the network is much slower than the performance of the same Subversion operation locally. I've run into this problem in Unix land with working directories mounted over NFS, but I suspect you may run into the same situation using Windows shares.</p>
<p>... | <p>Some subversion actions will perform a little bit better if you map the network folder to a drive letter. The apache Apr library performs some extra network requests when you use a unc path instead of a drive letter.</p>
<p>Generally you should just use a local folder for your working copy as the idea is that you c... | 37,699 |
<p>Ok, this probably has a really simple answer, but I've never tried to do it before: How do you launch a web page from within an app? You know, "click here to go to our FAQ", and when they do it launches their default web browser and goes to your page. I'm working in C/C++ in Windows, but if there's a broader, more p... | <pre><code>#include <windows.h>
void main()
{
ShellExecute(NULL, "open", "http://yourwebpage.com",
NULL, NULL, SW_SHOWNORMAL);
}
</code></pre>
| <p>For some reason, ShellExecute do not work sometimes if application is about to terminate right after call it. We've added Sleep(5000) after ShellExecute and it helps.</p>
| 18,465 |
<p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html" rel="noreferrer">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p>
<pre><code>n = 5.59
round(n, 1) # 5.6
</code></pre>
<p>But, in actuality, good... | <p>I can't help the way it's stored, but at least formatting works correctly: </p>
<pre><code>'%.1f' % round(n, 1) # Gives you '5.6'
</code></pre>
| <p>What about:</p>
<pre><code>round(n,1)+epsilon
</code></pre>
| 8,093 |
<p>With JPA I do not need to code the SQL for every new attribute as the o/r-mapping is being done automatically.</p>
<p>As I am new to JSF, i am wondering whether there is a similar possiblity with JSF?</p>
<p>I do not want to add new code to a jsf datatable every time I change something at the corresponding entity.... | <p>Can you assume Outlook is installed on the computer? If so, I believe it can be background scripted using OLE or something similar. I've done file conversions through Excel using Ruby that way.</p>
<p>And here's a <a href="http://www.unur.com/comp/ppp/perl-win32-ole-outlook-ex1.html" rel="nofollow noreferrer">Perl ... | <p>one time only? or programmatically?</p>
<p>if one time only, import into a mail program that handles mbox (e.g. Thunderbird), at which point you just have text files, manipulate as desired.</p>
<p>otherwise, no idea, best of luck.</p>
| 41,201 |
<p>When reading a stack trace like:</p>
<pre class="lang-none prettyprint-override"><code>[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2755599
System.Number.Parse... | <p>I believe they're offsets into the code of the method - whether IL or JIT-compiled-assembly bytes, I'm not sure...</p>
<p>(Basically they're taking the place of line numbers, which of course aren't available without the pdbs.)</p>
| <p>Simply said, a Stack Trace is a reverse chronological listing of functions/methods in a flow, till current code. That is, up until a breakpoint is hit or an exception occurs.</p>
<p>On top of the stack trace listing, is the current method and its details like the Class, Assembly, filename, etc.</p>
<p>Following li... | 39,250 |
<p>I'd like to track down a possible bug in Visual Studio, but that's awfully hard without the debug symbols for Visual Studio itself. Does Microsoft make these available?</p>
| <p>An up-to-date Visual Studio should already have the option to load symbols from Microsoft (Check: Tools->Options->Debug->Symbols). When it comes to debugging Visual Studio itself, have a look at this <a href="http://blogs.msdn.com/b/calvin_hsia/archive/2009/06/08/9711306.aspx" rel="nofollow">blog post</a>.</p>
| <p>Based on my experience, most of the Visual Studio Dlls had symbols in the symbol server. msenv.dll is one of the most important.</p>
| 34,061 |
<p>Given two computers attached to the Internet that know nothing about each other before hand, is it possible for one computer to be able to broadcast a message so that the second computer could receive it and respond?</p>
<p>I know UDP broadcast exsits, but I believe that those are generally filtered by the ISP befo... | <p>The current best way to achieve a multinode network without centralized coordination is through the use of <a href="http://en.wikipedia.org/wiki/Distributed_hash_table" rel="nofollow noreferrer">Distributed Hash Tables</a>. That link explains a bit and links to various implementations you can leverage.</p>
<p>That ... | <p>Multicasting is also a possible solution. It's certainly feasible in a corporate network</p>
| 36,394 |
<p>I'm looking for ideas on how to implement audit trails for my objects in C#, for the current project,basically I need to:</p>
<ol>
<li>Store the old values and new values of a given object.</li>
<li>Record creation of new objects.</li>
<li>Deletion of old object.</li>
</ol>
<p>Is there any generic way of doing this,... | <p>Question is pretty similar to
<a href="https://stackoverflow.com/questions/148291/how-do-you-implement-audit-trail-for-your-objects-programming">How do you implement audit trail for your objects (Programming)?</a></p>
<p>We've implemented a similar solution, using AOP (aspectJ implementation). Using this particular... | <p>Pretty old question, but for those wanting to audit C# objects, I would recommend the <a href="https://github.com/thepirat000/Audit.NET" rel="nofollow noreferrer">Audit.NET</a> library.</p>
<p>It has extensions to log to different storage systems (SQL, Azure, Mongo) and for auditing different systems (WCF, EF, MVC)... | 42,613 |
<p>Lisp developed a set of interesting language features quite early on in the academic world, but most of them never caught on in production environments.</p>
<p>Some languages, like JavaScript, adapted basic features like garbage collection and lexical closures, but all the stuff that might actually change how you w... | <blockquote>
<p><em>Are there any modern, practical
languages that actually learn from
Lisp instead of half-assedly copying
"first class functions", or is there
an inherent conflict that makes this
impossible?</em></p>
</blockquote>
<p>Why aren't lisp, haskell, ocaml, or f# modern?</p>
<p>You might just n... | <p>The features you refer to ("powerful" macros, the code-as-data thing and custom control structures) have not propagated within other functional languages. They died after Lisp taught us that they are a bad idea.</p>
<p>Modern functional languages (OCaml, Haskell, Erlang, Scala, F#, C# 3.0, JavaScript) do not have t... | 10,095 |
<p>I am confused about how popen() redirects stdin, stdout and stderr of the child process in unix. The man page on popen() is not very clear in this regard. The call</p>
<pre><code>FILE *p = popen("/usr/bin/foo", "w");
</code></pre>
<p>forks a child process and executes a shell with arguments "-c", "/usr/bin/foo", a... | <p><code>popen(3)</code> is just a library function, which relies on <code>fork(2)</code> and <code>pipe(2)</code> to do the real work.</p>
<p>However <code>pipe(2)</code> can only create unidirectional pipes. To send the child process input, and also capture the output, you need to open two pipes.</p>
<p>If you wan... | <blockquote>
<p>The return value from popen() is a normal standard I/O stream in all
respects save that it must be closed with pclose() rather than
fclose(3). Writing to such a stream writes to the standard input of
the command; the command's standard output is the same as that of the
process that called ... | 35,483 |
<p>What is the purpose of the LongLength property for arrays in .Net. Using a standard integer for length, you could accommodate up to 2 billion indices. Are there really people using .Net to maintain a single array with more the 2 billion elements. Even if each element was a single byte, that would still be 2 GB of... | <p>For example, if you had a > 2 GB file and needed to read it all into memory at once, that would call for such an array. Not that that is necessarily a recommended approach most of the time, but there could well be some case (on a powerful enough 64 bit system with a lot of memory anyway) that this might be required ... | <p>It's very possible to have an array with more than 2 Billion entries in a 64 bit scenario. LongLength is indeed meant to support such scenarios.</p>
<p>As to whether or not that is actually used. I can say with certainty that there is some customer, somewhere, that considers this a vital business need. Customers... | 43,145 |
<p>How do I avoid read locks in my database?</p>
<p>Answers for multiple databases welcome!</p>
| <p>In Oracle the default mode of operation is the <em>Read committed</em> isolation level where a select statement is not blocked by another transaction modifying the data it's reading.
From <a href="http://download.oracle.com/docs/cd/B10501_01/server.920/a96524/c21cnsis.htm" rel="nofollow noreferrer">Data Concurrency ... | <p>In SQL Server you can use the with(nolock) keyword in your select statements. For example:</p>
<pre><code>Select table1.columna, table2.columna
from table1 with(nolock), table2 with(nolock)
</code></pre>
<p>Make sure to specify with(nolock) for each table/view in the query.</p>
| 5,778 |
<p>Does anybody know if there is a way to create an SQLite database based on an XSD <code>DataSet</code>? In the past, I've just used a basic SQLite manager, but I want to fuse things a bit more with my <code>.NET</code> development if possible.</p>
| <p>I suspect in the general case this is hard; XML Schema allows for some quite bizarre type constructions. I'm not sure how you would do substitution groups, or extensions to restrictions of types for example.</p>
<p>However it should be possible to knock something together quite quickly (especially mapping from the... | <p>I'm sure you could write a small app that takes an XSD file and parses it into a SQL script. I've never seen code out there to do it though, but that's not saying it doesn't exist.</p>
| 2,274 |
<p>I have a application deployed through clickonce, but How can I modify the config file on the deployment server?. I mean, once the product is tested, it should be deployed in our production server, but need to modify some of the config parameters to consume production resources?. I heard we should use MageUI.exe, bu... | <p>Yes, the best way to do it would probably be MageUI. Just open your manifests with MageUI, click <strong>Save</strong> and it should prompt you to resign the manifests.</p>
<p>You have two options when signing manifests. You can use a self-certificate or purchase a certificate. Self certificates are easy to use ... | <p>codeConcussion is correct - we do this all the time for our config changes. The thing to remember is that if you are managing versions such that a user will only get the new version of the smartclient when there's a new version on the server, you'll need to arbitrarily increase the version in the manifest file to g... | 11,204 |
<p>I'm heavily using Cygwin (with <a href="http://en.wikipedia.org/wiki/PuTTY" rel="noreferrer">PuTTY </a> shell). But, it's quite tricky to invoke <code>cl.exe</code> (that is, the Visual C++ compiler toolchain) in the Cygwin Bash shell. Running <code>vcvars*.bat</code> in the Bash shell doesn't work obviously. I trie... | <p>I usually solve this by adding </p>
<pre><code>call "%VS80COMNTOOLS%vsvars32.bat" >NUL:
</code></pre>
<p>to c:/cygwin/cygwin.bat. Note that the VS80COMNTOOLS variable is extremely useful, since it gives you a foolproof (hm) way of locating vsvars32.bat.</p>
<p>Another approach is this, which allows you to easi... | <p>I couldn't add comments to <a href="https://stackoverflow.com/questions/366928/invoking-cl-exe-msvc-compiler-in-cygwin-shell/366934#366934">Diomidis's reply</a> :(, so had to post an answer instead.
I agree with his answer, but it would be tedious to do "open a command prompt", run Visual Studio/<code>vcvars32.bat</... | 47,895 |
<p>How do I set the code page to UTF-8 in a C Windows program? </p>
<p>I have a third party library that uses fopen to open files. I can use wcstombs to convert my Unicode filenames to the current code page, however if the user has a filename with a character outside the code page then this breaks. </p>
<p>Ideally ... | <p>Unfortunately, there is no way to make Unicode the current codepage in Windows. The <code>CP_UTF7</code> and <code>CP_UTF8</code> constants are pseudo-codepages, used only in <a href="http://msdn.microsoft.com/en-us/library/ms776413(VS.85).aspx" rel="noreferrer">MultiByteToWideChar</a> and <a href="http://msdn.micro... | <p>Use cygwin (which provides a UTF-8 locale by default), or write your own libc hack for Windows that does the necessary UTF-8 to UTF-16 translations and wraps the nonstandard <code>_wfopen</code> etc. functions.</p>
| 20,111 |
<p>How can I determine if I'm in the final loop of a For Each statement in VB.NET?</p>
| <p>The generally, collections on which you can perform <code>For Each</code> on implement the <a href="http://msdn.microsoft.com/en-us/library/system.collections.ienumerator.aspx" rel="noreferrer"><code>IEnumerator</code></a> interface. This interface has only two methods, <code>MoveNext</code> and <code>Reset</code> a... | <p>If you are tied to IEnumerable. Do you have to be inside the foreach loop? If not you could declare a variable just before the foreach loop. Set it during the loop. Then, use it after the loop (if its not null)</p>
| 49,276 |
<p>I recently had a problem in my app where some of the subviews I was creating in a UIViewController subclass's <code>-awakeFromNib</code> method were disappearing from the view. After some poking around I found that moving the code I had put in <code>-awakeFromNib</code> to <code>-viewDidLoad</code> solved the probl... | <p><code>awakeFromNib</code> is called when the <strong>controller</strong> itself is unarchived from a nib. <code>viewDidLoad</code> is called when the <strong>view</strong> is created/unarchived. This distinction is especially important when the controller's view is stored in a separate nib file.</p>
| <p>For a ViewController, IBOutlets are available in viewDidLoad()</p>
<p>Here <strong>stackView</strong> represents an IBOutlet in a ViewController, <strong>stackView</strong> is nil in awakeFromNib, but it has been instantiated when viewDidLoad() is called. </p>
<p><a href="https://i.stack.imgur.com/kvK7c.png" rel="... | 49,392 |
<p>It appear that SQL Server like most other products Random Function really is not that random. So we have this nice little function to generate a 10 char value. Is there a better way to accomplish what the following does. I am betting there is.</p>
<pre><code>DECLARE @SaltCount INT;
SELECT @SaltCount = COUNT(*) F... | <p>Most programmers make a mistake of reinventing the randomization functionality and end up with something that is not random at all. I'd recommend you to stick with built-in RAND() function. Seed it once then fetch as many values as you need.</p>
| <p>Not the full-alphabet-randomness you have but kind of random:</p>
<pre><code>select substring(replace(newid(),'-',''),0,10)
</code></pre>
<p><strong>Edit:</strong> I learned from the comments that newid() isn't very good for randomness, especially in combination with substring.</p>
| 33,802 |
<p>Does anyone have any experience in using compression on their cached data?
I understand that stackoverflow is internally using this method. </p>
<p>What are the pros and cons? </p>
<p>And are there any gotchyas?</p>
| <p>Scott Hanselman just created a Session wrapper class that can zip items before putting them into your cache/session/whatever. You may want to take a look!</p>
<p><a href="http://www.hanselman.com/blog/TheWeeklySourceCode35ZipCompressingASPNETSessionAndCacheState.aspx" rel="nofollow noreferrer">http://www.hanselman.... | <p>you should try memcached. It's a distributed caching server that is easy to use and provides impressive compression capabilities.</p>
| 28,211 |
<p>This might seem like a stupid question I admit. But I'm in a small shop me plus two designers. Our backups are getting out of hand because they just copy/paste files if they need to make a change (version). </p>
<p>I was all set to try Subversion to handle all of our files my text (code) files and their photoshop/i... | <p><a href="http://www.pixelnovel.com/timeline" rel="nofollow noreferrer">PixelNovel Timeline</a> is a dedicated Subversion client for Photoshop - works as a plugin and shows all you versions in an additional Photoshop palette. It also comes with a <a href="http://www.pixelnovel.com" rel="nofollow noreferrer">web stor... | <p>Subversion is not an ideal solution for binary files, regardless of how little has changed it will save a new copy each time you check it in. Moreover, although Subversion has some locking capabilities, it doesn't lock by default, which means that if two persons modify the same binary file the one that checks in the... | 5,674 |
<p>I know many people who use computers every day, who do not know how to select multiple items in a HTML select box/list. I don't want to use this control in my pages any more:</p>
<pre><code>Please pick 3 options:
<select name="categories" size="10" multiple="yes">
</code></pre>
<p>So what user-friendly alter... | <p>Alternatives I used in past are:</p>
<p>1) For small number of items use a checkbox list.
The checkboxes are much more intuitive and simple to use, but for large number of items it can became an issue. Still, when the number of items is growing you can add a:</p>
<pre><code><div style="overflow: scroll" />
... | <p>For unfrequent users having three drop downs might work the best>: </p>
<pre><code><select><option>Capa Verde</option></select>
<select><option>Holiday</option></select>
<select><option>Competition</option></select>
</code></pre>
<p>Alternativ... | 24,965 |
<p>In SQL Server 2005, a snapshot of a database can be created that allows read-only access to a database, even when the database is in "recovery pending" mode. One use case for this capability is in creating a reporting database that references a copy of a production database, which is kept current through log-shipp... | <p>Are you able to manage permissions on this database? Would adding a separate user who only has read access to a database be sufficient for this type of scenario? This could be a read-only user on the main database, but is only effectively used on the snapshot db.</p>
<p>i.e. Add a new user, readerMan5000 who is o... | <p>You can't change permissions after you take the snapshot, but here's one workaround: instead of having them access the tables directly, require them to use views instead. If the views are used only for reporting, then you can set tight security on them in the original database, and then have the users hit those vie... | 10,425 |
<p>My production environment involves a pair of IIS 6 web servers, one running legacy .NET 1.1 applications and the other running .NET 2.0 applications. We cannot install .NET 2.0 alongside 1.1 on the same machine because it is a tightly-regulated 'Validated System' and would present a bureaucratic nightmare to revali... | <p>No, because you're not using cookies for authentication in that scenario, so ScaleOvenStove's link won't help.</p>
<p>Basic authentication sends the login information in the HTTP headers with every request, but it's the browser that does this, when it sees a new server, new password request.</p>
<p>(Or indeed as s... | <p>yes, check out here</p>
<p><a href="http://weblogs.asp.net/scottgu/archive/2005/12/10/432851.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/scottgu/archive/2005/12/10/432851.aspx</a></p>
| 10,186 |
<p>I've only done a bit of Flex development thus far, but I've preferred the approach of creating controls programmatically over mxml files, because (and <em>please</em>, correct me if I'm wrong!) I've gathered that you can't have it both ways -- that is to say, have the class functionality in a separate ActionScript c... | <p>Don't be afraid of MXML. It's great for laying out views. If you write your own <em>reusable</em> components then writing them in ActionScript may sometimes give you a little more control, but for non-reusable views MXML is much better. It's more terse, bindings are extemely easy to set up, etc.</p>
<p>However, bin... | <p>there is a way that I usually use to use mxml and action script together: All my mxml components inherit from a action script class where I add the more complex code. Then you can refer to event listeners implemented in this class in the mxml file.</p>
<p>Regards,</p>
<p>Ruth</p>
| 3,501 |
<p>Suppose I have a python object <code>x</code> and a string <code>s</code>, how do I set the attribute <code>s</code> on <code>x</code>? So:</p>
<pre><code>>>> x = SomeObject()
>>> attr = 'myAttr'
>>> # magic goes here
>>> x.myAttr
'magic'
</code></pre>
<p>What's the magic? The g... | <pre><code>setattr(x, attr, 'magic')
</code></pre>
<p>For help on it:</p>
<pre class="lang-none prettyprint-override"><code>>>> help(setattr)
Help on built-in function setattr in module __builtin__:
setattr(...)
setattr(object, name, value)
Set a named attribute on an object; setattr(x, 'y', v) i... | <p>If you want a filename from an argument:</p>
<pre class="lang-py prettyprint-override"><code>import sys
filename = sys.argv[1]
file = open(filename, 'r')
contents = file.read()
</code></pre>
<p>If you want an argument to show on your terminal (using <code>print()</code>):</p>
<pre class="lang-py prettyprint-overr... | 36,180 |
<p>I'm having an issue with my regex.</p>
<p>I want to capture <% some stuff %> and i need what's inside the <% and the %></p>
<p>This regex works quite well for that.</p>
<pre><code>$matches = preg_split("/<%[\s]*(.*?)[\s]*%>/i",$markup,-1,(PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE));
</code></pr... | <p>In your case, it's better to use preg_match with its additional parameter and parenthesis:</p>
<pre><code>preg_match("#((?:<|&lt;)%)([\s]*(?:[^ø]*)[\s]*?)(%(?:>|&gt;))#i",$markup, $out);
print_r($out);
Array
(
[0] => <% your stuff %>
[1] => <%
[2] => your stuff
[3] =... | <p>One possible solution is to use the extra parens, like so, but to ditch those in the results, so you actually only <em>use</em> 1/2 of the total restults.</p>
<p>this regex</p>
<pre><code>$matches = preg_split("/(<|&lt;)%[\s]*(.*?)[\s]*%(>|&gt;)/i",$markup,-1,(PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM... | 12,981 |
<p>I have the following code snippet.</p>
<pre><code>$items['A'] = "Test";
$items['B'] = "Test";
$items['C'] = "Test";
$items['D'] = "Test";
$index = 0;
foreach($items as $key => $value)
{
echo "$index is a $key containing $value\n";
$index++;
}
</code></pre>
<p>Expected output:</p>
<pre><code>0 is a A c... | <p>Your $index variable there kind of misleading. That number isn't the index, your "A", "B", "C", "D" keys are. You can still access the data through the numbered index $index[1], but that's really not the point. If you really want to keep the numbered index, I'd almost restructure the data:</p>
<pre>
$items[] = arra... | <p>Be careful how you're defining your keys there. While your example works, it might not always:</p>
<pre><code>$myArr = array();
$myArr[A] = "a"; // "A" is assumed.
echo $myArr['A']; // "a" - this is expected.
define ('A', 'aye');
$myArr2 = array();
$myArr2[A] = "a"; // A is a constant
echo $myArr['A']; // error... | 9,410 |
<p>I have a very simple WPF application in which I am using data binding to allow editing of some custom CLR objects. I am now wanting to put some input validation in when the user clicks save. However, all the WPF books I have read don't really devote any space to this issue. I see that you can create custom Validatio... | <p>I think the new preferred way might be to use IDataErrorInfo</p>
<p>Read more <a href="http://blogs.msdn.com/wpfsdk/archive/2007/10/02/data-validation-in-3-5.aspx" rel="noreferrer">here</a></p>
| <p>If your business class is directly used by your UI is preferrable to use IDataErrorInfo because it put logic closer to their owner.</p>
<p>If your business class is a stub class created by a reference to an WCF/XmlWeb service then you can not/must not use IDataErrorInfo nor throw Exception for use with ExceptionVal... | 8,905 |
<p>I want to write something that acts just like confirm() in javascript, but I want to write it myself so I can skin the dialog box. In having trouble thinking through how I would basically force the javascript thread to wait until the user responds and then return true or false.</p>
| <p>If I were you, I would look at one of the popular javascript libraries. Most contain some sort of modal dialog.</p>
<p>A couple I found for JQuery are <a href="http://dev.iceburg.net/jquery/jqModal/" rel="nofollow noreferrer">jqModal</a> and <a href="http://www.ericmmartin.com/projects/simplemodal/" rel="nofollow ... | <p>You could use window.<a href="http://msdn.microsoft.com/en-us/library/ms536759(VS.85).aspx" rel="nofollow noreferrer">showModalDialog</a> (<a href="http://developer.mozilla.org/en/DOM/window.showModalDialog" rel="nofollow noreferrer">mozilla</a>), but it's a non-standard function introduced by Internet Explorer. Now... | 22,882 |
<p>I am looking for a device that reads wiring voltages via a USB interface and returns the data. How would I go about programming something to interpret this data and what language would I use?
<br /><br />
edit:
If it helps, this project is to develop a digital tachometre for older engines that don't support a compre... | <p>Cheat and use <strong><a href="http://libusb.wiki.sourceforge.net/" rel="noreferrer">libusb</a></strong>. I did this for a project I've been working on for a while and wrote a <strong>C++/<a href="http://wxwidgets.org/" rel="noreferrer">wxWidgets</a></strong> app to handle the data.</p>
<p>I've been thinking recent... | <p>In addition to WinUSB, libusb and Jungo, there is another option for programming USB devices from user-mode - <a href="http://www.microsoft.com/whdc/driver/wdf/UMDF.mspx" rel="nofollow noreferrer">User-Mode Driver Framework (UMDF)</a>.</p>
<p>Writing a UMDF driver is basically creating an in-process COM component w... | 19,496 |
<p>I can't find a good way of putting Eclipse windows on two monitors. Currently I just detached (clicked on a header and dragged) a few windows to a secondary monitor (package explorer, console, and outline) while leaving primary monitor with maximized source editing window. </p>
<p>It works pretty well except few an... | <p>In the Eclipse Helios (currently 3.6.2) I found very useful the use of another window to bring up multiple documents in different screens.
in the main menu, go:</p>
<p>Window > New window, </p>
<p>and drag it to the screen you prefer. Double click in the filename on the editor and will maximize the editor's window... | <p>I've reduced (but not eliminated) the need for the package explorer to always be showing by using Ctrl+Shift+R in eclipse, this pops up a filter-as-you type window that makes switching between files which you remember the name of easy, as well as accepting wildcards to make it easy to find files you partially rememb... | 41,234 |
<p>I am interested to learn: what are the most common technical causes (from the perspective of operating system programming) of an operating system crash (not limited to Windows crashes)? I'm looking for an answer not like "too many apps open", but what specifically happens when too many apps are open that causes the... | <p>In my opinion</p>
<ol>
<li>Bad drivers </li>
<li>Kernel bugs</li>
<li>Hardware failure</li>
<li>End of resources</li>
</ol>
<p>A modern operating system will not let a mere application crash it.</p>
| <p>No you are way off. Typically there is nothing an application can do that can cause the OS to crash. OS crashes are generally caused by buggy device drivers and hardware failures.</p>
| 13,927 |
<p>I have a Visual Basic .NET program which needs to open and close an Excel spreadsheet. Opening and reading the spreadsheet work fine, but trying to close the Excel 2007 application causes it to hang. It seems to close, but if you look in the task manager the application is still running. The code that I'm using t... | <p>The answer to your question has been covered here i think:
<a href="https://stackoverflow.com/questions/158706/how-to-properly-clean-up-excel-interop-objects-in-c">How to properly clean up excel interop objects in c</a></p>
<p>i cant see from your code sample, but basically, always assign your excel objects to loca... | <p>I found a <a href="http://blogs.msdn.com/excel/archive/2006/06/19/636534.aspx" rel="nofollow noreferrer">solution in the MSDN Excel Blog</a> which worked for me. It's explained as</p>
<blockquote>
<p>There are two problems with the above:</p>
<p>(1) Although the code appears to
dispose of the 'wbkData' ob... | 30,787 |
<p>It seems that when I have one mysql_real_query() function in a continuous while loop, the query will get executed OK.</p>
<p>However, if multiple mysql_real_query() are inside the while loop, one right after the other. Depending on the query, sometimes neither the first query nor second query will execute properly... | <p>Always check the return value of an API call.</p>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-real-query.html" rel="nofollow noreferrer"><code>mysql_real_query()</code></a> returns an integer. The value is zero if the call worked, and nonzero if there's an error.</p>
<p>Check the return value and rep... | <p>OK, For test purposes, take your <code>tagBuffer</code> variable out of the first <code>mysql_real_query</code> call and replace it with a constant, like your second test query.</p>
<p>At that point you'd just be repeatedly inserting two constant strings. That <strong>really</strong> should work.</p>
<p>If that d... | 35,459 |
<p>I am using the open source <a href="http://openwebware.com/" rel="nofollow noreferrer">Javascript WYSIWYG from OpenWebWare</a> and Asp.Net <strong>RequiredFieldValidator</strong> on the <strong>TextBox</strong> which I am calling the WYSIWYG for. Everything works fine, but the first time I try to submit the form, I... | <p>I think the reason for this behavior is that validation code runs earlier than the code that updates underlying TextBox from value of WYSIWYG. So the first time you get the error, then the field is updated and the second time you don't get it. Try removing all the content the second time and I bet you wont get valid... | <p>the textarea HTML tag is one of the most unpleasent tags to work with and I'm not 100% sure if the client-side validator will support it, regardless of whether it's a WYSIWYG or not.</p>
<p>I think you'd be best off using a CustomValidator and writing the JavaScript which does the checking manually.</p>
<p>Alterna... | 14,605 |
<pre><code>$sql = "INSERT INTO images (path, useremail, approved, flagged,caption,date) VALUES ('$target','$email',0,0, '$caption','$b')";
$sql1 = "INSERT INTO users (name, email, phone) VALUES ('$peoplename','$email','$phone')"
$conn->execute($sql, $sql1);
</code></pre>
<p>Above is the code Ι am using to try and w... | <p>I thought that the second parameter was for passing parameters to be bound to the query.</p>
<p>If the server lets you execute two sql statements in one go maybe this would work. (added a terminating semi-colon at the end of each query and concatenated both queries together as one string.)</p>
<pre><code>$sql = "I... | <p>You have a missing semicolon on the second line.</p>
| 29,643 |
<p>I have some Python code that creates a Calendar object based on parsed VEvent objects from and iCalendar file.</p>
<p>The calendar object just has a method that adds events as they get parsed.</p>
<p>Now I want to create a factory function that creates a calendar from a file object, path, or URL.</p>
<p>I've been... | <p>[<strong>Note</strong>. Be very cautious about separating "Calendar" a collection of events, and "Event" - a single event on a calendar. In your question, it seems like there could be some confusion.]</p>
<p>There are many variations on the Factory design pattern.</p>
<ol>
<li><p>A stand-alone convenience functi... | <p>The factory pattern has its own <a href="http://en.wikipedia.org/wiki/Factory_method_pattern" rel="nofollow noreferrer">strengths and weaknesses</a>. However, choosing one way to create instances usually has little pragmatic effect on your code.</p>
| 14,110 |
<p>I need to an algorithm, to write frames (Pictures) into a file, which can be read by some Video-Cutting/Producing-Software to work with.</p>
<p>So I got frames, and I want to give them a input into a function/Method.
Let's do i in Java.</p>
<p>How can I do this?
Is there a simple way, I can write videofiles withou... | <p>Depending on the program you want to use to further process your movie you can also simply create PNGs (or TGAs or BMPs) for the single frames. VirtualDub e.g. can use images as frames for a movie.</p>
| <p>The AVI container format can contain streams of uncompressed video, of which there are many types to choose from. Have a look here <a href="http://fourcc.org/" rel="nofollow noreferrer">http://fourcc.org/</a> at the RGB and YUV formats, and here <a href="http://www.alexander-noe.com/video/documentation/avi.pdf" rel=... | 44,682 |
<p>Is there support in Ruby for (for lack of a better word) non-escaped (verbatim) strings?</p>
<p>Like in C#:</p>
<pre><code>@"c:\Program Files\"
</code></pre>
<p>...or in Tcl:</p>
<pre><code>{c:\Program Files\}
</code></pre>
| <p>Yes, you need to prefix your string with <code>%</code> and then a single character delineating its type.</p>
<p>The one you want is <code>%q{c:\program files\}</code>.</p>
<p>The pickaxe book covers this nicely <a href="http://www.rubycentral.org/pickaxe/language.html" rel="nofollow noreferrer">here,</a> section ... | <pre><code>mystring = %q["'\t blahblahblah]
</code></pre>
<p>Or if you want to interpret <code>\t</code> as tab:</p>
<pre><code>mystring = %Q["'\t blahblahblah]
</code></pre>
| 26,850 |
<p>Sometimes gdb prints "incomplete type" for some type of variables. What does this mean and how can we see that value?</p>
| <p>It means that the type of that variable has been incompletely specified. For example:</p>
<pre><code>struct hatstand;
struct hatstand *foo;
</code></pre>
<p>GDB knows that <code>foo</code> is a pointer to a <code>hatstand</code> structure, but the members of that structure haven't been defined. Hence, "incomplete ... | <p>I had the same problem. If you load the symbols from your libraries manually:</p>
<pre><code>set auto-solib-add off
attach thread_id
shared any_lib
shared another_lib
</code></pre>
<p>You need to load the symbols from the library, where this object is declared, with the same command as well.</p>
| 28,804 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.