instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Please suggest a good MVC framework for Winforms.</p>
| <p><a href="http://www.mvcsharp.org/" rel="nofollow noreferrer">http://www.mvcsharp.org/</a>
Welcome to the MVC# home page
MVC# - is a Model-View-Presenter framework for .NET platform. It allows taking advantage of the MVP pattern with minimal effort required. As a result applications gain 3-tier structure, become bett... | <p>CAB isn't too bad</p>
| 34,794 |
<p>My printer just stopped working. It seems like it's working perfectly, but it gives me an error whenever I move the Z-Axis (Error: Printer set into dry run mode until restart) then, the bed temperature appears to be at 293ºC when it's actually at 95ºC.</p>
<p>I suspect that the bed wires short-circuited since they ... | <p>Following on from Harvey Lim's <a href="https://3dprinting.stackexchange.com/questions/3771/commercially-available-3d-printer-fume-and-ufp-extractor#answer-3977">answer</a>, to give a concrete example of a DIY filter, which uses active carbon, see <a href="https://web.archive.org/web/20200514160332/http://www.3dprin... | <p>To try to answer your question, I found these enclosures on <a href="https://www.3dprintclean.com/store-1/" rel="nofollow noreferrer">3DPrintClean</a>, by browsing the Ultimaker forum. I'm not sure it fits your needs since you did not give any details about which Ultimaker you have, nor the amount of money you are w... | 553 |
<p>It seems like MS really left a massive gaping hole in their automated testing tools in Visual Studio for web pages with AJAX components and I have been hard pressed to find any commentary or third party add-ons that remedy the problem. Anyone have any advice on automating web tests in MSVS for AJAX pages?</p>
| <p>I eventually gave up trying, and just stuck with WATIR</p>
| <p>I don't know if this will help, but you can try this:</p>
<p><a href="https://github.com/pivotal/jsunit" rel="nofollow noreferrer">https://github.com/pivotal/jsunit</a></p>
<p>EDIT:Sorry I reread your Q and realized you meant specific to VS. I don't know if you are familiar with Script#, but I had read some talk a... | 12,225 |
<p>I'm using exim on both the sending and relay hosts, the sending host seems to offer:</p>
<pre><code>HELO foo_bar.example.com
</code></pre>
<p>Response: </p>
<pre><code>501 Syntactically invalid HELO argument(s)
</code></pre>
| <p>Possibly a problem with underscores in the hostname?
<a href="http://www.exim.org/lurker/message/20041124.113314.c44c83b2.en.html" rel="noreferrer">http://www.exim.org/lurker/message/20041124.113314.c44c83b2.en.html</a></p>
| <p>The argument to <code>HELO</code> should be a hostname or an IP address. foo_bar.example.com is neither an IP address nor a hostname (underscores are illegal in hostnames), so the error message is correct and there is nothing to fix.</p>
| 11,241 |
<p>One of our weblogic 8.1s has suddenly started logging giant amounts of logs and filling the disk.</p>
<p>The logs giving us hassle resides in </p>
<pre><code>mydrive:\bea\weblogic81\common\nodemanager\NodeManagerLogs\generatedManagedServer1\managedserveroutput.log
</code></pre>
<p>and the entries in the logfile i... | <p>Turn that into a spec:<br>
-that objects need to implement an interface in order to be allowed into the collection
Something like <code>ArrayList<ICloneable>()</code></p>
<p>Then you can be assured that you always do a deep copy - the interface should have a method that is guaranteed to return a deep copy. <... | <p>I suppose it is an ovbious answer:</p>
<p>Make a requisite for the classes stored in the collection to be cloneable. You could check that at insertion time or at retrieval time, whatever makes more sense, and throw an exception.</p>
<p>Or if the item is not cloneable, just fail back to the return by reference opti... | 4,963 |
<p>We have a product with an install base of about 50, over 50% of these installs have customizations in the code for the business logic, and that is currently done by huge IF and Switch statements. </p>
<p>We are currently in the process of updating the code to .NET 3.5 and would like to handle the customizations in ... | <p>I would be tempted to arrange things so that customization is in text-form (possibly XML, but I guess that's not the only option), and the main application is generic, and gets the customer specific features by parsing those configuration files. </p>
<p>You could then have a repository for each customer, containing... | <p>A DI framework in combination with inheritance could keep your system in accord to Open/Closed principle, would make it more modular, and would resolve lifecycle and distribution problem, like when you need to distribute a base library that was extended for a specific customer.</p>
<p>For example, you can have a cl... | 28,072 |
<p>When using Business Objects' CrystalReportViewer control, how can you detect and manually print the report the user has currently drilled into? You can print this automatically using the Print() method of the CrystalReportViewer, but I want to be able to do a manual printing of this report.</p>
<p>It is possible to... | <p>You are after a native SQL query.</p>
<p>If you are using JPA the syntax is:</p>
<pre><code>Query q = em.createNativeQuery("select foo.* from Foo foo " +
"where f.x = max(f.x) over " +
"(partition by f.y)", Foo.class);
</code></pre>
<p>If you need to r... | <p>Another approach would be to use the mapping. Please see this article: <a href="https://forums.hibernate.org/viewtopic.php?f=1&t=998482" rel="nofollow noreferrer">https://forums.hibernate.org/viewtopic.php?f=1&t=998482</a></p>
<p>I am against the usage of native SQL queries in Hibernate... you lose the bene... | 9,977 |
<p>I'm looking for suggestions for a beginner level ASP/XML test. Essentially I'm trying to hire an extremely junior programmer. I'm in the process of trying to hire a junior programmer to help maintain a large code base of somewhat repetitive ASP pages. I'm slowly in the process of making more modular, maintainable... | <p>I would ask some basic math questions involving sets, statistics and the like. That kind of question can be somewhat hard, as they don´t depend on a background in IT.</p>
<p>If you want to include some programming questions I would ask something in the line:</p>
<p>"How do you implement integer division without us... | <p>Well as an absolute base you could try testing their consistency at mental modelling as per <a href="http://www.cs.mdx.ac.uk/research/PhDArea/saeed/" rel="nofollow noreferrer">the academic articles</a> linked from <a href="http://www.codinghorror.com/blog/archives/000635.html" rel="nofollow noreferrer">this Coding H... | 32,582 |
<p>I homebuilt a delta 3D printer (like Kossel mini) with a Z probe near the hotend with manual deploy and RAMPS 1.4 board:</p>
<ul>
<li>I configured the Repetier firmware with the online tool;</li>
<li>All my endstops (included the Z probe endstop) work in reverse mode, so I reversed the endstops triggering option;</... | <p>As a guess, you are using the wrong command. If set for n x n grid, you get 3 point measurement with G29, but that is not auto leveling, it is just setting Z height - based on average height at 3 points.</p>
<p>What you need is <code>G32 S2</code> with <code>S2</code> to store result in EEPROM (and therefore you sh... | <p>Delta bed leveling has been dodgy in Repetier for a long time. There are a number of fixes occurring in the dev branch right now (June 2016) if you look at Github. So it's getting better, but I wouldn't call it mature yet. (Delta auto-calibration is one of the only big shortcomings of Repetier, in my opinion.)</p>
... | 335 |
<p>When are <strong>custom Exception classes</strong> most-valuable?<br>
Are there cases when they should or should not be used? What are the benefits?</p>
<p><strong>Related questions:</strong></p>
<ol>
<li><strong><a href="https://stackoverflow.com/questions/6891/performance-considerations-for-throwing-exceptions"... | <h3>Questions to ask yourself:</h3>
<ol>
<li>Who will be catching it? If no one, then you don't really need a custom exception.</li>
<li>Where will you be throwing it? Is there enough context readily available, or will you need to catch and re-throw several times before the exception is useful to the final catcher?</li... | <p>I think the simple answer is "Create a custom exception when no existing exception adequetely expresses the exceptional situation." </p>
<p>I also have a second rule that I apply: "Only create a custom exception if you expect a developer to be able to handle the exception." There is no point in creating a new exc... | 23,797 |
<p>Say I have the following C++:</p>
<pre><code>char *p = new char[cb];
SOME_STRUCT *pSS = (SOME_STRUCT *) p;
delete pSS;
</code></pre>
<p>Is this safe according to the C++ standard? Do I need to cast back to a <code>char*</code> and then use <code>delete[]</code>? I know it'll work in most C++ compilers, because it'... | <p>It's not guaranteed to be safe. Here's a relevant link in the C++ FAQ lite:</p>
<p>[16.13] Can I drop the <code>[]</code> when deleting array of some built-in type (<code>char</code>, <code>int</code>, etc.)?</p>
<p><a href="https://isocpp.org/wiki/faq/freestore-mgmt#delete-array-built-ins" rel="nofollow noreferr... | <p>While this <em>should</em> work, I don't think you can guarantee it to be safe because the SOME_STRUCT is not a char* (unless it's merely a typedef).</p>
<p>Additionally, since you're using different types of references, if you continue to use the *p access, and the memory has been deleted, you will get a runtime e... | 9,635 |
<p>Assuming this is a multi-user system</p>
| <p>I don't know that it's inherently good or bad. If there's no reason to centralize the data access from a business standpoint, having a client app talk directly to the database isn't a problem. You'll want to build a decent data access layer regardless of whether it's done in the client or through a centralized dat... | <p>For security reasons, I prefer to access a database through a web service. That way, you don't have to have the database userid/password in the client application.</p>
| 38,939 |
<p>Let me first say, we validate every field on the server side, so this a question
about client-side usability.</p>
<p>What is the conventional wisdom on <em>exactly when</em> to validate and format html form input fields using javascript?</p>
<p>As an example, we have a phone number field. We allow numbers, spaces... | <blockquote>
<p>Validate and format it when the user exits the field. </p>
</blockquote>
<p>Yes. Provide noninvasive feedback to the user if validation or formatting rules fail. By noninasive I mean don't popup an alert or modal dialog box, thereby forcing the user to click something. Rather dynamically display a ... | <p>I find the first three options to be really annoying. There's nothing worse than being interrupted in the middle of typing something. </p>
<p><strong>Your user's main goal is getting through the form as fast as possible and anything you do that slows them down is just one more reason for them to give up on it ent... | 14,223 |
<p>Are there any drawbacks to using the STL or templates. Are there any situations for which they are inappropriate.</p>
| <p>First, you should use probably use them if they help you solve your problem. Templates are a very important part of C++ and have been part of the standard for years. STL is very powerful and fast at run time and should be supported on all decent compilers, but of course there are issues.</p>
<ul>
<li>If you have ... | <p>See the <a href="http://yosefk.com/c++fqa/templates.html" rel="nofollow noreferrer">templates section</a> of the <a href="http://yosefk.com/c++fqa/" rel="nofollow noreferrer">C++ FQA</a> [sic] for lots of good reasons to not use templates.</p>
| 33,415 |
<p>I changed the MembershipProvider in my ASP.net MVC website, and now the stylesheet for the login page isn't referenced correctly. Below is a copy of the forms tag in my web.config if that could be the reason. It looks identical though to the one generated by a new project with the exception of the name and timeout a... | <p>I haven't used ASP.NET MVC yet myself, but you could try using <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.control.resolveclienturl.aspx" rel="nofollow noreferrer">ResolveClientUrl</a> when writing out the href for your CSS:</p>
<pre><code><link href="<%= ResolveClientUrl("../../content/Sit... | <p>I haven't used ASP.NET MVC yet myself, but you could try using <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.control.resolveclienturl.aspx" rel="nofollow noreferrer">ResolveClientUrl</a> when writing out the href for your CSS:</p>
<pre><code><link href="<%= ResolveClientUrl("../../content/Sit... | 20,176 |
<p>The system I am currently working on requires some role-based security, which is well catered for in the Java EE stack. The system intends to be a framework for business domain experts to write their code on top of.</p>
<p>However, there is also a requirement for data <code>security</code>. That is, what informatio... | <p>Hibernate has a <a href="http://in.relation.to/Bloggers/Hibernate3Filters" rel="noreferrer">filter mechanism</a> that may work for you. The filters will rewrite the queries hibernate generates to include an additional clause to limit the rows returned. I'm not aware of anything in hibernate to mask/hide columns.</... | <p>When using Hibernate filters you need to be aware that the additional restrictions will not be applied to SQL statements generted by the <code>load()</code> or <code>get()</code> methods.</p>
| 5,495 |
<p>What would the differences be in implementing remote business logic?</p>
<p>Currently we are planning on using <a href="http://en.wikipedia.org/wiki/Oracle_Application_Development_Framework" rel="nofollow noreferrer">ADF</a> to develop front-end web applications (moving from <a href="http://en.wikipedia.org/wiki/Ap... | <p>ADF is pretty broad, as it encompasses front end all the way down through data access. It's a great <a href="http://en.wikipedia.org/wiki/Rapid_application_development" rel="nofollow noreferrer">RAD</a> framework if you are going to use the entire stack, but isn't so hot if you are only going to use one portion or ... | <p>You should not use the EJB deployment of ADF BC. It needs a lot of RMI synchronisation. I used it with ADF <a href="http://en.wikipedia.org/wiki/Swing_%28Java%29" rel="nofollow noreferrer">Swing</a>. Going to the next record takes about three seconds. We need to rewrite the comboboxes to make it perform.</p>
<p>In ... | 12,240 |
<p>I am trying to setup a failover location for MOSS. The current farm is built on 32 bit Windows 2003. The servers ar the failover location are all 64 bit Windows 2008.</p>
<p>Is there any way to make these two environments talk and stay in sync? I have considered a "stretched" farm configuration, but that won't work... | <p>You can mix 32 bits and 64 bits in the same farm, it's fully supported. </p>
<p>However, it's highly recommenced to keep each tiers in the same bit width (for example all WFE 64 bits, application server 32 bits, SQL servers 64 bits).</p>
<p>From msdn @ <a href="http://technet.microsoft.com/en-us/library/cc261700.... | <p>We are actually running 32 and 64 bit wfe's in the same farm with no problems. We talked to an MVP and he said it is absolutely supported. The issue you have is load balancing 32 and 64 together.</p>
<p>MVP quote about the MSDN article <a href="http://technet.microsoft.com/en-us/library/cc261700.aspx" rel="nofoll... | 36,153 |
<p>Does anyone know how I can retrieve the previous JSP URL that a page has come from within a JSP?</p>
<p>Can I retrieve this from the session/ request/ response object?</p>
<p>Hope this makes sense, Thank you </p>
| <p>Many thanks - apologies for not being able to mark my correct answer as the site seems to have changed and i cant see how to do this but i used </p>
| <p>(assuming Struts 1) </p>
<p>Well in the struts-config.xml there is a input parameter in the action element (in the action-mappings section)
So in your action (java class) you can access this value like this :</p>
<p><code>
public ActionForward action(ActionMapping mapping, ActionForm form,
HttpServle... | 25,583 |
<p>When I build XML up from scratch with <code>XmlDocument</code>, the <code>OuterXml</code> property already has everything nicely indented with line breaks. However, if I call <code>LoadXml</code> on some very "compressed" XML (no line breaks or indention) then the output of <code>OuterXml</code> stays that way. So... | <p>Based on the other answers, I looked into <a href="https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmltextwriter" rel="noreferrer"><code>XmlTextWriter</code></a> and came up with the following helper method:</p>
<pre><code>static public string Beautify(this XmlDocument doc)
{
StringBuilder sb = new Stri... | <p>Set <strong>PreserveWhitespace</strong> to <strong>true</strong> before <strong>Load</strong>.</p>
<pre><code>var document = new XmlDocument();
document.PreserveWhitespace = true;
document.Load(filename);
</code></pre>
| 24,903 |
<p>What Database Abstraction Layer libraries would you recommend for use with C++? I am more interested in solutions for non-Windows platforms, but that is personal preference. Which libraries would you recommend and why?</p>
| <p>Take a look at <a href="http://soci.sourceforge.net/" rel="noreferrer">SOCI</a></p>
<p>Apparently, it is a serious candidate for Boost.</p>
| <p>I'd recommend using an <a href="http://en.wikipedia.org/wiki/Odbc" rel="nofollow noreferrer">ODBC</a> library.</p>
<p>Here are the first two when I googled:</p>
<p><a href="http://libodbcxx.sourceforge.net/" rel="nofollow noreferrer">libodbc++</a></p>
<p><a href="http://www.sqlapi.com/" rel="nofollow noreferrer">... | 37,879 |
<p>I'm trying to install <a href="http://godi.camlcity.org/godi/index.html" rel="noreferrer">GODI</a> on linux (Ubuntu). It's a library management tool for the ocaml language. I've actually installed this before --twice, but awhile ago-- with no issues --that I can remember-- but this time I just can't figure out what ... | <p>What is the output of <code>which godi_confdir</code>?</p>
<p>P.S. I remember having this exact same problem, but I don't remember precisely how I fixed it.</p>
| <p>What is the output of <code>which godi_confdir</code>?</p>
<p>P.S. I remember having this exact same problem, but I don't remember precisely how I fixed it.</p>
| 6,952 |
<p>How can a program capture <del>generates</del> events from a dynamically created button control in asp.net?</p>
| <p>You can attach the event programmatically:</p>
<pre><code>Button myButton = new Button();
myButton.Click += new ClickEventHandler...etc
</code></pre>
| <blockquote>
<p>Button ButtonDeleteFromDB = new Button();</p>
<p>ButtonDeleteFromDB.Text = "Delete";</p>
<p>ButtonDeleteFromDB.ID = "btnDeleteFromDB" + ctrlCount.ToString();</p>
<p>ButtonDeleteFromDB.Click += new EventHandler(ButtonDeleteFromDB_Click);</p>
</blockquote>
<p>Call the event in foll manne... | 45,015 |
<p>In Erlang, every process has a group leader, and when a process wants to print something (i.e. it calls the io library or does something similar), it will send a message to its group leader.</p>
<p>My question is, where can I find the specification of these messages? Or in general, the specification of what a group... | <p><a href="https://erlangcentral.org/erlang-rationale-2/" rel="nofollow noreferrer">The Erlang Rationale (video)</a> or <a href="http://www.erlang-factory.com/upload/presentations/329/EFKR10-ErlangRationale.pdf" rel="nofollow noreferrer">(slides)</a>; is a good source of information, as is the source code for <a href... | <p>The Erlang I/O protocol is described in detail here:</p>
<p><a href="http://www.erlang.org/doc/apps/stdlib/io_protocol.html" rel="nofollow">http://www.erlang.org/doc/apps/stdlib/io_protocol.html</a></p>
| 35,915 |
<p>My team is trying to setup an Apache reverse proxy from a customer's site into one of our web applications. </p>
<p><a href="http://www.example.com/app1/some-path" rel="noreferrer">http://www.example.com/app1/some-path</a> maps to <a href="http://internal1.example.com/some-path" rel="noreferrer">http://internal1.ex... | <p>There is an article titled <a href="http://www.askapache.com/htaccess/reverse-proxy-apache.html" rel="noreferrer">Running a Reverse Proxy in Apache</a> that seems to address your problem. It even uses the same example.com and /app1 that you have in your example. Go to the "Configuring the Proxy" section for exampl... | <p>Try using the AJP connector instead of reverse proxy. Certainly not a trivial change, but I've found that a lot of the URL nightmares go away when using AJP instead of reverse proxy.</p>
| 22,978 |
<p><strong>Closed</strong> as duplicate of <a href="https://stackoverflow.com/questions/308772/what-are-some-ways-to-protect-emails-on-websites-from-spambots">What are some ways to protect emails on websites from spambots?</a></p>
<p>I am finally puting up my personal web site. I want to publish a webmaster/feedback ... | <p>See <a href="https://stackoverflow.com/questions/308772/what-are-some-ways-to-protect-emails-on-websites-from-spambots">this Stackoverflow thread</a></p>
<p>I'm partial to using javascript to construct the mailto URL on the client side.</p>
| <p>Some alternatives to the JavaScript method.</p>
<p>Spell out your address and avoid making it a link.
Example: someone (at) somewhere (dot) com.</p>
<p>HTML encode the email address in the href attribute and inside the anchor tag.</p>
| 42,704 |
<p>I'd like to re-brand (and send error emails) for all of the SSRS default error pages (picture below) when you access reports via /ReportServer/. I'm already handling the ASP OnError event and <em>some</em> of the default SSRS errors appear to catch their own exceptions and then render this page cancel the response ... | <p>To get the average of the minimum values for each incnum, you could write this SQL</p>
<pre><code>select avg(min_time) as avg_time from
(select incnum, min(col2) as min_time from inc group by incnum)
</code></pre>
<p>using the correct average function for your brand of SQL.</p>
<p>If you're doing this in Acce... | <p>SELECT DISTINCT()</p>
<p>or</p>
<p>GROUP BY ()</p>
<p>or</p>
<p>SELECT UNIQUE()</p>
<p>... but usually averages <em>have</em> duplicates included. Just tell me this isn't for financial software, I wont stand for <a href="http://scienceblogs.com/goodmath/2008/09/bad_probability_and_economic_d.php" rel="nofollow... | 22,838 |
<p>I asked <a href="https://stackoverflow.com/questions/288409/how-do-i-get-the-html-output-of-a-usercontrol-in-net-c">how to render a UserControl's HTML</a> and got the code working for a dynamically generated UserControl.</p>
<p>Now I'm trying to use LoadControl to load a previously generated Control and spit out it... | <p>Alternatively you could disable the ServerForm/Event-validation on the page that is rendering the control to a string.</p>
<p>The following example illustrates how to do this.</p>
<pre><code>public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
... | <p>I was having the same problem using similar code to @TcKs and haven't been able to make any of these examples work for me. I got it working by using the <code>LoadControl</code> method of a <code>UserControl</code> as such:</p>
<pre><code>UserControl uc = new UserControl();
Control c = uc.LoadControl("newUserContro... | 43,356 |
<p>In the process of developing my first WCF service and when I try to use it I get "Method not Allowed" with no other explanation. </p>
<p>I've got my interface set up with the ServiceContract and OperationContract:</p>
<pre><code> [OperationContract]
void FileUpload(UploadedFile file);
</code></pre>
<p>Alon... | <p>Your browser is sending an HTTP GET request: Make sure you have the WebGet attribute on the operation in the contract:</p>
<pre><code>[ServiceContract]
public interface IUploadService
{
[WebGet()]
[OperationContract]
string TestGetMethod(); // This method takes no arguments, returns a string. Perfect fo... | <p>Only methods with WebGet can be accessed from browser IE ; you can access other http verbs by just typing address</p>
<p>You can either try Restful service startup kit of codeples or use fiddler to test your other http verbs</p>
| 6,241 |
<p>When using Fiddler to monitor HTTP Requests & Responses in Internet Explorer it ignores all traffic directed to <a href="http://localhost" rel="noreferrer">http://localhost</a>.</p>
| <p>To get Fiddler to capture traffic when you are debugging on local host, after you hit F5 to begin degugging change the address so that localhost has a "." after it. </p>
<p>For instance, you start debugging and the you have the following URL in the Address bar: </p>
<p><a href="http://localhost:49573/Default.aspx"... | <p>Go to Tools, Fiddler Options ..., select the Connections tab, then make sure Monitor all connections is ticked. Like Antony Scott said, but also make sure that the "Web Sessions" pane is set to "Capturing" and [ "Web Browsers" OR "All Processes" ]. Looks like the default is "Non-Browser".</p>
| 26,344 |
<p>I need to find out what ports are attached to which processes on a Unix machine (HP Itanium). Unfortunately, <code>lsof</code> is not installed and I have no way of installing it. </p>
<p>Does anyone know an alternative method? A fairly lengthy Googling session hasn't turned up anything.</p>
| <p><a href="http://www.faqs.org/docs/linux_network/x-087-2-iface.netstat.html" rel="noreferrer">netstat -l</a> (assuming it comes with that version of UNIX)</p>
| <p>If you want to know <strong>all listening ports along with its details</strong>: local address, foreign address and state as well as Process ID (PID). You can use following command for it in linux.</p>
<pre><code> netstat -tulpn
</code></pre>
| 15,320 |
<p>I'm facing a real problem in understanding how to draw a variable diagram to a linked list</p>
<p>In the book I'm reading its not giving enough info</p>
<p>I will post an example:</p>
<hr>
<p>the insert:</p>
<pre><code>public void Insert(Object newItem, Object after)
{
Node current = new Node();
Node n... | <p>Are you trying to draw it out on paper for homework? If so, the Link property of each node has a reference to the next node in the linked list. To draw it, you would probably have a series of boxes in a row that represent the node classes. In each node, you would have two properties, the Item and the Link. Link woul... | <p>First of all, you will need to know the basics of drawing.<br>
A good idea would be to provide a separated "DrawNode" function. Then, you will need to retrieve the Node's children, and draw each of them. Finally, you'll need to draw the links.</p>
<p>Make sure one drawn node is not hiding another.
I hope this helps... | 37,579 |
<p>I'm looking at setting up unit tests and integration testing, but I've run into the problem that the connection string in the web.config is unavailable for testing. The solution we've come up with to get around this is to have another connection string for testing, but I was wondering if there was a better way.</p>
... | <p>The recommended approach is to architect your system that you can test your code without a DB. What this means to a code perspective is using seperation of concerns. You want all of your core business logic seperated from your pages. You can do this using a MVC or MPV pattern, which if you good you can find a great ... | <p>In your unit tests, isolate the data access code and abstract it (usually using interfaces, e.g. the <a href="http://martinfowler.com/eaaCatalog/repository.html" rel="nofollow noreferrer">repository pattern</a>) so that you don't have any database code in your unit tests. Instead, mock your data access abstractions,... | 47,891 |
<p>Using the <code>zip</code> function, Python allows for loops to traverse multiple sequences in parallel. </p>
<p><code>for (x,y) in zip(List1, List2):</code></p>
<p>Does MATLAB have an equivalent syntax? If not, what is the best way to iterate over two parallel arrays at the same time using MATLAB?</p>
| <p>If x and y are column vectors, you can do:</p>
<pre><code>for i=[x';y']
# do stuff with i(1) and i(2)
end
</code></pre>
<p>(with row vectors, just use <code>x</code> and <code>y</code>).</p>
<p>Here is an example run:</p>
<pre class="lang-matlab prettyprint-override"><code>>> x=[1 ; 2; 3;]
x =
1
... | <p><code>for</code> loops in MATLAB used to be slow, but this is not true anymore.</p>
<p>So vectorizing is not always the miracle solution. Just use the profiler, and <code>tic</code> and <code>toc</code> functions to help you identify possible bottlenecks.</p>
| 7,183 |
<p>I’m working on an in-house app that tracks a bunch of tasks. I wanted to have a simple task monitor that would list the task name and the task’s status. I need this to look just a little nice, I’m no designer so whatever I do is going to suck, but a basic text display won’t work for the project requirements.</p>
<p... | <p>It sounds like what you may be looking for is an <a href="http://java.sun.com/javase/6/docs/api/javax/swing/JList.html" rel="noreferrer"><code>JList</code></a>.</p>
<p>You can add your items to the <code>JList</code>'s by first adding your "task" to the <code>JList</code> object's <a href="http://java.sun.com/javas... | <p>How about a <code>JTable</code> (which you can set to allow multiple rows to be selected) with an internal <code>JPanel</code> occupying the single cell in each row, which contains a <code>JProgressBar</code> and a <code>JLabel</code>. Or you could use a <code>JList</code> with the same structure as I just described... | 49,531 |
<p>I have a Python script I recently wrote that I call using the command line with some options. I now want a very thin web interface to call this script locally on my Mac.</p>
<p>I don't want to go through the minor trouble of installing mod_python or mod_wsgi on my Mac, so I was just going to do a system() or popen(... | <p>Depending on what you are doing, <a href="http://php.net/manual/en/function.system.php" rel="noreferrer">system()</a> or <a href="http://php.net/manual/en/function.popen.php" rel="noreferrer">popen()</a> may be perfect. Use system() if the Python script has no output, or if you want the Python script's output to go... | <p>If you want to execute your Python script in PHP, it's necessary to do this command in your php script:</p>
<pre><code>exec('your script python.py')
</code></pre>
| 20,159 |
<p>I would like such empty span tags (filled with <code>&nbsp;</code> and space) to be removed:</p>
<p><code><span> &nbsp; &nbsp; &nbsp; </span></code></p>
<p>I've tried with this regex, but it needs adjusting: </p>
<p><code>(<span>(&nbsp;|\s)*</span>)</code></p>
<p><code... | <p>Translating Kent Fredric's regexp to PHP :</p>
<pre><code>preg_match_all('#<span[^>]*(?:/>|>(?:\s|&nbsp;)*</span>)#im', $html, $result);
</code></pre>
<p>This will match :</p>
<ul>
<li>autoclosing spans</li>
<li>spans on multilines and whatever the case</li>
<li>spans with attributes</li>
<l... | <p>If your only issue are nested span tags, you can run the search-and-replace with the regex you have in a loop until the regex no longer finds any matches.</p>
<p>This may not be a very elegant solution, but it'll perform well enough.</p>
| 37,321 |
<p>Using Oracle 10g with our testing server what is the most efficient/easy way to backup and restore a database to a static point, assuming that you always want to go back to the given point once a backup has been created.</p>
<p>A sample use case would be the following</p>
<ol>
<li>install and configure all softwar... | <p>You do not need to take a backup at your base time. Just enable flashback database, create a guaranteed restore point, run your tests and flashback to the previously created restore point.</p>
<p>The steps for this would be:</p>
<ol>
<li>Startup the instance in mount mode.<p>
startup force mount;</li>
<li>Create t... | <p>@Michael Ridley solution is perfectly scriptable, and will work with any version of oracle.</p>
<p>This is exactly what I do, I have a script which runs weekly to</p>
<ol>
<li>Rollback the file system</li>
<li>Apply production archive logs</li>
<li>Take new "Pre-Data-Masking" FS snapshot</li>
<li>Reset logs</li>
<... | 9,321 |
<p>How exactly can one implement a Log off function when using ASP.NET Forms Authentication on an intranet application?</p>
<p>How will this work if I am an administrator and want to log in "as someone else" into the application?</p>
<p>Please share your ideas</p>
| <p><code>FormsAuthentication.SignOut();</code> ;)</p>
| <p>The preferred authentication for an intranet application is to use windows authentication instead of forms authentication.</p>
<p>In which case you can just log off of windows and login as "someone" else.</p>
| 30,733 |
<p>I'm troubleshooting a problem with creating Vista shortcuts.</p>
<p>I want to make sure that our Installer is reading the Programs folder from the right registry key.</p>
<p>It's reading it from:</p>
<pre><code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Programs
</code></pr... | <p>Don't use the registry to read this. Use <a href="http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx" rel="nofollow noreferrer">SHGetFolderPath</a> with CSIDL_PROGRAMS.</p>
<p>For a reason why, see Raymond Chen's comments on the "Shell Folders" key:</p>
<p><a href="http://blogs.msdn.com/oldnewthing/arch... | <p>Sounds correct to me.</p>
| 8,228 |
<p>I'm a newbie in the great world of NHibernate. I'm using version 2.0.1.GA. Here's my question. I have a table <code>Cars</code> with column <code>Manufacturer(nvarchar(50))</code> and a primary key <code>ID(int)</code>. My .NET class is:</p>
<pre><code>public class Car
{
public virtual int ID { get; set; }
... | <p>Like Google Ninja said, you can do it with NHibernate.Linq.
The query would then be:</p>
<p><code>session.Linq<Car>.Where(c => c.Manufacturer == "Mercedes").ToList()</code></p>
<p>If someone ends up here and is using NH3.0 the syntax is just a tad different (thanks to Michael Mrozek and Mike for the sugg... | <p>Look at <a href="https://stackoverflow.com/questions/299384/linq-to-nhibernate-project-status-contributing-lead">this question here</a>. Someone had the same worry, and from I can gather, NHibernate.Linq is well alive.</p>
| 44,344 |
<p><a href="http://blog.stevenlevithan.com/archives/balancing-groups" rel="nofollow noreferrer">.NET balanced group regexes</a> make my head explode. I've got this string i'm trying to match:</p>
<pre><code>other stuff blah blah....
{
stuff stuff
{ke... | <p>Have you checked what it is matching in the second case? Since you don't have any anchors, I think the engine starts the match just after the first '{'. From there, until the end, the string matches.</p>
<p>Try surrounding the pattern with \A and \z.</p>
| <p>Not to be a kill joy but what you're attempting to do with a regular expression is boggling your mind because it's simply not possible. Regular expressions are a class of finite automata and do not posses enough state in which to peform recursive/nested matching. You'll need a context free grammar of sorts in orde... | 22,227 |
<p>Simply put, is there a way to create a 2D javascript array using similar syntax to this?</p>
<pre><code>var newArray = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8]
]
</code></pre>
| <p>You can create any n-dimensional arrays using <em>exactly</em> the format you suggest as in the following sample:</p>
<pre><code><script>
var newArray = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8]
]
var newArray3d =
[[[ 0, 1, 2],[ 3, 4, 5],[ 6, 7, 8]],
[[10, 11... | <p>Yes. This works fine:</p>
<pre><code><script>
var newArray = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8]
]
alert(newArray[0][2]);
</script>
</code></pre>
| 23,653 |
<p>I find that what not to do is a harder lesson to learn than what should be done. </p>
<p>From my experience, what separates an expert from an intermediate is the ability to select from among various seemingly equivalent ways of doing the same thing.</p>
<p>So, when it comes to JavaScript <strong>what kinds of thin... | <p>Language:</p>
<ul>
<li><p>Namespace polluting by creating a large footprint of variables in the global context.</p></li>
<li><p>Binding event handlers in the form 'foo.onclick = myFunc' (inextensible, should be using attachEvent/addEventListener).</p></li>
<li><p>Using eval in almost any non-JSON context</p></li>
<... | <p><strong>Effective caching is seldomly done:</strong></p>
<ul>
<li>Don't store a copy of the library (jQuery, Prototype, Dojo) on your server when you can use a shared API like <a href="http://code.google.com/apis/libraries/devguide.html" rel="nofollow">Google's Libraries API</a> to speed up page loads</li>
<li><a h... | 49,508 |
<p>Let's say we have a method signature like </p>
<pre><code>public static function explodeDn($dn, array &$keys = null, array &$vals = null,
$caseFold = self::ATTR_CASEFOLD_NONE)
</code></pre>
<p>we can easily call the method by omitting all parameters after <code>$dn</code>:</p>
<pre><code>$dn=Zend_Ldap... | <p>It's because you can't have a reference to null.</p>
<p>You can have a reference to a variable that contains null - that is exactly what the default value does. Or you can pass in null as a literal value - but since you want an out parameter this is not possible here.</p>
| <p>Just to confirm what <a href="https://stackoverflow.com/users/18771/tomalak">Tomalak</a> stated <a href="https://stackoverflow.com/questions/280385/php-by-reference-parameters-and-default-null#280397">here</a>:</p>
<p>The following works:</p>
<pre><code>$k=array();
$v=null;
$dn=Zend_Ldap_Dn::explodeDn('CN=Alice Ba... | 35,454 |
<p>pdb files contain symbol information for .NET assemblies. I'd like to read a pdb file in order to correlate methods with their file location. The data is contained within it but I can't seem to find a good description of how to get it out.</p>
<p>I know about <a href="http://blogs.msdn.com/jmstall/archive/2005/08/2... | <p>You should look:</p>
<ul>
<li><a href="http://www.mono-project.com/Cecil" rel="nofollow noreferrer">Mono.Cecil</a> and especially the Mono.Cecil.Pdb module. It should do what you want and more.</li>
</ul>
| <p>In DBGHELP.DLL, you can use the SymGetLineFromAddr64 function. You'll need to use P/Invoke. There might be a corresponding API in the DIA SDK, but I'm not as familiar with it as I am DBGHELP.</p>
| 19,479 |
<p>For example, one instance of apache is managing</p>
<blockquote>
<p>www.site.com/folder1/a.html</p>
<p>www.site.com/folder2/b.html</p>
<p>www.site.com/folder3/c.html</p>
</blockquote>
<p>I need to make sure that access to
<code>www.site.com/folder3/c.html</code>
is https only.</p>
<p>All these folder... | <p>I'm always just downloading <strong>classic</strong> edition and just add plugins I need. That way I keep Eclipse as lean as possible.</p>
| <p>Agree with <a href="https://stackoverflow.com/questions/305708/best-eclipse-version-for-java-development#305743">Marko</a> and <a href="https://stackoverflow.com/questions/305708/best-eclipse-version-for-java-development#305749">Epaga</a></p>
<p>I have Eclipse 3.4 (Ganymede) with following additional plugins (links... | 39,329 |
<p>It's my first time printing in vase mode, and I noticed my printer underextruding badly. The settings have not been changed from default vase mode settings in slicer, and earlier I was printing non-vase mode and the prints came out fine. Layer height is 0.2 mm and perimeter width is 0.3 mm. </p>
<p><a hre... | <p>Finding the cause of under-extrusion is very hard as a lot of parameters of the print process can influence this. There are some nice websites that describe these problems in detail. From your question it is unclear what you have done to solve the problem, or if you have printed products after the vase mode and show... | <p>Finding the cause of under-extrusion is very hard as a lot of parameters of the print process can influence this. There are some nice websites that describe these problems in detail. From your question it is unclear what you have done to solve the problem, or if you have printed products after the vase mode and show... | 858 |
<p>I'm new to extending Drupal, though I've done similar kinds of things for other CMSes. Anyone care to share opinions on the best way to access an external API from within Drupal?</p>
<p>I need to show things like search results, listings, and listing summaries. In my reading up on Drupal, I think this implies I nee... | <p>Yes, they are all possible from within the same module; consult the various <a href="http://api.drupal.org/api/group/hooks/6" rel="nofollow noreferrer">hook functions</a> on how to declare nodes and blocks in a function.</p>
<p>There's also the PHP filter, which lets you embed pure PHP code on content pages, and do... | <p>Andrew - generally, you will want to put any kind of non-trivial code in an external module. With the exception of display code, which should be put into the template.php file associated with your theme.</p>
<p>If you care to describe your project in greater depth, I may be able to make more useful suggestions.</p>... | 23,866 |
<p>I don't seem to be able to close the OledbDataReader object after reading data from it. Here is the relevant code -</p>
<pre><code>Dim conSyBase As New OleDb.OleDbConnection("Provider=Sybase.ASEOLEDBProvider.2;Server Name=xx.xx.xx.xx;Server Port Address=5000;Initial Catalog=xxxxxxxxxx;User ID=xxxxxxxx;Password=xxxx... | <p>I found the answer!</p>
<p>Before</p>
<pre><code>drSyBase.Close()
</code></pre>
<p>You need to call the cancel method of the Command object </p>
<pre><code>cmdSyBase.Cancel()
</code></pre>
<p>I believe that this may be specific to Sybase databases</p>
| <p>This is a long-shot, but try moving your .Close() and .Dispose() lines in a Finally block of the Try. Like this:</p>
<pre><code>
Dim conSyBase As New OleDb.OleDbConnection("Provider=Sybase.ASEOLEDBProvider.2;Server Name=xx.xx.xx.xx;Server Port Address=5000;Initial Catalog=xxxxxxxxxx;User ID=xxxxxxxx;Password=xxxxx... | 15,409 |
<p>We are utilizing the XML data type in Microsoft SQL Server 2005 for a project. Some members of the team and I feel that we should also use XSDs while members of the other camp feel that we should keep the XMLs ad hoc and not treat them as "types".</p>
<p>The XMLs are an effort to bring structure and centrality to a... | <p>Unfortunately even the authoring body of XSD (W3C) understands that XSD is a pretty bad technology. That said, it's intention isn't necessarily bad. One of C#'s major benefits is that it is statically typed. Statically typing your XML documents gives them the same benefits. What's probably best here is reverse engin... | <p>important reason for the development of XML is that it allows for the use of data from more sources and in more ways as it has become a widely accepted standard for exchanging data between any number of computer systems.</p>
| 16,977 |
<h3>See: <a href="https://stackoverflow.com/questions/5727/understanding-pointers">Understanding Pointers</a></h3>
<hr />
<p>In many C flavoured languages, and some older languages like Fortran, one can use <strong>Pointers</strong>.</p>
<p>As someone who has only really programmed in basic, javascript, and actionscrip... | <p>A pointer is a variable that contains the address of another variable. This allows you to reference another variable indirectly. For example, in C:</p>
<pre><code>// x is an integer variable
int x = 5;
// xpointer is a variable that references (points to) integer variables
int *xpointer;
// We store the address (... | <p>As someone already mention, a pointer is a variable that contains the address of another variable.</p>
<p>It's mostly used when creating new objects (in run-time).</p>
| 18,585 |
<p>I have 3 .net projects.</p>
<p>Project1.dll is generated by a VS2008 project. </p>
<p>Project2.dll is generated by a VS2005 project that references Project1.dll. </p>
<p>Project3.dll is generated by a VS2008 project that references both Project1.dll and Project2.dll.</p>
<p>Right now, I build Project1.dll, and... | <p>Probably the best option would be to have a common build folder for all three projects. This can be done in the Project Properties-> Build -> Output path. Then point the references to the output folder. That way anytime you build any of the lower projects, the higher projects would have the latest versions. You ... | <p>We use a build script that handles the dependencies, builds the DLLs and does what you're doing manually.</p>
| 19,128 |
<p>I am currently using SQL Server Management Studio (Ver 9.00.3042.00) and click the "New Query" and wrote the following code:</p>
<pre><code>Select
colA,
colB,
colC
colD
From
table1
</code></pre>
<p>When I click the parse (checkbox) button to validate the SQL statement, it says "Command(s) comp... | <p>That's because that is valid SQL. You're effectively aliasing colC with the name colD. It's the same as typing:</p>
<pre><code>colC as colD
</code></pre>
<p>Edit: For what it's worth, this is one of the reasons why people will argue that you should put the commas at the beginning of the line in cases like this. It... | <p>After a little playing around, it throws the "Incorrect syntax near" on the following code snippets</p>
<pre><code>Select
colA,
colB
colC
colD
From
table1
Select
colA,
colB,
colC,
colD,
From
table1
</code></pre>
| 40,726 |
<p>Expanding on <a href="https://stackoverflow.com/questions/137657/free-insaller">Free install wizard software</a> I am looking for a cross platform installer. We support something like 27 platform variations and most of the installers mentioned in the other question are windows only. We are looking for something po... | <p><A HREF="http://izpack.org/" rel="noreferrer">IzPack</A> ?</p>
| <p>Here's a list of some: <a href="http://java-source.net/open-source/installer-generators" rel="nofollow noreferrer">Open Source Installer Generators in Java</a>.</p>
| 16,658 |
<p>Is it possible to fork a users session (or do something similar) in a Internet Explorer plugin?</p>
<p>I want to process the page the user is on when they click a button in the toolbar. To avoid interrupting the users browsing, I'd like to "copy" everything so I can parse and process the page in the backgr... | <p>A BHO or plugin would work.
There are so many options to get the source, it's kinda. pick your poising.
Look up IDocHostUIHandler to alter behaviour. IHTMLElementCollection to parse the page in browser.
The easiest thing I can think of at the moment is....</p>
<p>Save the current contents to a stream. same as get/... | <p>Interesting thought. Could you copy the DOM holus-bolus and then replace a new window's DOM with the copy. It's just a guess. I'm as much in the dark as you at this point.</p>
| 33,155 |
<p>I am instantiating a class A (which I am importing from somebody
else, so I can't modify it) into my class X.</p>
<p>Is there a way I can intercept or wrap calls to methods in A?
I.e., in the code below can I call</p>
<pre><code>x.a.p1()
</code></pre>
<p>and get the output</p>
<pre><code>X.pre
A.p1
X.post
</code... | <p>Here is the solution I and my colleagues came up with:</p>
<pre><code>from types import MethodType
class PrePostCaller:
def __init__(self, other):
self.other = other
def pre(self): print 'pre'
def post(self): print 'post'
def __getattr__(self, name):
if hasattr(self.other, name):
... | <p>Here's what I've received from Steven D'Aprano on comp.lang.python.</p>
<pre><code># Define two decorator factories.
def precall(pre):
def decorator(f):
def newf(*args, **kwargs):
pre()
return f(*args, **kwargs)
return newf
return decorator
def postcall(post):
de... | 32,212 |
<p>I am trying to copy a file using the following code:</p>
<pre><code>File targetFile = new File(targetPath + File.separator + filename);
...
targetFile.createNewFile();
fileInputStream = new FileInputStream(fileToCopy);
fileOutputStream = new FileOutputStream(targetFile);
byte[] buffer = new byte[64*1024];
int i = 0... | <p>This can occur when filename has timestamp with colons, eg. <code>myfile_HH:mm:ss.csv</code> Removing colons fixed the issue.</p>
| <p>Do you check that the targetPath is a directory, or just that something exists with that name? (I know you say the user can copy it from the operating system, but maybe they're typing something else).</p>
<p>Does targetPath end with a File.separator already?</p>
<p>(It would help if you could log and tell us what ... | 15,998 |
<p>I've got a web application that is running against Windows Authentication using our Active Directory. I've got a new requirement to pull some personal information through from the Active Directory entry. What would be the easiest way to get access to this information?</p>
| <p>Accessing the user directly through a DirectoryEntry seems like the most straightforward approach. Here are some AD-related tidbits I learned from my first AD-related project:</p>
<ul>
<li>In a URI, write LDAP in lowercase. Otherwise you'll get a mystery error. I spent more than a day on this depressing issue...</l... | <p>I've used a standard LDAP library to retrieve information from an Active Directory server, but you'd have to verify that the data you need is available via the LDAP server's schema. In general, you can get any information stored in InetOrganizationalPerson and most of the information related to the group(s) they be... | 16,037 |
<p>How would you get a reference to an executing class several stack frames above the current one? For example, if you have:</p>
<pre><code>Class a {
foo() {
new b().bar();
}
}
Class b {
bar() {
...
}
}
</code></pre>
<p>
Is there a way to get the value that would be retrieved by usi... | <p>No, you can't. In all the languages that use a stack that I know of, the contents of other stack frames are hidden from you. There are a few things you can do to get it, beyond the obvious passing it as a parameter. One of the aspect oriented frameworks might get you something. Also, you can get a bit of debugging i... | <p><code>this</code> is always a reference to the current instance of the object. So any usage of <code>this</code> in <code>foo()</code> will return an instance of Class A.</p>
| 41,793 |
<p>I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: <em><a href="http://www.gallup.com" rel="nofollow noreferrer">www.gallup.com</a></em> and <em><a href="http://www.rassmussenreports.com" rel="nofollow noreferrer">www.rassmussenreports.com</a></em></p>
<p>I'm... | <p>Would something like this work?</p>
<pre><code>from random import randint
mcworks = []
for n in xrange(NUM_ITERATIONS):
mctest = [randint(0, 100) for i in xrange(5)]
if sum(mctest[:3])/3 == mcavg[2]:
mcworks.append(mctest) # mcavg is real data
</code></pre>
<p>In the end, you are left with a li... | <p>A neat way to do it is to use a list of lists in combination with Pandas. Then you are able to create a 3-day rolling average.
This makes it easy to search through the results by just adding the real ones as another column, and using the loc function for finding which ones that match.</p>
<pre><code>rand_vals = [r... | 8,428 |
<p>This might be a stupid question but if there's a better or proper way to do this, I'd love to learn it.</p>
<p>I have run across this a few times, including recently, where small spaces show up in the rendered version of my HTML page. Intuitively I think these should not be there because outside of text or entities... | <p>The whitespace (carriage return included) is usually rendered as space in all browsers.</p>
<p>You need to put the elements one after another, but you can use a trick:</p>
<pre><code><a href="page1.html"><img src="image1.png"
/></a><a href="page2.html"><img src="image2.png"
/></a... | <p>If you're going to do a tabbed interface on a website, take great pains to do it properly, and it will be worthwhile. There are many websites with great examples of CSS tab implementations. Consider using one of them.</p>
<p><a href="http://www.noupe.com/javascript/37-great-ajax-css-tab-based-interfaces.html" rel="... | 16,307 |
<p>I want to do this in Actionscript:</p>
<pre><code>typeof(control1) != typeof(control2)
</code></pre>
<p>to test if two objects are of the same type. This would work just fine in C#, but in Actionscript it doesnt. In fact it returns <code>'object'</code> for both <code>typeof()</code> expressions because thats the ... | <p>The best way is to use <code>flash.utils.getQualifiedClassName()</code>. Additionally, you can use <code>flash.utils.describeType()</code> to get an XML document the describes more about the class.</p>
| <pre><code>Object obj = new Object();
Object o = new Object();
if(o.getClass().getName().endsWith(obj.getClass().getName())){
return true;
}else{
return false;
}
</code></pre>
| 40,056 |
<p>I use this question in interviews and I wonder what the best solution is.</p>
<p>Write a Perl sub that takes <em>n</em> lists, and then returns 2^<em>n</em>-1 lists telling you which items are in which lists; that is, which items are only in the first list, the second, list, both the first and second list, and all ... | <p>Your given solution can be simplified quite a bit still.</p>
<p>In the first loop, you can use plain addition since you are only ever ORing with single bits, and you can narrow the scope of <code>$bit</code> by iterating over indices. In the second loop, you can subtract 1 from the index instead of producing an unn... | <p>Here is my solution:</p>
<p>Construct a hash whose keys are the union of all the elements in the input lists, and the values are bit strings, where bit <em>i</em> is set if the element is present in list <em>i</em>. The bit strings are constructed using bitwise or. Then, construct the output lists by iterating over... | 9,387 |
<p>I've found that on some occasions I can edit the source while debugging. Are there any other advantages of using the Visual Studio built-in webserver instead of a virtual directory in IIS?</p>
<p>I'm using Windows XP on my development environment, and a local instance of IIS 5. I work on several projects,... | <p>The built-in web server for Visual Studio is called Cassini and here are a few of its limitations...</p>
<ul>
<li>It can host only one ASP.NET
application per port.</li>
<li>It does not support HTTPS.</li>
<li>It does not support authentication.</li>
<li>It responds only to localhost
requests.</li>
<li>It is slow s... | <p>If your project resides in the IIS directory you can still edit code. It just depends if it has been published or not.</p>
<p>You will run into so many issues on the Cassini vs. IIS when you are debugging certain permission based scenarios, like <a href="https://duckduckgo.com/html/?q=Wikipedia%20ntlm" rel="nofollo... | 12,943 |
<p>Should I use the GWT for a struts web application?</p>
| <p>I think you'll find that GWT complements something like Stripes much more than it does struts. I don't want to start some kind of flame/development platform war but in my opinion Stripes is a far superior and easier to use framework than struts, we migrated from struts a year ago and have never looked back.</p>
<p>... | <p>I don't think GWT would integrate so well into Struts - GWT is more like a framework which you would use instead of Struts.</p>
<p>You could try something like <a href="http://extjs.com/" rel="nofollow noreferrer">Ext JS</a>, which (being a pure JavaScript library) I think would be more likely to integrate into Str... | 19,492 |
<p>Ok I have an <code>apache IBM HTTP Server WAS 6.1</code> setup </p>
<p>I have my <code>certs</code> correctly installed and can successfully load <code>http</code> and <code>https</code> pages.</p>
<p>After a successful <code>j_security_check</code> authentication via <code>https</code>, I want the now authorized ... | <p>This is the solution for http to https to http</p>
<p>You have to put the condition and the rewrite rule in the virtual host like the arcticle said but for some reason inheritance didn't want to work.</p>
<pre><code>RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /path/login\.jsp... | <p>Wild guess: should the second logical OR be an AND (i.e. no [OR] and the RewriteCond defaults to AND)?</p>
<pre><code>RewriteCond %{THE_REQUEST} !login\.jsp.*action=init
RewriteCond %{THE_REQUEST} !login\.jsp.*action=submit
</code></pre>
| 31,278 |
<p>In Eclipse I can set all kinds of preferences for coding style. I'd like to be able to enforce these as an ant task to make the build break. </p>
<p>Can anyone give me an example of how to enforce eclipse coding styles in an Ant task?</p>
<p>(I KNOW about PMD, checkstyle etc - none of these EXACTLY match the eclip... | <p>Try checkstyle (there is an eclipse plugin, and an ant task that produces reports. You can 'break' the build if you want).</p>
<p><a href="http://checkstyle.sourceforge.net/" rel="nofollow noreferrer">http://checkstyle.sourceforge.net/</a></p>
| <p>I'd like to plug eclipse into checkstyle - and use the eclipse style preferences - not the checkstyle preferences in eclipse. </p>
| 42,184 |
<p>I am programmatically exporting data (using PHP 5.2) into a .csv test file.<br>
Example data: <code>Numéro 1</code> (note the accented e).
The data is <code>utf-8</code> (no prepended BOM).</p>
<p>When I open this file in MS Excel is displays as <code>Numéro 1</code>.</p>
<p>I am able to open this in a text edi... | <p>A correctly formatted UTF8 file can have a <a href="http://en.wikipedia.org/wiki/Byte_order_mark" rel="noreferrer">Byte Order Mark</a> as its first three octets. These are the hex values 0xEF, 0xBB, 0xBF. These octets serve to mark the file as UTF8 (since they are not relevant as "byte order" information).<a href=... | <p>open the file csv with notepad++
clic on Encode, select convert to UTF-8 (not convert to UTF-8(without BOM))
Save
open by double clic with excel
Hope that help
Christophe GRISON</p>
| 18,752 |
<p>Is there some way to get a value from the last inserted row?</p>
<p>I am inserting a row where the PK will automatically increase, and I would like to get this PK. Only the PK is guaranteed to be unique in the table.</p>
<p>I am using Java with a JDBC and PostgreSQL.</p>
| <p>With PostgreSQL you can do it via the RETURNING keyword:</p>
<p><a href="http://www.postgresql.org/docs/8.3/interactive/sql-insert.html" rel="noreferrer">PostgresSQL - RETURNING</a></p>
<pre><code>INSERT INTO mytable( field_1, field_2,... )
VALUES ( value_1, value_2 ) RETURNING anyfield
</code></pre>
<p>It will r... | <p>Don't use SELECT currval('MySequence') - the value gets incremented on inserts that fail.</p>
| 29,821 |
<p>I am searching for an open-source implementation of an <a href="http://elinux.org/UPnP" rel="nofollow noreferrer">UPnP</a> client in Python, and more specifically of its <a href="http://en.wikipedia.org/wiki/Internet_Gateway_Device_Protocol" rel="nofollow noreferrer">Internet Gateway Device</a> (IGD) part.</p>
<p>F... | <p>MiniUPnP source code contains a Python sample code using the C library as an extension module (see <code>testupnpigd.py</code>), which I consider as a proper solution to my problem.</p>
<p>Rationale: this is not the pure Python solution I was looking for, but:</p>
<ul>
<li>significant effort has already been inves... | <p>I think you should really consider BRisa. It recently became a pure python UPnP Framework, not focused only on Media Server.</p>
<p>It provides lots of utilitary modules and functions for you to build and deploy your UPnP device.</p>
<p>The project also is lacking feedback :-). I suggest you to use the latest svn ... | 37,594 |
<p>I'm relatively new to C++. In Java, it's easy for me to instantiate and use a hashmap. I'd like to know how to do it in a simple way in C++, since I saw many different implementations and none of them looked simple to me.</p>
| <p>Most compilers should define <code>std::hash_map</code> for you; in the coming <code>C++0x</code> standard, it will be part of the standard library as <a href="http://en.cppreference.com/w/cpp/container/unordered_map" rel="noreferrer"><code>std::unordered_map</code></a>. The <a href="http://www.sgi.com/tech/stl/hash... | <p>Try boost's <a href="http://www.boost.org/doc/libs/1_37_0/doc/html/unordered.html" rel="nofollow noreferrer">unordered</a> classes.</p>
| 33,377 |
<p>I'm going to 3D print a part that needs to meet certain strength requirements, due to its usages. I know how strong a particular plastic (eg. comrpessive/tensile/shear strength) is when dealt with in a solid chunk, but not when it is 3D printed. What is a good way to estimate the change?</p>
| <p>I have a bunch of solutions to this problem but I'm always looking for additional ideas. I usually start by slicing as much as possible off with a hobby knife. The more than can be removed before sanding the better.</p>
<p>For big prints I like big <a href="http://rads.stackoverflow.com/amzn/click/B001449TPS">gener... | <p>I've noticed if I'm printing too close too the bed or if the bed isn't level to nozzle across the whole bed the supports will leave marks on the print where the print was 'smushed' by the nozzle being slightly closer on that side. Also, in Simplify3d you can increase the vertical and horizontal distance between the ... | 110 |
<p>Here is the problem, I have written an event loop to detect keydown and keyup events. The problem I am running into is that a keydown event is generating a keydown and a keyup event when the key is pressed and held down. I am using the arrow keys to move an object and then to stop moving when the key is released(k... | <p>Heck no - logging is <em>incredibly</em> important for web applications. If you log appropriately, it makes troubleshooting <em>so</em> much easier.</p>
<p>Log4Net is probably a good bet as a framework. You might also want a way of gathering logs together from multiple servers - and even if you don't use more than ... | <p>I would certainly vouch for enterprise information sink (I think this is the right name, it's a Microsoft api for logging), or Enterprise Library.</p>
<p>I use the latter for all sorts of things such as caching, logging, etc, and it is a very powerful and time saving tool. I also use health monitoring. This is for ... | 42,434 |
<p>I'm writing an iPhone app with Cocoa in xcode. I can't find any tutorials or sample code that shows how to take photos with the built in camera. How do I do this? Where can I find good info?</p>
<p>Thanks!</p>
| <p>Just Copy and paste following code into your project to get fully implemented functionality.</p>
<p>where <strong>takePhoto</strong> and <strong>chooseFromLibrary</strong> are my own method names which will be called on button touch.</p>
<p>Make sure to reference outlets of appropriate buttons to these methods. ... | <p>Here is my code that i used to take picture for my app</p>
<pre><code>- (IBAction)takephoto:(id)sender {
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:picker animated:YES completio... | 15,023 |
<p>I'm working on a cube in Blender. I just deleted one of the faces (the top face) of the cube and added solidify to avoid non manifold edges. </p>
<p>In this case, when I check the design it shows that the bottom face is an overhang face (shown with yellow color). However, if I change the overhang parameter in 3D ... | <p>Overhangs that are substantially greater than 45° to the vertical generally require supports, and overhangs of 90° will definitely require supports, unless they are bridges (supported at both ends). Depending on how well you have your printer and filament "dialled in", it is possible to print overhangs up to 70° wit... | <p>Overhangs that are substantially greater than 45° to the vertical generally require supports, and overhangs of 90° will definitely require supports, unless they are bridges (supported at both ends). Depending on how well you have your printer and filament "dialled in", it is possible to print overhangs up to 70° wit... | 1,333 |
<p>I have the following XML structure:</p>
<pre><code><?xml version="1.0" ?>
<course xml:lang="nl">
<body>
<item id="787900813228567" view="12000" title="0x|Beschrijving" engtitle="0x|Description"><![CDATA[Dit college leert studenten hoe ze een onderzoek kunn$
<item id="54531166... | <p>When you load the XML file, you'll need to handle the CDATA.. This example works:</p>
<pre><code><?php
$xml = simplexml_load_file('file.xml', NULL, LIBXML_NOCDATA);
$description = $xml->xpath("//item[@title='0x|Beschrijving']");
var_dump($description);
?>
</code></pre>
<p>Here's the output:</p>
<pre><co... | <pre><code>$description = $xml->xpath("//item[@title='0x|Beschrijving']");
while(list( , $node) = each($description)) {
echo($node);
}
</code></pre>
<p>dreamwerx's solution is better</p>
| 14,596 |
<p>Are there any free tools for scripting MSSQL table data? I'll gladly write one, but am hoping it's been done, and the app matured a bit before/</p>
| <p>Here are some scripts I wrote for reverse engineering SQL server schemas. They may be of some use. Also, as a general interest they give some examples of how to get various bits of information out of the data dictionary. I've added an MIT license below to make permission-to-use explicit and for some basic no-impl... | <p>TOAD for Oracle can do it, so I suspect TOAD for SQL Server will be able to too.</p>
| 21,970 |
<p>I'm having a disagreement with someone over how best to implement a simple method that takes an array of integers, and returns the highest integer (using C# 2.0).</p>
<p>Below are the two implementations - I have my own opinion of which is better, and why, but I'd appreciate any impartial opinions.</p>
<p><strong>... | <p>Ôption B of course.</p>
<p>A is ugly :</p>
<ul>
<li><p>Catch(Exception) is a really bad practice</p></li>
<li><p>You shoul not rely on exception for null ref, out of range,...</p></li>
<li><p>Sorting is way complexier than iteration</p></li>
</ul>
<p>Complexity :</p>
<ul>
<li><p>A will be O(n log(n)) and even O(... | <p>I would say that it depends on what your goal is, speed or readability. </p>
<p>If processing speed is your goal, I'd say the second solution, but if readability is the goal, I'd pick the first one.</p>
<p>I'd probably go for speed for this type of function, so I'd pick the second one.</p>
| 30,698 |
<p>I have a .NET 2.0 server that seems to be running into scaling problems, probably due to poor design of the socket-handling code, and I am looking for guidance on how I might redesign it to improve performance.</p>
<p><strong>Usage scenario:</strong> 50 - 150 clients, high rate (up to 100s / second) of small messag... | <p>A lot of this has to do with many threads running on your system and the kernel giving each of them a time slice. The design is simple, but does not scale well.</p>
<p>You probably should look at using Socket.BeginReceive which will execute on the .net thread pools (you can specify somehow the number of threads it ... | <p>I don't have an answer but to get more information I'd suggest sprinkling your code with timers and logging avg and max time taken for suspect operations like adding to the queue or opening a socket. </p>
<p>At least that way you will have an idea of what to look at and where to begin.</p>
| 41,346 |
<p>I'm currently passing the pid on the command line to the child, but is there a way to do this in the Win32 API? Alternatively, can someone alleviate my fear that the pid I'm passing might belong to another process after some time if the parent has died?</p>
| <p>Just in case anyone else runs across this question and is looking for a code sample, I had to do this recently for a Python library project I'm working on. Here's the test/sample code I came up with: </p>
<pre><code>#include <stdio.h>
#include <windows.h>
#include <tlhelp32.h>
int main(int argc, ... | <blockquote>
<p>"Alternatively, can someone alleviate my fear that the pid I'm passing
might belong to another process after some time if the parent has
died?"</p>
</blockquote>
<p>Yes, the PID can be reused. Unlike UNIX, Windows does not maintain a strong parent-child relationship tree.</p>
| 22,405 |
<p>I have a log file being written by another process which I want to watch for changes. Each time a change occurs I'd like to read the new data in to do some processing on it.</p>
<p>What's the best way to do this? I was hoping there'd be some sort of hook from the PyWin32 library. I've found the <code>win32file.Find... | <p>Did you try using <a href="http://packages.python.org/watchdog/" rel="noreferrer">Watchdog</a>?</p>
<blockquote>
<p>Python API library and shell utilities to monitor file system events.</p>
<h3>Directory monitoring made easy with</h3>
<ul>
<li>A cross-platform API.</li>
<li>A shell tool to run comma... | <p>I don't know any Windows specific function. You could try getting the MD5 hash of the file every second/minute/hour (depends on how fast you need it) and compare it to the last hash. When it differs you know the file has been changed and you read out the newest lines.</p>
| 22,019 |
<p>Such as deleting the output file during run, directing two instances of the sw to the same IO etc ?</p>
| <p>There isn't much you can do to prevent the user from doing that, but what you can do is to apply <a href="http://en.wikipedia.org/wiki/Defensive_programming" rel="nofollow noreferrer">defensive programming</a>. </p>
<p>In your two examples you'd have to, every time you access a resource, detect failure conditions a... | <p>One thing I've heard of people doing is running untrusted stuff under <a href="http://www.microsoft.com/windows/products/winfamily/virtualpc/overview.mspx" rel="nofollow noreferrer">VirtualPC</a>, so that the base system can't get damaged no matter what.</p>
| 30,604 |
<p>I'm new to unit testing. But how do I unit test my DAL which is written with Entity Framework, so I can make sure my DAL code is working correctly but no database is actually touched? Could someone give as much detail as possible please.</p>
| <p>If you want to test that your data access layer works correct you really need to test it against a database at some point as otherwise you aren't actually testing it works.</p>
| <p>When I unit test my DAL I use transactions and rollback at the end of the unit test, so the db is clean.</p>
| 39,900 |
<p>The maintenance problems that uninitialised locals cause (particularly pointers) will be obvious to anyone who has done a bit of c/c++ maintenance or enhancement, but I still see them and occasionally hear performance implications given as their justification.</p>
<p>It's easy to demonstrate in c that redundant ini... | <p>Short answer: declare the variable as close to first use as possible and initialize to "zero" if you still need to.</p>
<p>Long answer: If you declare a variable at the start of a function, and don't use it until later, you should reconsider your placement of the variable to as local a scope as possible. You can th... | <p>As you've showed with respect to performacne it does not make a difference. The compiler will (in optimized builds) detect if a local variable is written without beeing read from and remove the code unless it has other side-effects.</p>
<p>That said: If you initialize stuff with simple statements just to be sure it... | 16,897 |
<p>I've got a WCF service which handles some sensitive data. I'd like to make sure I keep that data from being exposed and so I'm looking at netTCPBinding... primarily because I can control the network it runs across and performance is a high priority.</p>
<p>I recognize that there are two areas that can be encrypted... | <p>The message-level encryption is needed when you do not control an intermediary. Intermediary services need to be able to modify the soap headers and could peek at your sensitive data for malicious purposes. But if you control everything from initial sender to ultimate receiver, then you do not need encryption at tha... | <p>In general terms, as long as you're dealing with point to point connections, and certificates are being validated on both sides (particularly if you're using mutual authentication), then yes, transport level security might be enough. Checking the certificates is useful to ensure that someone doesn't supplant the ser... | 12,428 |
<p>Or do I have to pinvoke native code?<br>
I don't want the power status...well I do, but I don't want to poll it all the time and would rather have an event fire. </p>
| <p>No there is not. Generally an application is completely unaware of the power state. When the device suspends, code simply stops executing. When you resume, it starts again at the exact spot it left off.</p>
<p>You can hook into the <a href="http://msdn.microsoft.com/en-us/library/ms902997.aspx" rel="nofollow nore... | <p>If you absolutly need to know when a device is suspending the best alternative available is to run your program in unattended mode. Instead of suspending your device will change to the unattended power state. That is your warning that the device wants to suspend. Do what ever work you needed to do before the devi... | 43,993 |
<p>I'm writing into a log file, but I want to log into a table named "Log" in my database. </p>
<p>How can I accomplish this?</p>
| <p>Check out logging.apache.org for the log4X that fits the language you are using. I know they have log4j (Java) and log4net (C#/.Net). They also have examples on how to configure the logging framework to log to a database table instead of a file.</p>
| <p>Check out logging.apache.org for the log4X that fits the language you are using. I know they have log4j (Java) and log4net (C#/.Net). They also have examples on how to configure the logging framework to log to a database table instead of a file.</p>
| 44,569 |
<p>Is it possible to extend LINQ-to-SQL entity-classes with constructor-methods and in the same go; make that entity-class inherit from it's data-context class?--In essence converting the entity-class into a business object.</p>
<p>This is the pattern I am currently using:</p>
<pre><code>namespace Xxx
{
public cl... | <p>It doesn't seem to make sense to make an entity a type of DataContext. It doesn't need to be a DataContext in order to be considered a business object, nor do you necessarily need to create a type that contains the original entity. It might be better to just extend the entity class and contain a reference to a DataC... | <p>It doesn't seem to make sense to make an entity a type of DataContext. It doesn't need to be a DataContext in order to be considered a business object, nor do you necessarily need to create a type that contains the original entity. It might be better to just extend the entity class and contain a reference to a DataC... | 27,508 |
<p>Right now I have a log parser reading through 515mb of plain-text files (a file for each day over the past 4 years). My code currently stands as this: <a href="http://gist.github.com/12978" rel="nofollow noreferrer">http://gist.github.com/12978</a>. I've used psyco (as seen in the code) and I'm also compiling it and... | <p>Don't waste time profiling. The time is always in the database operations. Do as few as possible. Just the minimum number of inserts.</p>
<p>Three Things.</p>
<p>One. Don't SELECT over and over again to conform the Date, Hostname and Person dimensions. Fetch all the data ONCE into a Python dictionary and use ... | <p>Additionally to the many fine suggestions @Mark Roddy has given, do the following:</p>
<ul>
<li>don't use <code>readlines</code>, you can iterate over file objects</li>
<li>try to use <code>executemany</code> rather than <code>execute</code>: try to do batch inserts rather single inserts, this tends to be faster be... | 16,552 |
<p>What is the most efficient way given to raise an integer to the power of another integer in C?</p>
<pre><code>// 2^3
pow(2,3) == 8
// 5^5
pow(5,5) == 3125
</code></pre>
| <p>Exponentiation by squaring.</p>
<pre><code>int ipow(int base, int exp)
{
int result = 1;
for (;;)
{
if (exp & 1)
result *= base;
exp >>= 1;
if (!exp)
break;
base *= base;
}
return result;
}
</code></pre>
<p>This is the standard ... | <p>My case is a little different, I'm trying to create a mask from a power, but I thought I'd share the solution I found anyway.</p>
<p>Obviously, it only works for powers of 2.</p>
<pre><code>Mask1 = 1 << (Exponent - 1);
Mask2 = Mask1 - 1;
return Mask1 + Mask2;
</code></pre>
| 12,691 |
<p>As far as I know, in gcc you can write something like:</p>
<pre><code>#define DBGPRINT(fmt...) printf(fmt);
</code></pre>
<p>Is there a way to do that in VC++?</p>
| <p>Yes but only since VC++ 2005. The syntax for your example would be:</p>
<pre><code>#define DBGPRINT(fmt, ...) printf(fmt, __VA_ARGS__)
</code></pre>
<p>A full reference is <a href="http://msdn.microsoft.com/en-us/library/ms177415(VS.80).aspx" rel="noreferrer">here</a>.</p>
| <p>Almost. It's uglier than that though (and you probably don't want a trailing semi-colon in the macro itself:</p>
<pre><code>#define DBGPRINT(DBGPRINT_ARGS) printf DBGPRINT_ARGS // note: do not use '(' & ')'
</code></pre>
<p>To use it:</p>
<pre><code>DBGPRINT(("%s\n", "Hello World"));
</code></pre>
<p>(was mi... | 9,075 |
<p>In developing Windows forms based application, are there any standards that should be followed when designing your form's main menu system? </p>
<p>Most windows applications with menu systems will have your standard File | Edit | View | Tools | Help menus. How do you determine placement of any additional top leve... | <p>Microsoft’s Vista User Experience Guidelines are at:
<a href="http://msdn.microsoft.com/en-us/library/aa511258.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/aa511258.aspx</a></p>
<p>Content specific to menus, including standard menus, is at:
<a href="http://msdn.microsoft.com/en-us/library/aa511502... | <p>Not a standard, but you could use the office products as a guideline.</p>
<p>By the way, menu's are from the past, it is all Ribbon now. And at first I was sceptic about the ribbon, but now I think it's a very good idea. (Minimizing mouse clicks is always a good idea).</p>
<p>Nice link: <a href="http://blogs.msdn.... | 33,704 |
<p>I have a development vm which is running sql server as well as some other apps for my stack, and I found that the other apps are performing awfully. After doing some digging, SQL Server was hogging the memory. After a quick web search I discovered that by default, it will consume as much memory as it can in order ... | <p>Since this is a development environment, I agree with Greg, just use trial and error. It's not that crucial to get it perfectly right.</p>
<p>But if you do a lot of work in the VM, why not give it at least half of the 2GB?</p>
| <blockquote>
<p>so id like to be able to run the vm on
768 mb or less if possible.</p>
</blockquote>
<p>That will depend on your data and the size of your database. But I usually like to give SQL server at least a GB</p>
| 4,805 |
<p>What's the quickest/neatest way to calculate the next anniversary of someone's birthday.</p>
<p>For example, if I knew a person was born on 31st January, 1990, and today is the 10th February 2000, their next anniversary will be 31st January, 2001.</p>
<p>February 29th should roll onto March 1st (e.g. if they were ... | <p>I haven't worked in VB.Net, but I think the C# code will make enough sense:</p>
<pre><code>private DateTime nextDate(DateTime currentDate, DateTime anniversaryDate)
{
DateTime nextDate;
try{
nextDate = new DateTime(currentDate.Year, anniversaryDate.Month, anniversaryDate.Day);
} catch (ArgumentO... | <p>Edit: Changed my example so it handles birthdays on leapday. </p>
<pre><code>Function NextBirthDay(ByVal BirthDate As Date) As Date
If Not Date.IsLeapYear(Now.Year) And BirthDate.Month = 2 And BirthDate.Day = 29 Then BirthDate.AddDays(1)
Dim TestDate As Date = New Date(Now.Year, BirthDate.Month, BirthDa... | 43,321 |
<p>Is it possible through a plugin - activeX, Java or Flex to write a brower plugin that is able to detect an read a data stream from a USB device channel.</p>
<p>I have done some research but have not found an answer.</p>
<p><a href="http://support.microsoft.com/kb/832678" rel="noreferrer">http://support.microsoft.c... | <p>It's considered a security risk to expose local resources and the sandbox environments for the different plugins should deny access to these resources.</p>
<p>So I would say that the answer to your question is a No.</p>
| <p>I believe it can at least be done with Flash. I use an EasyBloom, a USB gardening diagnostic device. The flash app on their website access the device on my local laptop.</p>
<p>Sadly, I have no idea how they do it since I don't do Flash. :-(</p>
| 43,687 |
<p>Does anybody know any good resources for learning how to program CIL with in-depth descriptions of commands, etc.? I have looked around but not found anything particularly good.</p>
| <p>The only CIL book on my shelf is <a href="https://rads.stackoverflow.com/amzn/click/com/1590596463" rel="nofollow noreferrer" rel="nofollow noreferrer">Expert .NET 2.0 IL Assembler</a> by Serge Lidin. In terms of what the individual opcodes do or mean, the Microsoft documentation on System.Reflection.Emit has some ... | <p><a href="https://rads.stackoverflow.com/amzn/click/com/1590596463" rel="nofollow noreferrer" rel="nofollow noreferrer">Expert .NET 2.0 IL Assembler by Serge Lidin</a></p>
<p>There was a 1.1 version of the same book, but I haven't seen anything for the latest .NET release. It's an excellent book. I used it to wri... | 6,672 |
<p>There are literally thousands of locations where an application is running (.net desktop app),and a requirement is to have the updates to their database (diff from the last upload) to be sent to a central server that will store all the locations data.</p>
<p>What options do I have in coming up with a solution?</p>
... | <p>I would probably make an effort to avoid writing this code. It sounds like the kind of problem database replication was designed to solve. It would depend on criteria you don't communicate in your question, such as database engine in use, available transports, whether different locations updates would overlap each... | <p>Since there are 1000's of locations I suggest that each desktop application sends an xml string to a web server. The web server application could update the database upon receiving the string. </p>
<p>If you are using .NET on both sides you could implement this using the framework's Web Services classes. </p>
| 15,215 |
<h2>Some Context</h2>
<p>From <a href="http://books.google.com/books?id=VOS6IlCsuU4C" rel="nofollow noreferrer">Javascript: The Definitive Guide</a>:</p>
<blockquote>
<p>When <code>regexp</code> is a global regular expression, however, <code>exec()</code> behaves in a slightly more complex way. It begins searching... | <p>The problem is that the dot in</p>
<pre><code>^(.*)$
</code></pre>
<p>does not match new line characters, but with your <code>"m"</code> switch you make <code>"^"</code> and <code>"$"</code> anchor to new line characters. That means the "nothing" between <code>"\n"</code> and <code>"\n"</code> can be matched succe... | <p>The problem with lastIndex is that a JavaScript implementation that follows the standard to the letter sets it to the offset of the next character after the match. For regular expressions, like yours, that allow zero-length matches, exec() will thus get stuck in an infinite loop when a zero-length match is found. ... | 49,966 |
<p>People in java/.net world has framework which provides methods for sorting a list.</p>
<p>In CS, we all might have gone through Bubble/Insertion/Merge/Shell sorting algorithms.
Do you write any of it these days?</p>
<p>With frameworks in place, do you write code for sorting?<br></p>
<p>Do you think it makes sense... | <p>There are two pieces of code I write today in order to sort data</p>
<pre><code>list.Sort();
enumerable.OrderBy(x => x); // Occasionally a different lambda is used
</code></pre>
| <p>Man, if someone asked me in an interview what the best sort algorithm was, and didn't understand immediately when I said 'timsort', I'd seriously reconsider if I wanted to work there.</p>
<p>Timsort</p>
<blockquote>
<p>This describes an adaptive, stable,
natural mergesort, modestly called
timsort (hey, I ear... | 33,537 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.