instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I have a 3d object that I wish to be able to rotate around in 3d. The easiest way is to directly translate X and Y mouse motion to rotation about the Y and X axes, but if there is some rotation along both axes, the way the model rotates becomes highly counterintuitive (i.e. if you flip the object 180 degrees about ... | <p>Create an accumulator matrix and initialize it with the identity.</p>
<p>Each frame, apply that to your modelview/world matrix state before drawing the object.</p>
<p>Upon mouse motion, construct a rotation matrix about the X axis with some sensitivity_constant * delta_x. Construct another rotation matrix about t... | <p>You can deal with loss of precision by renormalising your rotation matrix so each of the 3 rows are perpendicular again. Or you can regenerate the rotation matrix you are about to modify based on existing information about the object, and this takes away the need for renormalisation. </p>
<p>Alternatively you can u... | 13,290 |
<p>I am developping in C#.
I need to capture a password written inside a Text Box, but would like to not show the password that is being typed, showing instead **** or any other character to hide the password.</p>
<p>How can I do that? I'm sure it's by modifying an attribute, but can't find which one.</p>
| <p><a href="http://msdn.microsoft.com/en-us/library/d3223ht2.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/d3223ht2.aspx</a></p>
<p>set the PasswordChar property of the textbox</p>
| <p>There is a property on the TextBox class called "UseSystemPasswordChar" (assuming winforms) that let you do this.</p>
| 45,729 |
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/71419/whats-wrong-with-delphis-with">What's wrong with Delphi's “with”</a> </p>
</blockquote>
<p>I am have a problem debugging code that uses a ‘WITH’ statement in BDS 2006
The debugger will... | <p><code>With</code> is considered by many one of those language features that falls into the "just because you have it doesn't mean you have to use it" category. There are <em>very</em> few occasions where I'd give it house-room - I've found one or two cases where it's use is essential when using extremely complex mu... | <p><strong>With</strong> is not a bad practice at all. The only bad thing is that you can not debug easily that lines, but if you use it carefully there is no problem at all. May be its not a good practice for juniors, but if you know where to use it, its just ok.</p>
<p>Lets EMBA improve it in any way they can to avo... | 40,254 |
<p>When exporting an STL from Fusion 360, one must select an STL refinement level to use for calculating the maximum triangle count. </p>
<p>For FDM printing (<em>0.05mm and above layer heights</em>), where is the point of diminishing returns on STL refinement level when printing PLA and PETG on an Ender 3 with a 0.4m... | <p>I don't know that this can be definitively answered for a specific printer and all arbitrary designs.</p>
<p>The refinement level basically determines how smooth a curved surface will turn out. The STL file format can only express an object in terms of triangular-shaped surfaces, so Fusion 360 will need to approxi... | <p>If you print for example a thin wall cylinder vertically you cannot turn the refinement high enough to not see the flats on the surface. My triangle counts are 524 for Low, 828 for Medium, 2206 for High, and if you select custom and pull the surface deviation slider all the way to the left you get 6572 triangles. ... | 1,058 |
<p>I would like to discover the type of the NAT (FullCone, Restricted Cone, Port Restricted cone, Symmetric) a given network interface is behind. </p>
<p>I've tested different tools (<a href="http://freshmeat.net/projects/jstun/" rel="noreferrer">http://freshmeat.net/projects/jstun/</a>, <a href="http://code.google.c... | <p>I second the answer from @S.Lott: It is not possible to use STUN (or any other protocol) to determine with 100% certainty what type of NAT you're behind.</p>
<p>The problem is (as I witnessed recently) that the NAT may sometimes act as <a href="https://www.rfc-editor.org/rfc/rfc4787#section-4.1" rel="nofollow norefe... | <p>As @S.Lott 's say, STUN is your first choice protocol .</p>
<p>And then, STUN is just a protocol.Here is my advice:</p>
<p>1 <strong>STUN</strong> now has two version : the old version is <a href="http://www.ietf.org/rfc/rfc3489.txt" rel="nofollow">RFC3489</a> - this is a lightweight protocol that allows applicat... | 48,282 |
<p>I'm currently experimenting with build script, and since I have an ASP.net Web Part under source control, my build script should do that at the end:</p>
<ol>
<li>Grab the "naked" Windows 2003 IIS VMWare or Virtual PC Image from the Network</li>
<li>Boot it up</li>
<li>Copy the Files from the Build Folder to the Ser... | <p>With VMWare, there is the <a href="http://www.vmware.com/support/developer/vix-api/" rel="noreferrer">Virtual Machine Automation APIs (VIX API)</a>. You can find the reference guide <a href="http://pubs.vmware.com/vix-api/ReferenceGuide/" rel="noreferrer">here</a>. It works with VMWare Server and WorkStation, but ... | <p>VirtualBox also has API's for automating their VM's.</p>
| 2,671 |
<p>I'm writing a small app for my friend's business, and thought I'd take the opportunity to brush up on some Agile Project Management training I did at the start of the year.</p>
<p>I (and I think, my current organisation!) have always struggled with gathering requirements in the form of User Stories, which take the ... | <p>We used to miss it out as well. And by leaving it out we missed a lot.
To understand the feature properly and not just do the thing right but DO THE RIGHT THING it is key to know WHY the feature, and for that the next key is WHO (the role)
In DDD terms, stakeholder. Stakeholders can be different, everyone who cares... | <p>I think you should really try to get a reason defined, even if it may seem obvious. If you can't come up with a reason then why build the feature in the first place? Also the reason may point out other deficiencies in the design that could trigger improvements in other areas.</p>
| 38,437 |
<p>My company develop web apps using combination of mod_perl, axkit and apache.
We have tons of Perl modules, javascripts, etc, all in unix operating system.</p>
<p>Whenever I need to write a new function, I try to do some code reuse, but the thing is all the Perl modules and javascripts are scattered across folders.<... | <p><strong>Organize</strong> your source directory so that each functionality has only one place where it should be and it's easy to find something.</p>
<p>Make sure to share <strong>naming convention</strong> to prevent duplication. </p>
<p><strong>Design</strong> your module so that they do one thing only - and do... | <p>I've once worked in a company that used Perl, and have similar problems. The solution we come up with, was to reorganize the functions in files, taking in consideration a 3-tier architecture (presentation, business and persistence), and the elements being manipulated.</p>
<p>So, we have one perl file to each main t... | 48,443 |
<p>What are some C++ related idioms, misconceptions, and gotchas that you've learnt from experience?</p>
<p>An example:</p>
<pre><code>class A
{
public:
char s[1024];
char *p;
A::A()
{
p = s;
}
void changeS() const
{
p[0] = 'a';
}
};
</code></pre>
<p>Even know changeS is a const member ... | <p>You don't need to know C++'s complicated function typedef declaration syntax. Here's a cute trick I found.</p>
<p>Quick, describe this typedef:</p>
<pre><code>typedef C &(__cdecl C::* const CB )(const C &) const;
</code></pre>
<p>Easy! CB is a pointer to a member function of class C accepting a const refe... | <p>I can't say that I am an experienced C++ programmer but I have recently learned how hard it is to pass and array of arrays as a function parameter. Try to avoid this at all cost :(</p>
<p>If you know the size at compile its simple. Even if you know one of the dimensions at compile time.
If you simply don't know... ... | 37,536 |
<p>I'm having a problem using the java.text.MessageFormat object.</p>
<p>I'm trying to create SQL insert statements. The problem is, when I do something like this:</p>
<pre><code>MessageFormat messageFormat = "insert into {0} values ( '{1}', '{2}', '{3}', {4} )";
Object[] args = { str0, str1, str2, str3, str4 };
St... | <p>I just tried double quotes and it worked fine for me:</p>
<pre><code>MessageFormat messageFormat = new MessageFormat("insert into {0} values ( ''{1}'', ''{2}'', ''{3}'', {4} )");
Object[] args = {"000", "111", "222","333","444","555"};
String result = messageFormat.format(args);
</code></pre>
<p>The result is:</p>... | <p>First thing that came to mind was to change str1, str2, str3 to have the single quotes around them.</p>
<pre>
Object[] args = { str0, "'" + str1 + "'", "'" + str2 + "'", "'" + str3 + "'", str4 };
</pre>
<p>Then, of course, remove the single-quotes from your query string.</p>
| 23,039 |
<p>I'm not sure what the best api for simple 2d graphics with Java is. I know <code>java.awt.Graphics2D</code> was the standard but has it been replaced? Swing is the new API for Java GUI apps but it seems a bit heavy for what I want. What I really want is something like the C <a href="http://libsdl.org/" rel="noreferr... | <p><a href="http://docs.oracle.com/javase/tutorial/2d/" rel="noreferrer">Java 2D</a> (<code>Graphics2D</code> and friends) is indeed the best choice that I know of. Swing is actually implemented on top of Java 2D, so yes, if you want non-GUI-type graphics, Java 2D is the way to go.</p>
| <p><a href="http://code.google.com/p/piccolo2d/" rel="nofollow">Piccolo</a> can be a good choice for drawing graphics. It is a 2D graphics toolkit that supports zoomable user interface. Available for both Java and .Net.</p>
| 25,494 |
<p>just a quick question, if I have a matrix has n rows and m columns, how can I cut off the 4 sides of the matrix and return a new matrix? (the new matrix would have n-2 rows m-2 columns).</p>
<p>Thanks in advance</p>
| <pre><code>a[1:-1, 1:-1]
</code></pre>
| <p>A more general answer is:</p>
<pre><code>a[[slice(1, -1) for _ in a.shape]]
</code></pre>
| 47,708 |
<p>(Eclipse 3.4, Ganymede)</p>
<p>I have an existing Dynamic Web Application project in Eclipse. When I created the project, I specified 'Default configuration for Apache Tomcat v6' under the 'Configuration' drop down.</p>
<p>It's a month or 2 down the line, and I would now like to change the configuration to Tomcat ... | <p>This is kind of hacking eclipse and you can get into trouble doing this but this should work:</p>
<p>Open the navigator view and find that there is a .settings folder under your project expand it and then open the file: <code>org.eclipse.wst.common.project.facet.core.xml</code> you should see a line that says:
<co... | <p>If you are using maven you can generated the eclipse settings using the maven eclipse plugin. </p>
<p>For the jst.web version the Maven eclipse pluging takes into account the dependencies of the project. If you have a servlet api dependency defined :</p>
<pre><code><dependency>
<groupId>org.apache.... | 10,145 |
<p>Using CuraEngine with my Ender 3, I'm getting what I'd call inconsistent inner and outer dimensions - for example, a nominally 3 mm peg is significantly larger than a 3 mm hole, and it takes dimensions something like 2.9 mm for the peg and 3.1 mm for the hole to get them to fit. Is this level of ... | <p>Filament expands slightly as it is extruded. Also, the width of the extrusion depends on the volume of plastic extruded (not the nozzle size), as well as the amount that it is "squidged" down. Some slicers (e.g. Simplify3D) allow you to specify the width of the extrusion that you desire, but I'm not sure if Cura doe... | <p>Cura does correctly account for line extrusion widths wheen positioning the lines, and attempting to fix this with negative <code>xy_offset</code> was a mistake that led to lots of problems: in some cases, it completely eliminated tiny components of the model and left gaps in layers. At some point after asking this ... | 1,212 |
<p>Does Java Connection.close rollback into a finally block?.</p>
<p>I know .Net SqlConnection.close does it.</p>
<p>With this I could make try/finally blocks without catch...</p>
<p>Example:</p>
<pre><code>try {
conn.setAutoCommit(false);
ResultSet rs = executeQuery(conn, ...);
....
executeNonQuery... | <p>According to <a href="http://java.sun.com/javase/6/docs/api/java/sql/Connection.html#close()" rel="noreferrer">the javadoc</a>, you should try to either commit or roll back before calling the close method. The results otherwise are implementation-defined.</p>
| <p>It is useless to rollback in finally block. After you commit, and commit is successful, why to roll back? So if i were you, i would rollback in catch block. </p>
| 26,864 |
<p>I would like to be able to, as part of a maven build, set the build number (doesn't matter exactly what) in a properties file/class (so I can show it in a UI). Any ideas? </p>
| <p>We used the <a href="http://mojo.codehaus.org/buildnumber-maven-plugin/" rel="nofollow noreferrer">Build Number Plugin</a> now available from Codehaus. It can generate a sequential build number or allows you to use the time stamp.</p>
| <p>I use the maven-property-plugin to store the CruiseControl build label in a properties file (the build label is is available as a system property named 'label').</p>
<p><a href="http://weblogs.java.net/blog/johnsmart/archive/2008/03/using_hudson_en.html" rel="nofollow noreferrer">A post</a> on how to do this with H... | 14,635 |
<p>I need to store encrypted data (few small strings) between application runs. I do not want the user to provide a passphrase every time (s)he launches the application. I.e. after all it goes down to storing securely the encryption key(s).</p>
<p>I was looking into RSACryptoServiceProvider and using PersistentKeyInCs... | <p>The Data Protection API (DPAPI) does exactly what you want. It provides symmetric encryption of arbitrary data, using the credentials of the machine or (better) the user, as the encryption key. You don't have to worry about managing the keys; Windows takes care of that for you. If the user changes his password, W... | <p>I'd like to add to the DPAPI approach.</p>
<p>Although I haven't implemented the user-store approach myself, there is Microsoft documentation for a user-store approach which encrypts and decrypts data for a specific user.</p>
<p>I used the DPAPI using machine store. I'll describe it in case it fits with what you'... | 18,663 |
<p>I have an application for which log4j logging is configured in a log4j.properties file. Currently, this application runs on UNIX and creates a log file in /tmp. This application needs to run on Windows, and on that platform I would like for it to select the correct temporary directory, which I believe is C:\temp.<... | <p>I think you would just use <code>${java.io.tmpdir}</code> in place of a hard-coded path.</p>
| <p>As of Log4J v1.2.14, I was able to use this in both a log4j.xml file as well as a log4j.properties file. There was some discussion on the web that variables wouldn't parse in the DOMReader, but they do as of this version of log4j.</p>
<pre><code><appender name="rolling_file_appender_ourapp" class="org.apache.lo... | 40,621 |
<p>Is there a method of accessing an Exchange server that does not have <code>IMAP</code> or <code>POP3</code> enabled without Outlook?</p>
<p>It does not appear that Outlook Express supports Exchange (only <code>IMAP and POP3</code>).</p>
| <p>The only way I can think of is if the Exchange server has Outlook Web Access (OWA) turned on. You can test this by trying the server name in your browser like so: <a href="http://server/exchange" rel="nofollow noreferrer">http://server/exchange</a>.</p>
<p>If you mean programmatically then the recommended way is to... | <p>You can use <a href="http://www.mozilla.com/en-US/thunderbird/" rel="nofollow noreferrer">Thunderbird</a> to <a href="http://www.downloadsquad.com/2007/03/30/howto-thunderbird-and-ms-exchange-server/" rel="nofollow noreferrer">access Exchange e-mail and contact lists</a>.</p>
<p>Edit - Oops, this uses IMAP, didn't ... | 3,914 |
<p>Suppose I want to implement in C++ a data-structure to store oriented graphs. Arcs will be stored in Nodes thanks to STL containers. I'd like users to be able to iterate over the arcs of a node, in an STL-like way.</p>
<p>The issue I have is that I don't want to expose in the Node class (that will actually be an a... | <p>Try this:</p>
<pre><code>class Arc;
class Node {
private:
std::vector<Arc*> incoming_;
public:
typedef std::vector<Arc*>::iterator iterator;
iterator incoming_arcs_begin()
{ return incoming_.begin(); }
};
</code></pre>
<p>And use Node::iterator in the rest of the code. When/if you change the c... | <p>If you really don't want the client's of that class to know that it uses a vector underneath, but still want them to be able to somehow iterate over it, you most likely will need to create a class that forwards all its methods to std::vector::iterator.</p>
<p>An alternative would be to templatize Node based on the ... | 15,456 |
<p>There's a common way to store multiple values in one variable, by using a bitmask. For example, if a user has read, write and execute privileges on an item, that can be converted to a single number by saying <code>read = 4 (2^2), write = 2 (2^1), execute = 1 (2^0)</code> and then add them together to get 7.</p>
<p>... | <p>Off the top of my head, I'd write a <code>set_bit</code> and <code>get_bit</code> function that could take an array of bytes and a bit offset in the array, and use some bit-twiddling to set/get the appropriate bit in the array. Something like this (in C, but hopefully you get the idea):</p>
<pre class="lang-c prett... | <p>For example .NET uses array of integers as an internal storage for their BitArray class.
Practically there's no other way around.</p>
<p>That being said, in SQL you will need more than one column (or use the BLOBS) to store all the states.</p>
| 21,325 |
<p>I've just started using Java's enums in my own projects (I have to use JDK 1.4 at work) and I am confused as to the best practice of using JavaDoc for an enum.</p>
<p>I have found that this method works, but the resultant code is a little unrefined:</p>
<pre><code>/**
* Doc for enum
*/
public enum Something {
/**
... | <p>To answer the first part of your question, you do have to separate each enum value with a comma. As far as I know, there's no way around that.</p>
<p>Personally I don't have a problem with the code the way you've presented it. Seems like a perfectly reasonable way to document an enum to me.</p>
| <p>There is a google code search online tool -- <a href="http://www.google.com/codesearch" rel="nofollow noreferrer">http://www.google.com/codesearch</a></p>
<p>I try to lookup stuff by doing something like <a href="http://www.google.com/codesearch#search&q=lang:java+public+enum" rel="nofollow noreferrer">"lang:ja... | 23,692 |
<p>It's possible to write <a href="http://en.wikipedia.org/wiki/Markdown" rel="noreferrer">Markdown</a> content with invalid syntax. Invalid means that the <a href="http://www.deveiate.org/projects/BlueCloth" rel="noreferrer">BlueCloth</a> library fails to parse the content and throws an exception. The <code>markdown</... | <p>You should write your own validation method in which you would initialize BlueCloth object, and try to call <code>to_html</code> method catching any exception. If you catch an exception, validation fails, otherwise it should be ok.</p>
<p>In your model:</p>
<pre><code>protected:
def validate
bc = BlueCloth.new(... | <p>I've done a bit of research and decided to use <a href="http://github.com/rtomayko/rdiscount/tree/master" rel="nofollow noreferrer">RDiscount</a> instead of BlueCloth. RDiscount seems to be much faster and more reliable than BlueCloth.</p>
<p>It's easy to integrate RDiscount in your Rails environment. Include the f... | 29,334 |
<p>I'm a fan of SVN and I am comfortable setting up my own svn repository, but I'm wondering if there are better options than creating a separate repository.</p>
<p>Basically I'm just looking for a way to keep track of or roll back changes before my code is reviewed and checked in to the main repository (SourceSafe). ... | <p>Most distributed version control systems unify the concepts of <em>working copy</em> and <em>repository</em>. In other words: the working copy <em>is</em> the repository.</p>
<p>If you want to put a source tree under version control, in most DVCSs it's as simple as</p>
<ol>
<li><code>cd $PROJECT</code></li>
<li><c... | <p>I am developing a product that may be perfect for you.</p>
<p>It's called "Transactor Code Agent".
It's designed to automatically maintain local source code history.</p>
<p>You point it at the folders where you keep your code, and it automatically makes a backup every time you change a file. You can diff versions,... | 47,939 |
<p>If I need to copy a stored procedure (SP) from one SQL Server to another I right click on the SP in SSMS and select Script Stored Procedure as > CREATE to > New Query Editor Window. I then change the connection by right clicking on that window and selecting Connection > Change Connection... and then selecting the ne... | <p>Also, make sure when you write the query involving the linked server, you include brackets like this:</p>
<pre><code>SELECT * FROM [LinkedServer].[RemoteDatabase].[User].[Table]
</code></pre>
<p>I've found that at least on 2000/2005 the [] brackets are necessary, at least around the server name.</p>
| <p>If possible, check out SSIS (SQL Server Integration Services). I am just getting my feet wet with this toolkit, but already am looping over 40+ servers and preparing to wreak all kinds of havoc ;)</p>
| 15,248 |
<p>I just want to clarify one thing. This is not a question on which one is better, that part I leave to someone else to discuss. I don't care about it.
I've been asked this question on my job interview and I thought it might be useful to learn a bit more.</p>
<p>These are the ones I could come up with:</p>
<ul>
<li>... | <p><strong>Comparing Java 7 and C# 3</strong></p>
<p>(Some features of Java 7 aren't mentioned here, but the <code>using</code> statement advantage of all versions of C# over Java 1-6 has been removed.)</p>
<p>Not all of your summary is correct:</p>
<ul>
<li>In Java methods are virtual <em>by default</em> but you ca... | <p>Please go through the link given below
msdn.microsoft.com/en-us/library/ms836794.aspx
It covers both the similarity and difference between C# and java</p>
| 37,721 |
<p>I've tried variations of this, but had no luck other than the ability to start a cygwin window. (wrapped on <strong>;</strong> for clarity)</p>
<pre><code>Filename: "c:\cygwin\bin\bash.exe";
Parameters: "-c c:/scripts/step1.sh paramX";
Flags: shellexec waituntilterminated;
StatusMsg: "Running the script..."
<... | <p>Your problem is that <code>-c</code> tells bash to read instructions from the next parameter:
e.g.</p>
<pre><code>c:\cygwin\bin\bash.exe -c 'for NUM in 1 2 3 4 5 6 7 8 9 10; do echo $NUM; done'
</code></pre>
<p>you just need:</p>
<pre><code>c:\cygwin\bin\bash.exe "/scripts/step1.sh paramX"
</code></pre>
<p>So yo... | <p>I think you're going to need to make the whole thing part of a <code>cmd.exe</code> invocation, and then I'm not sure it will do exactly what you want/need.</p>
<p>I'm looking at Inno-Setup 5 documentation (may be out-of-date), but I don't think you need the <code>shellexec</code> or <code>waituntilterminated</code... | 31,724 |
<p>Env.: VS 2008, .NET 2.0, WinForms</p>
<p>I have a listview in Tile mode. Some items have an associated image. Some don't.</p>
<p>The contents (listview items) is often renewed when user clicks some controls. When this happens, it sometimes appears that none of the new items have images. In that case, I would like ... | <p>Are you sure? I've got it working in this test case:</p>
<pre><code>using System;
using System.Windows.Forms;
public class MainForm : Form
{
private System.ComponentModel.IContainer components = null;
private System.Windows.Forms.ListView listView;
private System.Windows.Forms.ImageList emptySmallImageL... | <p>If you want complete control, use the listview.drawitem event.</p>
| 40,908 |
<p>I recently received an email from my girlfriend that spamassassin marked as spam, mostly because spamassassin detected a tracker ID... except there wasn't one. I'd like to know what triggered it, so that I can report a sensible bug.</p>
| <p>It looks as if new_task_attributes= is expecting an array of hashes, but you're passing it a hash. Try this:</p>
<pre><code>def test_adding_task_to_project
p = Project.new
new_tasks_attributes = [{ "name" => "paint fence"}]
p.new_tasks_attributes = (new_tasks_attributes)
p.save
assert p.tasks.length ==... | <p>Can we see the whole stack trace? Where does it think String#stringify_keys! is being called?</p>
<p>Also, params looks odd to me. Is tasks.build() expecting input like this: <code>["new_tasks_attribute", {"name" => "paint fence"}]</code> ?</p>
<p>If not, maybe you actually want Hash#each_key() instead of Hash#... | 11,873 |
<p>I have a dl containing some input boxes that I "clone" with a bit of JavaScript like: </p>
<pre><code>var newBox = document.createElement('dl');
var sourceBox = document.getElementById(oldkey);
newBox.innerHTML = sourceBox.innerHTML;
newBox.id = newkey;
document.getElementById('boxes').appendChild(col... | <p>You could try the <code>cloneNode</code> method. It might do a better job of copying the contents. It should also be faster in most cases</p>
<pre><code>var newBox;
var sourceBox = document.getElementById(oldkey);
if (sourceBox.cloneNode)
newBox = sourceBox.cloneNode(true);
else {
newBox = document.createE... | <p>You could try the <code>cloneNode</code> method. It might do a better job of copying the contents. It should also be faster in most cases</p>
<pre><code>var newBox;
var sourceBox = document.getElementById(oldkey);
if (sourceBox.cloneNode)
newBox = sourceBox.cloneNode(true);
else {
newBox = document.createE... | 9,509 |
<p>I need to automatically copy files from a linux machine to a windows one every day. </p>
<p>I'm looking for something simple and secure like scp, rsync, sftp. Unfortunately, I'm at a loss of how to set this up on the Windows machine.</p>
<p>Does anyone know how to do this?</p>
| <p>You can try mounting the Windows drive as a mount point on the Linux machine, using smbfs; you would then be able to use normal Linux scripting and copying tools such as cron and scp/rsync to do the copying.</p>
| <p>You may try <a href="http://winscp.net/" rel="nofollow noreferrer">WinSCP</a> and its <a href="http://winscp.net/eng/docs/scripting" rel="nofollow noreferrer">scripting support</a>. And Windows support some kind of cron-like operation in its management stuff, don't they?</p>
| 36,914 |
<p>I have an option to purchase a hobby multi-purpose device (lathe/mill/drill/grinder/cutter) which is manually controlled, but easily converted for driving by stepper motors (all 3 axis are controlled by turning knobs that can be replaced by gears, with convenient mount to couple each to a stepper motor). I have the ... | <h2>Disclaimer</h2>
<p>Questions about other machines is still in kind of a grey area right now <sup>06/2016</sup> and your question is, in my opinion, a bit too broad. However, I think it's a great topic to perhaps help direct the scope of this community.</p>
<h2>The lowdown</h2>
<ol>
<li>3D printers, CNC Mills, CNC L... | <p>I haven't done this myself. But the temperature safeguards only apply to the 4th, the E axis for the filament. So configuring the right steps per mm would get you started.</p>
<p>The question is more what do you want to do with it and where do you get the G-Code to do that. You can not use a slicer to generate the ... | 324 |
<p>Ok, so I have a Rails app set up on DreamHost and I had it working a while ago and now it's broken. I don't know a lot about deployment environments or anything like that so please forgive my ignorance. Anyway, it looks like the app is crashing at this line in config/environment.rb:</p>
<pre><code>require File.jo... | <p>I had the same problem on DreamHost. Freezing rails and unpacking all gems got me past it.</p>
<pre><code>rake rails:freeze:gems
rake gems:unpack:dependencies
</code></pre>
| <p>Ya - the problem is not really in <code>boot.rb</code> - it's just that <code>boot.rb</code> is where rails is actually loaded.</p>
<p>So you'll get an error like this if you've specified a version of Rails that just doesn't exist on your dreamhost slice. This can happen if you either upgrade your project, start a ... | 27,742 |
<p>I've been asked to add Google e-commerce tracking into my site. This tracking involves inserting some javascript on your receipt page and then calling it's functions. From my asp.net receipt page, I need to call one function (_addTrans) for the transaction info and then another (_addItem) for each item on the orde... | <p>Probably the easiest way is to build up the required Javascript as a string with something like </p>
<pre><code>StringBuilder sb = new StringBuilder()
sb.AppendLine( "<script>" );
sb.AppendLine( "var pageTracker = _gat._getTracker('UA-XXXXX-1');" );
sb.AppendLine( "pageTracker._trackPageview();" );
sb.AppendF... | <p>In response to stevemegson (first answer) - shouldn't the first parameter into the pageTracker._addItem method be the OrderID, not the itemNumber?</p>
| 33,838 |
<p>We have a typical web application that is essentially a data entry application with lots of screens some of which have some degree of complexity. We need to provide that standard capability on making sure if the user forgets to click the "Save" button before navigating away or closing their browser they get a warni... | <p>One piece of the puzzle:</p>
<pre><code>/**
* Determines if a form is dirty by comparing the current value of each element
* with its default value.
*
* @param {Form} form the form to be checked.
* @return {Boolean} <code>true</code> if the form is dirty, <code>false</code>
* ... | <p>I made one more slight improvement to the jQuery implementations listed on this page. My implementation will handle if you have <strong>client-side ASP.NET page validation</strong> enabled and being used on a page.</p>
<p>It avoids the "error" of clearing the <code>onBeforeLeave</code> function when the page doesn'... | 16,984 |
<p>I'm having some trouble with plain old JavaScript (no frameworks) in referencing my object in a callback function.</p>
<pre><code>function foo(id) {
this.dom = document.getElementById(id);
this.bar = 5;
var self = this;
this.dom.addEventListener("click", self.onclick, false);
}
foo.prototype = {
... | <p><em>(extracted some explanation that was hidden in comments in other answer)</em></p>
<p>The problem lies in the following line:</p>
<pre><code>this.dom.addEventListener("click", self.onclick, false);
</code></pre>
<p>Here, you pass a function object to be used as callback. When the event trigger, the function is... | <p>this is one of the most confusing points of JS: the 'this' variable means to the most local object... but functions are also objects, so 'this' points there. There are other subtle points, but i don't remember them all.</p>
<p>I usually avoid using 'this', just define a local 'me' variable and use that instead.</p... | 22,150 |
<p>What is your suggested solution for the threat of website UI spoofing?</p>
| <p>By definition any solution that relies on the site showing you personalised information <em>once you've logged in</em> is ineffective against phishers. If you've attempted to login, <strong>they've already succeeded</strong>!</p>
<p>FWIW, I don't yet know the real answer, maybe this question will throw up some goo... | <p>I've seen some sites that let you select a "personal" icon. Whenever you log in, that icon is displayed as proof that you are on their site.</p>
| 44,842 |
<p>I am trying to install Php on Vista (IIS 7). The installation and configuration seems to be fine. Pretty much followed everything mentioned in <a href="http://blogs.iis.net/bills/archive/2006/09/19/How-to-install-PHP-on-IIS7-_2800_RC1_2900_.aspx" rel="nofollow noreferrer">http://blogs.iis.net/bills/archive/2006/09/1... | <p>In your PHP.INI file, try to comment all the extensions lines and restart IIS. Take note that MySql will no longer work. Do some tests.</p>
<p>If it's successfull, uncomment back the mySql line. Do some tests.</p>
<p>If it's unsucessfull, them I can't help you more. I suspect that's a loaded extension causing the ... | <p>Try moving the libmysql.dll that came with php to windows\system32</p>
| 18,644 |
<p>We have a page that ordinarily has two elements arranged side-by-side. Despite exploring a few angles for this, we can't seem to make it work. We're not averse to using JavaScript, it just feels that a CSS based solution ought to be possible. Is there a way of using just CSS (and possibly extra markup if necessary) ... | <p>There is a pure css solution, however it won't work in versions of IE less than 7 because it won't understand the sibling selector (+), for that you may want to consider a JavaScript solution (perhaps Dean Edwards' <a href="http://dean.edwards.name/IE7/" rel="nofollow noreferrer">IE7</a>). Anyway, some example css:<... | <p>A strict CSS2 solution:</p>
<pre><code>#container {
text-align:center;
}
#element1, #element2 {
display:inline-block;
}
</code></pre>
<p>The inner elements should layout like inline text inside #container, but remain blocks inside.</p>
<p>This is standard CSS, but getting browser support might take <a hre... | 33,195 |
<p>Using C#, is there any way to hook into a running application (my own app) and get an instance of a class? As it stands right now I'm doing this</p>
<pre><code>// Find the IAutomation interface.
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
if (!type.IsAbstract && type.GetInterfac... | <p>You can use <a href="http://msdn.microsoft.com/en-us/library/kwdt6w2k(VS.85).aspx" rel="nofollow noreferrer">remoting</a>, or make your existing instance a COM server, and use COM interop to the existing instance.</p>
<p>Maybe there are some debugging API's that you can use as well, but that I would not consider cl... | <p>If there's an existing instance of the IAutomation interface in the AppDomain there must be something pointing to it otherwise it would be garbage collected. So you will need to identify what is pointing to the instance and use it to get the instance. You should ask yourself questions such as: Who created the instan... | 49,727 |
<p>How can I use Hyperlink button in gridview. I mean when I run my program,all data is displayed in gridview,but I want hyperlink in gridview, so that when I will click in hyperlink it will show the select path which is in gridview : if there is pdf file path and I just click on this hyper link then I can see the pdf ... | <p>You need to use a template field. e.g. lets say you're column is called 'PdfUrl'</p>
<p>Then add a column to your datagrid. that looks like</p>
<pre><code><asp:TemplateField HeaderText="Link" SortExpression="PdfUrl">
<itemtemplate>
<asp:HyperLink runat="server" ID="hlkPDF" NavigateURL='&... | <p>Here is what i would do</p>
<p>
"
SelectCommand="SELECT * FROM [Customers]"> </p>
<p>Then for the test.aspx page i would have a datasource like this</p>
<pre><code><asp:SqlDataSource ID="S... | 31,523 |
<p>There are situations, where it is practical to have a type-cast return a null value instead of throwing a ClassCastException. C# has the <code>as</code> operator to do this. Is there something equivalent available in Java so you don't have to explicitly check for the ClassCastException?</p>
| <p>Here's an implementation of as, as suggested by @Omar Kooheji:</p>
<pre><code>public static <T> T as(Class<T> clazz, Object o){
if(clazz.isInstance(o)){
return clazz.cast(o);
}
return null;
}
as(A.class, new Object()) --> null
as(B.class, new B()) --> B
</code></pre>
| <p>I'm speculating you could propably creas an as operator </p>
<p>something like </p>
<pre><code>as<T,Type> (left, right)
which evaluates to
if (typeof(left) == right)
return (right)left
else
return null
</code></pre>
<p>I'm not sure how you'd do it, I'm a c# at the moment and my Java hat has gotten... | 17,928 |
<p>In C++ Windows app, I launch several long running child processes (currently I use CreateProcess(...) to do this. </p>
<p>I want the child processes to be automatically closed <strong>if my main processes crashes</strong> or is closed.</p>
<p>Because of the requirement that this needs to work for a crash of the "p... | <p>The Windows API supports objects called "Job Objects". The following code will create a "job" that is configured to shut down all processes when the main application ends (when its handles are cleaned up). This code should only be run once.:</p>
<pre class="lang-cpp prettyprint-override"><code>HANDLE ghJob = Create... | <p>You'd probably have to keep a list of the processes you start, and kill them off one by one when you exit your program. I'm not sure of the specifics of doing this in C++ but it shouldn't be hard. The difficult part would probably be ensuring that child processes are shutdown in the case of an application crash. ... | 7,664 |
<p>We use a CruiseControl.Net/NAnt/Subversion stack for CI. Doing a fresh checkout for every build is way too time-consuming, so currently we just do an update on a working copy. However, this leaves the possibility that orphaned files may remain in the working copy, after being deleted in source control. We have tried... | <p>If you do just 'update', SVN will delete all the files that were deleted in the source control. However files that were created during build process might still be there and might interfere with new build. I'm not sure if SVN has a command to delete them but I guess you could do that with a little script, SVN defini... | <p>If there are orphaned files left in your working copy having done an svn update then there's a bug in your Subversion version.</p>
| 11,775 |
<p>I'm using Parsley IoC in my current Flex project. So I'd like to embed the container configuration XML onto the result SWF. </p>
<p>How could I load embedded XML file into action script XML object?</p>
| <p>I think the problem is that sendmail (your process) is talking to the local sendmail daemon. The local sendmail daemon thinks that because it is website.com, it should know how to deliver the email. Unfortunately, the actual address in the to field does not exist on the web server and thus it dumps it in the "cat... | <p>Edit the tsm.cf file (in /etc/mail/ or similar) to include </p>
<pre><code>FEATURE(relay_entire_domain)
</code></pre>
<p>between the DOMAIN() and MAILER() lines. Since you're editing the file, you may want to also improve security with </p>
<pre><code>define(`confPRIVACY_FLAGS',``noexpn,novrfy'')
</code></pre>
... | 41,762 |
<p>I've got a column in a table (eg. UserName) which I want to make sure is unique. So I create a unique key for that column and call it IX_Users_UserName.</p>
<p>Now, if I do lots of searching for users based on their username I want to make sure there is an index for that field.</p>
<p>Do I need to create a separat... | <blockquote>
<p>Unique Key: Unique Key enforces
uniqueness of the column on which they
are defined. Unique Key creates a
non-clustered index on the column.
Unique Key allows only one NULL Value.</p>
<p>Alter table to add unique constraint
to column:</p>
<p>ALTER TABLE Authors ADD CONSTRAINT
IX_A... | <p>A unique key is an index in I suspect almost every database product. It has to be, otherwise the database would have a hard time enforcing it: when you insert a value, the database has to answer, "does that value already exist?" The sane way to do that is consult an index.</p>
<p>I don't have a SQL Server in front ... | 47,799 |
<p>We have a small embedded system without any video or serial ports (i.e. we can't output text via printf).<br>
We would like to track the progress of our code through the initialization sequence.<br>
Is there some simple things we can do to help with this.<br>
It is not running any OS, and the hardware platform is so... | <p>The simplest most scalable solution are state LEDs. Toggle LEDs based on actions, either in binary form or when certain actions occur if you can narrow your focus.</p>
<p>The most powerful will be a hardware JTAG device. You don't even need to set breakpoints - simply being able to stop the application and inspect ... | <p>A JTAG debugger is also an option, though cumbersome to set up.</p>
| 9,488 |
<p>What is the maximum value of an int in ChucK? Is there a symbolic constant for it?</p>
| <p>New in the latest version!</p>
<pre><code><<<Math.INT_MAX>>>;
</code></pre>
<p>For reference though, it uses the "<code>long</code>" keyword in C++ to represent integers.
So on 32-bit computers the max should be <code>0x7FFFFFFF</code>, or <code>2147483647</code>.
On 64-bit computers it will be <... | <p><a href="http://chuck.cs.princeton.edu/doc/program/stdlib.html" rel="nofollow noreferrer">The ChucK API reference</a> uses the C <code>int</code> type, so the maximum value would depend on your local machine (2^31-1, around two billion on standard 32-bit x86). I don't see any references to retrieving limits, but if ... | 12,385 |
<p>I need to store a double as a string. I know I can use <code>printf</code> if I wanted to display it, but I just want to store it in a string variable so that I can store it in a map later (as the <em>value</em>, not the <em>key</em>).</p>
| <p>The <em>boost (tm)</em> way:</p>
<pre><code>std::string str = boost::lexical_cast<std::string>(dbl);
</code></pre>
<p>The <em>Standard C++</em> way:</p>
<pre><code>std::ostringstream strs;
strs << dbl;
std::string str = strs.str();
</code></pre>
<p><strong>Note</strong>: Don't forget <code>#include &... | <p>You could try a more compact style:</p>
<pre><code>std::string number_in_string;
double number_in_double;
std::ostringstream output;
number_in_string = (dynamic_cast< std::ostringstream*>(&(output << number_in_double <<
std::endl)))->str();
</code></pre>
| 43,022 |
<p>We recently attempted to break apart some of our Visual Studio projects into libraries, and everything seemed to compile and build fine in a test project with one of the library projects as a dependency. However, attempting to run the application gave us the following nasty run-time error message:</p>
<blockquote>
... | <p>This debug error means that the stack pointer register is not returned to its original value after the function call, i.e. that the number of <em>pushes</em> before the function call were not followed by the equal number of <em>pops</em> after the call.</p>
<p>There are 2 reasons for this that I know (both with dyn... | <p>ESP is the stack pointer. So according to the compiler, your stack pointer is getting messed up. It is hard to say how (or if) this could be happening without seeing some code.</p>
<p>What is the smallest code segment you can get to reproduce this?</p>
| 17,235 |
<p>We're running into issues with how we specify font sizes. If we specify the font sizes using pt, they don't always look the same across browsers/platforms. If we specify font sizes using px, IE6 users can't resize the text.</p>
| <p><a href="http://www.alistapart.com/articles/howtosizetextincss/" rel="nofollow noreferrer">An article on A List Apart</a> (November 2007) explored this in depth in various browsers and concluded:</p>
<blockquote>
<p>Sizing text and line-height in ems, with a percentage specified on the body (and an optional cavea... | <p>You should always use relative units for font sizes, such as em.</p>
| 26,189 |
<p>Is there any real reason <strong>not</strong> to make a member function virtual in C++? Of course, there's always the performance argument, but that doesn't seem to stick in most situations since the overhead of virtual functions is fairly low.</p>
<p>On the other hand, I've been bitten a couple of times with forg... | <p>One way to read your questions is "Why doesn't C++ make every function virtual by default, unless the programmer overrides that default." Without consulting my copy of "Design and Evolution of C++": this would add extra storage to every class unless every member function is made non-virtual. Seems to me this would... | <p>As you are designing your class hierarchy, it may make sense to write a function that should not be overridden. One example is if you are doing the "template method" pattern, where you have a public method that calls several private virtual methods. You would not want derived classes to override that; everyone sho... | 37,273 |
<p>Are there any limitations on the amount of memory that the Flash player can use? If you have a SWF that over time gets a lot of data from the server, then more and more data will be kept in memory. Is there a limitation on this?</p>
| <p>Not in any version of Flash that runs on desktop PCs. As long as your application keeps using more memory, desktop Flash will keep requesting it from the OS, until the OS runs out of memory or something crashes. Of course you the developer should limit your memory usage as appropriate, but Flash won't force you to d... | <p>Iain has the right answer about checking the totalMemory used.</p>
<p>You could probably use a paging system. Although more and more data is loaded from the server I don't think all the data is used at all times. You could get data from the server and gradually save on the client's computer in a <a href="http://liv... | 24,932 |
<p>For some solutions, when I open them Visual Studio will get files that aren't in the project (particularly from obj/Debug) and add it to the changeset and I <strong>always</strong> have to perform a <em>Undo Pending Changes</em> operation on them. It's annoying. Is there any way to prevent Visual Studio from behavin... | <p>Convert these structs into arrays, and then provide accessor methods via a class.</p>
| <p>What do you mean with classes? As far as I remember classes was the term in matlab for type. I guess you mean a self defined class.</p>
<p>A solution (which is also recommended in to the matlab docs) is to switch from an array of structs to an struct of arrays (look in your link at the R, G, B) example.</p>
| 36,550 |
<p>My Program overrides <code>public void paint(Graphics g, int x, int y);</code> in order to draw some stings using <code>g.drawString(someString, x+10, y+30);</code></p>
<p>Now someString can be quite long and thus, it may not fit on one line.<br></p>
<p>What is the best way to write the text on multiple line.<br> ... | <p>Thanks to Epaga's hint and a couple of examples on the Net (not so obvious to find! I used mainly <a href="http://www.roseindia.net/java/example/java/swing/graphics2D/line-break-text-layout.shtml" rel="noreferrer" title="Break a Line for text layout">Break a Line for text layout</a>), I could make a component to dis... | <p>You can use a JLabel and embed the text with html.</p>
<pre><code>JLabel.setText("<html>"+line1+"<br>"+line2);
</code></pre>
| 29,639 |
<p>I have Enitity Type, Name of Primary Key and Guid of Primary Id. I want to get element of such Id in LinqToSql.</p>
<pre><code>model.GetTable<T>().Where(t => here equality );
</code></pre>
<p>I think I need to generate that Expression myself, but I dont know how :(</p>
| <p>I look forward, and after searching through generated by compiler code, in Reflector I found this creation of lambda. </p>
<pre><code> public static T GetById(Guid id)
{
Type entType = typeof(T);
if (!CheckTable(entType)) {
throw new TypeLoadException(string.Format(
... | <p>I look forward, and after searching through generated by compiler code, in Reflector I found this creation of lambda. </p>
<pre><code> public static T GetById(Guid id)
{
Type entType = typeof(T);
if (!CheckTable(entType)) {
throw new TypeLoadException(string.Format(
... | 41,628 |
<p>Is there any way to map to a network drive by using a stored procedure? I have tried: </p>
<pre><code>xp_cmdshell 'net use Q: [shared_network_drive] [pwd] /user:[username]'
</code></pre>
<p>but I got an error saying something like </p>
<pre><code>'System error 1312 has occurred.'
'A specified logon session does n... | <p>In an other forum someone <a href="http://www.msfn.org/board/topic/54894-info-net-use-command-returns-system-error-1312/" rel="noreferrer">posted a tip</a> about how to solve the <code>System error 1312 has occurred.</code> problem by specifying the username including its domain like this:</p>
<pre><code>net use Q:... | <p>Why would you even want to do this?!? Even if it is possible, you should be carefully asking yourself why you would want to do so.</p>
<p>My suggestion: don't. My impression is that you need to change your approach--whatever purpose that network drive mapping might serve should be pursued in a more appropriate p... | 49,615 |
<p>I have a php script that is executing an executable that writes to a serial port.
However, everytime it runs <pre>system("c:\Untitled1.exe")</pre>
it just opens up a cmd window and freezes.</p>
<p>Anybody know how to fix this? Or if there is an easier way to get PHP to write to the serial port directly? (I've alrea... | <p>What happens when you run "Untitled1.exe" - does it work outside of the php environment?</p>
<p>I would advise persevering with the loaded extension method - it's a much better way of implementing this.</p>
<p>If both methods aren't working then maybe the problem is somewhere else - related to permissions or confi... | <p>AFAIK <code>system()</code> call blocks the execution until the program finishes. Maybe using <code>popen()</code>, <code>fread()</code> and <code>pclose()</code> could solve this.</p>
<p>See <a href="http://php.net/manual/en/function.popen.php" rel="nofollow noreferrer">http://php.net/manual/en/function.popen.php<... | 29,415 |
<p>Which types of objects fall into the domain of "subscriptable"?</p>
| <p>It basically means that the object implements the <code>__getitem__()</code> method. In other words, it describes objects that are "containers", meaning they contain other objects. This includes strings, lists, tuples, and dictionaries.</p>
| <p>Basically this error will appear in case you are modifying or adding any field after type casting for the mentioned object instead of doing it before.</p>
| 26,674 |
<p>Via command line, I usually do this:</p>
<pre><code>cp -rRp /path/to/a\_folder/. /path/to/another\_folder
</code></pre>
<p>This copies just the contents underneath <strong>a_folder</strong> to <strong>another_folder</strong>. In SVN I need to do the same thing, but can't figure it out. I always end up with this:</... | <p>As you've certainly discovered, <b>copying to a target directory that already exists</b> won't work:</p>
<pre>svn cp svn://my_project/vendor/1.1 svn://my_project/trunk</pre>
<p>because trunk already exists, so you'd end up with:</p>
<pre>svn://my_project/trunk/1.1</pre>
<p>Using <strong>merge</strong> has the un... | <p>You're very, very close:</p>
<pre><code>svn copy -m"Copy Directory" file:///path/to/a_folder file:///path/to/another_folder
</code></pre>
<p>just drop the <code>/*</code> from the first argument.</p>
| 32,589 |
<p>I'm used to working with PHP but lately I've been working with Java and I'm having a headache trying to figure this out. I want to save this representation in Java:</p>
<pre>
Array (
["col_name_1"] => Array (
1 => ["col_value_1"],
2 => ["col_v... | <p>You can use a Map and a List (these both are interfaces implemented in more than one way for you to choose the most adequate in your case). </p>
<p>For more information check the tutorials for <a href="http://java.sun.com/docs/books/tutorial/collections/interfaces/map.html" rel="noreferrer">Map</a> and <a href="htt... | <p>Be forewarned that the <a href="http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/util/Vector.html" rel="nofollow noreferrer">Vector</a> is legacy code for the Collections framework. It synchronizes access to its elements which slows down performance. Most use cases for using List don't need this kind of threa... | 17,425 |
<p>I have a need to do auditing all database activity regardless of whether it came from application or someone issuing some sql via other means. So the auditing must be done at the database level. The database in question is Oracle. I looked at doing it via Triggers and also via something called Fine Grained Auditing ... | <p>I'm not sure if it's a mature enough approach for a production
system, but I had quite a lot of success with monitoring database
traffic using a network traffic sniffer.</p>
<p>Send the raw data between the application and database off to another
machine and decode and analyse it there. </p>
<p>I used PostgreSQL, ... | <p>if you are using oracle then there is feature called CDC(Capture data change) which is more performance efficient solution for audit kind of requirements.</p>
| 9,310 |
<p>I found the <a href="http://www.cgal.org/" rel="nofollow noreferrer">Computational Geometry Algorithms Library</a> in my search for an algorithm to decompose a concave polygon into the minimum number of convex components. Links off the site and numerous google results indicate there are python bindings for it, whic... | <p>A rewrite of the CGAL-Python bindings has been done as part of the cgal-bindings project. Check it out : <a href="http://code.google.com/p/cgal-bindings/">http://code.google.com/p/cgal-bindings/</a></p>
| <p>The fastest would probably be just to look at the code and re-implement it yourself in python. carrying around all of CGAL just for this tiny bit seems redundant.<br>
Also this calculation doesn't strike me as something that would extremely benefit by running compiled.</p>
| 44,631 |
<p>How can I fetch images from a server?</p>
<p>I've got this bit of code which allows me to draw some images on a canvas.</p>
<pre><code><html>
<head>
<script type="text/javascript">
function draw(){
var canvas = document.getElementById('canv');
var ctx = canvas.getConte... | <p>Use the built-in <a href="http://www.w3schools.com/htmldom/dom_obj_image.asp" rel="noreferrer">JavaScript Image object</a>.</p>
<p>Here is a very simple example of using the Image object:</p>
<pre><code>myimage = new Image();
myimage.src = 'http://myserver/nextimage.cgi';
</code></pre>
<p>Here is a more appropria... | <p>If you are using jQuery you can do:</p>
<pre><code>$.('<img src="http://myserver/nextimage.cgi" />').appendTo('#canv');
</code></pre>
<p>You can also add widths and anything else in the img tag.</p>
| 19,849 |
<p>I have a repeatable business process that I execute every week as part of my configuration management responsibilities. The process does not change: I download change details into Excel, open the spreadsheet and copy out details based on a macro, create a Word document from an agenda template, update the agenda with... | <p>Depending on the nature of your data and the parties that upload the excel files, you might want to consider having them save the data in .csv format. It will be much easier to parse on your end.</p>
<p>Assuming that isn't an option a quick google search turned up <a href="http://sourceforge.net/projects/phpexcelr... | <p>The open-source ETL tool Talend (<a href="http://wwww.talend.com" rel="nofollow noreferrer">http://wwww.talend.com</a>) will generate Java or Perl code and package such code with the necessary 3rd party libraries. </p>
<p>Talend should be able to handle all versions of Excel and output the result set in any format ... | 9,827 |
<p>If I have a 3D cylindrical extrusion (in Onshape), how can I scoop, carve, or indent a concave/parabolic curve in one of the ends?</p>
<p>The yellow surface is the target.
<a href="https://i.stack.imgur.com/80wQB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/80wQB.jpg" alt="Object"></a>
Here is... | <p>As is typical with many CAD type programs, a feature in Onshape known as revolve may be your solution. As you have a clear formula for the cross-section, half of the work is complete. </p>
<p>You would generate a sketch representing the curve, then use the Revolve feature with the axis oriented to vertical. Accordi... | <p>Create a midplane going through it, and then sketch half if a profile for what you want yo carve out on it that plane, and in the spot where you need it to carve out. Now revolve that profile around it's Central axis and this should cut wlthe piece you want out.</p>
| 732 |
<p>I am trying to find an algorithm to count from 0 to 2<sup>n</sup>-1 but their bit pattern reversed. I care about only n LSB of a word. As you may have guessed I failed.</p>
<p>For n=3: </p>
<pre><code>000 -> 0
100 -> 4
010 -> 2
110 -> 6
001 -> 1
101 -> 5
011 -> 3
111 -> 7
</code></pre>
<p>... | <p>This is, I think easiest with bit operations, even though you said this wasn't preferred</p>
<p>Assuming 32 bit ints, here's a nifty chunk of code that can reverse <em>all</em> of the bits without doing it in 32 steps:</p>
<pre><code> unsigned int i;
i = (i & 0x55555555) << 1 | (i & 0xaaaaaaaa) >... | <pre><code>void reverse(int nMaxVal, int nBits)
{
int thisVal, bit, out;
// Calculate for each value from 0 to nMaxVal.
for (thisVal=0; thisVal<=nMaxVal; ++thisVal)
{
out = 0;
// Shift each bit from thisVal into out, in reverse order.
for (bit=0; bit<nBits; ++bit)
out = (o... | 32,378 |
<p>I am giving link of a pdf file on my web page for download, like below</p>
<pre><code><a href="myfile.pdf">Download Brochure</a>
</code></pre>
<p>The problem is when user clicks on this link then</p>
<ul>
<li>If the user have installed Adobe Acrobat, then it opens the file in the same browser window i... | <p>Instead of linking to the .PDF file, instead do something like </p>
<pre><code><a href="pdf_server.php?file=pdffilename">Download my eBook</a>
</code></pre>
<p>which outputs a custom header, opens the PDF (binary safe) and prints the data to the user's browser, then they can choose to save the PDF desp... | <p>In a Ruby on Rails application (especially with something like the Prawn gem and the Prawnto Rails plugin), you can accomplish this a little more simply than a full on script (like the previous PHP example).</p>
<p>In your controller:</p>
<pre><code>def index
respond_to do |format|
format.html # Your HTML vie... | 47,636 |
<p>I have been noticing some very strange usage of O(1) in discussion of algorithms involving hashing and types of search, often in the context of using a dictionary type provided by the language system, or using dictionary or hash-array types used using array-index notation.</p>
<p>Basically, O(1) means bounded by a ... | <p>My understanding is that O(1) is not necessarily constant; rather, it is not dependent on the variables under consideration. Thus a hash lookup can be said to be O(1) with respect to the number of elements in the hash, but not with respect to the length of the data being hashed or ratio of elements to buckets in th... | <p>I think when many people throw around the term "O(1)" they implicitly have in mind a "small" constant, whatever "small" means in their context.</p>
<p>You have to take all this big-O analysis with context and common sense. It can be an extremely useful tool or it can be ridiculous, depending on how you use it.</p>... | 43,154 |
<p>I'm writing a mobile content adaptation plugin for a bespoke CMS in PHP. The CMS contains <code><img/></code> links to images with absolute URLs which are all 400 pixels wide and vary in height.</p>
<p>I'd like to parse the HTML (which is stored in MySQL) and re-scale each image to a new width - this will var... | <p>what about doing something a bit different. basically off load the caching/resizing to an on demand model. so say your application is being run on device A, which requires 200x200 images. you'd change the image links to:</p>
<pre><code><img src="/images/image.php?height=200&width=200&source=filename.jpg"... | <p>SEE
<a href="https://stackoverflow.com/questions/140734/best-way-to-cache-resized-images-using-php-and-mysql">Best way to cache resized images using PHP and MySQL</a><br>
for really good ideas on caching mechanism (especially apache webserver intervention concept)</p>
<p>and</p>
<p><a href="http://phpthumb.sourcef... | 27,002 |
<p>This is about practicality. I'm hearing that people are using their BLTouch not to adjust the Z offset, but as the limit switch for the machine! Why is this so? What are the pros and cons of using a BLTouch (or any touch sensor for that matter) in lieu of a physical limit switch?</p>
<p>(NB: I'm looking for objectiv... | <p>Touch sensors (or inductive or capacitive sensors) are generally used to probe the bed to determine the bed shape. For metallic beds that are not perfectly straight this works excellent. But, if your bed is straight and level (e.g. when you are using a straight slate of glass), you do not need to probe the surface a... | <p>One other way a bed sensor may be preferable over a common limit switch: it automatically adjusts when you change out the build surface.</p>
<p>Most glass build surfaces are anywhere from three to five millimeters thick, while the surface they replace (texture coated or uncoated fiberglass/resin, magnetic sheet, etc... | 1,487 |
<p>I'm attempting to do an AJAX call (via JQuery) that will initiate a fairly long process. I'd like the script to simply send a response indicating that the process has started, but JQuery won't return the response until the PHP script is done running.</p>
<p>I've tried this with a "close" header (below), and also wi... | <p>The following PHP manual page (incl. user-notes) suggests multiple instructions on how to close the TCP connection to the browser without ending the PHP script:</p>
<ul>
<li><a href="http://php.net/features.connection-handling" rel="noreferrer">Connection handling <sup><em>Docs</em></sup></a></li>
</ul>
<p>Suppose... | <p>Your problem can be solved by doing some parallel programming in php. I asked a question about it a few weeks ago here: <a href="https://stackoverflow.com/questions/70855/how-can-one-use-multi-threading-in-php-applications">How can one use multi threading in PHP applications</a></p>
<p>And got great answers. I like... | 16,752 |
<p>In C and C++ what do the following declarations do?</p>
<pre><code>const int * i;
int * const i;
const volatile int ip;
const int *i;
</code></pre>
<p>Are any of the above declarations wrong?</p>
<p>If not what is the meaning and differences between them?</p>
<p>What are the useful uses of above declarations (I ... | <p><code>const int * i;</code></p>
<p><code>i</code> is a pointer to constant integer. <code>i</code> can be changed to point to a different value, but the value being pointed to by <code>i</code> can not be changed.</p>
<p><code>int * const i;</code></p>
<p><code>i</code> is a constant pointer to a non-constant in... | <p>You read variables declarations in C/C++ right-to-left, so to speak.</p>
<pre><code>const int *i; // pointer to a constant int (the integer value doesn't change)
int *const i; // constant pointer to an int (what i points to doesn't change)
const volatile int ip; // a constant integer whose value will never be ... | 28,765 |
<p>With code like the following, sometimes the child controls correctly finish their animation and sometimes they stop at random places in the middle. Why don't they work correctly?</p>
<pre><code>var t:Tween;
t = new Tween(child1,"x",Elastic.easeOut,0,100,2,true);
t = new Tween(child1,"y", Elastic.easeOut,0,100,2,tr... | <p>Each tween must be assigned to a separate variable in global scope. The following code behaves reliably:</p>
<pre><code>var t1:Tween = new Tween(child1,"x",Elastic.easeOut,0,100,2,true);
var t2:Tween = new Tween(child1,"y", Elastic.easeOut,0,100,2,true);
var t3:Tween = new Tween(child2,"x",Strong.easeOut,300,400,1... | <p>Each tween must be assigned to a separate variable in global scope. The following code behaves reliably:</p>
<pre><code>var t1:Tween = new Tween(child1,"x",Elastic.easeOut,0,100,2,true);
var t2:Tween = new Tween(child1,"y", Elastic.easeOut,0,100,2,true);
var t3:Tween = new Tween(child2,"x",Strong.easeOut,300,400,1... | 39,583 |
<p>I wrote this scheme code to compute one solution of the quadratic equation a<em>x2 + b</em>x + c = 0</p>
<pre><code>(define (solve-quadratic-equation a b c) (define disc (sqrt (- (* b b) (* 4.0 a c)))) (/ (+ (- b) disc) (* 2.0 a)))
</code></pre>
<p>However, someone told me that this procedure is hard to understand... | <p>Well, one reason is that it's all on one line. You can make it more readable using something called <strong>pretty-printing</strong>, where you break it up into multiple lines and use whitespace:</p>
<pre><code>(define (solve-quadratic-equation a b c)
(define disc (sqrt (- (* b b)
(* 4.0 a... | <p>Isn't scheme all about developing a language to solve a problem? I admit I don't know much scheme, but I would add some indentation and add a square definelike so.</p>
<pre><code> (define (solve-quadratic-equation a b c)
(define square (x) (* x x)
(define disc (sqrt (- (square b) (* 4.0 a c))))
... | 30,998 |
<p>I've recently decided that I just have to finally learn C/C++, and there is one thing I do not really understand about pointers or more precisely, their definition.</p>
<p>How about these examples:</p>
<ol>
<li><code>int* test;</code></li>
<li><code>int *test;</code></li>
<li><code>int * test;</code></li>
<li><cod... | <p>4, 5, and 6 are the same thing, only <em>test</em> is a pointer. If you want two pointers, you should use:</p>
<pre><code>int *test, *test2;
</code></pre>
<p>Or, even better (to make everything clear):</p>
<pre><code>int* test;
int* test2;
</code></pre>
| <p>A good rule of thumb, a lot of people seem to grasp these concepts by: In C++ a lot of semantic meaning is derived by the left-binding of keywords or identifiers.</p>
<p>Take for example:</p>
<pre><code>int const bla;
</code></pre>
<p>The const applies to the "int" word. The same is with pointers' asterisks, they... | 21,763 |
<p>I'm trying to modify the class of an element if an ajax call based on that element is successful</p>
<pre><code><script type='text/javascript'>
$("#a.toggle").click(function(e){
$.ajax({
url: '/changeItem.php',
dataType: 'json',
type: 'POST',
success: function(data,text){
... | <p>You can just store it in a variable. Example:</p>
<pre><code>$("#a.toggle").click(function(e)
{
var target = $(this);
$.ajax({
url: '/changeItem.php',
dataType: 'json',
type: 'POST',
success: function(data,text)
{
if(data.error=='')
{
if(target.hasCl... | <p>I know it's old but you can use the 'e' parameter from the click function.</p>
| 18,594 |
<p>I have written a vector-based 3D editor (UI customized somewhat like technical drawings). I now want save the vectors/drawing data in portable formats. Which formats are available; which (one?) of them are the most widely accepted, and where can I get hold of the format specifications?</p>
| <p>Commercially, many users will look for AutoCAD DWG and Bentley DGN formats. While not free, libraries for producing these formats can be found from <a href="http://www.opendwg.org/home" rel="nofollow noreferrer">the open design alliance</a></p>
<p>The GIS community use <a href="http://en.wikipedia.org/wiki/Shapefi... | <p><a href="http://www.w3.org/Graphics/SVG/" rel="nofollow noreferrer">Scalable Vector Graphics (SVG)</a></p>
| 22,776 |
<p>Writing a JSP page, what exactly does the <code><c:out></code> do? I've noticed that the following both has the same result:</p>
<pre><code><p>The person's name is <c:out value="${person.name}" /></p>
<p>The person's name is ${person.name}</p>
</code></pre>
| <p><code>c:out</code> escapes HTML characters so that you can avoid cross-site scripting.</p>
<p>if <code>person.name = <script>alert("Yo")</script></code></p>
<p>the script will be executed in the second case, but not when using <code>c:out</code></p>
| <p>Older versions of JSP did not support the second syntax.</p>
| 37,116 |
<p>I would like to use JConsole to monitor my Websphere application, but I am not sure how to enable JMX.</p>
| <p>Following information is for Websphere 6.1 on Windows.</p>
<p>First of all, the magic URL to connect to the MBean server is:</p>
<pre><code>service:jmx:iiop://<host>:<port>/jndi/JMXConnector
</code></pre>
<p>If you have a default Websphere installation, the JNDI port number will likely be 2809, 2810, ... | <p>you can try the following, it uses the SOAP protocol adapter. I think it's as lean a configuration possible.</p>
<pre><code>#!/bin/sh
current_dir=`dirname "$0"`
HOSTNAME=host.fqdn
PORT=2809
WAS_HOME=/opt/IBM/WebSphere/AppServer
WAS_PROFILE=$WAS_HOME/profiles/AppSrv01
WAS_RUNTIMES=$WAS_HOME/runtimes
WAS_LIB=$WAS... | 46,567 |
<p>I am looking for some JavaScript plugin (preferably jQuery) to be able to scroll through an image, in the same way that <a href="http://maps.google.com" rel="noreferrer">Google Maps</a> works.</p>
<p>I can make the image draggable but then I see the whole image while dragging even if the parent div is <code>overflo... | <p>I may be a little late to the party, but I was just looking for the same thing. What I stumbled upon is <a href="http://code.google.com/p/jquery-scrollview/" rel="nofollow noreferrer">scrollview</a> for jquery, it works perfect and does exactly this google maps-like drag-to-scroll for overflowed divs.</p>
| <p>Google Maps uses images sliced into blocks which are dynamically loaded as the user pans in different directions. The <a href="http://www.casa.ucl.ac.uk/software/googlemapimagecutter.asp" rel="nofollow noreferrer">Google Maps Image Cutter</a> Paul Dixon mentions is the tool you want for this.</p>
<p>If you just wan... | 9,216 |
<p>I can't for the life of me find a form that doesn't email the results that you submit.</p>
<p>I'm looking to find a form that I can have users enter simple data that i can then spit back out at them in different arrangements. If they submit First and Last, I'll spit out, amongst other things, FirstLast@domain.com. ... | <p>Form:</p>
<pre><code><form action="process.php" method="post">
First: <input type="text" name="first" />
Last: <input type="text" name="last" />
<input type="submit" />
</form>
</code></pre>
<p>Next page:</p>
<pre><code><?php
$first = $_POST['first'];
$last = $_POST[... | <p>What language/platform/environment are you working in?</p>
<p>I guess you might be looking for a hosted script or webform (the way that people will host web-to-mail scripts I suppose) but I doubt there would be one out there that does this.</p>
<p>But if you have a specific framework to work in, e.g. PHP or .net, ... | 28,183 |
<p>I am looking for resources on Microsoft Sync Framework. Although MSDN and Google Search gave me the brief overview, I want some demos and presentations.</p>
<p>Also, is Live Mesh based on Sync Framework?</p>
| <p>Maybe those links will be helpful:</p>
<ul>
<li><a href="http://code.msdn.microsoft.com/sync/Release/ProjectReleases.aspx?ReleaseId=615" rel="noreferrer">Sync101 - Getting Started with Sync</a></li>
<li><a href="http://code.msdn.microsoft.com/sync/Release/ProjectReleases.aspx?ReleaseId=949" rel="noreferrer">Tutoria... | <p>For using NoSQL DB, couchbase mobile supports sync with couchbase server through Sync Gateway. Very scalable solution. <a href="http://www.couchbase.com/mobile#sync-gateway" rel="nofollow">http://www.couchbase.com/mobile#sync-gateway</a>. </p>
| 29,587 |
<p>Basically, I have a class with 2 methods: one to serialize an object into an XML file and another to read an object from XML.
Here is an example of synchronized part from the method that restores an object:</p>
<pre><code> public T restore(String from) throws Exception {
// variables declaration
syn... | <p>1.
Yes, it's OK to synchronize on a String, however you'd need to synchronize on the string.<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html#intern()" rel="noreferrer">intern()</a> in order to always get the same Object</p>
<pre><code>StringBuffer sb = new StringBuffer(); sb.append("a").append("... | <p>Given that the some parts of your code are missing, my bet is that the problem lies with synchronizing on a string. You cannot freely assume that strings are pooled (which would break your synchronization scheme). </p>
<p>The best approach would be to add a map that will associate a key (string) with its actual syn... | 23,747 |
<p>I'm struggling here with a problem:
I have a controller <em>questions</em> which has action <em>new</em>.
Whenever I need to create new question, I'm typing </p>
<pre><code>/questions/new
</code></pre>
<p>What changes to routes.rb should I make to change the URI to </p>
<pre><code>/questions/ask
</code></pre>
<h... | <p>Try this:</p>
<pre><code>map.ask_question '/questions/ask', :controller => 'questions', :action => 'new'
</code></pre>
<p>Then you'll have a named route and you can:</p>
<pre><code>link_to "Ask a question", ask_question_path
</code></pre>
| <p>Which version of rails?</p>
<p>Generally the default route should catch anything like /:controller/:action, so you could just create an ask method in your questions controller. Take a look at the api documentation for named_route and map_resource if you want something a bit smoother to work with.</p>
| 43,224 |
<p>I'm using the JFrame plugin with jquery 1.2.6.</p>
<p>It works fine in FF3, however it won't display the requested pages in IE 7.</p>
<p>The jQuery library and the JFrame plugin are called in the included header.cfm.</p>
<p>Page code is here (note: ignore the ColdFusion calls, I don't think they're generating the... | <p>When you have a problem like this, the best way of tracking down the problem is to reduce the page to the minimum necessary to reproduce the problem.</p>
<p><em>"Ignore the [x] because I don't think that's the problem"</em> is no good, if you don't think that's the problem, save it to a temporary static page, delet... | <p>I would suggest updating to the newest release of jquery (v 1.3.2). This might be the simplest way to attempt to fix the bug. <a href="http://jquery.com/" rel="nofollow noreferrer">http://jquery.com/</a></p>
| 9,027 |
<p>I need to parse a transcript of a live chat conversation. My first thought on seeing the file was to throw regular expressions at the problem but I was wondering what other approaches people have used. </p>
<p>I put elegant in the title as i've previously found that this type of task has a danger of getting hard to... | <p>No and in fact, for the specific type of task you describe, I doubt there's a "cleaner" way to do it than regular expressions. It looks like your files have embedded line breaks so typically what we'll do here is make the line your unit of decomposition, applying per-line regexes. Meanwhile, you create a small state... | <p>Just a quick post, I've only glanced at your transcript example but I've recently also had to look into text parsing and hoped to avoid going the route of hand rolled parsing. I did happen across <a href="http://www.complang.org/ragel/" rel="nofollow noreferrer">Ragel</a> which I've only started to get my head aroun... | 27,649 |
<p>When entering a question, stackoverflow presents you with a list of questions that it thinks likely to cover the same topic. I have seen similar features on other sites or in other programs, too (Help file systems, for example), but I've never programmed something like this myself. Now I'm curious to know what sort ... | <p>One approach is the so called bag-of-words model.</p>
<p>As you guessed, first you count how many times words appear in the text (usually called document in the NLP-lingo). Then you throw out the so called stop words, such as "the", "a", "or" and so on.</p>
<p>You're left with words and word counts. Do this for a ... | <p>Here is the bag of words solution with tfidfvectorizer in python 3</p>
<pre><code>#from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfVectorizer
import nltk
nltk.download('stopwords')
s=set(stopwords.words('english'))
train_x_cleaned = []
for i in train_x:
... | 9,598 |
<p>I want to find any text in a file that matches a regexp of the form <em>t</em><code>[A-Z]</code><em>u</em> (i.e., a match <em>t</em> followed by a capital letter and another match <em>u</em>, and transform the matched text so that the capital letter is lowercase. For example, for the regexp <code>x[A-Z]y</code></p>
... | <p>It looks like <a href="http://steve-yegge.blogspot.com/" rel="noreferrer">Steve Yegge</a> actually already posted the answer to this a few years back: <a href="http://steve-yegge.blogspot.com/2006/06/shiny-and-new-emacs-22.html" rel="noreferrer">"Shiny and New: Emacs 22."</a> Scroll down to "Changing Case in Replace... | <p>I'd do this with a macro as well, but only because executing code from within a replacement string for a regular expression is very unintuitive to me. If you're writing a batch script or something that needs to go very fast, \, is certainly the way to go.</p>
| 8,213 |
<p>How can I specify the filename when dumping data into the response stream?</p>
<p>Right now I'm doing the following:</p>
<pre><code>byte[] data= GetFoo();
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(data);
Response.End();
</code></pre>
<p>Wi... | <p>Add a content-disposition to the header: </p>
<pre><code>Response.AddHeader("content-disposition", @"attachment;filename=""MyFile.pdf""");
</code></pre>
| <pre><code> Response.AddHeader("Content-Disposition", "attachment;filename=" & FileName & ";")
</code></pre>
| 9,974 |
<p>I'm fairly new to the world of versioning but would like to introduce Subversion into our small development team as we're finding that more and more we are working on the same projects/files. We primarily code in <code>PHP</code> on a <code>LAMP</code> environment (Red Hat Enterprise).</p>
<p>What I'm looking for a... | <p>It depends on what version of RHEL you are running. Setting up Subversion in general is very easy you just have to install the binaries and run svnserve or adapt the Apache configuration.</p>
<ol>
<li>Get it: <a href="http://subversion.tigris.org/getting.html" rel="nofollow noreferrer">http://subversion.tigris.org... | <p>These are good for Linux + Subversion:<br>
<a href="http://articles.slicehost.com/subversion" rel="nofollow noreferrer">http://articles.slicehost.com/subversion</a><br>
Plus it goes into multiple repositories, WebDAV and a lot of other things. Useful for Windows devs too as most of the info can be used in Windows to... | 13,987 |
<p>reference, OpenCv\samples\c\lkdemo.c </p>
<p>Anybody know what does the following snippet of codes does ?</p>
<p>Code extracted from lkdemo.c</p>
<pre><code> for( i = k = 0; i < count; i++ )
{
if( add_remove_pt )
{
double dx = pt.x - points[1][i].... | <p>Q1:</p>
<p>Perhaps it would help if I refactor the code:</p>
<pre><code>if( status[i] ) {
points[1][k++] = points[1][i]; // <---- Q1
cvCircle( image, cvPointFrom32f(points[1][i]), 3, CV_RGB(0,255,0), -1, 8,0);
}
</code></pre>
<p>So in the line for question 1, i always increments (it's incremented by t... | <p>I manage to figure out the where the clearing of points are done.
As frame loops the new points are reflected on the new frame and the new
frame refreshes the previous.</p>
| 44,086 |
<p>How can I return to the start of a line and overwrite what has already been output on the console? The following does not appear to work:</p>
<pre><code>System.out.print(mystuff+'\r');
</code></pre>
| <p>I suspect that your cursor IS moving to the front of the line. The text you already have isn't disappearing because you haven't overwritten it with anything. You could output spaces to blank the line and then add another \r.</p>
<p>I just tested the following on Windows XP and AIX and it works as expected:</p>
<pr... | <p>If you just want to write a new line to the console, you should use the println() method:</p>
<pre><code>System.out.println(mystuff);
</code></pre>
<p>However, this will not delete what is already on the line. Actually, since System.out is a PrintStream, which is a type of OutputStream, that is basically hard to d... | 38,731 |
<p>I have a list of 2-item tuples and I'd like to convert them to 2 lists where the first contains the first item in each tuple and the second list holds the second item.</p>
<p><strong>For example:</strong></p>
<pre><code>original = [('a', 1), ('b', 2), ('c', 3), ('d', 4)]
# and I want to become...
result = (['a', '... | <p><a href="http://docs.python.org/library/functions.html#zip" rel="noreferrer"><code>zip</code></a> is its own inverse! Provided you use the special * operator.</p>
<pre><code>>>> zip(*[('a', 1), ('b', 2), ('c', 3), ('d', 4)])
[('a', 'b', 'c', 'd'), (1, 2, 3, 4)]
</code></pre>
<p>The way this works is by ca... | <p>Here's a simple one-line answer that produces the desired output:</p>
<pre class="lang-py prettyprint-override"><code>original = [('a', 1), ('b', 2), ('c', 3), ('d', 4)]
list(zip(*original))
# [('a', 'b', 'c', 'd'), (1, 2, 3, 4)]
</code></pre>
| 3,976 |
<p>Less than 10 client computers, each with their own installation have to upload data to a central server.</p>
<p>The client database looks like:</p>
<p>tblSales
- rowGuid
- randomNumber</p>
<p>Central Server database:</p>
<ul>
<li>rowGuid</li>
<li>randomNumber</li>
<li>dateInserted</li>
</ul>
<p>I plan to use WC... | <p>You can also enable reliable messaging if using a binding like WsHttpBinding that will ensure the reliability of the messages themselves if that is a concern.</p>
| <p>Using WCF you're going to be basically calling a function thru a proxy. Just have that function return a bool true for success or false for failure.</p>
<pre><code>bool Success;
Success = MyWCFService.InsertRecord(MyNewRecord);
</code></pre>
| 33,765 |
<p>We're making the switch from SourceGear Vault to TortoiseSVN with VisualSVN for Visual Studio integration - absolutely love it. However, there are multiple class libraries that we reference in multiple different applications that aren't a part of the working copy root in any of the applications. What's the best way ... | <p>Found the best answers <a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-import.html" rel="nofollow noreferrer">here</a>:</p>
<p>Referenced Projects</p>
<p>Sometimes it is useful to construct a working copy that is made out of a number of different checkouts. For example, you may want different ... | <p>I understand it's been more than ten years since you asked this question, but I am glad to tell you that there was progress in implementing support for multiple working copies in the VisualSVN plug-in.</p>
<p>VisualSVN 7.1 and 6.5 <strong>support multiple working copies within a single solution</strong>. The new fu... | 19,373 |
<p>I'm writing a program and am having trouble using the scanf and fopen working together.</p>
<p>From what I can tell my erroneous lines seems to be:</p>
<pre><code>FiLE * DataFile
DataFile = fopen("StcWx.txt","r");
scanf(DataFile, "%i %i %i %.2f %i %i", &Year, &Month, &Day, &Precip, &High, &... | <p>I think you want <a href="http://en.wikipedia.org/wiki/Scanf#fscanf" rel="nofollow noreferrer"><strong>fscanf</strong></a> not <a href="http://en.wikipedia.org/wiki/Scanf" rel="nofollow noreferrer"><strong>scanf</strong></a>.</p>
| <p>How about:</p>
<p><code>freopen ("StcWx.txt","r",stdin);</code></p>
<p><code>scanf("%i %i %i %.2f %i %i", &Year, &Month, &Day, &Precip, &High, &Low);</code></p>
<p><a href="http://www.cplusplus.com/reference/cstdio/freopen/" rel="nofollow noreferrer">http://www.cplusplus.com/reference/cstd... | 15,682 |
<p>I run into this quite often where a new page is supposedly "tested" and ready to go. But as soon as I change the page from http to https (secure) mode I get the "This page contains both secure and nonsecure items." error.</p>
<p>Usually I can find the problem and fix it pretty quick. Today is different. I've checke... | <p><a href="http://getfirebug.com/" rel="nofollow noreferrer">Firebug's</a> <a href="http://getfirebug.com/net.html" rel="nofollow noreferrer">Net panel</a>. Again, only in Firefox, although Firebug Lite might include this, I'm not sure. If it does, that'd cover this too.</p>
| <p>If you're in Firefox you can use Tools -> Page Info -> Media, then just scan down the list to find the non-https link. There might also be JavaScript building dynamic <code><script></code> tags, or CSS including non-secure elements.</p>
| 21,275 |
<p>I have a short preliminary interview with Microsoft in less than 2 hours.
I've been told that they might ask questions in Java and/or C++.
Where can I find a quick overview of both languages?
I don't need to full tutorial, just something that goes over the language-specific features and a refresher of the semantics.... | <p>Teach yourself programming in ... 80 minutes?</p>
<p>I would bet on the quick reference cards:</p>
<p><a href="http://users.ece.utexas.edu/~adnan/c-refcard.pdf" rel="noreferrer">C ref card</a>,
<a href="http://www.dcs.gla.ac.uk/~pd/JavaRefCard/" rel="noreferrer">A Java ref card</a>,
<a href="http://gufsc.das.ufsc.... | <p>An hour and a half is a bit fast to learn a language. You can try Wikipedia, but you may want to avoid discussion of either language if you don't know them. Instead focus on the languages you do know. Learning a new language is not difficult, but you shouldn't try to rush it and then sound like you know more than yo... | 32,513 |
<p>With the following file reading code:</p>
<pre><code>using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None))
{
using (TextReader tr = new StreamReader(fileStream))
{
string fileContents = tr.ReadToEnd();
}
}
</code></pre>
<p>And the following fil... | <p>You can open a file for writing and only lock write access, thereby allowing others to still read the file.</p>
<p>For example,</p>
<pre><code>using (FileStream stream = new FileStream(@"C:\Myfile.txt", FileMode.Open, FileAccess.ReadWrite, FileShare.Read))
{
// Do your writing here.
}
</code></pre>
<p>Other fi... | <p>Write to a temp file, when finished writing rename/move the file to the location and/or name that the reader is looking for.</p>
| 27,393 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.