instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>i want to get datetime for 2days before. i.e) how to subtract 2 days from datetime.now</p>
| <p>I think you are just looking for:</p>
<pre><code>DateTime.Now.AddDays(-2);
</code></pre>
| <p>Yet another solution:</p>
<pre><code>DateTime twoDays = DateTime.Now.Subtract(new TimeSpan(2,0,0,0));
</code></pre>
| 27,767 |
<p>One of my goals over the next few months is to get familiar with NHibernate and am curious if anyone out there has any suggestions of where to begin. Preferably, I'd like to find a example project that demonstrates what you would see in an in-the-field application.</p>
| <p>I pretty much based the first iteration of an application architecture solely on this article from CodeProject: <a href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx" rel="nofollow noreferrer">NHibernate Best Practices</a>. Also check out this blog: <a href="http://ayende.com/" rel="nofoll... | <p>The <a href="https://web.archive.org/web/20110227204838/http://blogs.hibernatingrhinos.com/nhibernate/Default.aspx" rel="nofollow noreferrer">nhibernate FAQ blog</a> is pretty useful.</p>
| 15,823 |
<p>I have defined a Delphi TTable object with calculated fields, and it is used in a grid on a form. I would like to make a copy of the TTable object, including the calculated fields, open that copy, do some changes to the data with the copy, close the copy, and then refresh the original copy and thusly the grid view. ... | <p>You can use the <strong>TBatchMove</strong> component to copy a table and its structure.</p>
<p>Set the Mode property to specify the desired operation. The Source and Destination properties indicate the datasets whose records are added, deleted, or copied. The online help has additional details.</p>
<p>(Although I... | <p>You should be able to select the table on the form, copy it using <kbd>Ctrl</kbd>-<kbd>C</kbd>, then paste it into any text editor. You will get the text version of the object's properties which you can then edit as needed. When you are done, select all the text again and you can copy it to the clipboard and paste i... | 13,992 |
<p>Suppose an Oracle instance has to be recovered after a disaster. Do sequences get reset to the initial state, or the last saved state, or are cached values preserved?</p>
<p>Thank you very much. :-)</p>
| <p>The sequnce values are stored in the SYSTEM.SEQ$ (I think) table, and a cache is maintained in memory of the next values to be used, with the size of that cache being dependent on the CACHE value for the sequence.</p>
<p>When the cache is exhausted the SEQ$ table is updated to a new value (in a non-consistent manne... | <p>Not that I have any experience with this, but I very much assume that a recovery to a consistent system change number state would also return the sequence to the last saved state. Anything else would be fairly useless in terms of recovery.</p>
<p>As for cached values, those are (can be) lost even when the instance ... | 48,898 |
<p>I'm trying to host a PHP web site that was given to me. I see this warning:</p>
<blockquote>
<p><strong>Warning:</strong> Unknown: Your script possibly
relies on a session side-effect which
existed until PHP 4.2.3. Please be
advised that the session extension
does not consider global variables as
a sou... | <p>basically you have a variable with the same name as your session. ex:</p>
<pre><code>$_SESSION['var1'] = null;
$var1 = 'something';
</code></pre>
<p>which will reproduce this error. you can stop PHP from trying to find existing variables and warning you about them by adding these lines to your script:</p>
<pre><c... | <p>in my case, php.ini change from on to off </p>
<p>like this : </p>
<pre><code>session.bug_compat_42 = off
session.bug_compat_warn = off
</code></pre>
<p>if not working, restart apache </p>
| 21,109 |
<p>I found this site</p>
<p><a href="http://www.shutterfly.com/documentation/api_OrderImage.sfly" rel="nofollow noreferrer">http://www.shutterfly.com/documentation/api_OrderImage.sfly</a></p>
<p>but there are no examples of actually walking through the whole process. Does anyone have any good documentation on using ... | <p>I went through these steps:</p>
<ul>
<li><a href="https://www.shutterfly.com/signup/viewSignup.sfly" rel="noreferrer">Sign up for an account</a></li>
<li><a href="https://www.shutterfly.com/developer/apps.sfly" rel="noreferrer">Sign up as a developer</a></li>
</ul>
<p>Create an application (I called mine Test). No... | <p>For Reference:</p>
<p>The original link above is a middle step of the Shutterfly Open API ordering procedure. </p>
<p>The whole process goes through a series of steps allowing you to control much more than just pushing photos into somebody's album in Shutterfly.</p>
<p>With this process, your application can act... | 34,672 |
<p>While working on a .Net application (let's say an Asp.Net one), are there any differences in the way you would do things while working on the 64 bit platform, as compared to working on a 32 bit platform.</p>
<p>I would imagine very little since you are working on the framework, and the framework is taking care of m... | <p>There are two cases where considering 64-bit-ness might be interesting:</p>
<ol>
<li>you need to consider containers that have more than 2^31 elements. The standard array .Length property returns Int32, and is thus not capable of representing large arrays - which you can't create in a 32-bit VM anyway. In a 64-bit ... | <p>There are two cases where considering 64-bit-ness might be interesting:</p>
<ol>
<li>you need to consider containers that have more than 2^31 elements. The standard array .Length property returns Int32, and is thus not capable of representing large arrays - which you can't create in a 32-bit VM anyway. In a 64-bit ... | 35,443 |
<p>I'm working on a project where I am using a script.aculo.us Sortable object.</p>
<p>It works nice and fast in Firefox and Chrome, but in IE it is incredibly slow whenever I drop an element.</p>
<p>I've done a little checking, and it turns out that in IE, the "onUpdate" callback function gets called about 8 times e... | <p>Well you can't do it. The <code>any</code> mechanism works like this:</p>
<pre><code>struct base {
virtual ~base() { }
};
template<typename T>
struct concrete_base : base {
T t;
concrete_base(T t):t(t) { }
};
struct my_any {
base * b;
template<typename T>
my_any(T t):b(new con... | <p>any_cast can't do it but if the base and derived types are complete (which they usually are for types that are in a hierarchy) you could implement your own system which converts by means of throw and catch, since throwing a pointer to a derived type can be caught as a base pointer type.</p>
| 41,258 |
<p>I keep seeing people say that exceptions are slow, but I never see any proof. So, instead of asking if they are, I will ask how do exceptions work behind the scenes, so I can make decisions of when to use them and whether they are slow.</p>
<p>From what I know, exceptions are the same as doing a return bunch of tim... | <p>Instead of guessing, I decided to actually look at the generated code with a small piece of C++ code and a somewhat old Linux install.</p>
<pre><code>class MyException
{
public:
MyException() { }
~MyException() { }
};
void my_throwing_function(bool throwit)
{
if (throwit)
throw MyException();
}... | <p>All good answers.</p>
<p>Also, think about how much easier it is to debug code that does 'if checks' as gates at the top of methods instead of allowing the code to throw exceptions.</p>
<p>My motto is that it's easy to write code that works. The most important thing is to write the code for the next person who loo... | 39,590 |
<p>I'm supposed to create a simple rule engine in C#. Any leads on how I can proceed?. It's a minimalistic rule engine, and would use SQL server as the back end. Do we have any general blueprint or design patterns that generally apply to rule engines? What kind of .Net technologies can I use to design one? Any directio... | <p>If you're using .NET 3.0 or later, you <a href="http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/08/09/WF-Rules-Engine-without-Workflow.aspx" rel="noreferrer">can use the Rules Engine of Windows Workflow Foundation</a> without having to acutally use Workflow.</p>
<p>I've done this on a project, and you can u... | <p>What kind of Rule engine you looking for? For styling practices? If so, go check out <a href="http://spoiledtechie.com/post/StyleCop-was-just-released!.aspx" rel="nofollow noreferrer">StyleCop</a>. Not the answer, but there might already be something out there for you.</p>
| 11,863 |
<p>I am looking get to grips with functional programming concepts.</p>
<p>I've used Javascript for many years for client side scripting in web applications and apart from using prototypes it was all simple DOM manipulation, input validation etc. </p>
<p>Of late, I have <a href="http://eloquentjavascript.net/chapter6... | <p>JavaScript supports first class functions. See <em><a href="http://www.ibm.com/developerworks/library/wa-javascript.html" rel="noreferrer">Use functional programming techniques to write elegant JavaScript</a></em>.</p>
| <p>Javascript is a multi-paradigm language. If your goal is to learn functional language concepts, try starting with a pure functional language like <a href="http://caml.inria.fr/ocaml/" rel="nofollow noreferrer">OCaml</a> or <a href="http://www.haskell.org/" rel="nofollow noreferrer">Haskell</a>.</p>
| 17,491 |
<p>Does anyone know if it's possible to determine, using JavaScript, whether the user's browser allows checkboxes and radio buttons to be focused? In other words, whether you can tab to select them.</p>
<p>I can't just use browser detection to do this, because in at least one case (Safari), the user can turn the abili... | <p>One approach is to try to set the focus and then detect if it was successful. Do this by assigning an onfocus event that set a variable to true, try to focus it and then check if the variable is true. </p>
| <p>JavaScript cannot read the browser's settings. Doing so would be a security violation.</p>
<p>That being said, there is no way to test for something <strong>not</strong> happening if it requires the user's interaction without giving them explicit directions so to perform the testable action. So there is no passive ... | 37,101 |
<p>I have a Windows C++ program that is doing something like:<br></p>
<pre>
FILE* pf = ...;
*stdout = *pf; // stdout is defined in stdio.h
</pre>
<p>I'm looking for an explanation about what happens when you change the value of the stdout file handle. Is this just a way of redirecting stdout?</p>
<p>-cr</p>
| <p>Yes, when you change stdout, you're effectively redirecting it elsewhere. However, you should <strong>not</strong> directly assign to stdout like that. If you want to redirect stdout, you should instead use <a href="http://www.opengroup.org/onlinepubs/000095399/functions/freopen.html" rel="nofollow noreferrer"><co... | <p>Yes, when you change stdout, you're effectively redirecting it elsewhere. However, you should <strong>not</strong> directly assign to stdout like that. If you want to redirect stdout, you should instead use <a href="http://www.opengroup.org/onlinepubs/000095399/functions/freopen.html" rel="nofollow noreferrer"><co... | 49,229 |
<p>Thats what I am using to read e-mail using C#:</p>
<pre><code>outLookApp.NewMailEx += new ApplicationEvents_11_NewMailExEventHandler(outLookApp_NewMailEx);
Outlook.NameSpace olNameSpace = outLookApp.GetNamespace("mapi");
olNameSpace.Logon("xxxx", "xxxxx", false, true);
Outlook.MAPIFolder oInbox = olNa... | <p>You'll likely run into <a href="https://stackoverflow.com/questions/235231/how-to-avoid-outlook-security-alert-when-reading-outlook-message-from-c-program">this</a> when Outlook is closed.</p>
<p>Also following <a href="http://www.programminghelp.com/programming/dotnet/access-your-email-within-outlook-pt-1-of-3-c/"... | <p>Are you sure you want to use Outlook as a proxy? </p>
<p><a href="http://www.codeproject.com/KB/IP/popapp.aspx" rel="nofollow noreferrer">people</a> <a href="http://www.java2s.com/Code/CSharp/Network/APOP3emailchecker.htm" rel="nofollow noreferrer">seems</a> to deal low level with such a task in C# (surprising ther... | 38,747 |
<p>I have the classical table with expandable and collapsible records that if expanded show several subrecords (as new records in the same parent table, not some child div/child table). I am also using tablesorter and absolutely love it.</p>
<p>The problem is that tablesorter isn't keeping expanded child records next ... | <p>If you want to keep tablesorter, there is a mod which I have used for this purpose <strong><a href="http://www.pengoworks.com/workshop/jquery/tablesorter/tablesorter.htm" rel="noreferrer">available here</a></strong> </p>
<p>After including it, you make your second (expandable child) row have the class "expand-child... | <p>I was able to overcome this by assigning child rel attributes to children and parent rel attributes to parents. Then I loop through the table at the beginning and hide all of the children and reappend them after the sorting is completed. I also use a toggling function to display the children. Here is my solution:</p... | 26,943 |
<p>Is there a tool that allows one to monitor GDI calls?</p>
| <p>Tools like <a href="http://www.automatedqa.com/products/aqtime/index.asp" rel="nofollow noreferrer">AutomatedQA AQTime</a> can help you diagnose GDI usage. A much simpler, but free tool one can be found <a href="http://msdn.microsoft.com/en-us/magazine/cc188782.aspx" rel="nofollow noreferrer">here</a>.</p>
| <p>Good advice, Lars. I've had a similar problem. Now use deleaker and do not worry;) GDI do not lose!</p>
| 6,887 |
<p>I have seen <a href="https://stackoverflow.com/questions/4046/can-someone-give-me-a-working-example-of-a-buildxml-for-an-ear-that-deploys-in">this question</a> about deploying to WebSphere using the WAS ant tasks.</p>
<p>Is there a simpler way to do this? In the past I have deployed to Tomcat by dropping a war fil... | <p>There is the concept of <a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.etools.wrd.freeform.doc/topics/cwrdrapid.html" rel="nofollow noreferrer">WebSphere Rapid Deployment</a>. It's supposed to be the same experience as what you describe for Tomcat.</p>
| <p>WAS does provide a client jar containing some custom ant tasks. However they seem to be extremely bugy and dont work with remote servers.</p>
<p><a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.javadoc.doc/public_html/api/com/ibm/websphere/ant/tasks/InstallApplicatio... | 8,150 |
<p>I want to automate the process of gathering code metrics on a .NET solution. Is there any way of getting msbuild to run the Code Metrics feature included in VS2008 Development Edition? </p>
<p>I may end up using <a href="http://www.campwoodsw.com/sourcemonitor.html" rel="noreferrer">SourceMonitor</a>, but I would l... | <p>Finally, Microsoft have provided us with <a href="http://blogs.msdn.com/b/camerons/archive/2011/01/28/code-metrics-from-the-command-line.aspx" rel="noreferrer">a way to automate the Visual Studio code metrics feature</a> using a new "<a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=edd1dfb0-b9fe-... | <p>jgwood - I believe he's referring to Code Metrics (cyclomatic complexity, etc.) and not FxCop. I have been looking for a solution for this as well, as the FxCop rule for complexity has hardcoded threshholds. It sounds like there's no command-line or API for the metrics in VS2008 yet (per <a href="http://blogs.msdn... | 45,522 |
<p>I'm working on a project using the <a href="http://antlr.org" rel="noreferrer">ANTLR</a> parser library for C#. I've built a grammar to parse some text and it works well. However, when the parser comes across an illegal or unexpected token, it throws one of many exceptions. The problem is that in some cases (not ... | <p>I believe I understand the problem. The exception is being caught, the issue is confusion over the debugger's behavior and differences in the debugger settings among each person trying to repro it.</p>
<p>In the 3rd case from your repro I believe you are getting the following message: "NoViableAltException was unha... | <blockquote>
<p>"Also, you can put some code in to
catch all unhandled exceptions. Read
the link for more info, but the basics
are these two lines."</p>
</blockquote>
<p>This is false. This used to catch all unhandled exceptions in .NET 1.0/1.1 but it was a bug and it wasn't supposed to and it was fixed in .NE... | 5,664 |
<p>I'm creating a new mail item, in C# VS-2008 outlook 2007, and attaching a file. The first issue is that I don't see an attachment area under the subject line showing the attachment. If I send the e-mail its properties show that there is an attachment and the e-mail size has grown by the attachment amount. I just ... | <p>I have found the issue. I change the code to use the following:</p>
<pre><code>attachments.Add(ReleaseForm.ZipFile, Outlook.OlAttachmentType.olByValue, Type.Missing, Type.Missing);
</code></pre>
<p>It appears that the Position and DisplayName parameters control what happens with an olByValue. Using Type.Missing ... | <p>I have excactly problem as yours, but even I change the code as yours, but it seems not work still. again, it seems already in the mailitems but not display on the mail items display.
OK, you have to make sure the mailItem body is not null to diplay the attechament</p>
| 17,704 |
<p>I've begun to the the built-in TraceSource and TraceListener classes and I would like to modify the output format of the events independently of the TraceSources and TraceListeners. It seems that the TraceListeners apply their own formatting. Is it possible to completely change the formatting without creating a ne... | <p>The Enterprise Library Logging Application Block (<a href="http://msdn.microsoft.com/en-us/library/cc309506.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/cc309506.aspx</a>) is built on the .Net TraceSource and TraceListener classes (so you can pretty much just drop it into your project and it'll wor... | <p>You can use the direct <code>Write()</code> or <code>WriteLine()</code> methods on <code>Trace</code> to put straight text into your TraceListener.</p>
| 25,610 |
<p>I know in the MVC Framework, you have the Html Class to create URLs:</p>
<pre><code>Html.ActionLink("About us", "about", "home");
</code></pre>
<p>But what if you want to generate Urls in Webforms?</p>
<p>I haven't found a really good resource on the details on generating URLs with Webf... | <p>As you say, ASP.NET MVC offers you a set of helper methods to "reverse lookup" the RouteTable and generate a URL for you. I've not played with this much yet but as far as I can see you need to call the GetVirtualPath method on a RouteCollection (most likely RouteTable.Routes). So something like:</p>
<pre><code>Dim ... | <p>Hyperlink hl = new Hyperlink();
hl.Text = "click here";
hl.NavigateUrl="~/Forms/Article.aspx";
MostlyAnyControl.Controls.Add(hl);</p>
<p>as for putting it in a list... either (1) loop / iterate, or (2) Linq to XML.</p>
| 35,367 |
<p>I have a stored procedure which takes as its parameter a <em>varchar</em> which needs to be cast as a <em>datetime</em> for later use:</p>
<pre><code>SET @the_date = CAST(@date_string AS DATETIME)
</code></pre>
<p>I'm expecting the date string to be supplied in the format "DD-MON-YYYY", but in an effort to code de... | <p>I'm having a similar issue. You might be able to do something like this:</p>
<pre><code>SET arithabort arith_overflow off
SET @the_date = CAST(@date_string AS DATETIME)
IF @the_date is NULL
set @the_date = getdate()
SET arithabort arith_overflow on
</code></pre>
<p>However, this doesn't work well in a select.... | <p>Found <a href="http://blog.sqlauthority.com/2007/07/12/sql-server-validate-field-for-date-datatype-using-function-isdate/" rel="nofollow noreferrer">this in the second result</a> in Google when searching for "validate date string sql".</p>
<pre><code>----Invalid date
SELECT ISDATE('30/2/2007')
RETURNS : 0 (Zero)
--... | 3,049 |
<p>Basically I have some code to check a specific directory to see if an image is there and if so I want to assign a URL to the image to an ImageControl.</p>
<pre><code>if (System.IO.Directory.Exists(photosLocation))
{
string[] files = System.IO.Directory.GetFiles(photosLocation, "*.jpg");
if (files.Length >... | <p>As far as I know, there's no method to do what you want; at least not directly. I'd store the <code>photosLocation</code> as a path relative to the application; for example: <code>"~/Images/"</code>. This way, you could use MapPath to get the physical location, and <code>ResolveUrl</code> to get the URL (with a bit ... | <p>I think this should work. It might be off on the slashes. Not sure if they are needed or not.</p>
<pre><code>string url = Request.ApplicationPath + "/" + photosLocation + "/" + files[0];
</code></pre>
| 3,676 |
<p>How do I change the size of figure drawn with Matplotlib?</p>
| <p><a href="https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.figure.html" rel="noreferrer"><code>figure</code></a> tells you the call signature:</p>
<pre><code>from matplotlib.pyplot import figure
figure(figsize=(8, 6), dpi=80)
</code></pre>
<p><code>figure(figsize=(1,1))</code> would create an inch-by-inch... | <p>I've made research and wrote article about <a href="https://mljar.com/blog/matplotlib-change-figure-size/" rel="nofollow noreferrer">3 different ways to change figure size in Matplotlib</a>. It is important to remember that:</p>
<ul>
<li>figure size in Matplotlib is in <strong>inches</strong>,</li>
<li><code>dpi</co... | 43,045 |
<p>In a sorted table, it's common to have an up or a down arrow indicating the sort style. However, I'm having some trouble determining which direction the arrow should point. In an ASC sort, characters are sorted 1-9A-Za-z. Should the arrow point up or down?</p>
<p>I've found implementations of both on the web, so th... | <p>I don't think of them as arrows, but as a visual mnemonic of the current state. So, showing a triangle pointing down shows descending order. It is visually in line with the icon with the largest item (base of the triangle) at the top of the list and the smallest (point of the triangle) at the bottom.</p>
| <p>Remember that <strong>d</strong>escending is for <strong>d</strong>own. So, I would use the down arrow for descending. But, I always get confused by this anyway. I recommend that you use letters instead, like A-Z and Z-A instead of the arrows. Or, use them in conjunction with the arrows.</p>
| 43,890 |
<p>I'm trying to get the <strong>GWTShell</strong> mode to load my <em>context.xml</em> file in which my database is described.</p>
<p>The only usable info can be found <a href="http://gwt-maven.googlecode.com/svn/docs/maven-googlewebtoolkit-plugin/configure_tomcatlite.html" rel="nofollow noreferrer">here</a>, but thi... | <p>I'm using Eclipse with Cypal Studio (previously called Googlipse).
If there is any other <em>better</em> plugin for Eclipse please recommend it.</p>
<p>As the Shell mode uses a Tomcat instance, which is the same target server we are using in the final deployment, it should be possible to achieve (or fake) a similar... | <p>As of version 1.4, I have been running all my server side code, in my container of choice (Glassfish) and hooking up the GWTShell to that. Are you using Netbeans, Eclipse or something else? The Netbeans plugin gwt4nb does this for you out of the box, you just have to start your web project in debug mode. I'm sure th... | 8,451 |
<p>Is this defined by the language? Is there a defined maximum? Is it different in different browsers?</p>
| <p>JavaScript has two number types: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number" rel="noreferrer"><code>Number</code></a> and <a href="https://developer.mozilla.org/en-US/docs/Glossary/BigInt" rel="noreferrer"><code>BigInt</code></a>. </p>
<p>The most frequently-use... | <p>Firefox 3 doesn't seem to have a problem with huge numbers. </p>
<p>1e+200 * 1e+100 will calculate fine to 1e+300.</p>
<p>Safari seem to have no problem with it as well. (For the record, this is on a Mac if anyone else decides to test this.)</p>
<p>Unless I lost my brain at this time of day, this is way bigger th... | 39,528 |
<p>I have a server application that receives information over a network and processes it.
The server is multi-threaded and handles multiple sockets at time, and threads are created without my control through BeginInvoke and EndInvoke style methods, which are chained by corresponding callback functions.</p>
<p>I'm tryi... | <p>I've always used something along these lines:</p>
<pre><code> c = <your control>
if (c.InvokeRequired)
{
c.BeginInvoke((MethodInvoker)delegate
{
//do something with c
});
}
else
{
//do something with... | <p>Using BeginInvoke or Invoke should work fine. Could you post a short but complete program which demonstrates the problem? You should be able to work one up which doesn't actually need any server-side stuff - just have a bunch of threads which "pretend" to receive incoming connections.</p>
| 28,379 |
<p>When we run a update query we get prompt saying that 'these many records are going to be updated. do you want to continue' is it possible to capture the value in the prompt message to a variable i.e the number of records going to be updated.</p>
| <p>If you run the query from code, you can use the records affected property:</p>
<pre><code>Dim db As Database
Set db=CurrentDB
db.Execute "Some SQL here"
db.RecordsAffected
</code></pre>
<p>If you use a transaction, you can rollback.</p>
| <p>Yes, you can get the number of records updated via the <code>RecordsAffected</code> property: </p>
<pre><code>Function RowsChanged(updateQuery As String) As Long
Dim qry As QueryDef
Set qry = CurrentDb.QueryDefs(updateQuery)
qry.Execute
RowsChanged = qry.RecordsAffected
End Function
</code></pre>
... | 44,657 |
<p>I have a marker interface defined as</p>
<pre><code>public interface IExtender<T>
{
}
</code></pre>
<p>I have a class that implements IExtender</p>
<pre><code>public class UserExtender : IExtender<User>
</code></pre>
<p>At runtime I recieve the UserExtender type as a parameter to my evaluating method... | <p>There are 2 main solutions:</p>
<p>The pure HTML one:</p>
<pre><code><input type="text" id="Textbox" name="Textbox" maxlength="10" />
</code></pre>
<p>The JavaScript one (attach it to a onKey Event):</p>
<pre><code>function limitText(limitField, limitNum) {
if (limitField.value.length > limitNum) {
... | <p>you can set maxlength with jquery which is very fast</p>
<pre><code>jQuery(document).ready(function($){ //fire on DOM ready
setformfieldsize(jQuery('#comment'), 50, 'charsremain')
})
</code></pre>
| 13,844 |
<p>Suppose we have an iterator (an infinite one) that returns lists (or finite iterators), for example one returned by</p>
<pre><code>infinite = itertools.cycle([[1,2,3]])
</code></pre>
<p>What is a good Python idiom to get an iterator (obviously infinite) that will return each of the elements from the first iterator, ... | <p>Starting with Python 2.6, you can use <a href="https://docs.python.org/library/itertools.html#itertools.chain.from_iterable" rel="noreferrer"><code>itertools.chain.from_iterable</code></a>:</p>
<pre><code>itertools.chain.from_iterable(iterables)
</code></pre>
<p>You can also do this with a nested generator compreh... | <p>Use a generator:</p>
<pre><code>(item for it in infinite for item in it)
</code></pre>
<p>The * construct unpacks into a tuple in order to pass the arguments, so there's no way to use it.</p>
| 14,699 |
<p>What is an efficient way to shrink a two dimensional array to a smaller size in C#?</p>
<p>For example:</p>
<pre><code>var bigArray = new object[100, 100];
var smallArray = new object[10, 10];
bigArray[0, 0] = 1;
bigArray[0, 1] = 2;
...
bigArray[99, 99] = 100000;
startRowIndex = 0;
startColumnIndex = 0;
endRowI... | <p>You've got to create a new array of the desired size (in your code, you've already done this) and copy the content. I'm not sure what the “shrinking” operation needs to do in your case. However, you cannot modify the dimensions of an existing array.</p>
<p>The function you proposed is defective because it can't kno... | <p>Yes the best method is almost certainly to loop over each cell, although it might be possible to copy a sequence of each 'row'. The method would need to know lower indices of the square to be copied from the source square, and the size (which might be implicit in the destination square definition).</p>
| 22,185 |
<p>i have a number of jsp files under web-inf folder. Inside my web.xml i specify an errorppage for 404 amd 403 and java.lang.exception. Do i need to include a page directive for each of my jsp's or will they automatically get forwarded to the exception handling page because they are under web-inf?</p>
<p>If this is t... | <p>You just need to have whatever errorpage you would like to use in your app available with all the other jsps. So in the following example you would just need to have the error pages in the root of the context path(where all of the other jsps are). Anytime the webapp receives a 404 or 403 error it will try to displ... | <p>ok so just to clarify; my jsps dont need to be in the web-inf folder in order for my web descriptor to pick up the exception and forward to the error page</p>
| 16,838 |
<p>I have the following piece of code which replaces "template markers" such as %POST_TITLE% with the contents of a variable called $post_title.</p>
<pre><code>function replaceTags( $template, $newtext ) {
$template = preg_replace( '/%MYTAG%/', $newtext, $template );
return $template;
}
</code></pre>
<p>The i... | <p>According to <a href="http://theserverpages.com/php/manual/en/function.preg-replace.php" rel="nofollow noreferrer">preg_replace manual</a>, preg_replace() treats this (<code>$1</code>) as <strong><a href="http://www.regular-expressions.info/brackets.html" rel="nofollow noreferrer">backreference</a></strong>.<br>
(an... | <p>According to <a href="http://theserverpages.com/php/manual/en/function.preg-replace.php" rel="nofollow noreferrer">preg_replace manual</a>, preg_replace() treats this (<code>$1</code>) as <strong><a href="http://www.regular-expressions.info/brackets.html" rel="nofollow noreferrer">backreference</a></strong>.<br>
(an... | 43,639 |
<p>What is the web interface tool that Debian or Ubuntu use for publicizing their custom repositories on the web?</p>
<p>Like <a href="http://www.debian.org/distrib/packages" rel="nofollow noreferrer">packages.debian.org</a></p>
<p>Is such tool open sourced, so that it could be re-used for a custom repository?</p>
| <p>The scripts that manage the archive are open source, they're in a debian package called dak. I don't think this includes the web pages, but I'm not sure. I'd suggest emailling ftpmaster@debian.org or debian-www@lists.debian.org and asking.</p>
<p>Parsing the packages file is indeed very straightforward but there's ... | <p>There are perl modules to parse the Packages file if you want to get at that type of information, <a href="http://cpan.uwinnipeg.ca/htdocs/DPKG-Parse/DPKG/Parse.pm.html" rel="nofollow noreferrer">DPKG::Parse</a> for example can do that. You could build a web page from that data similar to the URL you provided.</p>
... | 13,697 |
<p>I programmed a bluetooth Television-Remote control for cellphones in J2ME using <code>javax.microedition.lcdui.*</code> (Gauge, List, ChoiseGroup) GUI-Elements. </p>
<p>I want the cellphone to have real-time interaction with my Television, I would like to find way to send user inputs performed with the GUI-Elements... | <p>I just found a half solution myself, if anyone is interested:
"javax.microedition.lcdui.ItemStateListener".
This function can handle the states (or state changes) of the GUI items in realtime.
Its not keyPress, but this will work as well for my application.</p>
| <p>I will strongly recommend that you should either draw your Gauge-like item on a Canvas object or you follow the advice given on Dec 19 at 15:00 by "zhengtonic".
I dont know any other approach to this problem, I was once there but used the first options provided by me</p>
| 49,939 |
<p>When writing unit tests, do you place your tests inside the assembly you wish to test or in a separate test assembly? I have written an application with the tests in classes in a separate assembly for ease of deloyment as I can just exclude the assembly. Does anyone write there tests within the assembly you wish to ... | <p>I have a single solution with an interface project, a tests project, a domain project and a data project. When i release i just publish the interface, which doesnt reference Tests so it doesnt get compiled in.</p>
<p>Edit: The bottom line is really that you dont want it to be part of your final release. You can ach... | <p>You can keep them in separate assemblies in the solution, and ILMerge them later for debugging, and don't ILMerge them for release.</p>
| 34,195 |
<p>I created a project using the default tab-controller project. I am using interface builder to edit the .xib file and add images and buttons. I hook them up to the FirstViewController object in interface builder (that I created and set it's class to the same as the code file). I hooked everything up using <code>IBout... | <p>There is no built-in function in the class library that will do this. The closest is <a href="http://msdn.microsoft.com/en-us/library/system.math.round.aspx" rel="noreferrer">System.Math.Round()</a> which is only for rounding numbers of types Decimal and Double to the nearest integer value. However, you can wrap you... | <p>Here's how I round to the nearest multiple of any arbitrary factor without converting from integral types to floating-point values. This works for any int from <code>int.MinValue + 1</code> to <code>int.MaxValue</code></p>
<p>I used the <a href="https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero" rel="... | 34,572 |
<p>If I am passing an object to a method, why should I use the ref keyword? Isn't this the default behaviour anyway?</p>
<p>For example:</p>
<pre><code>class Program
{
static void Main(string[] args)
{
TestRef t = new TestRef();
t.Something = "Foo";
DoSomething(t);
Console.Wri... | <p>Pass a <code>ref</code> if you want to change what the object is:</p>
<pre><code>TestRef t = new TestRef();
t.Something = "Foo";
DoSomething(ref t);
void DoSomething(ref TestRef t)
{
t = new TestRef();
t.Something = "Not just a changed t, but a completely different TestRef object";
}
</code>... | <p>If you're passing a value, however, things are different. You can force a value to be passed by reference. This allows you to pass an integer to a method, for example, and have the method modify the integer on your behalf.</p>
| 22,622 |
<p>I'd like to check if the current browser supports the onbeforeunload event.
The common javascript way to do this does not seem to work:</p>
<pre><code>if (window.onbeforeunload) {
alert('yes');
}
else {
alert('no');
}
</code></pre>
<p>Actually, it only checks whether some handler has been attached to the e... | <p>I wrote about a more-or-less <a href="http://perfectionkills.com/detecting-event-support-without-browser-sniffing/" rel="noreferrer">reliable inference for detecting event support</a> in modern browsers some time ago. You can see on a demo page that "beforeunload" is supported in at least Safari 4+, FF3.x+ and IE.</... | <p>It would probably be better to just find out by hand which browsers support it and then have your conditional more like:</p>
<pre><code>if( $.browser.msie ) {
alert( 'no' );
}
</code></pre>
<p>...etc.</p>
<p>The <code>$.browser.msie</code> is jQuery syntax, most frameworks have similar built-in functions since ... | 19,193 |
<p>Forgive this long-winded post, but I thought it would be helpful to include the back story leading up to a very scary situation on my Ender 3.</p>
<p>I was printing a job and everything started out fine just like it normally does. I'm not sure if it is related, but partway through the job, there was a power dip seve... | <p>Your onboard MOSFET has failed, you need to replace the component, yet better the board. It seems the MOSFET isn’t reacting to the signal from the microprocessor, instead it is “always on”.</p>
<p>Note that a MOSFET usually fails short, but can fail open in certain circumstances. See <a href="https://electronics.sta... | <p>My understanding is that the hot end heats until the thermistor signals to the board that it is near/at temperature.</p>
<p>On an Ender V2 with the Meanwell power supply, the unit has thermal runaway protection so if the thermistor fails the board will shut down.</p>
<p>In your case, the failed thermistor never aler... | 2,063 |
<p>I'm struggling with the following problem. I use the <a href="http://docs.jquery.com/Plugins/Autocomplete/autocomplete" rel="noreferrer">jQuery autocomplete plugin</a> to get a list of suggested values from the server. The list would look like this:</p>
<pre>
Username1|UserId1
Username2|UserId2
</pre>
<p>So if I s... | <p>Use the <code>result</code> method of the <code>autocomplete</code> plugin to handle this. The data is passed as an array to the callback and you just need to save <code>data[1]</code> somewhere. Something like this:</p>
<pre><code>$("#my_field").autocomplete(...).result(function(event, data, formatted) {
if (d... | <p>I was going to list a few methods here but all but one is junk. Do the string->user conversion on the server as you've been doing to generate a list for the auto-complete.</p>
<p>By all means keep the auto-complete and do AJAX validation, but if you try and smuggle vital form data (like this) in the form via JS, so... | 48,687 |
<p>I don't think that this is specific to a language or framework, but I am using xUnit.net and C#.</p>
<p>I have a function that returns a random date in a certain range. I pass in a date, and the returning date is always in range of 1 to 40 years before the given date.</p>
<p>Now I just wonder if there is a good wa... | <p>In addition to testing that the function returns a date in the desired range, you want to ensure that the result is well-distributed. The test you describe would pass a function that simply returned the date you sent in!</p>
<p>So in addition to calling the function multiple times and testing that the result stays... | <p>I don't think Unit testing is meant for this. You can use Unit testing for functions that return a stochastic value, but use a fixed seed, in which case in a way they are not stochastic, so to speak,
for random seed, I dont think Unit testing is what you want, for example for RNGs what you mean to have is a system t... | 40,183 |
<p>Please help! Have been staring at this for 12 hours; and have looked online and can't find solution.</p>
<p>In my application, I use 2 UIView controls in separate pages/controllers:</p>
<ul>
<li>UIImageView (retrieve data via
NSData dataWithContentsOfUrl)</li>
<li>UIWebView</li>
</ul>
<p>Just to isolate my code, ... | <p>I was also having trouble with leaks from NSData's <code>dataWithContentsOfURL:</code> in the iPhone simulator. I found that when I used the other convenience method (<code>dataWithContentsOfURL:options:error:</code>) I would not get the memory leak.</p>
<p>My code looked something like this:</p>
<pre><code>NSUR... | <p><code>[NSData dataWithContentsOfURL:url options:0 error:&error]</code> did not help me on iOS8.</p>
<p>But following works correctly:</p>
<pre class="lang-objectivec prettyprint-override"><code>NSURLRequest* request = [NSURLRequest requestWithURL:imageURL];
NSData* imageData = [NSURLConnection sendSynchronousR... | 35,401 |
<p>I was surprised to find today that I couldn't track down any simple way to write the contents of an <code>InputStream</code> to an <code>OutputStream</code> in Java. Obviously, the byte buffer code isn't difficult to write, but I suspect I'm just missing something which would make my life easier (and the code cleare... | <p>As WMR mentioned, <code>org.apache.commons.io.IOUtils</code> from Apache has a method called <a href="http://commons.apache.org/proper/commons-io/javadocs/api-2.4/org/apache/commons/io/IOUtils.html#copy(java.io.InputStream,%20java.io.OutputStream)" rel="noreferrer"><code>copy(InputStream,OutputStream)</code></a> whi... | <p>you can use this method</p>
<pre><code>public static void copyStream(InputStream is, OutputStream os)
{
final int buffer_size=1024;
try
{
byte[] bytes=new byte[buffer_size];
for(;;)
{
int count=is.read(bytes, 0, buffer_size);
if(count==-1)
... | 6,474 |
<p>How can I find/replace all CR/LF characters in Notepad++?</p>
<p>I am looking for something equivalent to the ^p special character in Microsoft Word.</p>
| <p><strong><code>[\r\n]+</code></strong> should work too</p>
<p>Update March, 26th 2012, release date of <strong><a href="http://notepad-plus-plus.org/news/notepad-6.0-release.html" rel="noreferrer">Notepad++ 6.0</a></strong>:</p>
<p>OMG, it actually does work now!!!</p>
<p><img src="https://i.stack.imgur.com/ZiyXX.... | <p>To change a document of separate lines into a single line, with each line forming one entry in a comma separated list:</p>
<ol>
<li><kbd>ctrl</kbd>+<kbd>f</kbd> to open the search/replacer.</li>
<li>Click the "Replace" tab.</li>
<li>Fill the "Find what" entry with "<code>\r\n</code>".</... | 16,212 |
<p>I'm having trouble setting up a scheduled task (now called Task Scheduler) under the actions tab to run on windows 2007 server. It also has exchange server 2007. </p>
<p>I've tried setting </p>
<p>Program/script : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add arguments (optional): -psconsolefile ex... | <p>I figured I'd share the resolution here to finish what is started. </p>
<blockquote>
<p>1) In your .ps1 file put Add-PSSnapin
<em>exchange</em></p>
<p>2) for the scheduled task, do this:
Program/script :
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add arguments (optional): -noprofile
... | <p>What doesn't work? Have you tried running one of those commands manually, to see what happens?</p>
<p>(BTW: Suggestion, you may want to take this to the PowerShell forum at minasi.com/forum or powershelcommunity.org. You're likely to be asking a larger audience that's knowledgeable about the topic, since this is ki... | 44,286 |
<p>I was working on a model today and I need to make the black surface into a normal surface so that the ship's cockpit is solid. I am unable to select the black surface. I tried using the flip normals feature, but I was still unable to select it. Any advice on how to make it into a solid is greatly appreciated. Thanks... | <p>The foundation of any 3D printer is the controller and the firmware. Many devices are based on Arduino type controllers, with stepper motor driver boards either integrated or added as a plug-in component.</p>
<p>Some manufacturers will use in-house or outside resources and develop their own boards and firmware.</p>... | <p>this is an extension to fred_dot_u answer.
As I am in the process of building my own printer, I decided to use RAMPS Arduino shield for electronics and Marlin firmware + Arduino mega2560 as a logic controller. </p>
<p>As above are battle-tested, I don't need to discover wheel again, but rather focus on the mechani... | 886 |
<p>In windows there is perfmon to monitor various performances aspects (called <em>counters</em>) of the system.</p>
<p><strong>Is there a perfmon-like for Linux?</strong></p>
<p>especially, in interested in...</p>
<ul>
<li>CPU usage (total/per process/in kernel)</li>
<li>Memory usage (total/per process/in kernel)</... | <p>The program "top" does most of this. It does not handle network traffic though.</p>
<p>Edit:</p>
<p>If you need to log this information for post processing/analysis you can use the standard package "sar" to do this. It supports MANY different performance numbers including: disk, cpu, memory, network, etc.</p>
<p>... | <p>I am a huge fan of <a href="http://members.dslextreme.com/users/billw/gkrellm/gkrellm.html" rel="nofollow noreferrer">gkrellm</a>, which packs a huge amount of information into a small vertical bar on your monitor. It's configurable; I get CPU use, disk use, memory use, <em>temperatures</em>, network traffic, and m... | 44,961 |
<p>I have a computer A with two directory trees. The first directory contains the original mod dates that span back several years. The second directory is a copy of the first with a few additional files. There is a second computer be which contains a directory tree which is the same as the second directory on comput... | <p>The following command will make sure that TEST2 gets the same date assigned that TEST1 has</p>
<pre><code>touch -t `stat -t '%Y%m%d%H%M.%S' -f '%Sa' TEST1` TEST2
</code></pre>
<p>Now instead of using hard-coded values here, you could find the files using "find" utility and then run touch via SSH on the remote mach... | <p>I think rsync (with the right options)
will do this - it claims to only send
file differences, so presumably will
work out that there are no differences
to be transferred.</p>
<p>--times preserves the modification times, which is what you want.</p>
<p>See (for instance)
<a href="http://linux.die.net/man/1/rsync" r... | 15,537 |
<ul>
<li>How can we implement the Builder
pattern of <a href="http://developers.sun.com/learning/javaoneonline/2006/coreplatform/TS-1512.pdf?" rel="noreferrer">Joshua's
Effective Java</a> in C#?</li>
</ul>
<p>Below is the code I have tried, is there a better way to do this?</p>
<pre><code> public class NutritionFa... | <p>In Protocol Buffers, we implement the builder pattern like this (vastly simplified):</p>
<pre><code>public sealed class SomeMessage
{
public string Name { get; private set; }
public int Age { get; private set; }
// Can only be called in this class and nested types
private SomeMessage() {}
public sealed ... | <p>The reason to use Joshua Bloch's builder pattern was to create a complex object out of parts, and also to make it immutable.</p>
<p>In this particular case, using optional, named parameters in C# 4.0 is cleaner. You give up some flexibility in design (don't rename the parameters), but you get better maintainable c... | 40,447 |
<p>Is there any standalone alternative to activerecord-like migrations. Something like a script that is able to track current schema version and apply outstanding migrations. Basically, these migration files could be just a plain SQL files, something like:</p>
<pre>
[timestamp]_create_users.sql
reverse_[timestamp]_cre... | <p>Try <a href="http://freshmeat.net/projects/liquibase/" rel="nofollow noreferrer">http://freshmeat.net/projects/liquibase/</a></p>
<p>If you are using MySQL specifically, have a look at: <a href="http://www.mysqldiff.org/" rel="nofollow noreferrer">http://www.mysqldiff.org/</a>
I used this to synchronize the schema... | <p>Not a linux option, but might answer this question for some people:</p>
<p>SQLYog can do this for MySQL - its a windows GUI tool:</p>
<p><a href="http://www.webyog.com/en/" rel="nofollow noreferrer">http://www.webyog.com/en/</a></p>
<p>It can (amongst other things) compare schemas and make one schema look like a... | 47,285 |
<p>How do the timeouts work in WCF? I know for example that you can configure <em>sendTimeout</em> and <em>receiveTimeout</em> for a clients binding. But how do they work?</p>
<p>MSDN describes <em>sendTimeout</em> as:</p>
<blockquote>
<p>A TimeSpan value that specifies the interval of time provided for a
send op... | <p>Client side:</p>
<ul>
<li>SendTimeout is used to initialize the OperationTimeout, which governs the whole interaction for sending a message (including receiving a reply message in a request-reply case). This timeout also applies when sending reply messages from a CallbackContract method.</li>
<li>OpenTimeout and C... | <p>In addition to what was on that post, there's also the Operation Timeout defined on the client end. See this:</p>
<p><a href="http://final-proj.blogspot.com/2009/09/wcf-timeouts.html" rel="nofollow noreferrer">http://final-proj.blogspot.com/2009/09/wcf-timeouts.html</a></p>
| 28,442 |
<p>The main user-case is:</p>
<ol>
<li>Create the 2D floor plan</li>
<li>See the 3D view of the room in colors and in dynamic lighting (switching on and off the lamps)</li>
<li>Select the furniture from the large library of predefined samples.</li>
<li>Change the color and texture of the furniture samples.</li>
<li>Cr... | <p>While doing 3D in flash is cool and nice, why not use a tool that actually supports 3D acceleration on the users graphics cards, while <a href="http://unity3d.com/" rel="nofollow noreferrer">Unity</a> is a game engine, i think you would be able to create your tool with it, in addition you get support for creating 3D... | <p>Take a look at what some people are doing using <a href="http://papervision3d.org/" rel="nofollow noreferrer">Papervision3D</a> in Flash/Flex.</p>
<p>However, if your asking this question, then this is way too ambitious of a project for you.</p>
| 31,945 |
<p>Here is a specific example which is not CLS-complaint according to VS.NET 2005.</p>
<pre><code>Public Interface IDbId
Function GetNativeObject() As Object
Function Equals(ByVal compObj As IDbId) As Boolean
Function CompareTo(ByVal compObj As IDbId) As Integer
Function ToString() As String
End Inte... | <p>I think it's due to the MustOverride keyword modifier in your example.
Check this out:
<a href="http://msdn.microsoft.com/en-us/library/0haa76bc.aspx" rel="nofollow noreferrer">Non-CLS-compliant 'MustOverride' member is not allowed in a CLS-compliant class</a></p>
| <p>Use .net reflector to take a look at the generated code both with and without the attribute, and see if there is any difference.</p>
<p>If there is, and it doesn't obviously explain the differences (i.e. if the only difference is the CLICompliant attribute), then amend your questions with the findings, and I'll hav... | 43,075 |
<p>When you unload a project in Visual Studio, any referencing projects get warning triangles on their reference to the unloaded project. I've written myself a macro to do clever stuff (detect add/remove of project and transform any references from-to file/project dependency), but I can't believe that I'm not missing s... | <p>EXEC sp_helpuser 'username' should do.</p>
| <p>THIS SHOULD DO IT:</p>
<pre><code>select 'ServerRole' = spv.name, 'MemberName' = lgn.name, 'MemberSID' = lgn.sid
from master.dbo.spt_values spv, master.dbo.sysxlogins lgn
where spv.low = 0 and
spv.type = 'SRV' and
lgn.srvid IS NULL and
spv.number & lgn.xstatus = spv.number
</code></pre>
| 21,363 |
<p>When discussing the evolution of computer languages, Alan Kay says that the single most important attribute of his Smalltalk is late binding; it gives the language its malleability and extensibility, and allows inappropriate coupling to be refactored out over time. Do you agree? Are there compensating advantages for... | <p>Traditionally the big advantage of early binding is for performance: a late binding language has to carry type information about all its data at runtime, and loses the opportunity to do some optimizations at compile time. This difference has become much less significant, though, as computers get faster, and as VMs g... | <p>compile time binding in which linking is performed during the time of compilation is known as early binding</p>
<p>dynamic binding in which linking of function performed during the execution when function is called is known as late binding</p>
| 47,953 |
<p>I'd like to use Rich Text Editing in place on forms in order to let admins change instructions. What are the best options for doing this?</p>
<p>[To be more clear - the admins are non-technical but may want to control some formatting without using markup or with as little markup as possible. What I'd like is for... | <p>We started with <a href="http://tinymce.moxiecode.com/" rel="nofollow noreferrer">TinyMCE</a> but we are switching to Yahoo's <a href="http://developer.yahoo.com/yui/editor/" rel="nofollow noreferrer">Rich Text Editor</a> because there were some weird issues with the way TinyMCE worked and because the Rich Text Edit... | <p>I know this threat is pretty old but I came across looking for a few good options the a few weeks back, so in case someone else is facing the same issue like I did I give a more resent response. So my favourite editor is <a href="https://www.froala.com/" rel="nofollow">Froala</a> (<a href="https://github.com/froala/... | 24,055 |
<p>Anyone know of any good MSBuild tasks that will execute a PowerShell script and pass it different parameters?</p>
<p>I was able to find <a href="http://bartdesmet.net/blogs/bart/archive/2008/02/16/invoking-powershell-scripts-from-msbuild.aspx" rel="nofollow noreferrer">B# .NET Blog: Invoking PowerShell scripts from... | <p>You might also want to look at <a href="https://github.com/psake/psake" rel="nofollow noreferrer">Psake</a> - a PowerShell based build environment.</p>
| <p>With a bit of fun, I managed to come up with a fairly clean way of making this work:</p>
<pre class="lang-xml prettyprint-override"><code><?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- #1 Place this line at the to... | 10,353 |
<p>We need to implement a simple state machine in <strong>C</strong>.<br>
Is a standard switch statement the best way to go?<br>
We have a current state (state) and a trigger for the transition.</p>
<pre><code>
switch(state)
{
case STATE_1:
state = DoState1(transition);
break;
case STATE_2:
state = ... | <p>I prefer to use a table driven approach for most state machines:</p>
<pre><code>typedef enum { STATE_INITIAL, STATE_FOO, STATE_BAR, NUM_STATES } state_t;
typedef struct instance_data instance_data_t;
typedef state_t state_func_t( instance_data_t *data );
state_t do_state_initial( instance_data_t *data );
state_t d... | <p>Boost has the statechart library. <a href="http://www.boost.org/doc/libs/1_36_0/libs/statechart/doc/index.html" rel="nofollow noreferrer">http://www.boost.org/doc/libs/1_36_0/libs/statechart/doc/index.html</a></p>
<p>I can't speak to the use of it, though. Not used it myself (yet)</p>
| 16,125 |
<p>Good morning everyone,</p>
<p>I am developing a consulting job in a clinic of dental CT scans.</p>
<p>This work involves the development of administrative software, and preparing a routine for conversion of tomographic files in DICOM format to STL format. The files in STL format will be used for both visualization... | <p>The marching cubes algorithm can convert voxel data into a surface mesh. A global threshold to determine the surface in the greyvalues is used.
This <a href="https://pyscience.wordpress.com/2014/09/11/surface-extraction-creating-a-mesh-from-pixel-data-using-python-and-vtk/" rel="nofollow">article</a> might be helpf... | <p>There is this software that should work: <a href="https://www.slicer.org/" rel="nofollow">https://www.slicer.org/</a></p>
<p>If that doesn't cut it, I use this site to convert images to STL: <a href="http://www.online-convert.com/" rel="nofollow">http://www.online-convert.com/</a></p>
<p>They do have DICOM listed ... | 377 |
<p>I am trying to build a dropdown list for a winform interop, and I am creating the dropdown in code. However, I have a problem getting the data to bind based on the DataTemplate I specify.</p>
<p>What am I missing?</p>
<pre><code>drpCreditCardNumberWpf = new ComboBox();
DataTemplate cardLayout = new DataTemplate ... | <p>Assuming that you've already set up the <code>ItemsSource</code> etc for <code>drpCreditCardNumberWpf</code>...</p>
<pre><code>//create the data template
DataTemplate cardLayout = new DataTemplate();
cardLayout.DataType = typeof(CreditCardPayment);
//set up the stack panel
FrameworkElementFactory spFactory = new F... | <p>Well, indeed we still have another way, you will really like it if you dislike those <em><code>FrameworkElementFactory</code></em> things.</p>
<p>And I think it just makes minor changes to the natural code, that is, declare a <em><code>UserControl</code></em> and put your control into it, and then, use just one <em... | 30,861 |
<p>I'm planning to use MS entity framework for new web apps (come on EF v2!).</p>
<p>So does it make sense to plan ahead by adding timestamp columns to all entity tables in existing and future databases, to support concurrency checks? Is there any reason why it would be a <em>bad</em> idea to have a timestamp column i... | <p>I've used timestamp columns as a matter of routine for years. Another option is a row-version, but then you need to update it etc. I've never had any problems with timestamp. One word of caution - if you ever select into a temp-table/table-var for processing, you need to use <code>varbinary(8)</code>, not <code>time... | <p>In previous projects I used timestamps a lot, and I never had a bad experience with it.
Additionally I would totally exclude the Entity Framework from that decision, because that's some that might change over time.</p>
| 49,495 |
<p>While trying to answer a question in the vicinity '<a href="https://stackoverflow.com/questions/331215/unit-test-wpf-bindings">Unit Testing WPF Bindings</a>' I had the following niggling question..<br>
<strong>What's the best way to find if you have WPF Data Binding wiring setup incorrectly (or you just broke someth... | <p>Best I could find... </p>
<h2><a href="https://web.archive.org/web/20151215181325/http://www.zagstudio.com/blog/486" rel="nofollow noreferrer">How can I debug WPF Bindings? by Beatriz Stollnitz</a></h2>
<p>Since everyone can't always keep one eye on the Output Window looking for Binding errors, I loved Option#2. W... | <p><strong>My suggestion at 2021:</strong></p>
<h2>The Best way is to use <code>Benoit Blanchon</code> small library from Nuget</h2>
<p>His original post at here: <a href="https://stackoverflow.com/a/19610384/6296708">https://stackoverflow.com/a/19610384/6296708</a></p>
<p>His GitHub link and more info about how to use... | 43,725 |
<p>What are some <em>common</em>, <em>real world examples</em> of using the Builder Pattern? What does it buy you? Why not just use a Factory Pattern?</p>
| <p>Below are some reasons arguing for the use of the pattern and example code in Java, but it is an implementation of the Builder Pattern covered by the Gang of Four in <em>Design Patterns</em>. The reasons you would use it in Java are also applicable to other programming languages as well.</p>
<p>As Joshua Bloch stat... | <p>I used builder in home-grown messaging library. The library core was receiving data from the wire, collecting it with Builder instance, then, once Builder decided it've got everything it needed to create a Message instance, Builder.GetMessage() was constructing a message instance using the data collected from the wi... | 42,565 |
<p>I have a property on a domain object that is declared in a many-to-one element. The basic syntax of this property looks like this:</p>
<pre><code><many-to-one name="propertyName" class="propertyClass" fetch="select" not-found="ignore" lazy="proxy" />
</code></pre>
<p>Now, the idea is to have Hibernate NOT e... | <p>If the other end of the association can be <em>null</em>, I believe hibernate must query for the association end in order to determine if it should use a proxy or not (no need for proxy if the other end is <em>null</em>). I can't find the reference to this right now, but I remember reading it somewhere.</p>
<p>In o... | <p>If you're passing the hibernate object from the model to the view via the controller, don't! </p>
<p>Instead make a "snapshot object" to store the values from the Hibernate object you want to pass to the view and be displayed. </p>
<p><strong>Why?</strong>
The proxy can still retrieve the values when it is in th... | 27,443 |
<p>Let's say that you have a product that is written in Visual Studio and you provide your customers and users with an installer for that product.</p>
<p>Then, you have some minor changes that you want to deploy to your users; you don't want your users to have to go through an uninstall process, backing up the configu... | <p>Use <a href="http://wix.sourceforge.net/" rel="nofollow noreferrer">WiX</a>. </p>
<p>It can deal with all those things (installation web applications, services, etc), and it's very flexible, free, and it's what Microsoft uses to build their installers.</p>
<p>You can install <a href="http://wix.sourceforge.net/vot... | <p>You can create deployment projects that can handle this in Visual Studio. These result in an MSI (or potentially multiple MSIs) that can be run on client machines or servers and perform the upgrade.</p>
| 22,331 |
<p>(ClientCookie is a module for (automatic) cookie-handling: <a href="http://wwwsearch.sourceforge.net/ClientCookie" rel="nofollow noreferrer">http://wwwsearch.sourceforge.net/ClientCookie</a>)</p>
<pre><code># I encode the data I'll be sending:
data = urllib.urlencode({'username': 'mandark', 'password': 'deedee'})
... | <p>Have you tried fetching the login page first?</p>
<p>I would suggest using <a href="https://addons.mozilla.org/en-US/firefox/addon/966" rel="nofollow noreferrer">Tamper Data</a> to have a peek at exactly what's being sent when you request the login page and then log in normally using a web browser from a fresh star... | <p>I'd recommend taking a look at the <a href="http://wwwsearch.sourceforge.net/mechanize/" rel="nofollow noreferrer">mechanize</a> library; it's designed for precisely this type of task. It's also far easier than doing it by hand.</p>
| 13,782 |
<p>In a .NET application, how can I identify which network interface is used to communicate to a given IP address?</p>
<p>I am running on workstations with multiple network interfaces, IPv4 and v6, and I need to get the address of the "correct" interface used for traffic to my given database server.</p>
| <p>The simplest way would be:</p>
<pre><code>UdpClient u = new UdpClient(remoteAddress, 1);
IPAddress localAddr = ((IPEndPoint)u.Client.LocalEndPoint).Address;
</code></pre>
<p>Now, if you want the NetworkInterface object you do something like:</p>
<pre><code>
foreach (NetworkInterface nic in NetworkInterface.GetAll... | <p>The info you are after will be in WMI.</p>
<p>This example using WMI may get you most of the way:</p>
<pre><code>using System.Management;
string query = "SELECT * FROM Win32_NetworkAdapterConfiguration";
ManagementObjectSearcher moSearch = new ManagementObjectSearcher(query);
ManagementObjectCollection moCollectio... | 46,908 |
<p>I am trying to make a structured light 3D scanner using single camera, light projector and a turntable.</p>
<p>After days on Google I did not find any reliable open source project which I can get to work. <a href="https://github.com/jakobwilm/slstudio" rel="noreferrer">SLStudio</a> really seemed a good choice but ... | <p>I did find only one 3d scanner which uses structured light. There is many projects using a laser diode. And these systems are completely opensource.</p>
<h1>Structured Light</h1>
<h2>Structured Light 3D Scanning by kylemcdonald</h2>
<ul>
<li><a href="http://www.instructables.com/id/Structured-Light-3D-Scanning/?A... | <p><a href="http://www.makeralot.com/ciclop-3d-scanner-diy-kit-p196/" rel="nofollow noreferrer" title="BQ Ciclop 3D Scanner">BQ Ciclop 3D Scanner</a></p>
<ul>
<li>Scan Volume: Bigger than 5 cm x 5 cm and smaller than 20 cm x 20 cm</li>
<li>Scanning Precision: 0.5 mm</li>
</ul>
<p>All the necessary parts for Ciclop are ... | 285 |
<p>I'm working on a boot loader on an x86 machine.</p>
<p>When the BIOS copies the contents of the MBR to 0x7c00 and jumps to that address, is there a standard meaning to the contents of the registers? Do the registers have standard values?</p>
<p>I know that the segment registers are typically set to 0, but will som... | <blockquote>
<p>This early execution environment is highly implementation defined, meaning the implementation of your particular BIOS. Never make any assumptions on the contents of registers. They might be initialized to 0, but they might contain a random value just as well. </p>
</blockquote>
<p>from the <a href="h... | <p>Best option would be to assume nothing. If they have meaning, you will find that from the other side when you need the information they provide.</p>
| 4,071 |
<p>I'm building an application where I should capture several values and build a text with them: <code>Name</code>, <code>Age</code>, etc.</p>
<p>The output will be a plain text into a <code>TextBox</code>.</p>
<p>I am trying to make those information appear in kind of <code>columns</code>, therefore I am trying to sep... | <p>Try using the <code>\t</code> character in your strings</p>
| <pre><code>string St = String.Format("{0,-20} {1,5:N1}\r", names[ctr], hours[ctr]);
richTextBox1.Text += St;
</code></pre>
<p>This works well, but you must have a mono-spaced font.</p>
| 47,791 |
<p>I'm creating several RSS feeds from a database to publish things like job openings, volunteer opportunities, and links in general. My question is, how many items should be returned in the feed so that it is most likely that someone will get all the items in their reader without any gaps?</p>
<p>SELECT TOP 100 ? (o... | <p>Well, it would depend on the rate that entries show up.</p>
<p>But I'd be guessing that aiming for the last 48 or so hours would be safe - seeing as a lot of users would be running stand alone RSS readers that will need to hit the feed to pull down whatever is current. But if that is going to be too much data, then... | <p>feedburner <a href="http://blogs.feedburner.com/feedburner/archives/2004/04/feedburner_saved_my_bandwidth.php" rel="nofollow noreferrer">seems to check every 5 minutes</a> but you might be able to set it up in your account. Another forum post seems to indicate <a href="http://groups.google.com/group/feedburner-servi... | 27,314 |
<p>ISSUE: Stepper motors are not working when connected with RAMPS 1.4.</p>
<p>OBSERVATION: The LED lights(LED 2,3,4) in the RAMPS 1.4 is not powering up.</p>
<p>PRACTICES: I use Arduino Mega 2560 and installed Marlin firmware in it. And I bought a RAMPS 1.4 in a local electronic dealer. I placed the RAMPS over Ardui... | <p>I actually thought the problem is in the electronic circuit but the problem is the baud rate. I initially took the baud rate as 115200 but later. after someone's suggestion, I changed it to 250000 and now it's fine.</p>
| <p>to help you to solve this problem - please see my checklist</p>
<ol>
<li>are the stepper drivers connected correctly (pin1 to pin1)?</li>
<li>stepper wiring is accurate (1a-1a..2b-2b)?</li>
<li>is there enough voltage provided to the steppers (regulate)?</li>
<li>if you are trying to move E0 or E1 then you need to ... | 1,014 |
<p>I have a string in a watch window in VS2008 and want to see the hex representation of each character. If I right click there's a hexadecimal option but this doesn't appear to do anything. Anybody know how to view the string as a series of hex values?</p>
| <p>Add your string as a watch, then edit the watch expression and append ".ToCharArray()" to view it as an array of chars. When you expand your watch you will see char code next to each individual char. Checking "Hexadecimal display" will show you hex codes for each character.</p>
| <p>Default visualizer in VS (at least 2005) does not support this. However, apparently it isn't too much trouble to roll one's own visualizer: <a href="http://msdn.microsoft.com/en-us/library/ms379596.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms379596.aspx</a> (That's an old article from 2... | 22,403 |
<p>I have this structure in my app:</p>
<p>USER has_one :publicprofile, :privateprofile</p>
<p>PUBLICPROFILE has many :emails, :phonenumbers</p>
<p>PRIVATEPROFILE has many :adresses, :creditcards</p>
<p>I would like to know how to go about having a profile page for the user where I can update his nested resources (... | <p>I recommend you watch this screencast: <a href="http://railscasts.com/episodes/139-nested-resources" rel="nofollow noreferrer">http://railscasts.com/episodes/139-nested-resources</a></p>
<p>It definitely helped me understand what is really possible using nested routes and resources in Rails (especially the new chan... | <p>I believe any nesting deeper than 1-level is generally frowned upon, and can normally be avoided. Jamis Buck <a href="http://weblog.jamisbuck.org/2007/2/5/nesting-resources" rel="nofollow noreferrer">blogged about it</a> a while back.</p>
<p>The PeepCode <a href="https://peepcode.com/products/rest-for-rails-2" rel=... | 49,737 |
<p>My stomach churns when I see this kind of output.</p>
<p><a href="http://www.freeimagehosting.net/uploads/e1097a5a10.jpg" rel="nofollow noreferrer">http://www.freeimagehosting.net/uploads/e1097a5a10.jpg</a></p>
<p>and this was my command
as suggested by <a href="https://stackoverflow.com/questions/75500/best-way-t... | <p>tiffg4 is a black&white output device.
You should use tiff24nc or tiff12nc as the output device colour PDFs - see <a href="http://pages.cs.wisc.edu/~ghost/doc/AFPL/8.00/Devices.htm#TIFF" rel="noreferrer">ghostscript output devices</a>.
These will be uncompressed but you could put the resulting TIFFs through imag... | <p>I ran into the same problem with fax pages.</p>
<p>I was using Imagick in php and this command fixed the way it looked.</p>
<pre><code>$Imagick->blackThresholdImage('grey');
</code></pre>
<p>I didn't see any threshold option using 'gs' but convert may also work for you.</p>
<pre><code>convert a.pdf -threshold... | 27,298 |
<p>I have a Java String that contains XML, with no line feeds or indentations. I would like to turn it into a String with nicely formatted XML. How do I do this?</p>
<pre><code>String unformattedXml = "<tag><nested>hello</nested></tag>";
String formattedXml = new [UnknownClass]().format(unforma... | <pre class="lang-java prettyprint-override"><code>Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
// initialize StreamResul... | <p>I was trying to achieve something similar, but without any external dependency. The application was already using DOM to format just for logging the XMLs!</p>
<p>Here is my sample snippet</p>
<pre><code>public void formatXML(final String unformattedXML) {
final int length = unformattedXML.length();
final i... | 16,833 |
<p>I'm writing a setup program to install an application to a USB drive. The application is meant to be used only from USB drives, so it would save an extra step for the user by automatically selecting USB drive to install to.</p>
<p>I might explore using Nullsoft or MSI for install, but since I'm mostly familiar with... | <p>You could use:</p>
<pre><code>from driveInfo in DriveInfo.GetDrives()
where driveInfo.DriveType == DriveType.Removable && driveInfo.IsReady
select driveInfo.RootDirectory.FullName
</code></pre>
| <p>This will enumerate all the drives on the system without LINQ but still using WMI:</p>
<pre><code>// browse all USB WMI physical disks
foreach(ManagementObject drive in new ManagementObjectSearcher(
"select * from Win32_DiskDrive where InterfaceType='USB'").Get())
{
// associate physical disks with partiti... | 15,073 |
<p>I am using the next class (simplified for the sake of understandability) to download images in a struts web application.
It is working fine in every browser but firefox, which cuts names containing spaces. That it is to say: <strong>file with spaces.pdf</strong> gets downloaded in firefox as: <strong>file</strong> ... | <p>The filename should be a <strong>quoted</strong> string. (According to <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1" rel="noreferrer">Section 19.5.1 of RFC 2616</a>)</p>
<pre><code>response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\"");
</code></pre>
| <p>This is a security feature of firefox 3 I believe.</p>
<p>Here we go</p>
<p><a href="http://support.mozilla.com/tiki-view_forum_thread.php?locale=no&forumId=1&comments_parentId=91513" rel="nofollow noreferrer">http://support.mozilla.com/tiki-view_forum_thread.php?locale=no&forumId=1&comments_parent... | 21,434 |
<p>If the framework is persistence agnostic, can my unit tests construct a file system version of the persistance store underneath my entity model?</p>
<p>I'll be using the model first features of entity framework in the GUI for sure because it's too easy for my devs to make schema changes and keep DAL layer in sync.<... | <p>Entity Framework does <em>not</em> have true persistence ignorance. That is one of the biggest criticisms (i.e. a forced base class, lots of EF ties, etc). LINQ-to-SQL <em>can</em> have persistence ignorance, but in reality people tend to use the lazy loading and attributed approach, which means that it still doesn'... | <p>Just an update, this has now changed as of Entity Framework 4.0 which supports <a href="http://aleembawany.com/2009/04/06/persistence-ignorance-in-adonet-entity-framework/" rel="nofollow noreferrer">Persistence Ignorance</a>.</p>
| 35,440 |
<p>I developed a greasemonkey script that refreshes a page and checks for certain updates. I would like to run this script in a tab and browse the internet in another tab, but then have the script automatically activate it's tab when an update is found.</p>
<p>Im not sure how clear that was, maybe this is better:</p>
... | <p>I'm pretty sure that firefox gives focus to tabs that call <code>alert()</code>. So just pop up an<br>
<code>alert('found foo')</code></p>
| <p>Have you looked at <a href="http://wiki.greasespot.net/GM_openInTab" rel="nofollow noreferrer">GM_openInTab()</a>? </p>
| 42,749 |
<p>My company needs a PDF viewer with Java API with the additional requirement on being able to use FDF form data.</p>
<p>The only one i found was <a href="http://www.jpedal.org/index.php" rel="nofollow noreferrer">JPedal</a> which promises to feature everything we need, but it costs a bunch. So what are my options? I... | <p>Have a look at the Foxit SDK. <a href="http://www.foxitsoftware.com/" rel="nofollow noreferrer">http://www.foxitsoftware.com/</a> The cost seems at bit less and i'm sure you'll get much more.</p>
<p>Maybe Open Office has something in its belt for you?</p>
<p>I also just found those:</p>
<p><a href="http://www.cri... | <p><a href="http://www.accesspdf.com/pdftk/" rel="nofollow noreferrer">http://www.accesspdf.com/pdftk/</a> (probably you will have to dig a little in it if you would like to find what you are searching for, but I think you'll find)</p>
| 36,479 |
<p>I've got two arrays of the same size. I'd like to merge the two so the values of one are the key indexes of the new array, and the values of the new array are the values of the other.</p>
<p>Right now I'm just looping through the arrays and creating the new array manually, but I have a feeling there is a much more... | <p>See <a href="http://php.net/array_combine" rel="noreferrer"><code>array_combine()</code></a> on PHP.net.</p>
| <p>This should do the trick</p>
<pre><code>function array_merge_keys($ray1, $ray2) {
$keys = array_merge(array_keys($ray1), array_keys($ray2));
$vals = array_merge($ray1, $ray2);
return array_combine($keys, $vals);
}
</code></pre>
| 19,597 |
<p>I am trying to create a simple dialog in MFC using Visual C++. My problem is that when I get the dialog on the screen and try to type in an Edit Box field, if I type the letter 'a' once, it appears in the edit box as 'aaaaaaaaaaa' (that's 12 a's). Furthermore, if I try to navigate around in the box using the arrow... | <p>Are you capturing any events such as WM_KEYUP in your PreTranslateMessage() function or anywhere else in your app ?</p>
<p>If you have overridden the default handling for keyboard events, it might cause the symptoms you are seeing.</p>
| <p>For some reason this brings back vague memories of early struggles with MFC. Have you looked for mutual recursion at all? I was <em>forever</em> doing something in one bit of the app that sent a message (unbeknown to me) that was picked up by another method that called the first method...</p>
<p>My guess is it's on... | 48,771 |
<p>I work with Fusion360 for designing lots of things. Recently I learned how to work with parameters that I can easily modify all at once, allowing to pretty much make easily customizable pieces.</p>
<p>Now, Thingiverse wants customizer pieces in the shape of <code>.SCAD</code> files, and some people just can't work ... | <p>Even though OpenSCAD can import a variety of formats, the file structure will not be accepted by Thingiverse in the manner presented by the OP.</p>
<p>OpenSCAD is a text-based description language. One creates parameters assigned to specific aspects of a model and implements those parameters to create the desired s... | <p>No, you cannot import STEP nor Fusion360 files in OpenSCAD.</p>
<p>OpenSCAD <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Importing_Geometry" rel="nofollow noreferrer">currently supports</a>:</p>
<p><strong>3D formats</strong></p>
<ul>
<li>STL (both ASCII and Binary)</li>
<li>OFF</li>
<li>AMF [Note:... | 1,619 |
<p><a href="http://en.wikipedia.org/wiki/Literate_programming" rel="noreferrer">Literate programming</a> is a way of developing software where documentation comes first, then the coding. One writes the documentation of a code snippet, and then writes the implementation of the snippet. The visual appearance of the softw... | <p>Kudos to you for trying to improve the way your team works. As long as you're trying to do that, you have an advantage over those that do not.</p>
<p>I used Literate Programming for a project once. It was really hard, and the results were really good. Seemed like a reasonable tradeoff.</p>
<p>However, today I'd... | <p>Hello source novel authors,</p>
<p>As some one referred to <strong>DOxygen</strong> here : although this does not allow real <strong>Literate Programming</strong> <em>(as an example of limitations, this does not allow to have a reordered view on sources)</em>, it however seems to be recognized as a valuable tools i... | 26,974 |
<p>Several times now I've been faced with plans from a team that wants to build their own bug tracking system - Not as a product, but as an internal tool.</p>
<p>The arguments I've heard in favous are usually along the lines of :</p>
<ul>
<li>Wanting to 'eat our own dog food' in terms of some internally built web fra... | <p>First, look at these <a href="http://ohloh.net" rel="noreferrer">Ohloh</a> metrics:</p>
<pre><code> Trac: 44 KLoC, 10 Person Years, $577,003
Bugzilla: 54 KLoC, 13 Person Years, $714,437
Redmine: 171 KLoC, 44 Person Years, $2,400,723
Mantis: 182 KLoC, 47 Person Years, $2,562,978
</code></pre>
<p>What do... | <p>I agree with most of the people here. It is no use to rebuild something when there are many tools (even free) available.
If you want to customize anything, most of the free tools give you the code, play with it.</p>
<p>If you do new development, you should not be doing it for yourself only.</p>
| 8,752 |
<p>Up till now, I've tended to scale my first layer according to the print quality, so a 0.12 mm first layer for a 0.08 mm print, and 0.28 mm for a 0.2 mm print.</p>
<p>After changing to a PLA which isn't sticking well, I'm wondering if the first layer is best determined by the printer/tolerance/ma... | <p>Default settings for first layer height in Slic3r Prusa Edition print profiles regardless layer height is 0.2 mm.</p>
<p>If you need to improve bed adhesion then try tips from this video <a href="https://www.youtube.com/watch?v=ShFaJ027pFs" rel="nofollow noreferrer">3D Prints not sticking anymore? Watch this! 3DP10... | <p>Layer height in my cura settings means that head of extruder will be going up at 0.3mmm, and how i know that? Because i measure few different settings with height of bed.
When I set bed to -0.2mm, ike everybody is proposing on internet, and i started printing first layer, I did stop it and measure with precise calip... | 1,003 |
<p>On Mac OS X, you can create a zip archive from the Finder by selecting some files and selecting "Compress" from the contextual menu or the File menu. Unfortunately, the resulting file is not identical to the archive created by the <code>zip</code> command (with the default options).</p>
<p>This distinction matters... | <p>Use the ditto command-line tool as follows:</p>
<pre><code>ditto -ck --rsrc --sequesterRsrc folder file.zip
</code></pre>
<p>See the <a href="https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/ditto.1.html" rel="noreferrer">ditto man page</a> for more.</p>
| <p>The clue's in the tag 'automation'.</p>
<p>Create an action in Automator.app that uses the 'Create Archive' action, invoke it from the command-line (see 'automator').</p>
| 13,329 |
<p>I am having trouble in exporting to excel and it crashes out at the .set_Value function.</p>
<p>It seems to work if I change object[,] to string[,] but by doing this I lose the formatting.</p>
<p>Anyone Help?</p>
| <p>Are you passing '<code>null</code>' for missing parameters rather than <code>System.Reflection.Missing.Value</code> ?</p>
| <p>I am passing <code>Missing.Value</code> but I have discovered what was the cause of this particular failure. The object[,] had a <code>=</code> sign as first character in some cells which caused Excel to fail so I checked for column type string and checked value <code>if substring(0,1) == "="</code> then add a <code... | 25,359 |
<p>Looking for an attractive, highly customizable forum plugin to implement. Don't want to build one myself, but don't want to settle for usual crap. Something Ajax-y? </p>
<p>Was leaning towards Community Server but would love to see what others had to reccomend. </p>
<p>Thanks. </p>
<p>EDIT: This is an ASP.NET/C#/... | <p>See <a href="http://ask.metafilter.com/52003/Good-community-forum-software" rel="nofollow noreferrer">http://ask.metafilter.com/52003/Good-community-forum-software</a></p>
<p>Options </p>
<ul>
<li><a href="http://getvanilla.com/" rel="nofollow noreferrer">Lussumo's Vanilla</a> </li>
<li><a href="http://www.simplem... | <p>YetAnotherForum is ASP.NET/C#/SQL like your application and it looks very nice. I'm not sure about AJAX though.</p>
<p>It can run in DotNetNuke, Rainbow, or stand-alone.</p>
<p><a href="http://www.yetanotherforum.net/features.aspx" rel="nofollow noreferrer">http://www.yetanotherforum.net/features.aspx</a></p>
| 29,672 |
<p>Specifically, we've got some external JavaScript tracking code on our sites that throws itself into an infinite loop each time an anchor is clicked on.</p>
<p>We don't maintain the tracking code, so we don't know exactly how it works. Since the code causes the browser to lock up almost immediately, I was wondering... | <p>Forget HTML and make a PDF. HTML printing is extremely variable - not just across browsers but across different versions of the same browser. PDF is a lot easier.</p>
<p>Even if you get it exactly right with one browser / font setup / printer / phase of the moon, it will be the most fragile thing you've ever had to... | <p>Add a few options to your app that let users adjust spacing for their particular configuration. You could include this right on the label if you want, and style it away via media selectors, but you'll probably want to persist them somewhere, too.</p>
| 19,852 |
<p>I'm working on an existing j2ee app and am required to remove some vendor specific method calls from the code.</p>
<p>The daos behind a session facade make calls into the ejb container to get the user's id and password - in order to connect to the database. The user id and password part of the initialContext used ... | <p>I can't give you a generic solution, but this is what has worked for us. We have the app server connect to LDAP as a specific user that has the ability to request credentials for other users. Then we have some generic security code that we can use to request a users credentials from inside the session beans, based... | <p>Normally the Java EE security model will not allow the retrieval of the user password, for security reasons. But it depends on the implementation. Some vendors provide methods to retrieve this kind of information, but if you rely on such implementations, be aware that the portability of the application will be compr... | 42,881 |
<p>I want to transform <code>/foo/bar/..</code> to <code>/foo</code></p>
<p>Is there a bash command which does this?</p>
<hr>
<p>Edit: in my practical case, the directory does exist.</p>
| <p>if you're wanting to chomp part of a filename from the path, "dirname" and "basename" are your friends, and "realpath" is handy too. </p>
<pre><code>dirname /foo/bar/baz
# /foo/bar
basename /foo/bar/baz
# baz
dirname $( dirname /foo/bar/baz )
# /foo
realpath ../foo
# ../foo: No such file or directory
realpath... | <p>I discovered today that you can use the <code>stat</code> command to resolve paths.</p>
<p>So for a directory like "~/Documents":</p>
<p>You can run this:</p>
<p><code>stat -f %N ~/Documents</code></p>
<p>To get the full path:</p>
<p><code>/Users/me/Documents</code></p>
<p>For symlinks, you can use the %Y form... | 36,118 |
<p>I can't understand the concept and, first of all, where it belongs.
Is it solely a Shrepoint concept or more general like of ASP.NET or IIS level?
Does it only affect authentication and if so how does it affect it? Or what effect does it have on an application?
I know it is a broad question, but I've googled for abo... | <p>Each "zone" is essentially a new IIS Website, where each of the web sites point to a single Application Pool. Theses are also called extensions. Application pools in IIS create complete thread isolation by running separate worker proccesses. </p>
<p>Any Web application can be extended into multiple zones. Extending... | <p>it allows you to have different access from different urls with different security.</p>
<p>This allows you to set "Windows Authentication" for Intranet, "Form Authentication" for the extranet and "Form Authentication with allow anonymous" for the Internet.</p>
<p>The cache settings are also different depending on ... | 28,834 |
<p>I try to write a simple client/server application (all application is a bluetooth service and client). The client code find the bluetooth devices and register in to the local db. But when the inquiry running, it's not discoverable. (The server code run on another thread). I the emulator it's work (the scan time is 0... | <p>As far as I see you try to create simultaneously working server and client, right? Well, I think this is not gonna work, you have to make one phone server and the other one will be a client.</p>
<p>I would suggest looking through the example apps bundled with WTK or SE SDK, you may use them as reference. Also I wou... | <p>As far as I see you try to create simultaneously working server and client, right? Well, I think this is not gonna work, you have to make one phone server and the other one will be a client.</p>
<p>I would suggest looking through the example apps bundled with WTK or SE SDK, you may use them as reference. Also I wou... | 38,525 |
<p>I am developing an application and want to display a form that will be filled in if editing the form, but will not be if the form will be a new entry. I believe the least verbose way of doing this is to have just one form and to suppress any errors for echoing my variables so that nothing will be printed if it is a... | <p>i tend to use:</p>
<pre><code>$variable = (isset($new_item) && $new_item) ? 'Example' : 'Default Value';
</code></pre>
<p>Overkill really, but i think going straight for !$new_item throws a notice if it isn't set. You can also switch the second clause out for !empty($new_item) depending on the behaviour yo... | <p>I think the best way is to always set the variable</p>
<pre><code>if ( ! $new_item) {
$variable = 'Example';
} else {
$variable = 'Default value';
//or
$variable = '';
}
</code></pre>
<p>Using the <code>@</code> error suppression is slow. </p>
<p><strong>edit</strong>
Note that when you print the... | 40,939 |
<p>This will hopefully be an easy one. I have an F# project (latest F# CTP) with two files (Program.fs, Stack.fs). In Stack.fs I have a simple namespace and type definition</p>
<p>Stack.fs</p>
<pre><code>namespace Col
type Stack=
...
</code></pre>
<p>Now I try to include the namespace in Program.fs by declaring... | <p>What order are the files in the <code>.fsproj</code> file? Stack.fs needs to come before Program.fs for Program.fs to be able to 'see' it.</p>
<p>See also the start of</p>
<p><a href="http://lorgonblog.spaces.live.com/blog/cns!701679AD17B6D310!444.entry" rel="nofollow noreferrer">http://lorgonblog.spaces.live.com/b... | <p>I'm using Visual Studio for Mac - 8.1.4 and i've noticed that some .fs files are not marked as "Compile". You can see this by Viewing Build Output and see if all your files are there and in the correct order.</p>
<p>I've had to manually make sure certain files are marked with "Compile", and have had to move them u... | 20,829 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.