instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>Management is thinking of changing out Content Management Systems. What do you use/recommend?</p>
<ol>
<li>What UCM solution is your company using?</li>
<li>How big is your company?</li>
<li>Are you happy with the implementation?</li>
</ol>
<p>Current setup:</p>
<ol>
<li>The company I work for uses <code>Oracle ECM</code> (formerly Stellent UCM).</li>
<li>We have somewhere over 10,000 employees across Australia, New
Zealand and Indonesia.</li>
<li>It works! Having worked with the system for a while now. I can see
where the initial implementation went wrong. Its 3 years later and
it is <em>Rewrite Time!</em> (Three year itch?)</li>
</ol>
|
<p>1) CMS: <a href="http://www.bea.com/framework.jsp?CNT=index.htm&FP=/content/products/aqualogic/" rel="nofollow noreferrer">Oracle's BEA Aqualogic</a><br>
2) Size: 10,000+<br>
3) Experience: As an end user with full community and content admin privileges, I find the tool to be outdated and stifling in terms of knowledge sharing and trying to get the benefits that exist in social networks. Perhaps this is due to the implementation, and not an inherent weakness in the product. Not sure of the future direction of the product either, since Oracle recently acquired it. </p>
|
<ol>
<li><p>We use the Alterian Content Manager application. It is very robust and suites our needs well.</p></li>
<li><p>20000 staff+</p></li>
<li><p>Very happy. Developers and business team find the application very easy to work with.</p></li>
</ol>
| 3,990
|
<p>Every time I create an object that has a collection property I go back and forth on the best way to do it?</p>
<ol>
<li>public property with a getter that
returns a reference to private variable</li>
<li>explicit get_ObjList and set_ObjList
methods that return and create new or cloned
objects every time</li>
<li>explicit get_ObjList that returns an
IEnumerator and a set_ObjList that
takes IEnumerator</li>
</ol>
<p>Does it make a difference if the collection is an array (i.e., objList.Clone()) versus a List?</p>
<p>If returning the actual collection as a reference is so bad because it creates dependencies, then why return any property as a reference? Anytime you expose an child object as a reference the internals of that child can be changed without the parent "knowing" unless the child has a property changed event. Is there a risk for memory leaks?</p>
<p>And, don't options 2 and 3 break serialization? Is this a catch 22 or do you have to implement custom serialization anytime you have a collection property?</p>
<p>The generic ReadOnlyCollection seems like a nice compromise for general use. It wraps an IList and restricts access to it. Maybe this helps with memory leaks and serialization. However it still has <a href="http://www.coversant.net/Coversant/Blogs/tabid/88/EntryID/34/Default.aspx" rel="noreferrer">enumeration concerns</a> </p>
<p>Maybe it just depends. If you don't care that the collection is modified, then just expose it as a public accessor over a private variable per #1. If you don't want other programs to modify the collection then #2 and/or #3 is better.</p>
<p>Implicit in the question is why should one method be used over another and what are the ramifications on security, memory, serialization, etc.?</p>
|
<p>How you expose a collection depends entirely on how users are intended to interact with it.</p>
<p><strong>1)</strong> If users will be adding and removing items from an object's collection, then a simple get-only collection property is best (option #1 from the original question):</p>
<pre><code>private readonly Collection<T> myCollection_ = new ...;
public Collection<T> MyCollection {
get { return this.myCollection_; }
}
</code></pre>
<p>This strategy is used for the <code>Items</code> collections on the WindowsForms and WPF <code>ItemsControl</code> controls, where users add and remove items they want the control to display. These controls publish the actual collection and use callbacks or event listeners to keep track of items.</p>
<p>WPF also exposes some settable collections to allow users to display a collection of items they control, such as the <code>ItemsSource</code> property on <code>ItemsControl</code> (option #3 from the original question). However, this is not a common use case.</p>
<p><br/>
<strong>2)</strong> If users will only be reading data maintained by the object, then you can use a readonly collection, as <a href="https://stackoverflow.com/questions/35007/how-to-expose-a-collection-property#35065">Quibblesome</a> suggested:</p>
<pre><code>private readonly List<T> myPrivateCollection_ = new ...;
private ReadOnlyCollection<T> myPrivateCollectionView_;
public ReadOnlyCollection<T> MyCollection {
get {
if( this.myPrivateCollectionView_ == null ) { /* lazily initialize view */ }
return this.myPrivateCollectionView_;
}
}
</code></pre>
<p>Note that <code>ReadOnlyCollection<T></code> provides a live view of the underlying collection, so you only need to create the view once.</p>
<p>If the internal collection does not implement <code>IList<T></code>, or if you want to restrict access to more advanced users, you can instead wrap access to the collection through an enumerator:</p>
<pre><code>public IEnumerable<T> MyCollection {
get {
foreach( T item in this.myPrivateCollection_ )
yield return item;
}
}
</code></pre>
<p>This approach is simple to implement and also provides access to all the members without exposing the internal collection. However, it does require that the collection remain unmodfied, as the BCL collection classes will throw an exception if you try to enumerate a collection after it has been modified. If the underlying collection is likely to change, you can either create a light wrapper that will enumerate the collection safely, or return a copy of the collection.</p>
<p><br/>
<strong>3)</strong> Finally, if you need to expose arrays rather than higher-level collections, then you should return a copy of the array to prevent users from modifying it (option #2 from the orginal question):</p>
<pre><code>private T[] myArray_;
public T[] GetMyArray( ) {
T[] copy = new T[this.myArray_.Length];
this.myArray_.CopyTo( copy, 0 );
return copy;
// Note: if you are using LINQ, calling the 'ToArray( )'
// extension method will create a copy for you.
}
</code></pre>
<p>You should not expose the underlying array through a property, as you will not be able to tell when users modify it. To allow modifying the array, you can either add a corresponding <code>SetMyArray( T[] array )</code> method, or use a custom indexer:</p>
<pre><code>public T this[int index] {
get { return this.myArray_[index]; }
set {
// TODO: validate new value; raise change event; etc.
this.myArray_[index] = value;
}
}
</code></pre>
<p>(of course, by implementing a custom indexer, you will be duplicating the work of the BCL classes :)</p>
|
<p>If you're simply looking to expose a collection on your instance, then using a getter/setter to a private member variable seems like the most sensible solution to me (your first proposed option).</p>
| 5,543
|
<p>In my C/C++ program, I'm using <a href="http://opencvlibrary.sourceforge.net/" rel="noreferrer">OpenCV</a> to capture images from my webcam. The camera (<a href="http://en.wikipedia.org/wiki/Quickcam" rel="noreferrer">Logitech QuickCam IM</a>) can capture at resolutions <strong>320x240</strong>, <strong>640x480</strong> and <strong>1280x960</strong>. But, for some strange reason, OpenCV gives me images of resolution <strong>320x240</strong> only. Calls to change the resolution using <strong>cvSetCaptureProperty()</strong> with other resolution values just don't work. How do I capture images with the other resolutions possible with my webcam?</p>
|
<p>There doesn't seem to be a solution. The resolution can be increased to <strong>640x480</strong> using <a href="http://tech.groups.yahoo.com/group/OpenCV/message/28735" rel="noreferrer">this hack</a> shared by <em>lifebelt77</em>. Here are the details reproduced:</p>
<p>Add to <strong>highgui.h</strong>:</p>
<pre><code>#define CV_CAP_PROP_DIALOG_DISPLAY 8
#define CV_CAP_PROP_DIALOG_FORMAT 9
#define CV_CAP_PROP_DIALOG_SOURCE 10
#define CV_CAP_PROP_DIALOG_COMPRESSION 11
#define CV_CAP_PROP_FRAME_WIDTH_HEIGHT 12
</code></pre>
<p>Add the function <strong>icvSetPropertyCAM_VFW</strong> to <strong>cvcap.cpp</strong>:</p>
<pre><code>static int icvSetPropertyCAM_VFW( CvCaptureCAM_VFW* capture, int property_id, double value )
{
int result = -1;
CAPSTATUS capstat;
CAPTUREPARMS capparam;
BITMAPINFO btmp;
switch( property_id )
{
case CV_CAP_PROP_DIALOG_DISPLAY:
result = capDlgVideoDisplay(capture->capWnd);
//SendMessage(capture->capWnd,WM_CAP_DLG_VIDEODISPLAY,0,0);
break;
case CV_CAP_PROP_DIALOG_FORMAT:
result = capDlgVideoFormat(capture->capWnd);
//SendMessage(capture->capWnd,WM_CAP_DLG_VIDEOFORMAT,0,0);
break;
case CV_CAP_PROP_DIALOG_SOURCE:
result = capDlgVideoSource(capture->capWnd);
//SendMessage(capture->capWnd,WM_CAP_DLG_VIDEOSOURCE,0,0);
break;
case CV_CAP_PROP_DIALOG_COMPRESSION:
result = capDlgVideoCompression(capture->capWnd);
break;
case CV_CAP_PROP_FRAME_WIDTH_HEIGHT:
capGetVideoFormat(capture->capWnd, &btmp, sizeof(BITMAPINFO));
btmp.bmiHeader.biWidth = floor(value/1000);
btmp.bmiHeader.biHeight = value-floor(value/1000)*1000;
btmp.bmiHeader.biSizeImage = btmp.bmiHeader.biHeight *
btmp.bmiHeader.biWidth * btmp.bmiHeader.biPlanes *
btmp.bmiHeader.biBitCount / 8;
capSetVideoFormat(capture->capWnd, &btmp, sizeof(BITMAPINFO));
break;
default:
break;
}
return result;
}
</code></pre>
<p>and edit <strong>captureCAM_VFW_vtable</strong> as following:</p>
<pre><code>static CvCaptureVTable captureCAM_VFW_vtable =
{
6,
(CvCaptureCloseFunc)icvCloseCAM_VFW,
(CvCaptureGrabFrameFunc)icvGrabFrameCAM_VFW,
(CvCaptureRetrieveFrameFunc)icvRetrieveFrameCAM_VFW,
(CvCaptureGetPropertyFunc)icvGetPropertyCAM_VFW,
(CvCaptureSetPropertyFunc)icvSetPropertyCAM_VFW, // was NULL
(CvCaptureGetDescriptionFunc)0
};
</code></pre>
<p>Now rebuilt <strong>highgui.dll</strong>.</p>
|
<pre><code>cvQueryFrame(capture);
cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH, any_supported_size );
cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT, any_supported_size);
cvQueryFrame(capture);
</code></pre>
<p>should be just enough!</p>
| 3,506
|
<p>In SQL Server would a <code>varbinary(16)</code> be the most efficient way of storing an <strong>MD5 hash</strong>? Won't be doing anything with it except returning it in a <strong>linq</strong> query.</p>
|
<p>Based on the <a href="http://msdn.microsoft.com/en-us/library/ms188362.aspx" rel="noreferrer">documentation on MSDN</a> and my experience, binary is better, since the md5 hash does not vary in size.</p>
<p>The size for a binary data type is n bytes, so the size of the data. The size of a varbinary data type is n bytes + 2 bytes on top of the size of the data.</p>
|
<p>Null values change things: </p>
<p>A null varbinary(16) is 2 bytes. <br />
A null binary(16) is 16 bytes. <br />
16 bytes stored in varbinary(16) takes 18 bytes. <br />
16 bytes in binary(16) takes 16 bytes. <br /></p>
<p><a href="https://stackoverflow.com/a/3731195">https://stackoverflow.com/a/3731195</a></p>
| 7,156
|
<p>I have an Asp.NET application (VS2008, Framework 2.0). When I try to set a property on one of the user controls like</p>
<pre><code>myUserControl.SomeProperty = someValue;
</code></pre>
<p>I get a <code>NullReferenceException</code>. When I debug, I found out that <code>myUserControl</code> is null. How is it possible that a user control handle is null? How do I fix this or how do I find what causes this?</p>
|
<p>Where are you trying to access the property? If you are in onInit, the control may not be loaded yet.</p>
|
<p>If you created the UserControl during runtime (through ControlCollection.Add), you need to create it on postback too.</p>
<p>Another case can be your UserControl does not match the designer.cs page</p>
| 5,015
|
<p>I am running oracle and have a query which pulls some results from the database. I would like to write the results as a text file. How would I go about doing this?</p>
<p>My prefered way would be by using UTL_FILE. Would some one have an example of how to do this?</p>
|
<p>If you're using Sql Plus, is as easy as:</p>
<pre>
SQL> spool c:\temp\out.txt
SQL> SELECT * FROM USERS;
SQL> spool off
</pre>
<p>This three sentences will output the result of the query "SELECT * FROM USERS" to the file c:\temp\out.txt.</p>
<p>You can format this query using the string manipulation functions of Oracle.</p>
|
<p>This seems to be a reasonable tutorial with a few simple examples <a href="http://www.adp-gmbh.ch/ora/plsql/utl_file.html" rel="nofollow noreferrer">UTL_FILE example</a></p>
| 4,715
|
<p>I am trying to set a flag to show or hide a page element, but it always displays even when the expression is false. </p>
<pre><code>$canMerge = ($condition1 && $condition2) ? 'true' : 'false';
...
<?php if ($canMerge) { ?>Stuff<?php } ?>
</code></pre>
<p>What's up?</p>
|
<p>This is broken because 'false' as a string will evaluate to true as a boolean.</p>
<p>However, this is an unneeded ternary expression, because the resulting values are simple true and false. This would be equivalent:</p>
<pre><code>$canMerge = ($condition1 && $condition2);
</code></pre>
|
<pre><code>$canMerge = ($condition1 && $condition2);
</code></pre>
<p>then</p>
<pre><code>if ($canMerge){
echo "Stuff";
}
</code></pre>
| 2,407
|
<p>Let's say I print a part out of ABS and wait for it to cool. I could theoretically do this with several copies of the same printer, modified to use print beds of different compositions.</p>
<p>Will the material a bed is made out of affect how long it takes a part to cool?</p>
|
<p><strong>What bed material cools faster?</strong></p>
<p>I found an <a href="http://www.engineeringtoolbox.com/thermal-conductivity-d_429.html">extensive list</a> which relates various materials to their <em>thermal conductivity</em>, k [W/mK]; the lower thermal conductivity, the better the material insulates, and the slower the print bed will resist changes in temperature - both heating up, and cooling down. </p>
<p>Here are the thermal conductivity for some common materials for 3d printer beds:</p>
<pre><code>Aluminum 205
Glass 1.05
Acrylic 0.2
Air 0.024 (for reference)
</code></pre>
<p>There is also the matter of thermal capacity, but I will not go into that right now (need to do some research myself first!).</p>
<p><strong>Will bed material affect cooling time?</strong></p>
<p>Bed material, I believe, is not necessarily related to print cooldown time: it depends on the situation, such as whether we are discussing cooldown during or after printing, and if the bed is heated or not. </p>
<ol>
<li>If you are <em>not</em> using a heated bed, I believe the bed material doesn't matter at all.</li>
<li>With a heated bed <em>while printing</em>, only the first dozen layers or so are probably affected by the rising heat sufficiently that it affects the printing process.</li>
<li>With a heated bed <em>after printing</em>, the thermal characteristics of the bed will determine how quickly the print cools (and thus can be removed).</li>
</ol>
<p>Also remember that other physical properties, such as flatness (both cold and during heating) of the bed material is vital for successful prints, and that not all materials can tolerate heating equally well! </p>
|
<p>Assuming you are meaning the build plate and not confusing it with a printed raft, yes, different materials for the build plate will have different cooling rates. I don't know the values of hand, but a Google search can get you to a formula to calculate how long a certain size build plate of a given material type should roughly take to cool. (I'm using the mobile app right now, so I'll have to get back to this answer later to give links and more details)</p>
| 143
|
<p>I just started thinking about creating/customizing a web crawler today, and know very little about web crawler/robot etiquette. A majority of the writings on etiquette I've found seem old and awkward, so I'd like to get some current (and practical) insights from the web developer community.</p>
<p>I want to use a crawler to walk over "the web" for a super simple purpose - "does the markup of site XYZ meet condition ABC?".</p>
<p>This raises a lot of questions for me, but I think the two main questions I need to get out of the way first are:</p>
<ul>
<li>It feels a little "iffy" from the get go -- is this sort of thing acceptable?</li>
<li>What specific considerations should the crawler take to not upset people?</li>
</ul>
|
<p>Obey robots.txt (and not too aggressive like has been said already).</p>
<p>You might want to think about your user-agent string - they're a good place to be up-front about what you're doing and how you can be contacted.</p>
|
<p>I'd say that it is very important to consider how much load you are causing. For instance, if your crawler requests every object of a single site, more or less at once, it might cause load problems for that particular site.</p>
<p>In other words, make sure your crawler is not too aggressive.</p>
| 5,228
|
<p>Let me preface this question by saying I use TextMate on Mac OSX for my text needs and I am in love with it. Anything comparable on the Linux platform? I'll mostly use it for coding python/ruby.</p>
<p>Doing a google search yielded outdated answers.</p>
<p>Edit: Since there has been some concern about the 'merit' of this question. I am about to start a new Ruby Programming Project in Linux and before I got started I wanted to make sure I had the right tools to do the job.</p>
<p>Edit #2: I use VIM on a daily basis -- all . the . time. I enjoy using it. I was just looking for some alternatives.</p>
|
<p><img src="https://i.stack.imgur.com/YayAV.png" alt="Real programmers set the universal constants at the start such that the universe evolves to contain the disk with the data they want."></p>
<p><a href="http://xkcd.com/378/" rel="noreferrer">http://xkcd.com/378/</a></p>
|
<p>You can try Emacs with ruby-mode, <a href="http://rinari.rubyforge.org/" rel="nofollow noreferrer">Rinari</a> (for Rails) and <a href="http://code.google.com/p/yasnippet/" rel="nofollow noreferrer">yasnippet</a> which provides automatic snippets like Textmate.</p>
| 2,504
|
<p>Pretty new to 3d Printing. Ultimaker Cura as my Slicer. I have the Ender3 3d Printer.</p>
<p>I have a model from Hero Forge I'm trying to print. I added some caltrops on the base but when I go to print the figure, my Ender3 won't finish the caltrops/smaller items and won't finish the figure. It will basically just go through the motions lol.</p>
<p>Here's an example of it happening on the base of my Figure.</p>
<p>This is the mockup and afterwards is basically where it stops and the filament either just stops coming out or the nozzle moves around the filament that actually does print.</p>
<p><a href="https://i.stack.imgur.com/UWp3p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UWp3p.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/gIME4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gIME4.jpg" alt="enter image description here" /></a></p>
<p>Here's an example of something similar happening to Pikachu's ears.
<a href="https://i.stack.imgur.com/MAR24.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MAR24.jpg" alt="enter image description here" /></a></p>
|
<h2>Resolution is limited</h2>
<p>You are printing with FDM. FDM is limited in printing detail by its nozzle diameter: you can not print something that is much smaller than your nozzle diameter. A typical nozzle is 0.4 mm in diameter. Your figurine? That is too thin and fragile.</p>
|
<p>I suggest you try again with another filament. It looks like your nozzle is either clogging or your filament is slipping. There could be multiple reasons why, but the easiest first troubleshooting strategy is to change filament because it can rule out half the reasons.</p>
| 2,218
|
<p>Recently I tried understanding the use of <strong>java.math.MathContext</strong> but failed to understand properly. Is it used for rounding in <code>java.math.BigDecimal</code>. If yes why does not it round the decimal digits but even mantissa part.</p>
<p>From API docs, I came to know that it follows the standard specified in <code>ANSI X3.274-1996</code> and <code>ANSI X3.274-1996/AM 1-2000</code> specifications but I did not get them to read online.</p>
<p>Please let me know if you have any idea on this.</p>
|
<p>@jatan</p>
<blockquote>
<p>Thanks for you answer. It makes sense. Can you please explain me MathContext in the context of BigDecimal#round method.</p>
</blockquote>
<p>There's nothing special about <code>BigDecimal.round()</code> <em>vs.</em> any other <code>BigDecimal</code> method. In all cases, the <code>MathContext</code> specifies the number of significant digits and the rounding technique. Basically, there are two parts of every <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/math/MathContext.html" rel="noreferrer"><code>MathContext</code></a>. There's a precision, and there's also a <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/math/RoundingMode.html" rel="noreferrer"><code>RoundingMode</code></a>.</p>
<p>The precision again specifies the number of significant digits. So if you specify <code>123</code> as a number, and ask for 2 significant digits, you're going to get <code>120</code>. It might be clearer if you think in terms of scientific notation.</p>
<p><code>123</code> would be <code>1.23e2</code> in scientific notation. If you only keep 2 significant digits, then you get <code>1.2e2</code>, or <code>120</code>. By reducing the number of significant digits, we reduce the precision with which we can specify a number.</p>
<p>The <code>RoundingMode</code> part specifies how we should handle the loss of precision. To reuse the example, if you use <code>123</code> as the number, and ask for 2 significant digits, you've reduced your precision. With a <code>RoundingMode</code> of <code>HALF_UP</code> (the default mode), <code>123</code> will become <code>120</code>. With a <code>RoundingMode</code> of <code>CEILING</code>, you'll get <code>130</code>.</p>
<p>For example:</p>
<pre><code>System.out.println(new BigDecimal("123.4",
new MathContext(4,RoundingMode.HALF_UP)));
System.out.println(new BigDecimal("123.4",
new MathContext(2,RoundingMode.HALF_UP)));
System.out.println(new BigDecimal("123.4",
new MathContext(2,RoundingMode.CEILING)));
System.out.println(new BigDecimal("123.4",
new MathContext(1,RoundingMode.CEILING)));
</code></pre>
<p>Outputs:</p>
<pre><code>123.4
1.2E+2
1.3E+2
2E+2
</code></pre>
<p>You can see that both the precision and the rounding mode affect the output.</p>
|
<p>If I'm understanding you correctly, it sounds like you're expecting the MathContext to control how many digits should be kept after the decimal point. That's not what it's for. It specifies how many digits to keep, <em>total</em>. So if you specify that you want 3 significant digits, that's all you're going to get.</p>
<p>For example, this:</p>
<pre><code>System.out.println(new BigDecimal("1234567890.123456789",
new MathContext(20)));
System.out.println(new BigDecimal("1234567890.123456789",
new MathContext(10)));
System.out.println(new BigDecimal("1234567890.123456789",
new MathContext(5)));
</code></pre>
<p>will output:</p>
<pre><code>1234567890.123456789
1234567890
1.2346E+9
</code></pre>
| 2,908
|
<p>here is what a I'm doing: </p>
<pre><code>object ReturnMatch(System.Type type)
{
foreach(object obj in myObjects)
{
if (obj == type)
{
return obj;
}
}
}
</code></pre>
<p>However, if obj is a subclass of <code>type</code>, it will not match. But I would like the function to return the same way as if I was using the operator <code>is</code>.</p>
<p>I tried the following, but it won't compile:</p>
<pre><code>if (obj is type) // won't compile in C# 2.0
</code></pre>
<p>The best solution I came up with was:</p>
<pre><code>if (obj.GetType().Equals(type) || obj.GetType().IsSubclassOf(type))
</code></pre>
<p>Isn't there a way to use operator <code>is</code> to make the code cleaner?</p>
|
<p>I've used the IsAssignableFrom method when faced with this problem.</p>
<pre><code>Type theTypeWeWant; // From argument or whatever
foreach (object o in myCollection)
{
if (theTypeWeWant.IsAssignableFrom(o.GetType))
return o;
}
</code></pre>
<p>Another approach that may or may not work with your problem is to use a generic method:</p>
<pre><code>private T FindObjectOfType<T>() where T: class
{
foreach(object o in myCollection)
{
if (o is T)
return (T) o;
}
return null;
}
</code></pre>
<p>(Code written from memory and is not tested)</p>
|
<p>the is operator indicates whether or not it would be 'safe' to cast one object as another obeject (often a super class).</p>
<pre><code>if(obj is type)
</code></pre>
<p>if obj is of type 'type' or a subclass thereof, then the if statement will succeede as it is 'safe' to cast obj as (type)obj.</p>
<p>see: <a href="http://msdn.microsoft.com/en-us/library/scekt9xw(VS.71).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/scekt9xw(VS.71).aspx</a></p>
| 9,798
|
<p>I would really like to see a proportional font IDE, even if I have to build it myself (perhaps as an extension to Visual Studio). What I basically mean is MS Word style editing of code that sort of looks like the typographical style in <a href="http://www.research.att.com/~bs/3rd.html" rel="nofollow noreferrer">The C++ Programming Language book</a>.</p>
<p>I want to set tab stops for my indents and lining up function signatures and rows of assignment statements, which could be specified in points instead of fixed character positions. I would also like bold and italics. Various font sizes and even style sheets would be cool.</p>
<p>Has anyone seen anything like this out there or know the best way to start building one?</p>
|
<p>I'd still like to see a popular editor or IDE implement <a href="http://nickgravgaard.com/elastictabstops/" rel="noreferrer">elastic tabstops</a>.</p>
|
<p>The major problem with proportional fonts is they destroy the vertical alignment of the code and this is a fairly major loss when it comes to writing code.</p>
<p>The vertical alignment makes it possible to manipulate rectangular blocks of code that span multiple lines by allowing block operations like cut, copy, paste, delete and indent, unindent etc to be easily performed.</p>
<p>As an example consider this snippet of code:</p>
<pre><code>a1 = a111;
B2 = aaaa;
c3 = AAAA;
w4 = wwWW;
W4 = WWWW;
</code></pre>
<p>In a mono-spaced font the <strong><em>=</em></strong> and the <strong><em>;</em></strong> all line up.</p>
<p>Now if this text is loded into <strong>Word</strong> and display using a <strong>proportional font</strong> the text effectively turns into this:</p>
<p><strong>NOTE:</strong> Extra white space added to show how the <strong><em>=</em></strong> and <strong><em>;</em></strong> no longer line up:</p>
<pre><code>a1 = a1 1 1;
B2 = aaaa;
c3 = A A A A;
w4 = w w W W;
W4 = W W W W;
</code></pre>
<p>With the vertical alignment gone those nice blocks of code effectively disappear.</p>
<p>Also because the cursor is no longer guaranteed to move vertically (i.e. the column number is not always constant from one line to the next) it makes it more difficult to write throw away macro scripts designed to manipulated similar looking lines.</p>
| 3,532
|
<p><strong>[SOLVED]</strong> on [EDIT 3]</p>
<p>I just finished changing my i3 Mega's PTFE tube and brass nozzle, reassembled it, always taking care not to damage the heating element and thermistor wires.
Then I check the temperature and it was cooling down, despite the set temperature being higher (210 ºC). I turned it off, let it cool down and turned it back on. I set it again to 210 ºC and it only reaches about 135 ºC-140 ºC, not going over it.
So I change the heating element and thermistor for fresh new ones (original ones, that came with the printer) and the same behavior takes place: not heating up beyond 140 ºC.</p>
<p>Any ideas on why this is happening or how to fix it? I checked the connectors and they all seem to be fine. Cooling fans run normally as well.</p>
<p>Printer: Anycubic i3 MEGA. All stock parts, except the new nozzle (standard brass nozzle) and the PTFE tube (a blue one with 1.9 mm internal diameter). I'm setting the temperatures through the printer's interface, as I have always done.</p>
<p><strong>[EDIT]</strong></p>
<p>I did check some stuff with the multimeter and what I got is that:</p>
<ul>
<li>The cables leading to the print head are fine;</li>
<li>The heating element's voltage is correct and the MOSFET seems to be
working fine both by checking the voltage and from the LED that
lights up when it is sending current to the HE;</li>
<li>The resistance of the HE is correct as well;</li>
</ul>
<p>Form that, I am guessing the problem is the current fed to the HE. Later today I will try to heat both the nozzle and the bed to the (safe) max temperatures and see if the bed heating is problematic too. If so, the problem should be related to current.</p>
<p>If anyone has any other ideas, they are appreciated! :)</p>
<p><strong>[EDIT2]</strong></p>
<p>Heating up the print bed and the hotend at the same time didn't affect the bed at all. It heated up at the same pace as usual. Since the cables are fine, it shouldn't be a problem related to the power supply.</p>
<p>So I'm gessing the problem is the motherboard (Trigorilla 1.1). It didn't seem to have any burned components at a glance but I'm gonna check with a multimeter.</p>
<p><strong>[EDIT3]</strong></p>
<p>Turns out I messed up the heatbreaker, so the heatsink was cooling the hotend way too much... This is one way of learning I need to be careful with the heatbreaker, I guess. I'll leave a solution here for the newbies like me that end up in a similar situation.</p>
|
<p>I recently had similar problem with my Prusa i3 MK2.5. It was not able to maintain the set tempereature. I measured the heater catridge (which was new) and its resistance was correct (about 4 ohms). So I changed the hotend MOSFET on the stock board with no result. So I changed the heater catridge for the older one and the issue was gone.</p>
<p>Since you have changed the heater, it is unlikely that you have multiple bad ones. Thus the only thing that remains is the MOSFET and the power supply. Make sure your power supply is stable under load and can deliver enough current.</p>
<p>More likely it is the MOSFET. It behaves like a resistor in the path for the current. If it is swithced off, it is like a large resistor (units or tens of megaohms) in series therefore no or very little current can flow. If it is switched on (units or tens of milliohms) the resistance is very small allowing the current to flow through the heater. If a MOSFET is bad, when it is switched on it can have higher resistance (units of ohms) and thus limiting the current and creating a voltage divider. Which you can measure.</p>
<p>You have to get to the bare wires that lead to the heater. Turn on the heater. Place your voltmeter lead on one wire and the other lead on the otehr wire. The voltemeter should show voltage close to your power supply voltage. If it is showing less, the MOSFET is bad and needs replacing.</p>
<p>For that you will need soldering tools and skills. You probably have an SMD MOSFET soldered directly to the board. I suggest removing it and replacing it with a THT MOSFET that you would place separately from the board with its own heatsink. When on the board, the board acts as a heatsink.</p>
<p>If you cannot do that yourself, ask someone to do it for you.</p>
<p>Before replacing the MOSFET, find whether it is a n-channel or p-channel MOSFET. It will most likely be an n-channel MOSFET but make sure it is.</p>
<p>If you replace it with THT MOSFET I would suggest these two: IRFZ44N (n-channel) or IRF4905 (p-channel). They are general purpose MOSFETs and should work well enough for drop-in replacement.</p>
<p>If it is not the MOSFET, power supply or the heater, then I have no idea.</p>
<p>You should be able to trace one of these loops:
power supply -> (fuse ->) heater -> n-channel MOSFET -> power supply
power supply -> (fuse ->) p-channel MOSFET -> heater -> power supply</p>
<p>Most likely will be the first loop.</p>
<p>NOTE: Checking the heater resistance might help but does not have to. At room temperature the resistance might be within limits (as with mine example) and when heated up the resistance increases with temperature and thus limiting the current. You would have to measure the resistance when heated up and disconnected from all circuits. (Heat up -> disconnect heater -> measure -> cooldown).</p>
<p>Hope that helps and good luck.</p>
|
<p>I recently had similar problem with my Prusa i3 MK2.5. It was not able to maintain the set tempereature. I measured the heater catridge (which was new) and its resistance was correct (about 4 ohms). So I changed the hotend MOSFET on the stock board with no result. So I changed the heater catridge for the older one and the issue was gone.</p>
<p>Since you have changed the heater, it is unlikely that you have multiple bad ones. Thus the only thing that remains is the MOSFET and the power supply. Make sure your power supply is stable under load and can deliver enough current.</p>
<p>More likely it is the MOSFET. It behaves like a resistor in the path for the current. If it is swithced off, it is like a large resistor (units or tens of megaohms) in series therefore no or very little current can flow. If it is switched on (units or tens of milliohms) the resistance is very small allowing the current to flow through the heater. If a MOSFET is bad, when it is switched on it can have higher resistance (units of ohms) and thus limiting the current and creating a voltage divider. Which you can measure.</p>
<p>You have to get to the bare wires that lead to the heater. Turn on the heater. Place your voltmeter lead on one wire and the other lead on the otehr wire. The voltemeter should show voltage close to your power supply voltage. If it is showing less, the MOSFET is bad and needs replacing.</p>
<p>For that you will need soldering tools and skills. You probably have an SMD MOSFET soldered directly to the board. I suggest removing it and replacing it with a THT MOSFET that you would place separately from the board with its own heatsink. When on the board, the board acts as a heatsink.</p>
<p>If you cannot do that yourself, ask someone to do it for you.</p>
<p>Before replacing the MOSFET, find whether it is a n-channel or p-channel MOSFET. It will most likely be an n-channel MOSFET but make sure it is.</p>
<p>If you replace it with THT MOSFET I would suggest these two: IRFZ44N (n-channel) or IRF4905 (p-channel). They are general purpose MOSFETs and should work well enough for drop-in replacement.</p>
<p>If it is not the MOSFET, power supply or the heater, then I have no idea.</p>
<p>You should be able to trace one of these loops:
power supply -> (fuse ->) heater -> n-channel MOSFET -> power supply
power supply -> (fuse ->) p-channel MOSFET -> heater -> power supply</p>
<p>Most likely will be the first loop.</p>
<p>NOTE: Checking the heater resistance might help but does not have to. At room temperature the resistance might be within limits (as with mine example) and when heated up the resistance increases with temperature and thus limiting the current. You would have to measure the resistance when heated up and disconnected from all circuits. (Heat up -> disconnect heater -> measure -> cooldown).</p>
<p>Hope that helps and good luck.</p>
| 1,761
|
<p>When I run a particular SQL script in Unix environments, I see a '^M' character at the end of each line of the SQL script as it is echoed to the command line.<br />
I don't know on which OS the SQL script was initially created.</p>
<p>What is causing this and how do I fix it?</p>
|
<p>It's caused by the DOS/Windows line-ending characters. Like Andy Whitfield said, the Unix command dos2unix will help fix the problem. If you want more information, you can read the man pages for that command.</p>
|
<p>Another vi command that'll do: <code>:%s/.$//</code> This removes the last character of each line in the file. The drawback to this search and replace command is that it doesn't care what the last character is, so be careful not to call it twice.</p>
| 9,033
|
<p>I just got my first 3D printer today, QIDI X-ONE[2], and so far so good with the setup and getting my 1<sup>st</sup> print. I wanted to power off the printer, but I don't see any instructions on how to properly power off the machine.</p>
<p>Does anyone know how long I should wait, or what the minimum temperature would be safe to power down the machine? </p>
|
<p>Kinda, sort of, but not really. I'll look at the A4988 (<a href="https://www.pololu.com/file/0J450/a4988_DMOS_microstepping_driver_with_translator.pdf" rel="nofollow noreferrer">datasheet</a>).</p>
<p>The motor pins are connected by diodes to ground and Vbb (the motor suppply voltage). Essentially, they act as a bridge rectifier making any back EMF or inductive spikes appear (rectified) on Vbb. If you were to suddenly power down the driver this could cause a rather large spike on Vbb.</p>
<p>According to the datasheet, there is a 40 V Zener on Vbb which will clamp the voltage to that level. (Another popular stepper driver, the DRV8825, does not appear to have this Zener - always check your datasheet!)</p>
<p>So, yes, there is inductive kickback protection. However, it only clamps the voltage to 40 V. Depending on the rest of your circuit, this could be quite damaging.</p>
<p>The datasheet recommends that a 100 μF capacitor be placed on Vbb. If you are driving a typical stepper motor with 2 A and 4 mH coil inductance, the energy stored in the coil is 8 mJ. This energy is only enough to take the capacitor up from 12 V to ~17.5 V, so if you have a large enough capacitor on your stepper driver (as you should!) then you're protected against inductive kickback.</p>
<p>Note that if you move the motors by hand then you can still build up a higher voltage on Vbb. I've heard anecdotes of people who damaged their printers like that.</p>
|
<p>"Inductive kickback" from motor coils is caused by the inductance of the coils and the wiring. It is not some strange effect. Inductance is charged with current, just as capacitance is changed with voltage. Most bipolar motor drivers use an H-bridge on the output. By driving the H-bridge correctly, the driver can continue to provide a path for the motor current when it is no longer applying voltage, such as by connecting both wires of a motor to ground.</p>
<p>Although some may find it counter-intuitive, connecting the Vmot side of the motor to Gmot, while the other side remains at Gmot, keeps current flowing in the coil more smoothly and with lower losses. The voltage across the motor coil is near zero, so there is little voltage trying to change the motor current. If the coil is undriven and subject to the clamping diodes, the voltage across the motor will me much higher, and the current will stop faster. </p>
<p>The higher ripple current in the motor increases the coil heating, may increase audible noise, and decreases the efficiency of the drive.</p>
| 830
|
<p>I just requested a hotfix from support.microsoft.com and put in my email address, but I haven't received the email yet. The splash page I got after I requested the hotfix said:</p>
<blockquote>
<p><strong>Hotfix Confirmation</strong></p>
<p>We will send these hotfixes to the following e-mail address:</p>
<pre><code> (my correct email address)
</code></pre>
<p>Usually, our hotfix e-mail is delivered to you within five minutes. However, sometimes unforeseen issues in e-mail delivery systems may cause delays.</p>
<p>We will send the e-mail from the “hotfix@microsoft.com” e-mail account. If you use an e-mail filter or a SPAM blocker, we recommend that you add “hotfix@microsoft.com” or the “microsoft.com” domain to your safe senders list. (The safe senders list is also known as a whitelist or an approved senders list.) This will help prevent our e-mail from going into your junk e-mail folder or being automatically deleted.</p>
</blockquote>
<p>I'm sure that the email is not getting caught in a spam catcher.</p>
<p>How long does it normally take to get one of these hotfixes? Am I waiting for some human to approve it, or something? Should I just give up and try to get the file I need some other way?</p>
<p>(<em>Update</em>: Replaced "me@mycompany.com" with "(my correct email address)" to resolve <a href="https://stackoverflow.com/questions/30297/ms-hotfix-delayed-delivery#30356">Martín Marconcini's</a> ambiguity.)</p>
|
<p>Divide your services by resource requirements at the very least. For example, if you are running a photo album site, separate your image download server from your image upload server. The download server will have many more requests, and because most people have a lower upload speed the upload server will have longer lasting connections. Similarly, and image manipulation server would probably have few connections, but it should fork off threads to perform the CPU intensive image manipulation tasks asynchronously from the web user interface.</p>
<p>If you have the hardware to do it, it's a lot easier to manage many separate tomcat instances with one application each than a few instances with many applications.</p>
|
<p>Divide your services by resource requirements at the very least. For example, if you are running a photo album site, separate your image download server from your image upload server. The download server will have many more requests, and because most people have a lower upload speed the upload server will have longer lasting connections. Similarly, and image manipulation server would probably have few connections, but it should fork off threads to perform the CPU intensive image manipulation tasks asynchronously from the web user interface.</p>
<p>If you have the hardware to do it, it's a lot easier to manage many separate tomcat instances with one application each than a few instances with many applications.</p>
| 5,018
|
<p>What is a magic number?</p>
<p>Why should it be avoided?</p>
<p>Are there cases where it's appropriate?</p>
|
<p>A magic number is a direct usage of a number in the code.</p>
<p>For example, if you have (in Java):</p>
<pre class="lang-java prettyprint-override"><code>public class Foo {
public void setPassword(String password) {
// don't do this
if (password.length() > 7) {
throw new InvalidArgumentException("password");
}
}
}
</code></pre>
<p>This should be refactored to:</p>
<pre class="lang-java prettyprint-override"><code>public class Foo {
public static final int MAX_PASSWORD_SIZE = 7;
public void setPassword(String password) {
if (password.length() > MAX_PASSWORD_SIZE) {
throw new InvalidArgumentException("password");
}
}
}
</code></pre>
<p>It improves readability of the code and it's easier to maintain. Imagine the case where I set the size of the password field in the GUI. If I use a magic number, whenever the max size changes, I have to change in two code locations. If I forget one, this will lead to inconsistencies.</p>
<p>The JDK is full of examples like in <code>Integer</code>, <code>Character</code> and <code>Math</code> classes.</p>
<p>PS: Static analysis tools like FindBugs and PMD detects the use of magic numbers in your code and suggests the refactoring.</p>
|
<p>What about return variables?</p>
<p>I specially find it challenging when implementing <strong>stored procedures</strong>.</p>
<p>Imagine the next stored procedure (wrong syntax, I know, just to show an example):</p>
<pre><code>int procGetIdCompanyByName(string companyName);
</code></pre>
<p>It return the Id of the company if it exists in a particular table. Otherwise, it returns -1.
Somehow it's a magic number. Some of the recommendations I've read so far says that I'll really have to do design somthing like that:</p>
<pre><code>int procGetIdCompanyByName(string companyName, bool existsCompany);
</code></pre>
<p>By the way, what should it return if the company does not exists? Ok: it will set <em>existesCompany</em> as <strong>false</strong>, but also will return -1.</p>
<p>Antoher option is to make two separate functions:</p>
<pre><code>bool procCompanyExists(string companyName);
int procGetIdCompanyByName(string companyName);
</code></pre>
<p>So a pre-condition for the second stored procedure is that company exists.</p>
<p>But i'm afraid of concurrency, because in this system, a company can be created by another user.</p>
<p>The bottom line by the way is: what do you think about using that kind of "magic numbers" that are relatively known and safe to tell that something is unsuccessful or that something does not exists?</p>
| 7,019
|
<p>We're running a custom application on our intranet and we have found a problem after upgrading it recently where IIS hangs with 100% CPU usage, requiring a reset.</p>
<p>Rather than subject users to the hangs, we've rolled back to the previous release while we determine a solution. The first step is to reproduce the problem -- but we can't. </p>
<p>Here's some background:</p>
<p>Prod has a single virtualized (vmware) web server with two CPUs and 2 GB of RAM. The database server has 4GB, and 2 CPUs as well. It's also on VMWare, but separate physical hardware.</p>
<p>During normal usage the application runs fine. The w3wp.exe process normally uses betwen 5-20% CPU and around 200MB of RAM. CPU and RAM fluctuate slightly under normal use, but nothing unusual.</p>
<p>However, when we start running into problems, the RAM climbs dramatically and the CPU pegs at 98% (or as much as it can get). The site becomes unresponsive, necessitating a IIS restart. Resetting the app pool does nothing in this situation, a full IIS restart is required.</p>
<p>It does not happen during the night (no usage). It happens more when the site is under load, but it has also happened under non-peak periods.</p>
<p>First step to solving this problem is reproducing it. To simulate the load, we starting using JMeter to simulate usage. Our load script is based on actual usage around the time of the crash. Using JMeter, we can ramp the usage up quite high (2-3 times the load during the crash) but the site behaves fine. CPU is up high, and the site does become sluggish, but memory usage is reasonable and nothing is hanging.</p>
<p>Does anyone have any tips on how to reproduce a problem like this in a non-production environment? We'd really like to reproduce the error, determine a solution, then test again to make sure we've resolved it. During the process we've found a number of small things that we've improved that might solve the problem, but I'd really feel a lot more confident if we could reproduce the problem and test the improved version.</p>
<p>Any tools, techniques or theories much appreciated!</p>
|
<p>You can find some information about troubleshooting this kind of problem at <a href="http://blogs.msdn.com/tess/archive/2008/05/21/debugdiag-1-1-or-windbg-which-one-should-i-use-and-how-do-i-gather-memory-dumps.aspx" rel="nofollow noreferrer">this blog entry</a>. Her blog is generally a good debugging resource.</p>
|
<p>Is your test env the same really as live?
i.e
2 separate vm instances on 2 physical servers - with the network connection and account types?</p>
<p>Is there any other instances on the Database?</p>
<p>Is there any other web applications in IIS?</p>
<p>Is the .Net Config right?</p>
<p>Is the App Pool Config right for service accounts ?
<a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/93275ef2-2f85-4eb1-8b92-a67545be11b4.mspx?mfr=true" rel="nofollow noreferrer">Try look at this - MS Article on II6 Optmising for Performance</a></p>
<p>Lots of tricks.</p>
| 3,091
|
<p>I configured Marlin 1.1.3 for auto-leveling with a fix mounted sensor connected to the Z end-stop pin.</p>
<p>I have the following settings in my config:</p>
<pre><code>#define X_PROBE_OFFSET_FROM_EXTRUDER 25
#define Y_PROBE_OFFSET_FROM_EXTRUDER 20
#define Z_PROBE_OFFSET_FROM_EXTRUDER 0 // Z offset: -below +above [the nozzle]
#define Z_CLEARANCE_DEPLOY_PROBE 10 // Z Clearance for Deploy/Stow
#define Z_CLEARANCE_BETWEEN_PROBES 5 // Z Clearance between probe points
#define AUTO_BED_LEVELING_BILINEAR
#define GRID_MAX_POINTS_X 7
#define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X
// The Z probe minimum outer margin (to validate G29 parameters).
#define MIN_PROBE_EDGE 10
// Set the boundaries for probing (where the probe can reach).
#define LEFT_PROBE_BED_POSITION 25
#define RIGHT_PROBE_BED_POSITION 150
#define FRONT_PROBE_BED_POSITION 30
#define BACK_PROBE_BED_POSITION 180
</code></pre>
<p>I enter <code>M111 S38</code> to enable LEVELING+INFO+ERROR debugging.
Then I enter <code>G28</code> to home all axes and then enter <code>G29</code> to start auto-leveling.</p>
<p>The auto-leveling starts successfully and after finishing I see the scan grid in console:</p>
<pre><code>12:41:35.983 : Bilinear Leveling Grid:
12:41:35.983 : 0 1 2 3 4 5 6
12:41:35.983 : 0 -3.127 -3.405 -3.405 -3.292 -3.595 -3.487 -3.537
12:41:35.983 : 1 -3.110 -3.367 -3.337 -3.220 -3.470 -3.350 -3.365
12:41:35.983 : 2 -3.138 -3.367 -3.330 -3.215 -3.442 -3.345 -3.385
12:41:35.984 : 3 -3.013 -3.225 -3.182 -3.047 -3.225 -3.132 -3.150
12:41:35.984 : 4 -2.970 -3.165 -3.097 -2.972 -3.160 -3.045 -3.065
12:41:35.984 : 5 -2.875 -3.075 -3.005 -2.847 -2.990 -2.872 -2.875
12:41:35.984 : 6 -2.680 -2.845 -2.755 -2.615 -2.753 -2.617 -2.622
12:41:35.985 : G29 uncorrected Z:10.00
12:41:35.985 : corrected Z:12.85
12:41:35.985 : <<< gcode_G29
12:41:35.985 : X:120.00 Y:160.00 Z:12.85 E:0.00 Count X:9600 Y:12800 Z:4000
12:41:35.985 : current_position=(120.00, 160.00, 12.85) : sync_plan_position
</code></pre>
<p>So the auto-leveling scanning seems to be successful.</p>
<p>Here is a visual of the leveling grid (but upside down to make it easier to view):</p>
<p><a href="https://i.stack.imgur.com/TOas7.jpg" rel="nofollow noreferrer" title="Inverted visual of the leveling grid"><img src="https://i.stack.imgur.com/TOas7.jpg" alt="Inverted visual of the leveling grid" title="Inverted visual of the leveling grid"></a></p>
<p>Naturally I <strong>DO NOT</strong> enter <code>G28</code> after the scanning. </p>
<p>I enter <code>G0 Z1</code> to down nozzle almost to table. But when I enter for example <code>G0 X25 Y30</code> and look at level and then I enter <code>G0 X150 Y150</code> I see the big difference between nozzle levels relatively to table. So it seems that height compensation does not work. I expect that Z axis would lift up or down depending on auto-leveling results but Z motor do not work when I move X/Y. </p>
<p>By the way I tried 3 point autoleveling. It was pretty rough but Z axis corrected it's level when I moved axes using <code>G0</code> commands.
And to avoid questions "why my table is inclined so much?" I deliberately inclined the table to be sure that auto leveling works. By the way, I tried different <code>Z_PROBE_OFFSET_FROM_EXTRUDER</code> so the current 0 setting is not actual but situation is the same with any value of this option.</p>
<p>What I am doing wrong?</p>
|
<p>Yes, with the proper equipment.</p>
<p>Printing wax filament (at 51 seconds): <a href="https://youtu.be/tibkVZB_n9c?t=51s" rel="noreferrer">https://youtu.be/tibkVZB_n9c?t=51s</a></p>
<p>There are also options for melting wax, filling a heated reservoir head, and printing with that. I recommend doing this with a cold ambient temperature, so that the wax solidifies quickly. There's no point in just printing a puddle. :)</p>
|
<p>Just make a silicone mold of any of your prints and pour you wax in the silicone,you silicone putty is pretty cheap so is wax ,no need to break the bank as printers have become less expensive and can do a pretty good job </p>
| 630
|
<p>I'm guessing it needs to be something like:</p>
<pre><code>CONVERT(CHAR(24), lastModified, 101)
</code></pre>
<p>However I'm not sure of the right value for the third parameter.</p>
<p>Thanks!</p>
<hr>
<p>Well I'm trying to write a script to copy my sql server db to a sqlite file, which gets downloaded to an air app, which then syncs the data to another sqlite file. I'm having a ton of trouble with dates. If I select a date in air and try to insert it, it fails because it's not in the right format... even if it was a valid date to begin with. I figured I'd try to experiment with the unix time since that's the only thing thats worked so far. I am considering just leaving them as varchar because I don't sort by them anyway.</p>
|
<p>Last epoch is when 1970 GMT?</p>
<pre><code>SELECT DATEDIFF(s,'19700101 05:00:00:000',lastModified)
</code></pre>
<p>See also <a href="http://wiki.lessthandot.com/index.php/Epoch_Date" rel="nofollow noreferrer">Epoch Date</a></p>
|
<p>Define "last epoch". Does this come close?</p>
<p>Select Cast(lastModified As Integer)</p>
| 3,237
|
<p>When printing several objects, I recently encountered a problem that arises when the structure in itself is relatively thin or the support towers have a small surface: the printhead would in motion tend to knock one or more over as it traveled or catch at them and create layer shift.</p>
<p>How can I avoid collisions with the already printed parts of a layer?</p>
|
<p>The problem was twofold:</p>
<ol>
<li>Lack of bed adhesion due to the small contact surface</li>
<li>motion into the already printed objects.</li>
</ol>
<p>The <em>quick and dirty</em> way was to change two settings:</p>
<ul>
<li>Print with a small (3 mm) brim to stick the supports to the print and provide more surface. Other materials than PLA may need considerably more brim!</li>
<li>Activate Z-Hop to force the nozzle to lift over the print when traveling</li>
</ul>
<p>These tricks don't solve issues with very thin structures or in all cases. In those cases, it can be mandatory to increase the structure's (support) thickness or change the alignment.</p>
|
<p>For the Creality Ender 3, I had the same collision problem and after a while I found it was because of the X-axis not being level.</p>
<p>I found right hand side was more than 3-4 mm below the left side when the Z-axis height exceeds around 8-10 cm. Below that, the two sides were even. I made some calibration by turning the eccentric nuts of the wheels and tighten them.</p>
<p>If you use Creality Ender 3, that might be the problem. Take a ruler and check between base extrusions and X-axis left/right hand sides at different Z heights.</p>
| 1,053
|
<p>I want to find any text in a file that matches a regexp of the form <em>t</em><code>[A-Z]</code><em>u</em> (i.e., a match <em>t</em> followed by a capital letter and another match <em>u</em>, and transform the matched text so that the capital letter is lowercase. For example, for the regexp <code>x[A-Z]y</code></p>
<pre><code>xAy
</code></pre>
<p>becomes</p>
<pre><code>xay
</code></pre>
<p>and</p>
<pre><code>xZy
</code></pre>
<p>becomes</p>
<pre><code>xzy
</code></pre>
<p>Emacs' <code>query-replace</code> function allows back-references, but AFAIK not the transformation of the matched text. Is there a built-in function that does this? Does anybody have a short Elisp function I could use?</p>
<p><strong>UPDATE</strong></p>
<p>@Marcel Levy has it: <code>\,</code> in a replacement expression introduces an (arbitrary?) Elisp expression. E.g., the solution to the above is</p>
<pre><code>M-x replace-regexp <RET> x\([A-Z]\)z <RET> x\,(downcase \1)z
</code></pre>
|
<p>It looks like <a href="http://steve-yegge.blogspot.com/" rel="noreferrer">Steve Yegge</a> actually already posted the answer to this a few years back: <a href="http://steve-yegge.blogspot.com/2006/06/shiny-and-new-emacs-22.html" rel="noreferrer">"Shiny and New: Emacs 22."</a> Scroll down to "Changing Case in Replacement Strings" and you'll see his example code using the <code>replace-regexp</code> function.</p>
<p>The general answer is that you use "\," to call any lisp expression as part of the replacement string, as in <code>\,(capitalize \1)</code>. Reading the help text, it looks like it's only in interactive mode, but that seems like the one place where this would be most necessary.</p>
|
<p>I'd do this with a macro as well, but only because executing code from within a replacement string for a regular expression is very unintuitive to me. If you're writing a batch script or something that needs to go very fast, \, is certainly the way to go.</p>
| 8,213
|
<p>I'm going to try something with the format of this question and I'm very open to suggestions about a better way to handle it.</p>
<p>I didn't want to just dump a bunch of code in the question so I've posted the code for the class on <code>refactormycode</code>.</p>
<p><strong><a href="http://www.refactormycode.com/codes/461-base-class-for-easy-class-property-handling" rel="nofollow noreferrer">base class for easy class property handling</a></strong></p>
<p>My thought was that people can either post code snippets here or make changes on <code>refactormycode</code> and post links back to their refactorings. I'll make upvotes and accept an answer (assuming there's a clear "winner") based on that.</p>
<p>At any rate, on to the class itself:</p>
<p>I see a lot of debate about getter/setter class methods and is it better to just access simple property variables directly or should every class have explicit get/set methods defined, blah blah blah. I like the idea of having explicit methods in case you have to add more logic later. Then you don't have to modify any code that uses the class. However I hate having a million functions that look like this:</p>
<pre><code>public function getFirstName()
{
return $this->firstName;
}
public function setFirstName($firstName)
{
return $this->firstName;
}
</code></pre>
<p>Now I'm sure I'm not the first person to do this (I'm hoping that there's a better way of doing it that someone can suggest to me).</p>
<p>Basically, the PropertyHandler class has a __call magic method. Any methods that come through __call that start with "get" or "set" are then routed to functions that set or retrieve values into an associative array. The key into the array is the name of the calling method after getting or setting. So, if the method coming into __call is "getFirstName", the array key is "FirstName".</p>
<p>I liked using __call because it will automatically take care of the case where the subclass already has a "getFirstName" method defined. My impression (and I may be wrong) is that the __get & __set magic methods don't do that.</p>
<p>So here's an example of how it would work:</p>
<pre><code>class PropTest extends PropertyHandler
{
public function __construct()
{
parent::__construct();
}
}
$props = new PropTest();
$props->setFirstName("Mark");
echo $props->getFirstName();
</code></pre>
<p>Notice that PropTest doesn't actually have "setFirstName" or "getFirstName" methods and neither does PropertyHandler. All that's doing is manipulating array values.</p>
<p>The other case would be where your subclass is already extending something else. Since you can't have true multiple inheritances in PHP, you can make your subclass have a PropertyHandler instance as a private variable. You have to add one more function but then things behave in exactly the same way.</p>
<pre><code>class PropTest2
{
private $props;
public function __construct()
{
$this->props = new PropertyHandler();
}
public function __call($method, $arguments)
{
return $this->props->__call($method, $arguments);
}
}
$props2 = new PropTest2();
$props2->setFirstName('Mark');
echo $props2->getFirstName();
</code></pre>
<p>Notice how the subclass has a __call method that just passes everything along to the PropertyHandler __call method.</p>
<hr>
<p>Another good argument against handling getters and setters this way is that it makes it really hard to document.</p>
<p>In fact, it's basically impossible to use any sort of document generation tool since the explicit methods to be don't documented don't exist.</p>
<p>I've pretty much abandoned this approach for now. It was an interesting learning exercise but I think it sacrifices too much clarity.</p>
|
<p>The way I do it is the following:</p>
<pre><code>class test {
protected $x='';
protected $y='';
function set_y ($y) {
print "specific function set_y\n";
$this->y = $y;
}
function __call($function , $args) {
print "generic function $function\n";
list ($name , $var ) = split ('_' , $function );
if ($name == 'get' && isset($this->$var)) {
return $this->$var;
}
if ($name == 'set' && isset($this->$var)) {
$this->$var= $args[0];
return;
}
trigger_error ("Fatal error: Call to undefined method test::$function()");
}
}
$p = new test();
$p->set_x(20);
$p->set_y(30);
print $p->get_x();
print $p->get_y();
$p->set_z(40);
</code></pre>
<p>Which will output (line breaks added for clarity)</p>
<pre><code>generic function set_x
specific function set_y
generic function get_x
20
generic function get_y
30
generic function set_z
Notice: Fatal error: Call to undefined method set_z() in [...] on line 16
</code></pre>
|
<p>I've always handled this issue in a similar with a __call which ends up pretty much as boiler plate code in many of my classes. However, it's compact, and uses the reflection classes to only add getters / setters for properties you have already set (won't add new ones). Simply adding the getter / setter explicitly will add more complex functionality. It expects to be </p>
<p>Code looks like this:</p>
<pre><code>/**
* Handles default set and get calls
*/
public function __call($method, $params) {
//did you call get or set
if ( preg_match( "|^[gs]et([A-Z][\w]+)|", $method, $matches ) ) {
//which var?
$var = strtolower($matches[1]);
$r = new ReflectionClass($this);
$properties = $r->getdefaultProperties();
//if it exists
if ( array_key_exists($var,$properties) ) {
//set
if ( 's' == $method[0] ) {
$this->$var = $params[0];
}
//get
elseif ( 'g' == $method[0] ) {
return $this->$var;
}
}
}
}
</code></pre>
<p>Adding this to a class where you have declared default properties like: </p>
<pre><code>class MyClass {
public $myvar = null;
}
$test = new MyClass;
$test->setMyvar = "arapaho";
echo $test->getMyvar; //echos arapaho
</code></pre>
<p>The reflection class may add something of use to what you were proposing. Neat solution @Mark.</p>
| 5,207
|
<p>I replaced the controller board in my Monoprice Select Mini with an Arduino/Ramps setup and compiled an uploaded Marlin 1.1.0-RC8 to run it. I've got most everything calibrated and working with one exception.</p>
<p>I tell the printer to home for xyz and then level my bed with a piece of paper then start a print and the nozzle consistently drops too far down into the bed and nothing can extrude. If I adjust the bed and put 1-2mm gap between the nozzle and bed then it prints fine. </p>
<p>I can't find anything in Marlin to adjust for this and I'm kind of stumped. I'm printing the original cat gcode that came with the printer that should just work fine as it always has and shouldn't have anything that a slicer would put in there to screw things up. </p>
<p>Can anyone point me in the right direction?</p>
<p>This is the output of M503</p>
<pre><code>Send: M503
Recv: echo:Steps per unit:
Recv: echo: M92 X93.00 Y93.00 Z1097.50 E99.00
Recv: echo:Maximum feedrates (mm/s):
Recv: echo: M203 X300.00 Y300.00 Z5.00 E25.00
Recv: echo:Maximum Acceleration (mm/s2):
Recv: echo: M201 X3000 Y3000 Z100 E10000
Recv: echo:Accelerations: P=printing, R=retract and T=travel
Recv: echo: M204 P3000.00 R3000.00 T3000.00
Recv: echo:Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)
Recv: echo: M205 S0.00 T0.00 B20000 X20.00 Y20.00 Z0.40 E5.00
Recv: echo:Home offset (mm)
Recv: echo: M206 X0.00 Y0.00 Z0.00
Recv: echo:Material heatup parameters:
Recv: echo: M145 S0 H180 B70 F255
Recv: M145 S1 H240 B110 F0
Recv: echo:PID settings:
Recv: echo: M301 P26.15 I2.74 D62.35
Recv: echo: M304 P231.09 I45.21 D295.34
Recv: echo:Filament settings: Disabled
Recv: echo: M200 D3.00
Recv: echo: M200 D0
Recv: ok
</code></pre>
<p>I also wanted to test whether the nozzle is actually moving closer. I did a G28 and manually put a piece of paper's width gap between the nozzle and the bed at all points. Then I started a print with no filament but with the sheet between the nozzle and bed. When it got to temp it homed all the axis and moved the nozzle to the first position. I would expect the paper to maintain the same gap but it tightly presses into the paper. The first gcode move that includes the Z before extruding is :</p>
<pre><code>G0 F3600 X42.228 Y46.985 Z0.3
</code></pre>
<p>Which you would expect would put even more space between the nozzle and bed for the first .3 layer of filament but it isn't.</p>
<p>I printed directly from the SD Card to hopefully rule out Octoprint running gcode before the print so I really think the culprit is Marlin at this point.</p>
|
<p>I found the issue. When the hotend and bed are at temps for PLA everything works fine but at temps for ABS the Z offset would get all messed up. After a bunch of testing I was able to track it down to a single gcode statment <code>G1 Z15.0 F6000</code>
At the higher temps my Z stepper skips steps at that feed rate. </p>
<p>The "Custom FDM printer" machine settings I used for my printer in Cura had that statement in it and so did the cat gcode that was on the card from the factory. I changed the feed rate to 200 and was able to print in ABS.</p>
<p>I was surprised Marlin didn't have a 'limit the feedrate for Z to this number' setting.</p>
|
<p>If nozzle sets lower than it should, after heating up, then you may need to calibrate with heater turned on.</p>
<p>Another (although less likely) reason can be an incorrect Z steps number. However, if the print, after adjusting the first line height, does well, this should not be the case.</p>
<p>Fast track solution is to use <code>M206</code> (something like <code>M206 Z0.3</code>) command to adjust nozzle offset, in your case Z position. This does not fix the root cause but should allow you to mitigate the problem.</p>
| 557
|
<p>I have a report with many fields that I'm trying to get down to 1 page horizontally (I don't care whether it's 2 or 200 pages vertically... just don't want to have to deal with 2 pages wide by x pages long train-wreck). That said, it deals with contact information.</p>
<p>My idea was to do:</p>
<pre><code>Name: Address: City: State: ...
Jon Doe Addr1 ThisTown XX ...
Addr2
Addr3
-----------------------------------------------
Jane Doe Addr1 ThisTown XX ...
Addr2
Addr3
-----------------------------------------------
</code></pre>
<p>Is there some way to set a <code>textbox</code> to be multi-line (or the SQL result)? Have I missed something bloody obvious?</p>
<hr>
<p>The CanGrow Property is on by default, and I've double checked that this is true. My problem is that I don't know how to force a line-break. I get the 3 address fields that just fills a line, then wraps to another. I've tried <code>/n</code>, <code>\n</code> (since I can never remember which is the correct slash to put), <code><br></code>, <code><br /></code> (since the report will be viewed in a ReportViewer control in an ASP.NET website). I can't think of any other ways to wrap the text. </p>
<p>Is there some way to get the results from the database as 3 lines of text/characters?
</p>
|
<p>Alter the report's text box to:</p>
<pre><code>= Fields!Addr1.Value + VbCrLf +
Fields!Addr2.Value + VbCrLf +
Fields!Addr3.Value
</code></pre>
|
<p>Try this one :</p>
<pre><code>= Fields!Field1.Value + System.Environment.NewLine + Fields!Field2.Value
</code></pre>
| 4,613
|
<p>What is the best way to transcode audio and video to show on the web? </p>
<p>I need to do it programmatically. I'd like to do something like YouTube or Google Video where users can upload whatever format they want, and I encode it to flv, mp3, and/or mp4. I could do it on our server, but I would rather use an EC2 instance or even a web service. We have a Windows 2008 server.</p>
|
<p>I strongly recommend ffmpeg. On Windows, I have found <a href="https://ffmpeg.zeranoe.com/builds/" rel="nofollow noreferrer">this site</a> to host good binaries.</p>
|
<p><a href="http://www.rhozet.com/carbon_coder.html" rel="nofollow noreferrer">Rhozet Carbon Coder</a> can handle a <a href="http://www.rhozet.com/rhozet_formatGuide.pdf" rel="nofollow noreferrer">wide range of formats</a> plus you can use plugins to alter the video (eg add a watermark)</p>
| 2,862
|
<p>I have a radio button list on a page that is used to configure products. when the page loads the first time the first list of options is displayed. you select one of them then click a "Next Step" button and the page posts back and shows a new radio button list for step 2. Now if i click a "Previous Step" button i can easily get the previous list of options to display but i can not for some reason get one of the radio buttons to be selected. I can easily bring back the value i need. right after making the radio button list i have a step that just says radiobuttonlist.selected = "somevalue" depending on whatever the user chose when they completed the first step the first time.</p>
<p>when i debug i see that the value is correct and is being applied. but then when the page is displayed the radiobutton is not selected.</p>
<p>I have noticed that when i click my "Previous" button while debugging the folowing steps occur.:</p>
<p>the page.load handler runs and the code inside my if not page.ispostback block does NOT run, which is correct.
then the handles for the button i just clicked gets run.
but then after that the page.load handler runs again but this time the code in the if not page.ispostback block DOES run...</p>
<p>is that normal? for the page.onload block to run twice like that on a postback? i think it may have something to do with why my value is not being applied.</p>
|
<p>It sounds like you are causing a redirect to happen. You aren't by chance doing a Response.Redirect in order to "get back" to the original page? This would cause the functionality you describe. You would first get the Postback from the Previous button to leave the page, and then you would get a fresh Request (IsPostback = false) as the page reloads.</p>
|
<p>Try setting <code>AutoEventWireup = False</code> in the page.</p>
| 8,456
|
<p>I use RCF with boost.serialization (why use RCF's copy when we already use the original?) It works OK, but when an exception is thrown in the server, it's not passed correctly to the client. Instead, I get an RCF::SerializationException quoting an <code>archive_exception</code> saying "class name too long". When I change the protocol to BsText, the exceptions is "unregistered class". When I change the protocol to SfBinary, it works.
I've registered RemoteException on both server and client like this:</p>
<pre><code>BOOST_CLASS_VERSION(RCF::RemoteException, 0)
BOOST_CLASS_EXPORT(RCF::RemoteException)
</code></pre>
<p>I even tried serializing and deserializing a <code>boost::shared_ptr<RCF::RemoteException></code> in the same test, and it works.</p>
<p>So how can I make RCF pass exceptions correctly without resorting to SF?</p>
|
<p>Here's a patch given by Jarl at <a href="http://www.codeproject.com/KB/threads/Rcf_Ipc_For_Cpp.aspx?msg=2739150#xx2730536xx" rel="nofollow noreferrer">CodeProject</a>:</p>
<p>In RcfServer.cpp, before the line where RcfServer::handleSession() is defined (around line 792), insert the following code:</p>
<pre><code>void serialize(SerializationProtocolOut & out, const RemoteException & e)
{
serialize(out, std::auto_ptr<RemoteException>(new RemoteException(e)));
}
</code></pre>
<p>And in Marshal.cpp, around line 37, replace this line:</p>
<pre><code>ar & boost::serialization::make_nvp("Dummy", apt.get());
</code></pre>
<p>, with</p>
<pre><code>T *pt = apt.get();
ar & boost::serialization::make_nvp("Dummy", pt);
</code></pre>
|
<p>According to Jarl it works, check <a href="http://www.codeproject.com/KB/threads/Rcf_Ipc_For_Cpp.aspx?fid=248794&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=101&select=2365783" rel="nofollow noreferrer">codeproject</a> for a question and answer with sample code:</p>
| 8,830
|
<p>I have a Linux web server farm with about 5 web servers, web traffic is about 20Mbps.</p>
<p>We currently have a Barracuda 340 Load Balancer (keep away from this device - piece of crap!) that is acting as a firewall. I want to put in a dedicated firewall and I'd like to know what peoples opinions are on building versus buying a dedicated firewall. </p>
<p>Main requirements:</p>
<ul>
<li>Dynamically block rouge traffic</li>
<li>Dynamically rate limit traffic</li>
<li>Block all ports except 80, 443</li>
<li>Limit port 22 to a set of IPs</li>
<li>High availability setup</li>
</ul>
<p>Also if we go for the build route, how do we know what level traffic the system can handle.</p>
|
<p>As they say - "there are more than one way to skin a cat":</p>
<p>Build it yourself, running something like Linux or *BSD. The benefit of this, is that it makes it easy to do the dynamic part of your question, it's just a matter of a few well-placed shell/python/perl/whatever scripts. The drawback is that your ceiling traffic rate might not be what it would be on a purpose-built firewall device, although you should still be able to achieve data rates in the 300Mbit/sec range. (You start hitting PCI bus limitations at this point) This may be high enough to where it won't be a problem for you.</p>
<p>Buy a dedicated "firewall device" - Possible drawbacks of doing this, is that doing the "dynamic" part of what you're trying to accomplish is somewhat more difficult - depending on the device, this could be easy (Net::Telnet/Net::SSH come to mind), or not. If you are worried about peak traffic rates, you'll have to carefully check the manufacturer's specifications - several of these devices are prone to the same traffic limitations as "regular" PC's, in that they still run into the PCI bus bandwidth issue, etc. At that point, you might as well roll your own.</p>
<p>I guess you could read this more as a "pro's and con's" of doing either, if you want.</p>
<p>FWIW, we run dual FreeBSD firewalls at my place of employment, and regularly push 40+Mbit/sec with no noticeable load/issues.</p>
|
<p>Don't know much about this field, but maybe an <a href="http://www.astaro.com/" rel="nofollow noreferrer">Astaro security gateway</a>?</p>
| 7,095
|
<p>I've printed a 2x2x2 cm test cube with Slic3r (left) and Ultimaker Cura (right) and my Prusa i3 derivative machine with tight belts. The print settings should be quite equal (0.15 mm layer height, 40 mm/s outer wall speed, default accelerations/jerks). Though the top surface of the Ultimaker Cura-cube looks much better than the Slic3r-cube,</p>
<p><a href="https://i.stack.imgur.com/NjqvC.jpg" rel="nofollow noreferrer" title="Left: Slic3er, right: Ultimaker Cura"><img src="https://i.stack.imgur.com/NjqvC.jpg" alt="Left: Slic3er, right: Ultimaker Cura" title="Left: Slic3er, right: Ultimaker Cura"></a></p>
<p>the latter has much flatter vertical walls than the first. </p>
<p><a href="https://i.stack.imgur.com/bxs8l.jpg" rel="nofollow noreferrer" title="Left: Slic3er, right: Ultimaker Cura"><img src="https://i.stack.imgur.com/bxs8l.jpg" alt="Left: Slic3er, right: Ultimaker Cura" title="Left: Slic3er, right: Ultimaker Cura"></a>
<a href="https://i.stack.imgur.com/OUmz6.jpg" rel="nofollow noreferrer" title="Left: Slic3er, right: Ultimaker Cura"><img src="https://i.stack.imgur.com/OUmz6.jpg" alt="Left: Slic3er, right: Ultimaker Cura" title="Left: Slic3er, right: Ultimaker Cura"></a></p>
<p>The front wall of the Ultimaker Cura-cube was printed from left to right which could explain the wavy result as some kind of vibration caused by the sharp y-stop at the left front corner.</p>
<p>But what setting could have influenced this? Should I try to manual setting of lower accelerations in Ultimaker Cura?</p>
|
<p>Those wavy lines could be artefacts caused by closely-spaced infill, but they could also be resonance patterns caused by noisy stepper motors and over-tight belts. Since you have said that you have your belts nice and tight, I would suggest reducing the tension on them and see what happens. I know that some pundits say that it is not possible to have timing belts too tight, but I disagree with that. Belts should obviously be tight enough to eliminate free play in the system, and you may have a lot of latitude in the tensions that you can use, but if you make them drum-tight, they will transmit motor vibrations very effectively to the build plate (and onto your models).</p>
<p>If your stepper motors are noisy, you may want to invest in some vibration dampers. They can reduce noise and vibration significantly. Another solution would be to use more sophisticated stepper motor drivers, such as the TMC2100.</p>
<p><a href="http://reprap.org/wiki/TMC2100" rel="noreferrer">RepRapWiki: TMC2100</a></p>
|
<p>It is difficult to see with the lighting and the shiny green, but try printing a more complex object, like the usual <a href="https://www.thingiverse.com/thing:1278865" rel="nofollow noreferrer">XYZ cube</a>. Does it look like this one? which means big waves after a change of direction, but then getting smaller?</p>
<p><a href="https://i.stack.imgur.com/m8t6k.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m8t6k.jpg" alt="enter image description here" /></a></p>
<p>If so, it is "ringing" or "ghosting", which means that the acceleration you set is too high for the mechanics of your printer and the machine vibrates too much.</p>
<p>Does it look like this one? Which means, exactly aligned vertically, and everywhere, not only after changes of direction?</p>
<p><a href="https://i.stack.imgur.com/Bujra.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bujra.png" alt="enter image description here" /></a></p>
<p>Then it is NOT ringing, it is due</p>
<ul>
<li>too tight belt (almost always!)</li>
<li>poor quality belt</li>
<li>poor bearings or idlers (not common)</li>
</ul>
<p>I also had it and it was the belt, too tight. Loosen it, it can be much looser than you think before you get issues.</p>
<p>Check <a href="https://3dprinting.stackexchange.com/questions/8020/how-to-fix-evenly-spaced-vertical-print-pattern">How to fix evenly spaced vertical print pattern</a> to get more information about the second issue.</p>
<p>There is another potential cause for wavy walls, however I'm mentioning it for completeness, it is not the case of the question.</p>
<p>If the waves repeat horizontally, but are not aligned vertically, and the extruder is a direct drive, it could be caused by the issue explained in this video, which shows that the dual gear of direct drives introduce periodic changes in flow, which are visible sometimes.</p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/dL6u0UwPJOQ?start=0"></iframe>
</div></div></p>
| 704
|
<p>I didn't see the option to point the workspace (or it's VS equivalent, I'm still learning the terminology for Visual Studio, but it is called a workspace in Eclipse) to My Documents/Programming instead of -- well -- wherever it is now.</p>
|
<p>What Craig said, plus if you do want to change the default it's in Tools -> Options -> Projects And Solutions.</p>
<p>I've never changed the default and never created a solution/project in the default location, which might tell you something about how relevant it is...</p>
|
<p>When you create the project you can specify whatever directory you want, you are not limited to the default.</p>
| 5,592
|
<p>What is the difference between old style and new style classes in Python? When should I use one or the other?</p>
|
<p>From <em><a href="http://docs.python.org/2/reference/datamodel.html#new-style-and-classic-classes" rel="noreferrer">New-style and classic classes</a></em>:</p>
<blockquote>
<p><strong>Up to Python 2.1, old-style classes were the only flavour available to the user.</strong></p>
<p>The concept of (old-style) class is unrelated to the concept of type:
if <code>x</code> is an instance of an old-style class, then <code>x.__class__</code>
designates the class of <code>x</code>, but <code>type(x)</code> is always <code><type
'instance'></code>. </p>
<p>This reflects the fact that all old-style instances, independently of
their class, are implemented with a single built-in type, called
instance.</p>
<p><strong>New-style classes were introduced in Python 2.2 to unify the concepts of class and type</strong>.
A new-style class is simply a user-defined type, no more, no less.</p>
<p>If x is an instance of a new-style class, then <code>type(x)</code> is typically
the same as <code>x.__class__</code> (although this is not guaranteed – a
new-style class instance is permitted to override the value returned
for <code>x.__class__</code>).</p>
<p><strong>The major motivation for introducing new-style classes is to provide a unified object model with a full meta-model</strong>. </p>
<p>It also has a number of immediate benefits, like the ability to
subclass most built-in types, or the introduction of "descriptors",
which enable computed properties.</p>
<p><strong>For compatibility reasons, classes are still old-style by default</strong>. </p>
<p>New-style classes are created by specifying another new-style class
(i.e. a type) as a parent class, or the "top-level type" object if no
other parent is needed. </p>
<p>The behaviour of new-style classes differs from that of old-style
classes in a number of important details in addition to what type
returns. </p>
<p>Some of these changes are fundamental to the new object model, like
the way special methods are invoked. Others are "fixes" that could not
be implemented before for compatibility concerns, like the method
resolution order in case of multiple inheritance.</p>
<p><strong>Python 3 only has new-style classes</strong>. </p>
<p>No matter if you subclass from <code>object</code> or not, classes are new-style
in Python 3.</p>
</blockquote>
|
<p>New-style classes inherit from <code>object</code> and must be written as such in Python 2.2 onwards (i.e. <code>class Classname(object):</code> instead of <code>class Classname:</code>). The core change is to unify types and classes, and the nice side-effect of this is that it allows you to inherit from built-in types.</p>
<p>Read <a href="http://www.python.org/download/releases/2.2.3/descrintro/" rel="noreferrer">descrintro</a> for more details.</p>
| 7,852
|
<p>Java has generics and C++ provides a very strong programming model with <code>template</code>s.
So then, what is the difference between C++ and Java generics?</p>
|
<p>There is a big difference between them. In C++ you don't have to specify a class or an interface for the generic type. That's why you can create truly generic functions and classes, with the caveat of a looser typing.</p>
<pre class="lang-cpp prettyprint-override"><code>template <typename T> T sum(T a, T b) { return a + b; }
</code></pre>
<p>The method above adds two objects of the same type, and can be used for any type T that has the "+" operator available.</p>
<p>In Java you have to specify a type if you want to call methods on the objects passed, something like:</p>
<pre class="lang-java prettyprint-override"><code><T extends Something> T sum(T a, T b) { return a.add ( b ); }
</code></pre>
<p>In C++ generic functions/classes can only be defined in headers, since the compiler generates different functions for different types (that it's invoked with). So the compilation is slower. In Java the compilation doesn't have a major penalty, but Java uses a technique called "erasure" where the generic type is erased at runtime, so at runtime Java is actually calling ...</p>
<pre class="lang-java prettyprint-override"><code>Something sum(Something a, Something b) { return a.add ( b ); }
</code></pre>
<p>Nevertheless, Java's generics help with type-safety.</p>
|
<p>Templates are nothing but a macro system. Syntax sugar. They are fully expanded before actual compilation (or, at least, compilers behave as if it were the case).</p>
<p>Example:</p>
<p>Let's say we want two functions. One function takes two sequences (list, arrays, vectors, whatever goes) of numbers, and returns their inner product. Another function takes a length, generates two sequences of that length, passes them to the first function, and returns it's result. The catch is that we might make a mistake in the second function, so that these two functions aren't really of the same length. We need the compiler to warn us in this case. Not when the program is running, but when it's compiling.</p>
<p>In Java you can do something like this:</p>
<pre><code>import java.io.*;
interface ScalarProduct<A> {
public Integer scalarProduct(A second);
}
class Nil implements ScalarProduct<Nil>{
Nil(){}
public Integer scalarProduct(Nil second) {
return 0;
}
}
class Cons<A implements ScalarProduct<A>> implements ScalarProduct<Cons<A>>{
public Integer value;
public A tail;
Cons(Integer _value, A _tail) {
value = _value;
tail = _tail;
}
public Integer scalarProduct(Cons<A> second){
return value * second.value + tail.scalarProduct(second.tail);
}
}
class _Test{
public static Integer main(Integer n){
return _main(n, 0, new Nil(), new Nil());
}
public static <A implements ScalarProduct<A>>
Integer _main(Integer n, Integer i, A first, A second){
if (n == 0) {
return first.scalarProduct(second);
} else {
return _main(n-1, i+1,
new Cons<A>(2*i+1,first), new Cons<A>(i*i, second));
//the following line won't compile, it produces an error:
//return _main(n-1, i+1, first, new Cons<A>(i*i, second));
}
}
}
public class Test{
public static void main(String [] args){
System.out.print("Enter a number: ");
try {
BufferedReader is =
new BufferedReader(new InputStreamReader(System.in));
String line = is.readLine();
Integer val = Integer.parseInt(line);
System.out.println(_Test.main(val));
} catch (NumberFormatException ex) {
System.err.println("Not a valid number");
} catch (IOException e) {
System.err.println("Unexpected IO ERROR");
}
}
}
</code></pre>
<p>In C# you can write almost the same thing. Try to rewrite it in C++, and it won't compile, complaining about infinite expansion of templates.</p>
| 5,700
|
<p>I left my printer to print a circular object and when I came back I saw it didn't print anything but left this layer of white on the surface. I can't get it off, I've tried washing it and scraping it off with the chisel, nothing works.</p>
<p><a href="https://i.stack.imgur.com/7zuyK.jpg" rel="nofollow noreferrer" title="Printer bed with white circular marking"><img src="https://i.stack.imgur.com/7zuyK.jpg" alt="Printer bed with white circular marking" title="Printer bed with white circular marking" /></a></p>
|
<p>My guess is it's damaged print surface from the hot extruder mashing against the print surface. Your description seems to indicate that it isn't a layer.</p>
|
<p>If it actually is residue from the material you were trying to print, pressed against the surface so tightly and so thin that you can't separate it, the best way to remove it is printing a new object on top of it, using the same material, with the bed properly leveled (i.e. not smashing the nozzle into it again) and with the bed and nozzle temperature high. If things go well, it will then come off with the print when you're done after the bed cools. This is because printable thermoplastics tend to stick better to themselves than to the bed.</p>
| 2,016
|
<p>While there are 100 ways to solve the conversion problem, I am focusing on performance.</p>
<p>Give that the string only contains binary data, what is the fastest method, in terms of performance, of converting that data to a byte[] (not char[]) under C#?</p>
<p>Clarification: This is not ASCII data, rather binary data that happens to be in a string.</p>
|
<p>I'm not sure ASCIIEncoding.GetBytes is going to do it, because it only supports the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.text.asciiencoding" rel="nofollow noreferrer">range 0x0000 to 0x007F</a>. </p>
<p>You tell the string contains only bytes. But a .NET string is an array of chars, and 1 char is 2 bytes (because a .NET stores strings as UTF16). So you can either have two situations for storing the bytes 0x42 and 0x98:</p>
<ol>
<li>The string was an ANSI string and contained bytes and is converted to an unicode string, thus the bytes will be 0x00 0x42 0x00 0x98. (The string is stored as 0x0042 and 0x0098)</li>
<li>The string was just a byte array which you typecasted or just recieved to an string and thus became the following bytes 0x42 0x98. (The string is stored as 0x9842)</li>
</ol>
<p>In the first situation on the result would be 0x42 and 0x3F (ascii for "B?"). The second situation would result in 0x3F (ascii for "?"). This is logical, because the chars are outside of the valid ascii range and the encoder does not know what to do with those values.</p>
<p>So i'm wondering why it's a string with bytes?</p>
<ul>
<li>Maybe it contains a byte encoded as a string (for instance <a href="https://en.wikipedia.org/wiki/Base64" rel="nofollow noreferrer">Base64</a>)?</li>
<li>Maybe you should start with an char array or a byte array?</li>
</ul>
<p>If you realy do have situation 2 and you want to get the bytes out of it you should use the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.text.unicodeencoding.getbytes" rel="nofollow noreferrer">UnicodeEncoding.GetBytes</a> call. Because that will return 0x42 and 0x98.</p>
<p>If you'd like to go from a char array to byte array, the fastest way would be Marshaling.. But that's not really nice, and uses double memory. </p>
<pre><code>public Byte[] ConvertToBytes(Char[] source)
{
Byte[] result = new Byte[source.Length * sizeof(Char)];
IntPtr tempBuffer = Marshal.AllocHGlobal(result.Length);
try
{
Marshal.Copy(source, 0, tempBuffer, source.Length);
Marshal.Copy(tempBuffer, result, 0, result.Length);
}
finally
{
Marshal.FreeHGlobal(tempBuffer);
}
return result;
}
</code></pre>
|
<p>There is <em>no such thing</em> as an ASCII string in C#! Strings <em>always</em> contain UTF-16. Not realizing this leads to a lot of problems. That said, the methods mentioned before work because they consider the string as UTF-16 encoded and transform the characters to ASCII symbols.</p>
<p>/EDIT in response to the clarification: how did the binary data get in the string? Strings aren't supposed to contain binary data (use <code>byte[]</code> for that).</p>
| 9,779
|
<p>I've been looking for a tool to extract exception information from a C++ program. The most wanted feature I'm looking for: I want to know all the exceptions that can be thrown from a function (which would include all the function that is called from that function recursively).</p>
<p>I've always thought that documenting errors and exceptions in particular is very hard (and takes a lot of effort to keep up to date). But if there is some way to automate that, it would be very helpful.</p>
<p>A tool for windows and Visual Studio would be preferred but not necessary, I could always work around that.</p>
|
<p><a href="http://www.gimpel.com/" rel="nofollow noreferrer">PC-Lint</a> claims to do static exception analysis of C++ code.<br>
<a href="http://www.coverity.com/" rel="nofollow noreferrer">Coverity</a> is another static C++ code analysis tool that apparently informs you of unhandled exceptions.<br>
<a href="http://www.automatedqa.com/products/aqtime/index.asp" rel="nofollow noreferrer">AQtime</a> claims to have exception tracing as part of its code analysis. Plus, they advertise Visual Studio integration.<br>
<a href="https://web.archive.org/web/20111007220353/http://testingfaqs.org/t-static.html" rel="nofollow noreferrer">Here</a> is a list of several static code analysis tools.</p>
|
<p>EDoC++ (<a href="http://edoc.sourceforge.net" rel="nofollow noreferrer">http://edoc.sourceforge.net</a>) is another alternative.</p>
| 4,793
|
<p>I Have a request for the TOTAL's and subtotals column to be moved to the top/left of columns it represents, and by default SSRS does it on the bottom or right hand side of the columns being totaled. Is there a way to this?</p>
|
<p>I found my own solution, when you right click on the tiny green triangle, in the top right hand corner of the sub total column. Then select properties, and you can adjust the "Layout" property.. it has 2 options, Before and After. </p>
|
<p>You can just add a row which comes before your set of data, for each field you want to total just give that cell an expression which does a SUM() of that particular field.</p>
| 8,202
|
<p>If unit-test names can become outdated over time and if you consider that the test itself is the most important thing, then is it important to choose wise test names?</p>
<p>ie </p>
<pre><code>[Test]
public void ShouldValidateUserNameIsLessThan100Characters() {}
</code></pre>
<p>verse </p>
<pre><code>[Test]
public void UserNameTestValidation1() {}
</code></pre>
|
<p>The name of any method should make it clear what it does.</p>
<p>IMO, your first suggestion is a bit long and the second one isn't informative enough. Also it's probably a bad idea to put "100" in the name, as that's very likely to change. What about:</p>
<pre><code>public void validateUserNameLength()
</code></pre>
<p>If the test changes, the name should be updated accordingly. </p>
|
<p>The name needs to matter within reason. I don't want an email from the build saying that test 389fb2b5-28ad3 failed, but just knowing that it was a UserName test as opposed to something else would help ensure the right person gets to do the diagnosis.</p>
| 6,973
|
<p>I'm using JBoss Seam Framework, but it's seems to me isn't very popular among java developers.
I want to know how many java programmers here are using it, and in what kind of projects.
Is as good as django, or RoR?</p>
|
<p>In our <a href="http://www.lunatech-research.com/archives/2007/12/14/javapolis-2007-seam" rel="noreferrer">JBoss Seam in Action presentation</a> at the Javapolis conference last year, my colleague and I said that 'Seam is the next Struts'. This needed some explanation, which I later wrote-up as <a href="http://www.lunatech-research.com/archives/2008/03/17/seam-is-the-new-struts" rel="noreferrer">Seam is the new Struts</a>. Needless to say, we like Seam.</p>
<p>One indication of Seam's popularity is the level of traffic on the <a href="http://www.seamframework.org/Community/SeamUsers" rel="noreferrer">Seam Users Forum</a>.</p>
|
<p>I have used JBoss Seam on two commercial projects for two different clients. Yet JBoss Seam is still a new approach to developing JSF Web Applications. One measure is the results from a Indeed Job Search. </p>
<p><a href="http://www.indeed.com/jobs?q=jboss+seam&l=" rel="nofollow noreferrer">Indeed Job Search</a></p>
| 5,014
|
<p>Under Windows XP WPF true 3D content (which is usually displayed using the Viewport3D control) looks extremely ugly because it is by default not antialiased as the rest of the WPF graphics are. Especially at lower resolution the experience is so bad that it can not be used in production code.</p>
<p>I have managed to force antialiasing on some Nvidia graphics cards using the settings of the driver. Unfortunately, this sometimes yields ugly artifacts and only works with specific cards and driver versions. The official word from Microsoft on this regard is that antialiased 3D is generally not supported under Windows XP and the artifact I see result from the fact that WPF already does its own antialiasing (on XP only for 2D).</p>
<p>So I was wondering if there is maybe some other secret trick that lets me force antialiasing on WPF 3D content under Windows XP.</p>
|
<p>Have you tried this (from your thread on MSDN forums)?</p>
<blockquote>
<p>Well, it seems the reference in the MSDN link above incorrectly specify the affected registry root key. In MSDN it is specified as HKEY_CURRENT_USER, while the correct root key should be HKEY_LOCAL_MACHINE. I've tried setting up the HKEY_LOCAL_MACHINE\Software\Microsoft\Avalon.Graphics\MaxMultiplesampleType to '4' and I can get antialiasing for my WPF Application on XP. </p>
</blockquote>
|
<p>Does your video card support Shader 2.0? You can refer <a href="http://en.wikipedia.org/wiki/Pixel_shader" rel="nofollow noreferrer">to this wiki page</a> to see if it does...</p>
| 6,050
|
<p>I was wondering if anyone could point to an Open Source date utility class that is fairly robust. I find myself rolling my own when I want to do a lot of things I take for granted in C# and Java. For instance I did find a decent example of a DateDiff() function that I tore apart and another DatePart() function. Another examples would be parsing different date/time formats. I'm trying to avoid reinventing something if it's already built.</p>
<p>Another possibility may be a nice set of Javascript files that I can convert to ActionScript 3. So far I've found <a href="http://www.datejs.com" rel="nofollow noreferrer">DateJS</a> but I want to get a good idea of what is out there. </p>
|
<p><a href="https://github.com/mikechambers/as3corelib" rel="nofollow noreferrer">as3corelib</a> has the <a href="https://github.com/mikechambers/as3corelib/blob/master/src/com/adobe/utils/DateUtil.as" rel="nofollow noreferrer">DateUtil</a> class and it should be pretty reliable since it's written by some Adobe employees. I haven't encountered any problems with it.</p>
|
<p>There is also <a href="http://www.depressedpress.com/Content/Development/JavaScript/Extensions/DP_DateExtensions/Index.cfm" rel="nofollow noreferrer">DP_DateExtensions</a>, though I believe DateJS is more robust.</p>
| 7,627
|
<p>JavaScript needs access to cookies if AJAX is used on a site with access restrictions based on cookies. Will HttpOnly cookies work on an AJAX site? </p>
<p><em>Edit:</em> Microsoft created a way to prevent XSS attacks by disallowing JavaScript access to cookies if HttpOnly is specified. FireFox later adopted this. So my question is: If you are using AJAX on a site, like StackOverflow, are Http-Only cookies an option?</p>
<p><em>Edit 2:</em> Question 2. If the purpose of HttpOnly is to prevent JavaScript access to cookies, and you can still retrieve the cookies via JavaScript through the XmlHttpRequest Object, <strong>what is the point of HttpOnly</strong>?</p>
<p><em>Edit 3:</em> Here is a quote from Wikipedia:</p>
<blockquote>
<p>When the browser receives such a cookie, it is supposed to use it as usual in the following HTTP exchanges, but not to make it visible to client-side scripts.[32] The <code>HttpOnly</code> flag is not part of any standard, and is not implemented in all browsers. Note that there is currently no prevention of reading or writing the session cookie via a XMLHTTPRequest. [33].</p>
</blockquote>
<p>I understand that <code>document.cookie</code> is blocked when you use HttpOnly. But it seems that you can still read cookie values in the XMLHttpRequest object, allowing for XSS. How does HttpOnly make you any safer than? By making cookies essentially read only? </p>
<p>In your example, I cannot write to your <code>document.cookie</code>, but I can still steal your cookie and post it to my domain using the XMLHttpRequest object.</p>
<pre><code><script type="text/javascript">
var req = null;
try { req = new XMLHttpRequest(); } catch(e) {}
if (!req) try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
if (!req) try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
req.open('GET', 'http://stackoverflow.com/', false);
req.send(null);
alert(req.getAllResponseHeaders());
</script>
</code></pre>
<p><em>Edit 4:</em> Sorry, I meant that you could send the XMLHttpRequest to the StackOverflow domain, and then save the result of getAllResponseHeaders() to a string, regex out the cookie, and then post that to an external domain. It appears that Wikipedia and ha.ckers concur with me on this one, but I would love be re-educated...</p>
<p><em>Final Edit:</em> Ahh, apparently both sites are wrong, this is actually a <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=380418" rel="noreferrer">bug in FireFox</a>. IE6 & 7 are actually the only browsers that currently fully support HttpOnly.</p>
<p>To reiterate everything I've learned:</p>
<ul>
<li>HttpOnly restricts all access to document.cookie in IE7 & and FireFox (not sure about other browsers)</li>
<li>HttpOnly removes cookie information from the response headers in XMLHttpObject.getAllResponseHeaders() in IE7.</li>
<li>XMLHttpObjects may only be submitted to the domain they originated from, so there is no cross-domain posting of the cookies.</li>
</ul>
<p><em>edit: This information is likely no longer up to date.</em></p>
|
<p>Yes, HTTP-Only cookies would be fine for this functionality. They will still be provided with the XmlHttpRequest's request to the server.</p>
<p>In the case of Stack Overflow, the cookies are automatically provided as part of the XmlHttpRequest request. I don't know the implementation details of the Stack Overflow authentication provider, but that cookie data is probably automatically used to verify your identity at a lower level than the "vote" controller method.</p>
<p>More generally, cookies are <strong>not</strong> required for AJAX. XmlHttpRequest support (or even iframe remoting, on older browsers) is all that is technically required.</p>
<p>However, if you want to provide security for AJAX enabled functionality, then the same rules apply as with traditional sites. You need some method for identifying the user behind each request, and cookies are almost always the means to that end.</p>
<blockquote>
<p>In your example, I cannot write to your document.cookie, but I can still steal your cookie and post it to my domain using the XMLHttpRequest object.</p>
</blockquote>
<p>XmlHttpRequest won't make cross-domain requests (for exactly the sorts of reasons you're touching on).</p>
<p>You could normally inject script to send the cookie to your domain using iframe remoting or JSONP, but then HTTP-Only protects the cookie again since it's inaccessible.</p>
<p>Unless you had compromised StackOverflow.com on the server side, you wouldn't be able to steal my cookie.</p>
<blockquote>
<p>Edit 2: Question 2. If the purpose of Http-Only is to prevent JavaScript access to cookies, and you can still retrieve the cookies via JavaScript through the XmlHttpRequest Object, what is the point of Http-Only?</p>
</blockquote>
<p>Consider this scenario:</p>
<ul>
<li>I find an avenue to inject JavaScript code into the page.</li>
<li>Jeff loads the page and my malicious JavaScript modifies his cookie to match mine.</li>
<li>Jeff submits a stellar answer to your question.</li>
<li>Because he submits it with my cookie data instead of his, the answer will become mine.</li>
<li>You vote up "my" stellar answer.</li>
<li>My real account gets the point.</li>
</ul>
<p>With HTTP-Only cookies, the second step would be impossible, thereby defeating my XSS attempt.</p>
<blockquote>
<p>Edit 4: Sorry, I meant that you could send the XMLHttpRequest to the StackOverflow domain, and then save the result of getAllResponseHeaders() to a string, regex out the cookie, and then post that to an external domain. It appears that Wikipedia and ha.ckers concur with me on this one, but I would love be re-educated...</p>
</blockquote>
<p>That's correct. You can still session hijack that way. It does significantly thin the herd of people who can successfully execute even that XSS hack against you though.</p>
<p>However, if you go back to my example scenario, you can see where HTTP-Only <em>does</em> successfully cut off the XSS attacks which rely on modifying the client's cookies (not uncommon).</p>
<p>It boils down to the fact that a) no single improvement will solve <em>all</em> vulnerabilities and b) no system will <em>ever</em> be completely secure. HTTP-Only <strong>is</strong> a useful tool in shoring up against XSS.</p>
<p>Similarly, even though the cross domain restriction on XmlHttpRequest isn't 100% successful in preventing all XSS exploits, you'd still never dream of removing the restriction.</p>
|
<p>No, the page that the AJAX call requests has access to cookies too & that's what checks whether you're logged in.</p>
<p>You can do other authentication with the Javascript, but I wouldn't trust it, I always prefer putting any sort of authentication checking in the back-end.</p>
| 4,764
|
<p>I maintain several client sites that have no dynamic data whatsoever, everything is static asp.net with c#.<br>
Are there any pitfalls to caching the entire page for extreme periods of time, like a week?</p>
<p>Kibbee, We use a couple controls on the sites (ad rotator, some of the ajax extensions) on the sites. They could probably be completely written in html but for convenience sake I just stuck with what we use for every other site.</p>
|
<p>The only significant pitfall to long cache times occurs when you want to update that data. To be safe, you have to assume that it will take up to a week for the new version to become available. Intermediate hosts such as a ISP level proxy servers often do cache aggressively so this delay will happen.</p>
<p>If there are large files to be cached, I'd look at ensuring your content engine supports If-Modified-Since.</p>
<p>For smaller files (page content, CSS, images, etc), where reducing the number of round-trips is the key, having a long expiry time (a year?) and changing the URL when the content changes is the best. This lets you control when user agents will fetch the new content.</p>
<p>Yahoo! have published a two part article on <a href="http://yuiblog.com/blog/2006/11/28/performance-research-part-1/" rel="nofollow noreferrer">reducing HTTP requests</a> and <a href="http://yuiblog.com/blog/2007/01/04/performance-research-part-2/" rel="nofollow noreferrer">browser cache usage</a>. I won't repeat it all here, but these are good reads which will guide you on what to do.</p>
<p>My feeling is to pick a time period high enough to cover most users single sessions but low enough to not cause too much inconvenience should you wish to update the content. Be sure to support If-Modified-Since if you have a Last-Modified for all your content. </p>
<p>Finally, if your content is cacheable at all and you need to push new content out now, you can always use a new URL. This final cachable content URL can sit behind a fixed <a href="http://en.wikipedia.org/wiki/HTTP_302" rel="nofollow noreferrer">HTTP 302 redirect</a> URL should you wish to publish a permanent link to the latest version.</p>
|
<p>When you say that you have no data, how are you even using asp.net or c#. What functionality does that provide you over plain HTML? Also, if you do plan on caching, it's probably best to cache to a file, and then when a request is made, stream out the file. The OS will take care of keeping the file in memory so that you won't have to read it off the disk all the time.</p>
| 5,707
|
<p>How do I lock compiled Java classes to prevent decompilation?</p>
<p>I know this must be very well discussed topic on the Internet, but I could not come to any conclusion after referring them.</p>
<p>Many people do suggest obfuscator, but they just do renaming of classes, methods, and fields with tough-to-remember character sequences but what about sensitive constant values?</p>
<p>For example, you have developed the encryption and decryption component based on a password based encryption technique. Now in this case, any average Java person can use <a href="http://www.kpdus.com/jad.html" rel="noreferrer">JAD</a> to decompile the class file and easily retrieve the password value (defined as constant) as well as <a href="http://en.wikipedia.org/wiki/Salt_%28cryptography%29" rel="noreferrer">salt</a> and in turn can decrypt the data by writing small independent program!</p>
<p>Or should such sensitive components be built in native code (for example, VC++) and call them via <a href="http://en.wikipedia.org/wiki/Java_Native_Interface" rel="noreferrer">JNI</a>?</p>
|
<p>Some of the more advanced Java bytecode obfuscators do much more than just class name mangling. <a href="http://www.zelix.com/" rel="noreferrer">Zelix KlassMaster</a>, for example, can also scramble your code flow in a way that makes it really hard to follow and works as an excellent code optimizer...</p>
<p>Also many of the obfuscators are also able to scramble your string constants and remove unused code.</p>
<p>Another possible solution (not necessarily excluding the obfuscation) is to use <a href="http://www.componio.com/products/jinstaller/jinstaller_secure_edition/jarcryp.html" rel="noreferrer">encrypted JAR files</a> and a custom classloader that does the decryption (preferably using native runtime library).</p>
<p>Third (and possibly offering the strongest protection) is to use native ahead of time compilers like <a href="http://en.wikipedia.org/wiki/GNU_Compiler_Collection" rel="noreferrer">GCC</a> or <a href="http://www.excelsior-usa.com/jet.html" rel="noreferrer">Excelsior JET</a>, for example, that compile your Java code directly to a platform specific native binary.</p>
<p>In any case You've got to remember that as the saying goes in Estonian "Locks are for animals". Meaning that every bit of code is available (loaded into memory) during the runtime and given enough skill, determination and motivation, people can and will decompile, unscramble and hack your code... Your job is simply to make the process as uncomfortable as you can and still keep the thing working...</p>
|
<p>Q: If I encrypt my .class files and use a custom classloader to load and decrypt them on the fly, will this prevent decompilation?</p>
<p>A: The problem of preventing Java byte-code decompilation is almost as old the language itself. Despite a range of obfuscation tools available on the market, novice Java programmers continue to think of new and clever ways to protect their intellectual property. In this Java Q&A installment, I dispel some myths around an idea frequently rehashed in discussion forums.</p>
<p>The extreme ease with which Java .class files can be reconstructed into Java sources that closely resemble the originals has a lot to do with Java byte-code design goals and trade-offs. Among other things, Java byte code was designed for compactness, platform independence, network mobility, and ease of analysis by byte-code interpreters and JIT (just-in-time)/HotSpot dynamic compilers. Arguably, the compiled .class files express the programmer's intent so clearly they could be easier to analyze than the original source code.</p>
<p>Several things can be done, if not to prevent decompilation completely, at least to make it more difficult. For example, as a post-compilation step you could massage the .class data to make the byte code either harder to read when decompiled or harder to decompile into valid Java code (or both). Techniques like performing extreme method name overloading work well for the former, and manipulating control flow to create control structures not possible to represent through Java syntax work well for the latter. The more successful commercial obfuscators use a mix of these and other techniques.</p>
<p>Unfortunately, both approaches must actually change the code the JVM will run, and many users are afraid (rightfully so) that this transformation may add new bugs to their applications. Furthermore, method and field renaming can cause reflection calls to stop working. Changing actual class and package names can break several other Java APIs (JNDI (Java Naming and Directory Interface), URL providers, etc.). In addition to altered names, if the association between class byte-code offsets and source line numbers is altered, recovering the original exception stack traces could become difficult.</p>
<p>Then there is the option of obfuscating the original Java source code. But fundamentally this causes a similar set of problems.
Encrypt, not obfuscate?</p>
<p>Perhaps the above has made you think, "Well, what if instead of manipulating byte code I encrypt all my classes after compilation and decrypt them on the fly inside the JVM (which can be done with a custom classloader)? Then the JVM executes my original byte code and yet there is nothing to decompile or reverse engineer, right?"</p>
<p>Unfortunately, you would be wrong, both in thinking that you were the first to come up with this idea and in thinking that it actually works. And the reason has nothing to do with the strength of your encryption scheme.</p>
| 7,191
|
<p>I am having two separate issues. One is specific to this particular model, the other is on all my prints, but more pronounced on 90° vertical walls.</p>
<p>The first issue is a localized area of under extrusion only in one area of the print. This issue is specific to this model. The second issue is evenly spaced horizontal bulges that appear approximately every 5mm during the first 30-35 mm of the print. This is a two-piece Christmas tree I designed for my wife and I have been printing both pieces together on the build plate.</p>
<p>I am printing on a mostly stock Voxelab Aquila with Voxelab Gold 1.75 mm PLA. I have changed the stock extruder to the aluminum extruder after the plastic one cracked, and am running a Satsana style shroud with stock fans. I am using CHEP's Cura 4.11 Ender 3 profile for .2 mm (good) - <a href="https://www.chepclub.com/cura-profiles.html" rel="nofollow noreferrer">CHEP Cura Profiles</a>, printing at 200 °C and 40 °C bed temp. I have lubed my Z screw with white lithium grease, checked that belts are tight and no screws or physical connection points are loose. I checked to make sure that the eccentric nuts are snug but not binding the gantry. I have calibrated my extruder E-steps and changed the value to 96.</p>
<p>Can someone offer me some guidance on where to go from here?</p>
<p><a href="https://i.stack.imgur.com/Ga1uq.jpg" rel="nofollow noreferrer" title="Photo of a 3D printed two-piece Christmas tree"><img src="https://i.stack.imgur.com/Ga1uq.jpg" alt="Photo of a 3D printed two-piece Christmas tree" title="Photo of a 3D printed two-piece Christmas tree" /></a></p>
<p><a href="https://i.stack.imgur.com/hOFLf.jpg" rel="nofollow noreferrer" title="Photo of the inside of the top part of Christmas tree"><img src="https://i.stack.imgur.com/hOFLf.jpg" alt="Photo of the inside of the top part of Christmas tree" title="Photo of the inside of the top part of Christmas tree" /></a></p>
<p><a href="https://i.stack.imgur.com/t5nSL.jpg" rel="nofollow noreferrer" title="Photo showing the printing errors inside the top of the Christmas tree"><img src="https://i.stack.imgur.com/t5nSL.jpg" alt="Photo showing the printing errors inside the top of the Christmas tree" title="Photo showing the printing errors inside the top of the Christmas tree" /></a></p>
<p><a href="https://i.stack.imgur.com/BC8q4.jpg" rel="nofollow noreferrer" title="Photo of horizontal bulges on the base of Christmas tree"><img src="https://i.stack.imgur.com/BC8q4.jpg" alt="Photo of horizontal bulges on the base of Christmas tree" title="Photo of horizontal bulges on the base of Christmas tree" /></a></p>
<p><a href="https://i.stack.imgur.com/lXNb3.jpg" rel="nofollow noreferrer" title="Photo of ruler measuring the evenly spaced horizontal bulges on the base of Christmas tree"><img src="https://i.stack.imgur.com/lXNb3.jpg" alt="Photo of ruler measuring the evenly spaced horizontal bulges on the base of Christmas tree" title="Photo of ruler measuring the evenly spaced horizontal bulges on the base of Christmas tree" /></a></p>
|
<p>The horizontal bands are 5mm apart, which is a common pitch for the screws often used for the Z axis.</p>
<p>I would look for something that binds, moves, slips, or touches once per screw revolution. The movement repeats along the screw, so if it is a screw defect I would look for a scratch or bump that affects the screw along its axis.</p>
<p>If you don't see that, check for how the screw is constrained at both ends. If they are loose constraints, does the screw wiggle while it is turning?</p>
<p>Move the nut to one extreme and rotate the screw. Does it appear to have any bend? Even a small degree of bending that doesn't bind the axis can add a small load to the drive.</p>
<p>The Z-azis error you are looking for is subtle. It is probably 10% (or less) of the layer height.</p>
|
<p>Try setting the z-seam to <em>random</em> in your slicer. In Slic3r it is <em>Seam position</em> under <em>Advanced</em> near the bottom of the <em>Layer and perimeters</em> page of the <em>Print Settings</em>.</p>
| 2,068
|
<p>We are working on a large project with a measure of new/modified GUI functionality. We've found in the past that we often introduced new problems in related code when adding new functionality.</p>
<p>We have non-technical users perform testing, but they often miss parts and allow bugs to slip through.</p>
<p>Are there any best practices for organizing the UI testing of a WinForms project? Is there any way to automate it?</p>
|
<p>There are GUI testing tools that will click buttons and stuff for you but they're pretty fragile in my experience.</p>
<p>The best thing to do is to keep your UI layer as thin as possible. Your event handler classes should optimally be only one or two lines that call out to other more testable classes. That way you can test your business logic in unit tests without having to actually do a button click.</p>
|
<p>I can't really help with organization or best practices, but an <a href="http://www.nunit.org/index.php" rel="nofollow noreferrer">NUnit</a> extension appears to be available for forms testing, <a href="http://www.google.com/search?q=nunitforms" rel="nofollow noreferrer">NUnitForms</a>.</p>
| 6,294
|
<p>Windows has a feature that allows an administrator to perform auto-logon whenever it is started. How can this feature be activated?</p>
|
<p>Based on the advice, moved the answer to the answers section:</p>
<p>There are tools out there that give you a GUI for setting this easily, but you can also do it relatively easily by editing the registry.</p>
<p>Under the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon</p>
<p>Add the following values:</p>
<ul>
<li>DefaultDomainName String < domain-name ></li>
<li>DefaultUserName String < username ></li>
<li>DefaultPassword String < password ></li>
<li>AutoAdminLogon String 1</li>
</ul>
<p>Important: Using auto-logon is insecure and should, in general, never be used for standard computer configurations. The problem is not only that your computer is accessible to anyone with physical access to it, but also that the password is saved in plain-text in a well known location in your registry. This is usually used for test environments or for special setups. This is even more important to notice if you intend to perform auto-logon as an administrator.</p>
|
<p>If you don't want to store the clear-text password in the registry, use this method:</p>
<ul>
<li>Start -> Run</li>
<li>enter "control userpasswords2"</li>
<li>disable checkbox "Users must enter a user name and password to use this computer"</li>
<li>click "OK"</li>
<li>enter a valid user name and password that is used for auto-logon</li>
</ul>
| 6,109
|
<p>Suddenly my prints start having small strings and I'm not sure what to do to eliminate them.</p>
<p>I have already tried to clean the filament tube, cleaned up the nozzle, and played with various retraction settings. Nothing seems to work and I still see these small strings.</p>
<p><a href="https://i.stack.imgur.com/uweHt.jpg" rel="nofollow noreferrer" title="3D print showing stringing"><img src="https://i.stack.imgur.com/uweHt.jpg" alt="3D print showing stringing" title="3D print showing stringing" /></a></p>
<p>Any idea how I can eliminate it?</p>
|
<p>These artifacts can be either moisture, as explored by <a href="https://3dprinting.stackexchange.com/a/16007/8884">this answer</a> or problems with temperature/speed control or the Z-Axis:</p>
<p>If the temperature is not hot enough, the filament might not get melted enough to squish down to the next layer nicely at the speed the head moves at, resulting in the cooling filament getting dragged behind the printhead and forming a line in the air. Due to such errors I generally tend to print PLA more in the upper temperatures than where it barely liquifies.</p>
<p>This also can happen if the printhead is not on the right Z-height and the gap is larger than expected. Usually, this happens only at the lowest layer when you are unlevel (bad bed adhesion is the result), but if you bump the printer or it hooks on something, during Z-travel, it can result in such a mechanical problem. Other reasons that show the same pattern are uneven Z-Axis movement. For example, a loose gantry or a defective Z-rod can lead to it, as could bad firmware or a worn-out motor that <em>lost</em> a coil or two.</p>
|
<p>What you're seeing does not look like <em>stringing</em>, which I would characterize as material that exited the nozzle after extrusion was supposed to have stopped, usually due to missing or insufficient retraction, but like the extrusions along the concave contours <em>failed to bond</em> to the previous layer and got drawn across to a point on the other side of the contour where some degree of adhesion resumed. This happens when the lateral acceleration force of going around the curve overcomes the bonding of the new material to the existing material it's being laid down against, and in my experience it's always the result of <strong>moisture-contaminated filament</strong>. This matches your description of the problem has something that "suddenly" started happening.</p>
<p>To fix it, dry your filament. If your bed is big enough, the easiest way to do this is to lay the whole spool on the heated bed covered by a cardboard filament box with one side cut out to make a heat chamber, and running the bed heater at around 60-70°C (for PLA) for several hours, flipping the spool a few times during it. You can also use an oven but I would not trust the temperature control not to shoot up high enough to ruin the filament. If you want a less hackish solution, all sorts of specialized filament drying systems are available but I don't have experience with any to recommend. I just use my bed for PLA and oven for materials that can withstand higher temperatures.</p>
| 1,909
|
<p>How do you disable autocomplete in the major browsers for a specific input (or form field)?</p>
|
<p>Firefox 30 ignores <code>autocomplete="off"</code> for passwords, opting to prompt the user instead whether the password should be stored on the client. Note the following <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=956906#c100" rel="noreferrer">commentary</a> from May 5, 2014:</p>
<blockquote>
<ul>
<li>The password manager <em>always</em> prompts if it wants to save a password. Passwords are not saved without permission from the user.</li>
<li>We are the third browser to implement this change, after IE and Chrome.</li>
</ul>
</blockquote>
<p>According to the <a href="https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion" rel="noreferrer">Mozilla Developer Network</a> documentation, the Boolean form element attribute <code>autocomplete</code> prevents form data from being cached in older browsers.</p>
<pre><code><input type="text" name="foo" autocomplete="off" />
</code></pre>
|
<p>I was having trouble on a form which included input fields for username and email with email being right after username. Chrome would autofill my current username for the site into the email field and put focus on that field. This wasn't ideal as it was a form for adding new users to the web application.</p>
<p>It seems that if you have two inputs one after the other where the first one has the term 'user name' or username in it's label or ID and the next one has the word email in it's label or ID chrome will autofill the email field.</p>
<p>What solved the issue for me was to change the ID's of the inputs to not include those words. I also had to set the text of the labels
to an empty string and use a javascript settimeout function to change the label back to what it should be after 0.01s.</p>
<pre><code>setTimeout(function () { document.getElementById('id_of_email_input_label').innerHTML = 'Email:'; }, 10);
</code></pre>
<p>If you are having this problem with any other input field being wrongly autofilled I'd try this method.</p>
| 2,466
|
<p>Do you know any grid control compatible with .NET and Mono?</p>
<p>DataGridView seems to be quite buggy on Mono, and GTK# controls depends on GTK+ so you need to install it in windows machines where, usually, it's not present.</p>
|
<p>You might want to try out the preview of Mono 2.0. DataGridView is vastly better in this version, though there are still several places where it is still lacking.</p>
<p><a href="http://mono.ximian.com/monobuild/preview/download-preview/" rel="nofollow noreferrer">http://mono.ximian.com/monobuild/preview/download-preview/</a></p>
|
<p>Which version did you try? Perhaps you should give <a href="http://mono.ximian.com/monobuild/preview/download-preview/" rel="nofollow noreferrer">Mono 2.0 preview</a> a go, it might work for you (no, the Data* controls are not yet perfect, but they have improved greatly). From my experience GTK# controls on Windows are not that great either...</p>
| 5,647
|
<p>I'd like to create a script that will configure the Visual Studio IDE the way I like it. Nothing vastly complicated, just a few Tools/Options settings, adding some External Tools, that kind of thing. </p>
<p>I know that this can be done inside VS with Import/Export Settings, but I'd like to be able to automate it from outside of VS. Is this possible, and if so, how?</p>
<hr>
<p>Edited to add: doing it from <em>outside</em> of VS is important to me -- I'm hoping to use this as part of a more general "configure this newly-Ghosted PC just the way I like it" script.</p>
<hr>
<p>Edited again: the solution seems to be to hack CurrentSettings.vssettings, or use <a href="http://www.autoitscript.com/" rel="noreferrer">AutoIt</a>. Details below.</p>
|
<p>Answering my own question, in two ways:</p>
<ol>
<li><p>In VS2005/8, the things I mentioned (Tools/Options, External Tools) are all stored in the CurrentSettings.vssettings file, in the folder "Visual Studio 200{5|8}\Settings". This file is just XML, and it can be edited programmatically by anything that knows how to parse XML. You can also just paste a new vssettings file over the top of the default one (at least, this works for me).</p></li>
<li><p>The larger question of configuring a virgin PC. It turns out that not everything I want to change has an API, so I need some way of pretending to be a user who is actually sitting there clicking on things. The best approach to this seems to be <a href="http://www.autoitscript.com/" rel="nofollow noreferrer">AutoIt</a>, whose scripting language I will now have to learn in my Copious Free Time.</p></li>
</ol>
|
<p>On my machine Visual Studio stores it's local settings in a file called VCComponents.dat. Its a text file, so perhaps you could find a way of placing your settings directly in there.</p>
<p>The file is stored in my users local AppData\Local\Microsoft\VC folder</p>
| 6,419
|
<p>I'm looking for suggestions on how to debug and chase down deadlock issues in an SQL Server 2000 database. I've had it recommended to me to use trace flags 1024 and 3605, which I have found give me the following:</p>
<p>1024 - this trace flag returns the type of locks participating in the deadlock and the current command affected. </p>
<p>3605 - this trace flag sends trace output to the error log.</p>
<p>The specific stored procedures, tables and indexes still need to be uncovered, so the goal is to use these trace flags to do so. And then from there I'll know better what indexes need tuning, locking hints for tuning queries, and potential sproc bugs to fix.</p>
<p>Any other suggestions or happy ending war stories on chasing down this all to common problem?</p>
|
<p>Here is the bible on deadlock troubleshooting: <a href="http://blogs.msdn.com/bartd/archive/2006/09/09/Deadlock-Troubleshooting_2C00_-Part-1.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/bartd/archive/2006/09/09/Deadlock-Troubleshooting_2C00_-Part-1.aspx</a></p>
|
<p>Once you know the sql statements involved, a code analysis will surely help. Some thumb rules are checking for the order in which the rows are accessed and checking for the isolation level used for the SQL statements. A profiler trace can help a lot.</p>
<p>Most of the time, it is because of a reader trying to get a shared lock on a resource locked exclusively by a writer.</p>
| 7,581
|
<p>As I put together each asp.net page It's clear that most of the time I could use the standard HTML tags just as easily as the web forms controls. When this is the case what is the lure of the webforms controls?</p>
|
<p>HTML controls will be output a lot faster than server controls since there is nothing required on part of the server.. It just literally copies the markup in the ASPX page.</p>
<p>Server controls however require instantiation.. Parsing of the postback data and the like, this is obviously where the work comes in for the server.</p>
<p>The general rule of thumb is:</p>
<p><strong>If its static (i.e. you dont need programmatic support), make it a HTML control. HTML controls can easily be "upgraded" to server controls so there is no <em>real</em> issue of maintanence at a later time.</strong></p>
|
<p>Webform controls have more server-side pre-built functionality (server side hooks, methods and attributes), I tend to use HTML controls only when I require a high degree of formatting (styling) as that bypasses the way .Net renders it's controls (which, at times, can be very strange).</p>
| 9,565
|
<p>I'm using Eclipse 3.4 and have configured the Java code formatter with all of the options on the <em>Comments</em> tab enabled. The problem is that when I format a document comment that contains:</p>
<pre><code>* @see <a href="test.html">test</a>
</code></pre>
<p>the code formatter inserts a space in the closing HTML, breaking it:</p>
<pre><code>* @see <a href="test.html">test< /a>
</code></pre>
<p>Why? How do I stop this happening?</p>
<p>This is not fixed by disabling any of the options on the <em>Comments</em> tab, such as <em>Format HTML tags</em>. The only work-around I found is to disable Javadoc formatting completely by disabling both the <em>Enable Javadoc comment formatting</em> and <em>Enable block comment formatting</em> options, which means I then have to format comment blocks manually.</p>
|
<p>I can only assume it's a bug in Eclipse. It only happens with <em>@see</em> tags, it happens also for all 3 builtin code formatter settings.</p>
<p>There are some interesting bugs reported already in the neighbourhood, but I couldn't find this specific one. See for example a search for <em>@see</em> in the <a href="https://bugs.eclipse.org/bugs/buglist.cgi?query_format=specific&order=relevance+desc&bug_status=__all__&product=JDT&content=%40see" rel="nofollow noreferrer">Eclipse Bugzilla</a>.</p>
|
<p>Strict XML specifications require that the self closing tags should have a space before the closing slash like so:</p>
<pre><code><gcServer enabled="true" /> <!-- note the space just after "true" -->
</code></pre>
<p>I can only assume, like Bart said, that there is a bug in Eclipse's reformatter that thinks the closing tag is actually a self-closing tag. Another idea: Can you verify that your <strong>a</strong> tags are balanced (i.e. no unclosed tags higher up in the document)?</p>
| 6,729
|
<p>Using .NET 2.0 with WinForms, I'd like to create a custom, multi-columned menu (similiar to the word 2007 look&feel, but without the ribbon).</p>
<p>My approach was creating a control, and using a left/right docked toolstrip, I have constructed a similar look&feel of a menu. However, there are a few shortcomings of this solution, such as</p>
<ul>
<li>the control can only be placed, and displayed within the form; </li>
<li>if the form is too small, some area of the control won't be displayed;</li>
<li>the control also have to be manually shown/hidden.</li>
</ul>
<p>Thus, I'm looking for a way to display this control outside of the boundaries of the application. Creating a new form would result in title-bar deactivating on display, so that's also out. Alternatively, any other approach to create a customized menu would be very welcomed.</p>
<p>Edit: I don't want to use any commercial products for this; and since it's about a simple menu customization, it's not related to Microsoft's ribbon "research" in any way.</p>
|
<ul>
<li>unless you are in the business of providing .net components, you should be looking to buy it off the shelf. Its a lot of work getting such a control right - There are already vendors providing this kind of UI. e.g. <a href="http://www.componentone.com/SuperProducts/RibbonWinForms/" rel="nofollow noreferrer">ComponentOne</a></li>
<li>if you are trying to build this component as a product, you should look at the link below. Apparently Microsoft has a 'royalty-free' license around the Office UI to protect their R&D investments. As of now you need to tell them that you are using something similar to the Office UI. <a href="http://msdn.microsoft.com/en-us/office/aa973809.aspx" rel="nofollow noreferrer">More of that here</a></li>
</ul>
|
<ul>
<li>unless you are in the business of providing .net components, you should be looking to buy it off the shelf. Its a lot of work getting such a control right - There are already vendors providing this kind of UI. e.g. <a href="http://www.componentone.com/SuperProducts/RibbonWinForms/" rel="nofollow noreferrer">ComponentOne</a></li>
<li>if you are trying to build this component as a product, you should look at the link below. Apparently Microsoft has a 'royalty-free' license around the Office UI to protect their R&D investments. As of now you need to tell them that you are using something similar to the Office UI. <a href="http://msdn.microsoft.com/en-us/office/aa973809.aspx" rel="nofollow noreferrer">More of that here</a></li>
</ul>
| 9,659
|
<p>Can I run a 64-bit VMware image on a 32-bit machine?</p>
<p>I've googled this, but there doesn't seem to be a conclusive answer.</p>
<p>I know that it would have to be completely emulated and would run like a dog - but slow performance isn't necessarily an issue as I'm just interested in testing some of my background services code on 64-bit platforms.</p>
|
<p>The easiest way to check your workstation is to download the <a href="http://downloads.vmware.com/d/details/processor_check_5_5_dt/dCpiQGhkYmRAZQ==" rel="noreferrer">VMware Processor Check for 64-Bit Compatibility</a> tool from the VMware website.</p>
<p>You can't run a 64-bit VM session on a 32-bit processor. However, you can run a 64-bit VM session if you have a 64-bit processor but have installed a 32-bit host OS and your processor supports the right extensions. The tool linked above will tell you if yours does.</p>
|
<p>You can if your processor is 64-bit and Virtualization Technology (VT) extension is enabled (it can be switched off in BIOS). You can't do it on 32-bit processor.</p>
<p>To check this under Linux you just need to look into <em>/proc/cpuinfo</em> file. Just look for the appropriate flag (<strong>vmx</strong> for Intel processor or <strong>svm</strong> for AMD processor)</p>
<pre><code>egrep '(vmx|svm)' /proc/cpuinfo
</code></pre>
<p>To check this under Windows you need to use a program like CPU-Z which will display your processor architecture and supported extensions.</p>
| 8,004
|
<p>I'm writing a web page in ASP.NET. I have some JavaScript code, and I have a submit button with a click event.</p>
<p>Is it possible to call a method I created in ASP with JavaScript's click event?</p>
|
<p>Well, if you don't want to do it using Ajax or any other way and just want a normal ASP.NET postback to happen, here is how you do it (without using any other libraries):</p>
<p><em>It is a little tricky though... :)</em></p>
<p>i. In your code file (assuming you are using C# and .NET 2.0 or later) add the following Interface to your Page class to make it look like</p>
<pre><code>public partial class Default : System.Web.UI.Page, IPostBackEventHandler{}
</code></pre>
<p>ii. This should add (using <kbd>Tab</kbd>-<kbd>Tab</kbd>) this function to your code file:</p>
<pre><code>public void RaisePostBackEvent(string eventArgument) { }
</code></pre>
<p>iii. In your onclick event in JavaScript, write the following code:</p>
<pre><code>var pageId = '<%= Page.ClientID %>';
__doPostBack(pageId, argumentString);
</code></pre>
<p>This will call the 'RaisePostBackEvent' method in your code file with the 'eventArgument' as the 'argumentString' you passed from the JavaScript. Now, you can call any other event you like.</p>
<p>P.S: That is 'underscore-underscore-doPostBack' ... And, there should be no space in that sequence... Somehow the WMD does not allow me to write to underscores followed by a character!</p>
|
<p>This reply works like a breeze for me thanks cross browser:</p>
<blockquote>
<p>The __doPostBack() method works well.</p>
</blockquote>
<p>Another solution (very hackish) is to simply add an invisible ASP button in your markup and click it with a JavaScript method.</p>
<pre><code><div style="display: none;">
<asp:Button runat="server" ... OnClick="ButtonClickHandlerMethod" />
</div>
</code></pre>
<p>From your JavaScript, retrieve the reference to the button using its ClientID and then call the .Click() method on it:</p>
<pre><code>var button = document.getElementByID(/* button client id */);
button.Click();
</code></pre>
<blockquote>
<p>Blockquote</p>
</blockquote>
| 2,576
|
<p>I'm writing a program that sends an email out at a client's specific local time. I have a .NET method that takes a timezone & time and destination timezone and returns the time in that timezone. So my method is to select every distinct timezone in the database, check if it is the correct time using the method, then select every client out of the database with that timezone(s). </p>
<p>The query will look like one of these. Keep in mind the order of the result set does not matter, so a union would be fine. Which runs faster, or do they really do the same thing?</p>
<pre><code>SELECT email FROM tClient WHERE timezoneID in (1, 4, 9)
</code></pre>
<p>or</p>
<pre><code>SELECT email FROM tClient WHERE timezoneID = 1
UNION ALL SELECT email FROM tClient WHERE timezoneID = 4
UNION ALL SELECT email FROM tCLIENT WHERE timezoneID = 9
</code></pre>
<p><em>Edit: <strong>timezoneID is a foreign key to tTimezone, a table with primary key timezoneID and varchar(20) field timezoneName.</strong></em>
<em>Also, I went with <code>WHERE IN</code> since I didn't feel like opening up the analyzer.</em></p>
<p><em>Edit 2: <strong>Query processes 200k rows in under 100 ms, so at this point I'm done.</strong></em></p>
|
<h1>Hey! These queries are not equivalent.</h1>
<p>Results will be same only if assuming that one email belongs only to the one time zone. Of course it does however SQL engine doesn't know that and tries to remove duplicities. So the first query should be faster.</p>
<p>Always use UNION ALL, unless you know why you want to use UNION.</p>
<p>If you are not sure what is difference see <a href="https://stackoverflow.com/questions/49925/what-is-the-difference-between-union-and-union-all-in-oracle">this</a> SO question.</p>
<p><em>Note: that yell belongs to <a href="https://stackoverflow.com/revisions/viewmarkup/31874">previous version</a> of question.</em></p>
|
<p>Some DBMS's Query Optimizers modify your query to make it more efficient, so depending on the DBMS your using, you probably shouldn't care.</p>
| 4,481
|
<p>I am using Marlin firmware with a RAMPS board on an Anet A8 printer. </p>
<p>The bed size for the printer is 220 x 220 mm and that is stated in the <code>configuration.h</code> file. When using mesh bed leveling, the nozzle jumps to the first corner on the bed perfectly after setting the x-min to 5.0 but the next two points are off the end of the bed. Here are my settings: </p>
<pre><code>// Travel limits after homing (units are in mm)
#define X_MIN_POS 5.0
#define Y_MIN_POS 0.0
#define Z_MIN_POS 0
#define X_MAX_POS 220
#define Y_MAX_POS 220
#define Z_MAX_POS 240
</code></pre>
<p>What could be my issue? </p>
|
<hr>
<p><em>None of the answers address your question to solve it! The only sensible contribution comes from a comment of <a href="https://3dprinting.stackexchange.com/users/26/tom-van-der-zanden">@TomvanderZanden</a>.</em></p>
<hr>
<p>For the sensor to stay <em>within</em> the limits of the bed (considering the offset of the sensor and the size of the hotend carriage) you need to define where the sensor (plus carriage) may go to (to keep the sensor also on the bed, you also need to define the <a href="/q/8153/">sensor limits</a>). The suggested constants are important in defining the size of the bed and the build volume, but changing them does in fact do not solve your problem. Your problem is that you need to address where the sensor may probe within that specified volume i.e. the sensor probing area.</p>
<p>I use ABL (Auto Bel Leveling) on my Anet A8 using a left-front mounted sensor at position (<code>x = -26 mm</code>; <code>y = -40 mm</code> seen from the nozzle center). In order to have the sensor on the bed area without running into the limits of the carriage, you have to calculate (yourself!) what the dimension of the auto bed leveling area is. This is because the sensor is off set from the nozzle. If the sensor reaches for the whole bed, you need extra space on the axis. To explain this, if your <strong>sensor is at the left front</strong>, as in my case, the amount of extra space you have <strong>left on the right side</strong> of the X carriage will determine how far the carriage may go and thus limits the right probe position. If there is no extra space on the carriage (the safest assumption) you just need to add the sensor offset to the maximum bed size (what the nozzle can reach). E.g. my probe X offset is <code>-26 mm</code>. The maximum probe distance is therefore <code>-26 mm + 220 mm = 194 mm</code>.</p>
<p>This means that you need to set the following constants (amongst the settings to enable ABL; the probe and the type of leveling...) in the configuration.h of your Marlin Firmware installation:</p>
<pre><code>#define X_PROBE_OFFSET_FROM_EXTRUDER -26 // X offset: -left +right [of the nozzle]
#define Y_PROBE_OFFSET_FROM_EXTRUDER -40 // Y offset: -front +behind [the nozzle]
// Set the boundaries for probing (where the probe can reach).
#define LEFT_PROBE_BED_POSITION (0 + 10) // 10
#define RIGHT_PROBE_BED_POSITION (220 - 26 - 10) // 184
#define BACK_PROBE_BED_POSITION (220 - 40 - 10) // 170
#define FRONT_PROBE_BED_POSITION (0 + 10) // 10
</code></pre>
<p>Furthermore the settings you do mention need to be:</p>
<pre><code>// The size of the print bed
#define X_BED_SIZE 220
#define Y_BED_SIZE 220
// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS -33 // Distance from end switch to X = 0 of origin
#define Y_MIN_POS -10 // Distance from end switch to Y = 0 of origin
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
#define Z_MAX_POS 240
</code></pre>
<p>The <code>-33</code> and the <code>-10</code> define how much the nozzle needs to travel from the endstop position to the print origin! This is not necessary to change when using ABL with a sensor (unless you are using a different print head carriage with a different center of the nozzle). Why these values are <code>-33</code> and <code>-10</code> (or values close to this; e.g. for my printer they are <code>-36</code> and <code>-8</code>) is explained in <a href="/a/6376/">this answer</a>.</p>
|
<p>The problem is in the code.
Please use these:</p>
<pre><code>// The size of the print bed
#define X_BED_SIZE 220
#define Y_BED_SIZE 220
// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS 5
#define Y_MIN_POS 0
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
#define Z_MAX_POS 240
</code></pre>
<p>Your problem will be ok.</p>
| 627
|
<p>I have an STL file from thingiverse. The model is of a rectangular lid with an engraving. I would like to print it using two different colors, so that the engraving would be in a different color than the lid base. In the model description, the creator explained that he simply switched the material mid printing.</p>
<p>However, I have a two-extruder printer, and I'd like to utilize it for this printing. What's the easiest way (tool) to select a part of the model and define that it should be printed using a different color?</p>
|
<p>You can also preview the gcode rendering layer by layer (if your software allows this), and insert a toolchange command at the layer where you want to switch colors.</p>
|
<p>With OpenScad i would take the stl, and cut half of it off, but subtracting a block. That result I would save to a.stl. Then i would move the block to the other side of the model and subtract that piece off. The result i would save as b.stl.</p>
<p>My slicer is RepG. It has an option for merging two stl files and printing them dual.</p>
| 635
|
<p>I am trying to port Marlin to my Qidi Tech 1 printer which previously ran Sailfish 7.8. Everything worked fine on the old board, including the temperature sensors.</p>
<p>All cables except for power, LCD, and USB (for flashing) are disconnected. I am still very early on in testing and have yet to plug anything else in.</p>
<p>When uploading Marlin to the board, at first startup I received the following error:</p>
<pre><code>Err: MAXTEMP: E1
PRINTER HALTED
Please Reset
</code></pre>
<p>There may be a problem with my configuration. So I commented out all of the thermal runaway protection options since the bed and extruders aren't yet connected:</p>
<pre><code>//#define THERMAL_PROTECTION_HOTENDS
//#define THERMAL_PROTECTION_BED
//#define THERMAL_PROTECTION_CHAMBER
</code></pre>
<p>I rebuilt, flashed, reset, and the printer is still telling me that E1 is at MAXTEMP.</p>
<p>Why am I still getting this thermal protection message?</p>
<p>I cleared the EEPROM from the LCD menu in Sailfish before flashing.</p>
<p>This board uses an ATmega2560 and I'm using the default fuses (E:FD, H:D8, L:FF, LOCK:CF).</p>
|
<p>#define THERMAL_PROTECTION_HOTENDS is for thermal runaway. When the temperature "should" be climbing or falling at a predicable rate, or holding steady once at running temp.</p>
<p>#define HEATER_0_MAXTEMP defines the maximum temperature Marlin will allow the extruder to get to before initiating a shutdown. This is ALWAYS active for an active extruder (E0) This setting is what will throw MAXTEMP if it is exceeded.</p>
<p>MAXTEMP error when there is no heat on is usually from a short in the thermistor cable.</p>
|
<p><code>MAXTEMP</code> and <code>MINTEMP</code> are <strong>not</strong> part of the <a href="https://3dprinting.stackexchange.com/questions/8466/what-is-thermal-runaway-protection">Thermal Runaway Protection</a>, but separate, equally needed safety nets: Mintemp is meant to make sure that the printer does not try to run cold, Maxtemp is the operational limit of your printer - if the machine tries to go hotter, the firmware denies and shuts down. Maxtemp is usually set to about 235 °C for a lined hotend.</p>
<p>A defective thermosensor can trigger Mintemp and Maxtemp errors by virtue of either shorting or by having no connectivity. The same behavior is exploited in a simple test if the triggers are set: disconnect the leads for unlimited resistance that the board interprets as an absurd high temperature, then short the leads, as 0 Ohm registers as an insanely low temperature.</p>
| 1,770
|
<p>What's the best way in c# to determine is a given QFE/patch has been installed?</p>
|
<p>Use WMI and inspect the <a href="http://msdn.microsoft.com/en-us/library/aa394391.aspx" rel="nofollow noreferrer">Win32_QuickFixEngineering</a> enumeration.</p>
<p>From TechNet:</p>
<pre><code>strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colQuickFixes = objWMIService.ExecQuery _
("Select * from Win32_QuickFixEngineering")
For Each objQuickFix in colQuickFixes
Wscript.Echo "Computer: " & objQuickFix.CSName
Wscript.Echo "Description: " & objQuickFix.Description
Wscript.Echo "Hot Fix ID: " & objQuickFix.HotFixID
Wscript.Echo "Installation Date: " & objQuickFix.InstallDate
Wscript.Echo "Installed By: " & objQuickFix.InstalledBy
Next
</code></pre>
<p><strong>The HotFixID is what you want to examine.</strong></p>
<p>Here's the output on my system:</p>
<pre>
Hot Fix ID: KB941569
Description: Security Update for Windows XP (KB941569)
Hot Fix ID: KB937143-IE7
Description: Security Update for Windows Internet Explorer 7 (KB937143)
Hot Fix ID: KB938127-IE7
Description: Security Update for Windows Internet Explorer 7 (KB938127)
Hot Fix ID: KB939653-IE7
Description: Security Update for Windows Internet Explorer 7 (KB939653)
Hot Fix ID: KB942615-IE7
Description: Security Update for Windows Internet Explorer 7 (KB942615)
Hot Fix ID: KB944533-IE7
Description: Security Update for Windows Internet Explorer 7 (KB944533)
Hot Fix ID: KB947864-IE7
Description: Hotfix for Windows Internet Explorer 7 (KB947864)
Hot Fix ID: KB950759-IE7
Description: Security Update for Windows Internet Explorer 7 (KB950759)
Hot Fix ID: KB953838-IE7
Description: Security Update for Windows Internet Explorer 7 (KB953838)
Hot Fix ID: MSCompPackV1
Description: Microsoft Compression Client Pack 1.0 for Windows XP
Hot Fix ID: KB873339
Description: Windows XP Hotfix - KB873339
Hot Fix ID: KB885835
Description: Windows XP Hotfix - KB885835
Hot Fix ID: KB885836
Description: Windows XP Hotfix - KB885836
Hot Fix ID: KB886185
Description: Windows XP Hotfix - KB886185
Hot Fix ID: KB887472
Description: Windows XP Hotfix - KB887472
Hot Fix ID: KB888302
Description: Windows XP Hotfix - KB888302
Hot Fix ID: KB890046
Description: Security Update for Windows XP (KB890046)
</pre>
|
<p>The most reliable way is to determine which files are impacted by the QFE and use <code>System.Diagnostics.FileVersionInfo.GetVersionInfo(path)</code> on each file and compare the version numbers.</p>
<p>edit: I think there's a way to check the uninstall information in the registry as well, but if the QFE ever becomes part of a Service Pack or rollup package that might report false negatives</p>
| 8,187
|
<p>I'm looking to add a testing suite to my application, however I can't move to the newer testing frameworks for .NET 3.5. </p>
<p>Does anyone have a suggestion about good testing frameworks to use?</p>
|
<p>We use <a href="http://www.mbunit.com/" rel="noreferrer">MbUnit</a> and <a href="http://www.ayende.com/Blog/archive/2007/03/28/Rhino-Mocks-3.0-Released.aspx" rel="noreferrer">Rihno Mocks</a> and they prove to work very well together. When doing TDD you will almost certainly need to do some form of dependency injection, while this can be done manually, its worth looking at an IoC container such as <a href="http://www.castleproject.org/projects/windsor/" rel="noreferrer">Castle Windsor</a>.</p>
<p>It well worth looking at John Paul Bodhood's screen casts to get you started. <a href="http://www.jpboodhoo.com/" rel="noreferrer">JPB's Blog</a></p>
|
<p>NUnit is always a favorite of mine. However if you are using TFS as your source control I suggest you stick with the Microsoft Stack.</p>
| 2,439
|
<p>I'm working on a .net solution that is run completely inside a single network. When users make a change to the system, I want to launch an announcement and have everyone else hear it and act accordingly. Is there a way that we can broadcast out messages like this (like UDP will let you do) while keeping guaranteed delivery (like TCP)?</p>
<p>This is on a small network (30ish clients), if that would make a difference.</p>
|
<p>Almost all games have a need for the fast-reacting properties (and to a lesser extent, the connectionless properties) of UDP and the reliability of TCP. What they do is they build their own reliable protocol on top of UDP. This gives them the ability to just burst packets to whereever and optionally make them reliable, as well.</p>
<p>The reliable packet system is usually a simple retry-until-acknowledged system simpler than TCP but there are protocols which go way beyond what TCP can offer.</p>
<p>Your situation sounds very simple. You'll probably be able to make the cleanest solution yourself - just make every client send back an "I heard you" response and have the server keep trying until it gets it (or gives up).</p>
<p>If you want something more, most custom protocol libraries are in C++, so I am not sure how much use they'll be to you. However, my knowledge here is a few years old - perhaps some protocols have been ported over by now. Hmm... RakNet and enet are two C/C++ libraries that come to mind.</p>
|
<p>do a RDP multicast. </p>
| 5,153
|
<p>I've created a few <code>autorun</code> script files on various USB devices that run <code>bash</code> scripts when they mount. These scripts run "in the background", how do I get them to run in a terminal window? (Like the "Application in Terminal" gnome Launcher type.)</p>
|
<p>Run them as a two stage process with your "autorun" script calling the second script in a new terminal eg</p>
<pre><code>gnome-terminal -e top --title Testing
</code></pre>
<p>Would run the program "top" in a new gnome terminal window with the title "Testing" You can add additional arguments like setting the geometry to determine the size and location of the window checkout the man page for <em>gnome-terminal</em> and the "X" man page for more details</p>
|
<pre><code>xterm -e shellscript.sh
</code></pre>
<p>or (if <code>xterm</code> isn't installed)</p>
<pre><code>gnome-terminal -e shellscript.sh
</code></pre>
<p>or (if you're using kubuntu / kde)</p>
<pre><code>konsole -e shellscript.sh
</code></pre>
| 5,649
|
<p>I was looking at <a href="http://tldp.org/LDP/abs/html/why-shell.html" rel="nofollow noreferrer">http://tldp.org/LDP/abs/html/why-shell.html</a> and was struck by:</p>
<blockquote>
<p>When not to use shell scripts</p>
<p>...</p>
<ul>
<li>Mission-critical applications upon which you are betting the future of the company</li>
</ul>
</blockquote>
<p>Why not?</p>
|
<p>Using shell scripts is fine when you're using their strengths. My company has some class 5 soft switches and the call processing code and the provisioning interface is written in java. Everything else is written in KSH - DB dumps for backups, pruning, log file rotation, and all the automated reporting. I would argue that all those support functions, though not directly related to call-path, are mission critical. Especially the DB interaction. If something went wrong with the DB-interaction code and dumped the call routing tables it could put us out of business.</p>
<p>But nothing ever does go wrong, because shell scripts are the perfect language for stuff like this. They're small, they're well understood, manipulating files is their strength, and they're stable. It's not like KSH09 is going to be a complete rewrite because someone thinks it should compile to byte code, so it's a stable interface. Frankly, the provisioning interface written in Java goes wonky fairly often and the shell scripts have never messed up that I can remember.</p>
|
<p>Scripts are inappropriate for implementing certain mission-critical functions, since they must have both +r and +x permissions to function. Executables need only have +x.</p>
<p>The fact that a script has +r means users might be able to make a copy of the script, edit/subvert it, and execute their edited Cuckoo's-Egg version.</p>
| 3,793
|
<p>I am currently working on a project with specific requirements. A brief overview of these are as follows: </p>
<ul>
<li>Data is retrieved from external webservices</li>
<li>Data is stored in SQL 2005</li>
<li>Data is manipulated via a web GUI</li>
<li>The windows service that communicates with the web services has no coupling with our internal web UI, except via the database.</li>
<li>Communication with the web services needs to be both time-based, and triggered via user intervention on the web UI.</li>
</ul>
<p>The current (pre-pre-production) model for web service communication triggering is via a database table that stores trigger requests generated from the manual intervention. I do not really want to have multiple trigger mechanisms, but would like to be able to populate the database table with triggers based upon the time of the call. As I see it there are two ways to accomplish this.</p>
<p>1) Adapt the trigger table to store two extra parameters. One being "Is this time-based or manually added?" and a nullable field to store the timing details (exact format to be determined). If it is a manaully created trigger, mark it as processed when the trigger has been fired, but not if it is a timed trigger.<br>
<em>or</em><br>
2) Create a second windows service that creates the triggers on-the-fly at timed intervals.</p>
<p>The second option seems like a fudge to me, but the management of option 1 could easily turn into a programming nightmare (how do you know if the last poll of the table returned the event that needs to fire, and how do you then stop it re-triggering on the next poll)</p>
<p>I'd appreciate it if anyone could spare a few minutes to help me decide which route (one of these two, or possibly a third, unlisted one) to take.</p>
|
<p>Why not use a SQL Job instead of the Windows Service? You can encapsulate all of you db "trigger" code in Stored Procedures. Then your UI and SQL Job can call the same Stored Procedures and create the triggers the same way whether it's manually or at a time interval.</p>
|
<p>The way I see it is this.</p>
<p>You have a Windows Service, which is playing the role of a scheduler and in it there are some classes which simply call the webservices and put the data in your databases.</p>
<p>So, you can use these classes directly from the WebUI as well and import the data based on the WebUI trigger.</p>
<p>I don't like the idea of storing a user generated action as a flag (trigger) in the database where some service will poll it (at an interval which is not under the user's control) to execute that action.</p>
<p>You could even convert the whole code into an exe which you can then schedule using the Windows Scheduler. And call the same exe whenever the user triggers the action from the Web UI.</p>
| 2,545
|
<p>For parsing player commands, I've most often used the <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#split%28java.lang.String%29" rel="noreferrer">split</a> method to split a string by delimiters and then to then just figure out the rest by a series of <code>if</code>s or <code>switch</code>es. What are some different ways of parsing strings in Java?</p>
|
<p>I assume you're trying to make the command interface as forgiving as possible. If this is the case, I suggest you use an algorithm similar to this:</p>
<ol>
<li>Read in the string
<ul>
<li>Split the string into tokens</li>
<li>Use a dictionary to convert synonyms to a common form </li>
<li>For example, convert "hit", "punch", "strike", and "kick" all to "hit"</li>
<li>Perform actions on an unordered, inclusive base</li>
<li><strong>Unordered</strong> - "punch the monkey in the face" is the same thing as "the face in the monkey punch"</li>
<li><strong>Inclusive</strong> - If the command is supposed to be "punch the monkey in the face" and they supply "punch monkey", you should check how many commands this matches. If only one command, do this action. It might even be a good idea to have command priorities, and even if there were even matches, it would perform the top action.</li>
</ul></li>
</ol>
|
<p>A simple string tokenizer on spaces should work, but there are really many ways you could do this.</p>
<p>Here is an example using a tokenizer:</p>
<pre><code>String command = "kick person";
StringTokenizer tokens = new StringTokenizer(command);
String action = null;
if (tokens.hasMoreTokens()) {
action = tokens.nextToken();
}
if (action != null) {
doCommand(action, tokens);
}
</code></pre>
<p>Then tokens can be further used for the arguments. This all assumes no spaces are used in the arguments... so you might want to roll your own simple parsing mechanism (like getting the first whitespace and using text before as the action, or using a regular expression if you don't mind the speed hit), just abstract it out so it can be used anywhere.</p>
| 2,509
|
<p>I have a few sites on a shared host that is running Apache 2. I would like to compress the HTML, CSS and Javascript that is delivered to the browser. The host has disabled mod_deflate and mod_gzip, so these options are out. I do have PHP 5 at my disposal, though, so I could use the gzip component of that.</p>
<p>I am currently placing the following in my .htaccess file:</p>
<blockquote>
<p>php_value output_handler ob_gzhandler</p>
</blockquote>
<p>However, this only compresses the HTML and leaves out the CSS and JS.</p>
<p>Is there a reliable way of transparently compressing the output of the CSS and JS without having to change every page? I have searched Google and a number of solutions are presented, but I've yet to get one to work. If anyone could suggest a solution that they know to work, that would be very gratefully received.</p>
<p>Note, <strong>Method 2</strong> in <strong><a href="http://www.fiftyfoureleven.com/weblog/web-development/css/the-definitive-css-gzip-method" rel="noreferrer">The Definitive Post on Gzipping your CSS</a></strong> looks like a good solution, but I couldn't get it working. Has anyone else succeeded using this method?</p>
|
<p>Sorry about the delay - it's a busy week for me.</p>
<p>Assumptions:</p>
<ul>
<li><code>.htaccess</code> is in the same file as <code>compress.php</code></li>
<li>static files to be compressed are in <code>static</code> subdirectory</li>
</ul>
<p>I started my solution from setting the following directives in .htaccess:</p>
<pre><code>RewriteEngine on
RewriteRule ^static/.+\.(js|ico|gif|jpg|jpeg|png|css|swf)$ compress.php [NC]
</code></pre>
<p>It's required that your provider allows you to override <code>mod_rewrite</code> options in <code>.htaccess</code> files.
Then the compress.php file itself can look like this:</p>
<pre><code><?php
$basedir = realpath( dirname($_SERVER['SCRIPT_FILENAME']) );
$file = realpath( $basedir . $_SERVER["REQUEST_URI"] );
if( !file_exists($file) && strpos($file, $basedir) === 0 ) {
header("HTTP/1.0 404 Not Found");
print "File does not exist.";
exit();
}
$components = split('\.', basename($file));
$extension = strtolower( array_pop($components) );
switch($extension)
{
case 'css':
$mime = "text/css";
break;
default:
$mime = "text/plain";
}
header( "Content-Type: " . $mime );
readfile($file);
</code></pre>
<p>You should of course add more mime types to the switch statement. I didn't want to make the solution dependant on the pecl <code>fileinfo</code> extension or any other magical mime type detecting libraries - this is the simplest approach.</p>
<p>As for securing the script - I do a translation to a real path in the file system so no hacked '../../../etc/passwd' or other shellscript file paths don't go through.</p>
<p>That's the</p>
<pre><code>$basedir = realpath( dirname($_SERVER['SCRIPT_FILENAME']) );
$file = realpath( $basedir . $_SERVER["REQUEST_URI"] );
</code></pre>
<p>snippet. Although I'm pretty sure most of the paths that are in other hierarchy than $basedir will get handled by the Apache before they even reach the script.</p>
<p>Also I check if the resulting path is inside the script's directory tree.
Add the headers for cache control as pilif suggested and you should have a working solution to your problem.</p>
|
<p>You can try your luck with <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html" rel="nofollow noreferrer">mod_rewrite</a>.</p>
<p>Create a script that takes a local static file name as input, through e.g. <code>$_SERVER['QUERY_STRING']</code> and outputs it in compressed form. Many providers don't allow configuring <code>mod_rewrite</code> with <code>.htaccess</code> files or have it completely disabled though.</p>
<p>If you haven't used <em>rewrite</em> before, I recommend a good beginner's guide, like probably <a href="http://www.workingwith.me.uk/articles/scripting/mod_rewrite" rel="nofollow noreferrer">this one</a>.
This way you can make the apache redirect all requests for a static file to a php script. style.css will be redirected to <em>compress.php?style.css</em> for instance.</p>
<p>As always be <strong>extremely</strong> cautious on the input you accept or you have an <code>XSS</code> exploit on your hands!</p>
| 7,102
|
<p>I have a list of structs and I want to change one element. For example :</p>
<pre><code>MyList.Add(new MyStruct("john");
MyList.Add(new MyStruct("peter");
</code></pre>
<p>Now I want to change one element:</p>
<pre><code>MyList[1].Name = "bob"
</code></pre>
<p>However, whenever I try and do this I get the following error:</p>
<blockquote>
<p>Cannot modify the return value of
System.Collections.Generic.List.this[int]‘ because it is not
a variable</p>
</blockquote>
<p>If I use a list of classes, the problem doesn't occur.</p>
<p>I guess the answer has to do with structs being a value type.</p>
<p>So, if I have a list of structs should I treat them as <em>read-only</em>? If I need to change elements in a list then I should use classes and not structs?</p>
|
<pre><code>MyList[1] = new MyStruct("bob");
</code></pre>
<p>structs in C# should almost always be designed to be immutable (that is, have no way to change their internal state once they have been created).</p>
<p>In your case, what you want to do is to replace the entire struct in specified array index, not to try to change just a single property or field.</p>
|
<p>As of C#9, I am not aware of any way to pull a struct by reference out of a generic container, including <code>List<T></code>. As Jason Olson's answer said:</p>
<p><em>The real underlying issue is that structs are a Value type, not a Reference type. So when you pull out a "reference" to the struct from the list, it is creating a new copy of the entire struct. So any changes you make on it are changing the copy, not the original version in the list.</em></p>
<p>So, this can be pretty inefficient. SuperCat's answer, even though it is correct, compounds that inefficiency by copying the updated struct back into the list.</p>
<p>If you are interested in maximizing the performance of structs, then use an array instead of <code>List<T></code>. The indexer in an array returns a reference to the struct and does not copy the entire struct out like the <code>List<T></code> indexer. Also, an array is more efficient than <code>List<T></code>.</p>
<p>If you need to grow the array over time, then create a generic class that works like <code>List<T></code>, but uses arrays underneath.</p>
<p>There is an alternative solution. Create a class that incorporates the structure and create public methods to call the methods of that structure for the required functionality. Use a <code>List<T></code> and specify the class for T. The structure may also be returned via a ref returns method or ref property that returns a reference to the structure.</p>
<p>The advantage of this approach is that it can be used with any generic data structure, like <code>Dictionary<TKey, TValue></code>. When pulling a struct out of a <code>Dictionary<TKey, TValue></code>, it also copies the struct to a new instance, just like <code>List<T></code>. I suspect that this is true for all C# generic containers.</p>
<p>Code example:</p>
<pre><code>public struct Mutable
{
private int _x;
public Mutable(int x)
{
_x = x;
}
public int X => _x; // Property
public void IncrementX() { _x++; }
}
public class MutClass
{
public Mutable Mut;
//
public MutClass()
{
Mut = new Mutable(2);
}
public MutClass(int x)
{
Mut = new Mutable(x);
}
public ref Mutable MutRef => ref Mut; // Property
public ref Mutable GetMutStruct()
{
return ref Mut;
}
}
private static void TestClassList()
{
// This test method shows that a list of a class that holds a struct
// may be used to efficiently obtain the struct by reference.
//
var mcList = new List<MutClass>();
var mClass = new MutClass(1);
mcList.Add(mClass);
ref Mutable mutRef = ref mcList[0].MutRef;
// Increment the x value defined in the struct.
mutRef.IncrementX();
// Now verify that the X values match.
if (mutRef.X != mClass.Mut.X)
Console.Error.WriteLine("TestClassList: Error - the X values do not match.");
else
Console.Error.WriteLine("TestClassList: Success - the X values match!");
}
</code></pre>
<p>Output on console window:</p>
<pre><code>TestClassList: Success - the X values match!
</code></pre>
<p>For the following line:</p>
<pre><code>ref Mutable mutRef = ref mcList[0].MutRef;
</code></pre>
<p>I initially and inadvertently left out the ref after the equal sign. The compiler didn't complain, but it did produce a copy of the struct and the test failed when it ran. After adding the ref, it ran correctly.</p>
| 7,461
|
<p>I need to deploy a few files that were checked in sometime ago (can't remember the exact ones), so I'm looking to get a list so I can deploy just those files. What is the svn command to do this?</p>
|
<p><code>svn log</code> has a <code>--verbose</code> parameter. I don't have a repository here to test with, but does that return a list of modified files?</p>
<p>You can also use <code>svn diff -r <revision></code> to retrieve the full change details, which you can parse or read manually to find out which files were changed.</p>
|
<p><code>svn log</code> has a <code>--verbose</code> parameter. I don't have a repository here to test with, but does that return a list of modified files?</p>
<p>You can also use <code>svn diff -r <revision></code> to retrieve the full change details, which you can parse or read manually to find out which files were changed.</p>
| 6,684
|
<p>About two months ago, I added a heated bed to my custom 3D printer in order to print larger ABS parts for my research project. The heated bed (the PCB kind) was not new, but taken from an old printer I had built, but took apart. The bed worked well for a few weeks, but after one print finished, the glass bed above the heater PCB had shattered into several pieces (represented by bed 1 in the image below) and the nozzle was below the level of the bed (I believed it had lowered into the glass causing the breakage. I haven't determined what caused this motion, but it hasn't happened since). Notably, this print was using the heated bed at 90 °C. I chalked this up to a freak accident, and since it did not happen again, just replaced the glass and kept printing.</p>
<p>However, as soon as the heated bed was activated after the replacement, a small crack appeared on the glass and continued to lengthen as time progressed. I took off the glass as soon as possible and prevented it from fully breaking (see bed 2 in the image below. This bed was smaller as I didn't have access to a large enough piece of glass at the time).</p>
<p>At this point, I figured something more than an impact caused the glass to shatter. Since both cracks occurred when the bed was heating or cooling, I figured that thermal shock could potentially be the source of the cracking, and a quick google reinforced this idea. Due to the nature of both cracks (not being straight shards but meandering around the build plate and propagating slowly), they both appeared to have been caused, or at least propagated, by thermal effects.</p>
<p>To try to avoid future cracking, I took care in assembling the third bed. The heater PCB was attached tightly to the glass with Kapton tape and a thin layer of thermal paste was added as an interface layer to try to get an even contact and heat distribution throughout the glass plate. I made sure that the cardboard shims (which press the glass into the clips) were not too compressed, thinking that pressure in the middle of the glass plate from the shims may have accentuated the cracking by putting the top of the glass under tension.</p>
<p>But after a few cycles with this new bed, the same problem appeared (bed 3 below). This time, the cracking was as severe as the first case, but no impact occurred and I was not touching the bed. The bed was heating up to temperature (90 °C) when the cracking occurred. The strangest part is, the file set to print was one I had already printed successfully on the newest bed.</p>
<p>At this point I am at a loss and don't know what to do next. I don't want to make another bed just to have it crack in a few prints, but I need the bed in the near future. Any suggestions to mitigate this problem would be greatly appreciated.</p>
<p><a href="https://i.stack.imgur.com/QRWws.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QRWws.jpg" alt="The three shattered build plates" /></a></p>
<p><strong>Update (currently fixed)</strong></p>
<p>I have replaced the bed with a borosilicate glass sheet, switched the heater to a stick-on 120V silicone heater (the same size as the bed), and added a PEI sheet on top. After about 2 months, it is working great and no cracks have formed. My best guess is that it was a combination of poor glass, possibly with small fractures on the edges already since I cut it myself, and the heater which was too small for the bed. Thanks for the suggestions!</p>
|
<p>The problem is in the design of your bed. Let's start from the basic setup of a glass bed:</p>
<p>The heater element is usually mounted to a metal carrier, which is both spreading the thermal energy over the bed, but also is the structural element that is leveled against the carriage. Atop that comes the glass print surface.</p>
<p>Now, once the heater element is turned on, the aluminium starts to expand and evens the distribution to the glass. As the glass has a much lower thermal expansion coefficient, it doesn't expand as fast. Because of this, the glass surface should <strong>never</strong> be glued to the bed or heater but held in position to the metal bed with a clip. This way the thermal and mechanical stress on the glass sheet is mitigated: The metal bed evens the heat transfer and the clip can move its position on the glass.</p>
|
<p>I would be careful before trying another glass just hoping it will go better, since you haven't found the issue.</p>
<p>I have a PCB heated bed in direct contact (PCB copper traces on top) a 2 mm glass (plain float glass, not hardened and not borosilicate). It never broke and I've been using it intensely for the last few months. My heated bed is very flat (even if it bends with the heat) and also clean: no residues which can push against the glass. Clean yours properly!</p>
<p>Also, how powerful is your heated bed? mine is about 120 W for 12x12 cm. If yours is too powerful, maybe you could slow down the heating by reducing the maximum duty cycle (you need maybe to recompile Marlin) or by increasing the temperature 10 °C at time. </p>
<p>I also see that you use mirrors, maybe recovered from other applications. I bought the glass new, which is very cheap but it is also guaranteed defect free. Maybe yours had issues already.</p>
| 1,672
|
<p>Here's the problem, you include multiple assemblies and add 'using namespaceX' at the top of your code file.<br>
Now you want to create a class or use a symbol which is defined in multiple namespaces,
e.g. <code>System.Windows.Controls.Image</code> & <code>System.Drawing.Image</code></p>
<p>Now unless you use the fully qualified name, there will be a crib/build error due to ambiguity inspite of the right 'using' declarations at the top. What is the way out here?</p>
<p><em>(Another knowledge base post.. I found the answer after about 10 minutes of searching because I didn't know the right keyword to search for)</em></p>
|
<p>Use alias</p>
<pre><code>using System.Windows.Controls;
using Drawing = System.Drawing;
...
Image img = ... //System.Windows.Controls.Image
Drawing.Image img2 = ... //System.Drawing.Image
</code></pre>
<p><a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-directive" rel="nofollow noreferrer">C# using directive</a></p>
|
<p>This page has a very good writeup on namespaces and the using-statement:</p>
<p><a href="http://www.blackwasp.co.uk/Namespaces.aspx" rel="noreferrer">http://www.blackwasp.co.uk/Namespaces.aspx</a></p>
<p>You want to read the part about "Creating Aliases" that will allow you to make an alias for one or both of the name spaces and reference them with that like this:</p>
<pre><code>using ControlImage = System.Windows.Controls.Image;
using System.Drawing.Image;
ControlImage.Image myImage = new ControlImage.Image();
myImage.Width = 200;
</code></pre>
| 8,643
|
<p>How do you manage deploying InfoPath forms to different sharepoint servers? Is there a better way to deal all the data connections being site-specific without opening the forms, editing the data connections and republishing for each environment?</p>
|
<p>If I understand your scenario correctly:</p>
<p>You have an InfoPath form, with data connections that submit your data.
You wish to deploy this form on multiple SharePoint Servers and have those data connections submit data to the currently deployed server.</p>
<p>You can't really get around needing to do work on every SharePoint server that you would want to deploy the form to. However, you can get around needing to modify the InfoPath Form Template.</p>
<p>If you use the SharePoint Data Connection Library (DCL), and create a UDC file from your data connection, on every SharePoint Server that you would want to use...then your InfoPath Template can just talk to the UDC file.</p>
<p>Here's a link to an article about integrating InfoPath with SharePoint's DCL:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb267335.aspx" rel="nofollow noreferrer" title="Integrating InfoPath 2007 with the Data Connection Library">http://msdn.microsoft.com/en-us/library/bb267335.aspx</a></p>
|
<p>By site-specific, do you mean that the data connections in your forms refer to the server the form is deployed to? If that's the case perhaps you could tweak your connections to use localhost instead of the server name for the hostname part of the data connection URLs.</p>
| 4,076
|
<p>What's the instruction to cause a hard-break in Xcode? For example under Visual Studio I could do '_asm int 3' or 'DebugBreak()'. Under some GCC implementations it's asm("break 0") or asm("trap").</p>
<p>I've tried various combos under Xcode without any luck. (inline assembler works fine so it's not a syntax issue).</p>
<p>For reference this is for an assert macro. I don't want to use the definitions in assert.h both for portability, and because they appear to do an abort() in the version XCode provides.</p>
<hr>
<p>John - Super, cheers. For reference the int 3 syntax is the one required for Intel Macs and iPhone.</p>
<hr>
<p>Chris - Thanks for your comment but there are many reasons to avoid the standard assert() function for codebases ported to different platforms. If you've gone to the trouble of rolling your own assert it's usually because you have additional functionality (logging, stack unwinding, user-interaction) that you wish to retain.</p>
<p>Your suggestion of attempting to replace the hander via an implementation of '__assert" or similar is not going to be portable. The standard 'assert' is usually a macro and while it may map to __assert on the Mac it doesn't on other platforms.</p>
|
<p><a href="http://developer.apple.com/documentation/DeveloperTools/Conceptual/XcodeProjectManagement/090_Running_Programs/chapter_11_section_3.html" rel="noreferrer">http://developer.apple.com/documentation/DeveloperTools/Conceptual/XcodeProjectManagement/090_Running_Programs/chapter_11_section_3.html</a></p>
<pre><code>asm {trap} ; Halts a program running on PPC32 or PPC64.
__asm {int 3} ; Halts a program running on IA-32.
</code></pre>
|
<p>There is also the following function that is available as cross platform straight Halt() alternative:</p>
<pre><code>#include <stdlib.h>
void abort(void);
</code></pre>
<p>We use it in our cross platform engine for the iPhone implementation in case of fatal asserts. Cross platform across Nintendo DS/Wii/XBOX 360/iOS etc...</p>
| 5,794
|
<p>When defining a method on a class in Python, it looks something like this:</p>
<pre><code>class MyClass(object):
def __init__(self, x, y):
self.x = x
self.y = y
</code></pre>
<p>But in some other languages, such as C#, you have a reference to the object that the method is bound to with the "this" keyword without declaring it as an argument in the method prototype. </p>
<p>Was this an intentional language design decision in Python or are there some implementation details that require the passing of "self" as an argument?</p>
|
<p>I like to quote Peters' Zen of Python. "Explicit is better than implicit."</p>
<p>In Java and C++, '<code>this.</code>' can be deduced, except when you have variable names that make it impossible to deduce. So you sometimes need it and sometimes don't.</p>
<p>Python elects to make things like this explicit rather than based on a rule. </p>
<p>Additionally, since nothing is implied or assumed, parts of the implementation are exposed. <code>self.__class__</code>, <code>self.__dict__</code> and other "internal" structures are available in an obvious way.</p>
|
<p>There is also another very simple answer: according to the <a href="http://www.python.org/dev/peps/pep-0020/" rel="nofollow noreferrer">zen of python</a>, "explicit is better than implicit".</p>
| 9,377
|
<p>I am using sp_send_dbmail in SQL2005 to send an email with the results in an attachment. When the attachment is sent it is UCS-2 Encoded, I want it to be ANSI or UTF-8.</p>
<p>Here is the SQL</p>
<pre><code>EXEC msdb.dbo.sp_send_dbmail
@recipients = 'temp@example.com'
, @query = 'DECLARE @string_to_trim varchar(60);SET @string_to_trim = ''1234''; select rtrim(@string_to_trim), ''tom'''
, @query_result_header=0
, @subject = 'see attach'
, @body= 'temp body'
, @profile_name= N'wksql01tAdmin'
, @body_format = 'HTML'
,@query_result_separator = ','
,@query_attachment_filename = 'results.csv'
,@query_no_truncate = '0'
,@attach_query_result_as_file = 1
</code></pre>
<p>I have seen some comments on the internet that this is fixed with sql2005 SP2, but do not find it to be the case.</p>
|
<p>After some research on SQL Server 2008 R2:</p>
<ol>
<li><p>Add to <code>sp_send_dbmail</code>:</p>
<pre><code>@ANSI_Attachment BIT = 0
WITH EXECUTE AS 'dbo'
</code></pre></li>
<li><p>Replace</p>
<pre><code>IF(@AttachmentsExist = 1)
BEGIN
.......
END
</code></pre>
<p>with:</p>
<pre><code>IF(@AttachmentsExist = 1)
BEGIN
if (@ANSI_Attachment = 1)
begin
--Copy temp attachments to sysmail_attachments
INSERT INTO sysmail_attachments(mailitem_id, filename, filesize, attachment)
SELECT @mailitem_id, filename, filesize,
convert(varbinary(max),
substring( -- remove BOM mark from unicode
convert(varchar(max), CONVERT (nvarchar(max), attachment)),
2, DATALENGTH(attachment)/2
)
)
FROM sysmail_attachments_transfer
WHERE uid = @temp_table_uid
end else begin
--Copy temp attachments to sysmail_attachments
INSERT INTO sysmail_attachments(mailitem_id, filename, filesize, attachment)
SELECT @mailitem_id, filename, filesize, attachment
FROM sysmail_attachments_transfer
WHERE uid = @temp_table_uid
end
END
</code></pre></li>
</ol>
|
<p>In order to have the file be ANSI/UTF-8 </p>
<p>alter the sp_send_dbmail that lives in the <code>msdb</code> with this line along with the other variables: <code>@ANSI_Attachment BIT = 0</code>
i.e. </p>
<pre><code>@mailitem_id INT = NULL OUTPUT,
@ANSI_Attachment BIT = 0
WITH EXECUTE AS 'dbo'
</code></pre>
<p>and then add this line to your call to sp_send_dbmail:</p>
<pre><code>@ansi_attachment = 1
</code></pre>
<p>then it should give you an ansi attachment instead of unicode.</p>
| 6,425
|
<p>I'm new to 3D printing and have bought a resin printer.</p>
<p>Cleaning with <strong>Isopropol Alcohol</strong> seems to be the rage, however I think this is unaware of cost savings. It appears <strong>methylated spirits</strong> is ok and is 25% the cost of Isopropol Alcohol.</p>
<p>I'm now down to wondering if I should buy methylated spirits or <strong>turpentine</strong> (I ruled out <strong>kerosene</strong> as too flammable)?
I'm leaning towards methylated spirits, however would like input.</p>
<p><strong>Factors</strong> I'm curious about:</p>
<ol>
<li>Cost: same for methylated spirits and turpentine.</li>
<li>Evaporation/solvency: ?</li>
<li>Flammability: ?</li>
<li>Poisonous levels: ?</li>
<li>Resin object cleaning effect: ?</li>
<li>Skin effects: ?</li>
<li>Smell: ?</li>
</ol>
<p>I checked a few <a href="https://www.sydneysolvents.com.au/mineral-turpentine" rel="nofollow noreferrer">sources</a>.</p>
|
<p>I would personally stick to isopropanol. Be aware that 3D printing is a very expensive hobby, but health wise this is a better option. Methylated spirits can quickly become dangerous, and often can burn with a close to invisible flame, meaning that you may not even see if it is burning. Also, the fumes can quickly become dangerous, whereas after years of dealing with isopropanol I have noticed no ill effects. Cost should not be your primary concern, health of you and your printer should be.</p>
|
<p>Are you for real?</p>
<p>Isopropyl alcohol is less dangerous to your health than ethanol with a touch of denaturant?</p>
<p>Seriously read the MSDS sheets for the products and know what's in them before you say stuff.</p>
<p>The amount of MEK or MIBK is so small.</p>
<p>Some and not many methylated spirits have a small fraction of methanol but so little that it is safe to work with.</p>
<p>Why would they sell methylated spirits in the supermarket and not IPA if it was more dangerous?</p>
<p>Personally, I would read the SDS/MSDS sheet for the metho if you are worried and find one that is only denatured with Bitrex but to be honest I doubt there will be a health issue any more so than IPA with any of them.</p>
| 1,584
|
<p>We have a two-screen DirectX application that previously ran at a consistent 60 FPS (the monitors' sync rate) using a NVIDIA 8400GS (256MB). However, when we swapped out the card for one with 512 MB of RAM the frame rate struggles to get above 40 FPS. (It only gets this high because we're using triple-buffering.) The two cards are from the same manufacturer (PNY). All other things are equal, this is a Windows XP Embedded application and we started from a fresh image for each card. The driver version number is 169.21.</p>
<p>The application is all 2D. I.E. just a bunch of textured quads and a whole lot of pre-rendered graphics (hence the need to upgrade the card's memory). We also have compressed animations which the CPU decodes on the fly - this involves a texture lock. The locks take forever but I've also tried having a separate system memory texture for the CPU to update and then updating the rendered texture using the device's UpdateTexture method. No overall difference in performance.</p>
<p>Although I've read through every FAQ I can find on the internet about DirectX performance, this is still the first time I've worked on a DirectX project so any arcane bits of knowledge you have would be useful. :)</p>
<p>One other thing whilst I'm on the subject; when calling Present on the swap chains it seems DirectX waits for the present to complete regardless of the fact that I'm using D3DPRESENT_DONOTWAIT in both present parameters (PresentationInterval) and the flags of the call itself. Because this is a two-screen application this is a problem as the two monitors do not appear to be genlocked, I'm working around it by running the Present calls through a threadpool. What could the underlying cause of this be?</p>
|
<p>Are the cards exactly the same (both GeForce 8400GS), and only the memory size differ? Quite often with different memory sizes come slightly different clock rates (i.e. your card with more memory might use slower memory!).</p>
<p>So the first thing to check would be GPU core & memory clock rates, using something like <a href="http://www.techpowerup.com/gpuz/" rel="nofollow noreferrer">GPU-Z</a>.</p>
|
<p>It's an easy test to see if the surface lock is the problem, just comment out the texture update and see if the framerate returns to 60hz. Unfortunately, writing to a locked surface and updating the resource kills perfomance, always has. Are you using mipmaps with the textures? I know DX9 added automatic generation of mipmaps, could be taking up a lot of time to generate those. If your constantly locking the same resource each frame, you could also try creating a pool of textures, kinda like triple-buffering except with textures. You would let the render use one texture, and on the next update you pick the next available texture in the pool that's not being used in to render. Unless of course your memory constrained or your only making diffs to the animated texture.</p>
| 8,035
|
<p>I'm still trying to get my head around LINQ and accessing a SQL Database.</p>
<p>I was always taught that you should only have execute permissions of stored procedures to your data.</p>
<p>You should never have select / insert / update / delete.</p>
<p>(This is because of performance and security)</p>
<p>To get the data out of LINQ you obviously need select permissions. I know you can use stored procs with LINQ, but since I can't do joins what's the point?</p>
<p>Have I missed something???</p>
|
<p>1) We're programmers, not DBA fascists. If your requirements state that the database must be locked down 100%, Linq is not for you. I'm not a DBA, so I believe that most of the performance/security hype is just that. Linq is for me.</p>
<p>2) You can do joins with linq.</p>
<p><em>@Philippe</em>: Linq automatically transforms evaluations into query parameters, so it provides some sql injection protection. However, you still have to closely evaluate your requirements to determine how much security you need and at what levels. Linq makes dealing with the database much easier, but it makes it easier to put secuirty design on the back burner, which is a bad thing. </p>
|
<p>I'm very much in agreement with Jeff Atwood on the "Stored Procedures vs. Inline SQL/LINQ" issue: <a href="https://blog.codinghorror.com/who-needs-stored-procedures-anyways/" rel="nofollow noreferrer">Who Needs Stored Procedures, Anyways?</a>.</p>
<p>I'm confused as to why you'd even want to perform a JOIN if you're in the SPROCs-for-everything crowd; shouldn't you wrap that JOIN up into another SPROC?</p>
<p>As Will said, LINQ wasn't designed for the kind of DB use you're talking about; it was designed to give us statically-typed inline SQL. You could, however, still control access through user permissions if you use LINQ to SQL.</p>
| 7,216
|
<p>I am looking for a simple unpatented one-way encryption algorithm, preferably in c.
I would like to use it to validate passwords.</p>
|
<p><a href="http://en.wikipedia.org/wiki/SHA-1" rel="nofollow noreferrer">SHA-1 and the rest of its family</a> were patented by the US government which "has released the patent under a royalty free license". Many public-domain implementations <a href="http://www.google.ca/search?q=sha+c+implementation" rel="nofollow noreferrer">may be found through Google</a>. <code>:-)</code></p>
|
<p>MD5 has suited me fine so far.</p>
| 9,497
|
<p>I coded a Mancala game in Java for a college class this past spring, and I used the <a href="https://www.eclipse.org" rel="nofollow noreferrer" title="Eclipse">Eclipse</a> IDE to write it. One of the great (and fairly simple) visual aids in Eclipse is if you select a particular token, say a declared variable, then the IDE will automatically highlight all other references to that token on your screen. <a href="https://notepad-plus-plus.org/" rel="nofollow noreferrer">Notepad++</a>, my preferred Notepad replacement, also does this.</p>
<p>Another neat and similar feature in Eclipse was the vertical "error bar" to the right of your code (not sure what to call it). It display little red boxes for all of the syntax errors in your document, yellow boxes for warnings like "variable declared but not used", and if you select a word, boxes appear in the bar for each occurrence of the word in the document.</p>
<p>A screenshot of these features in action:
<img src="https://i.stack.imgur.com/XZeTy.jpg" alt="screenshot"></p>
<p>After a half hour of searching, I've determined that Visual Studio cannot do this on its own, so my question is: does anyone know of any add-ins for 2005 or 2008 that can provide either one of the aforementioned features?</p>
<p>Being able to highlight the current line your cursor is on would be nice too. I believe the add-in ReSharper can do this, but I'd prefer to use a free add-in rather than purchase one.</p>
|
<p>In a different question on SO (<a href="https://stackoverflow.com/questions/41908/customizing-visual-studio">link</a>), someone mentioned the VS 2005 / VS 2008 add-in "RockScroll". It seems to provide the "error bar" feature I was inquiring about in my question above.</p>
<p><a href="http://www.hanselman.com/blog/IntroducingRockScroll.aspx" rel="nofollow noreferrer">RockScroll</a></p>
<p>EDIT: RockScroll also does the identical token highlighting that I was looking for! Great!</p>
|
<p>The "error bar" functionality is provided in JetBrains ReSharper. I'm not sure if it does highlighting of references to the currently selected identifier.</p>
| 5,243
|
<p>Can I use a metal filament such as Copper, Zinc Alloy, Silver filaments on M3D Micro? <em>The Pro hasn't come out yet but I assume it would if the Micro can since the Pro is suppose to be the improvement edition.</em></p>
<p>An example of a metal filament that I found is this <a href="http://rads.stackoverflow.com/amzn/click/B00T76GLWE" rel="noreferrer">Silver PLA 1.75mm Filament</a>. Here's one for <a href="http://www.sainsmart.com/sainsmart-plated-copper-pla-1-75mm-filament-1kg-2-2lb-for-3d-printers.html?gclid=CjwKEAjwtLO7BRDax4-I4_6G71USJAA6FjN1VDu_t4Co-u949PfHWjVL0x6BD-I-4ZLRUEij0bhWLhoCSSbw_wcB" rel="noreferrer">Cooper PLA 1.75mm Filament</a>.</p>
<p>I would like to make small sculptures or bracelet beads/charms, and whatever else I could think of making using metal. And, I'm asking because I'm new to 3d printing, I want to learn how to work with a 3d printer and M3D is very affordable for me. <em>So I'm making sure before I buy</em>. Note that I've emailed M3D twice and I didn't get any reply. </p>
<p>If not M3D, can any other 3D Printer comparable to M3D do this? The MBot Mini, maybe?</p>
|
<p>Most 3D printers that use non-proprietary filament <em>can</em> print exotic filaments, such as the ones you mention. One thing to be aware of, though, is that some of these filaments <a href="http://makezine.com/2015/09/11/carbon-fiber-filament-ruins-nozzles/" rel="noreferrer">wear down the nozzle</a> far more quickly than ordinary PLA, and therefore should be used with <a href="http://e3d-online.com/V6-nozzle-hardened-steel-3mmx0.4mm" rel="noreferrer">reinforced nozzles</a> (unless you have extra nozzles to spare). Carbon fibre and metallic filaments are generally known to increase nozzle wear, while softer alloys such as wood and bamboo generally are less abrasive.</p>
<p>A quick google search reveals that many people have used non-proprietary filament on the M3D Micro successfully, but be aware that using such filaments is not covered by your <a href="https://printm3d.com/terms-of-use" rel="noreferrer">warranty</a>. If you are going to use abrasive filaments with your Micro, I would check that M3D allows you to replace the nozzle first.</p>
|
<p>It is my understanding that the metals are so fine and mixed in with other ingredients that you cannot tell that there is metal at all. But looks like its 100% metals.</p>
| 329
|
<p>I love PrusaSlicer but I am having a problem.
As you can see in the picture the head makes movements that seem useless<a href="https://i.stack.imgur.com/1CLrS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1CLrS.png" alt="Previsualisation" /></a></p>
<p>(blue lines that come out of the print in the corners and go back instantly in the object) and these make damages to the object during the print.</p>
<p><a href="https://i.stack.imgur.com/UOA3y.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UOA3y.jpg" alt="During the print" /></a></p>
<p>How to configure PrusaSlicer so that doesn't happen again ?
Thank you.</p>
<p>Edit : Thank you for your answers but I think we have a misunderstanding. I already have z-hop activated, the real problem is that the slicer makes the head move outside the print (that's what you can see on the first screenshot, every blue line crossing the print shouldn't exist).
I actually don't have this problem with curaengine on repetierhost as you can see in the following screenshot :</p>
<p><a href="https://i.stack.imgur.com/c0b73.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c0b73.png" alt="enter image description here" /></a></p>
|
<p>I found the solution :
It was the option "avoid crossing perimeters" that seems to do exactly the contrary of what it means.
Thank you all for your answers.</p>
|
<p>Enable Z-Hop. I don't know what the actual parameter is called but it should say something like "Z-Hop".</p>
| 1,759
|
<p>I recently had a problem with the z-axis of my printer. To resolve the issue with the Z axis not moving I remove the left polished rod. Am I able to use the printer with just one smooth rod?</p>
|
<p>First a resounding no. Not a good idea. Are you saying it works now that you have removed the smooth rod?</p>
<p>That tells me for sure your issue was Binding. Which is a tricky problem to solve. Binding usually happens when your carriage is not level. Take a bubble leveler and verify.</p>
<p>Another time it happens is when your Acceleration / Jerk settings are too high. Try reducing the Acceleration for Z in the firmware.</p>
<p>Another possibility is your rod is Bent. Take the rod on a flat surface. Inspect it as you roll it around. Do the same with the other rod. If it bows and is not completely flat, then you will need to replace it.</p>
<p>Last is make sure your printers frame is put together. If it is causing the rod to bend as it is not aligned right then you should try to see if you can fix it and contact the seller.</p>
<p>Technically you can run without the second rod. Maybe. I do not advise. It is sort of like cutting off a leg because you have a cramp. It will hurt your overall quality and it is better to just resolve the issue. </p>
|
<p>No, this is not a good idea. Your X axis is now free to rotate by a few degrees around the remaining Z rod. Parts may appear to print OK, but depending on the dynamics of a print, you will see offsets between layers. You need to resolve the issues with your Z-axis.
These questions, <a href="https://3dprinting.stackexchange.com/questions/729/z-axis-hard-to-move-in-some-areas-what-could-be-faults-how-to-improve">z-axis hard to move in some areas - what could be faults, how to improve?</a> and <a href="https://3dprinting.stackexchange.com/questions/3065/z-axis-steppers-and-bed-alignment-problems">Z-axis steppers and bed alignment problems</a> have some answers that are probably relevant.</p>
<p>Obviously, you can use this limited setup to print new parts if you need them, but you'll be lucky to make anything accurate enough.</p>
| 470
|
<p>VB 6.0 does not have any global handler.To catch runtime errors,we need to add a handler in each method where we feel an error can occur.But, still some places might be left out.So,we end up getting runtime errors.Adding error handler in all the methods of an application,the only way?</p>
|
<p>No there is no way to add a global error handler in VB6. However, you do not need to add an error handler in every method. You only really need to add an error handler in every event handler. E.g. Every click event,load event, etc</p>
|
<p>on error resume next - is kinda close but its been a while.
you might want to look up any caveats</p>
| 9,072
|
<p>I want to make some prints of pressure resistants. I am currently trying to print a simple cylinder to find the best parameters to make my prints airtight (by airtight I mean, it needs to resist to 10 bar).</p>
<p>Here is the test model that I have made for this:</p>
<p><a href="https://i.stack.imgur.com/IQyNO.png" rel="nofollow noreferrer" title="Screenshot of a model for a pressure resistant"><img src="https://i.stack.imgur.com/IQyNO.png" alt="Screenshot of a model for a pressure resistant" title="Screenshot of a model for a pressure resistant" /></a></p>
<p>Here are the parameters that I have changed in Cura:</p>
<ul>
<li>layer height: 0.1 mm</li>
<li>infill : 100 %</li>
<li>print temp: 250 °C (high temp to make the layers stick between them)</li>
<li>wall line count: 5</li>
<li>infill overlap: 40 %</li>
<li>flow: 115 %</li>
</ul>
<p>But all these changes in Cura don't give good results for ABS. It's not even airtight at 2.5 bar:</p>
<p><a href="https://i.stack.imgur.com/rt0B8.jpg" rel="nofollow noreferrer" title="Photo of pressure resistant under water producing bubbles; not airtight"><img src="https://i.stack.imgur.com/rt0B8.jpg" alt="Photo of pressure resistant under water producing bubbles; not airtight" title="Photo of pressure resistant under water producing bubbles; not airtight" /></a></p>
<p>And here is a mid-cut of the print :</p>
<p><a href="https://i.stack.imgur.com/EkNP6.jpg" rel="nofollow noreferrer" title="Photo of pressure resistant cut in two to show internal structure"><img src="https://i.stack.imgur.com/EkNP6.jpg" alt="Photo of pressure resistant cut in two to show internal structure" title="Photo of pressure resistant cut in two to show internal structure" /></a></p>
<p>Do you have any ideas/suggestions to have better results? Can it be from the ABS itself? There is a sort of white powder between the layers, is this normal for ABS? Should I try using PETG? What could I change in my parameters?</p>
|
<p>This is going to be hard. Even holding a vacuum is hard (I've tried it and not succeeded). I'm not sure what the mechanism of air molecules getting thru the print is - whether it's defects in inter-layer bonding, defects at seams, imperfect mating with the fitting, or even permeability of the plastic itself. It might not actually be existing flaws in the print, but rather the high pressure being a stronger force than the bonded layers can withstand, essentially ripping the layers apart from the weakest point until the pressure can discharge through the opening produced.</p>
<p>If using ABS, you might try an acetone bath followed by a long period of trying or use of vacuum chamber to quickly remove the solvent, if you can stand some possible part deformation. This would tend to fill any gaps. Coating with low-viscosity CA glue (Loctite 420 or equivalent) might be a better version of this approach, as the solvent will both attack the ABS and deliver fill material.</p>
<p>In principle PET (maybe also PETG, but PET is preferable anyway if you can get it) should be a suitable material for pressure vessels, as it's what's used for soda bottles at comparable pressure, but those are blown from a single piece, not fused together with seams.</p>
<p>At some point I will attempt this again, and will update my answer if I have any findings that contribute to your question.</p>
|
<h2>Not without postprocessing</h2>
<p>FDM is pretty much welding plastic to plastic. Many many layers. Each of them is a potential breaking point, a corner for stress to arise and break the print.</p>
<h2>Easy with a hollow body</h2>
<p>Printing a hollow item that can be filled with resin is comparatively easy. Once filled with a monolithic curing resin (epoxy), that will take the pressure much better and seal it fully.</p>
| 2,198
|
<p>I have a bunch of perfmon files that have captured information over a period of time. Whats the best tool to crunch this information? Idealy I'd like to be able to see avg stats per hour for the object counters that have been monitored.</p>
|
<p>Perhaps look into using <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en" rel="nofollow noreferrer">LogParser</a>.
It depends on how the info was logged (Perfmon doesn't lack flexibility)</p>
<p>If they're CSV you can even use the ODBC Text drivers and run queries against them! </p>
<p>(performance would be 'intriguing')</p>
<p>And here's the obligatory link to a <a href="http://blog.codinghorror.com/microsoft-logparser/" rel="nofollow noreferrer">CodingHorror article</a> on the topic ;-)</p>
|
<p>Take a look at SmartMon (www.perfmonanalysis.com). It analyzes Perfmon data in CSV and SQL Server databases.</p>
| 4,676
|
<p>Every now and then in a high volume .NET application, you might see this exception when you try to execute a query:</p>
<blockquote>
<p>System.Data.SqlClient.SqlException: A transport-level error has
occurred when sending the request to the server.</p>
</blockquote>
<p>According to my research, this is something that "just happens" and not much can be done to prevent it. It does not happen as a result of a bad query, and generally cannot be duplicated. It just crops up maybe once every few days in a busy OLTP system when the TCP connection to the database goes bad for some reason.</p>
<p>I am forced to detect this error by parsing the exception message, and then retrying the entire operation from scratch, to include using a new connection. None of that is pretty.</p>
<p>Anybody have any alternate solutions?</p>
|
<p>I posted <a href="https://stackoverflow.com/questions/154897/what-do-you-do-if-you-cannot-resolve-a-bug#155077">an answer on another question</a> on another topic that might have some use here. That answer involved SMB connections, not SQL. However it was identical in that it involved a low-level transport error.</p>
<p>What we found was that in a heavy load situation, it was fairly easy for the remote server to time out connections <em>at the TCP layer</em> simply because the server was busy. Part of the reason was the defaults for how many times TCP will retransmit data on Windows weren't appropriate for our situation.</p>
<p>Take a look at the <a href="http://support.microsoft.com/kb/314053" rel="nofollow noreferrer">registry settings for tuning TCP/IP</a> on Windows. In particular you want to look at <strong>TcpMaxDataRetransmissions</strong> and maybe <strong>TcpMaxConnectRetransmissions</strong>. These default to 5 and 2 respectively, try upping them a little bit on the client system and duplicate the load situation.</p>
<p>Don't go crazy! TCP doubles the timeout with each successive retransmission, so the timeout behavior for bad connections can go exponential on you if you increase these too much. As I recall upping <strong>TcpMaxDataRetransmissions</strong> to 6 or 7 solved our problem in the vast majority of cases.</p>
|
<p>You should also check hardware connectivity to the database.</p>
<p>Perhaps this thread will be helpful:
<a href="http://channel9.msdn.com/forums/TechOff/234271-Conenction-forcibly-closed-SQL-2005/" rel="nofollow noreferrer">http://channel9.msdn.com/forums/TechOff/234271-Conenction-forcibly-closed-SQL-2005/</a></p>
| 3,731
|
<p>We need to add WorkFlow to our Spring managed application. Does anyone have any useful experience in using any of the myriad of OSS Work Flow solutions? Which one is best? Which one integrates with Spring best? Which ones should we avoid?</p>
|
<p>If you only need some simple process orchestration, Spring's own <a href="http://springframework.org/webflow" rel="nofollow noreferrer">Web Flow</a>, despite its name can serve as a orchestration task manager. If you need to preserve state for several days then you will need to become an 'early adopter' of one of the open-source projects. You may want to look at <a href="http://www.eclipse.org/bpel/" rel="nofollow noreferrer">Eclipse's BPEL project</a>. </p>
<p>My hunch is that once a clearer picture of the BPEL/BPM/Workflow space emerges you will see Spring provide an abstraction layer the same way they have for JDBC, Transactions, ORM frameworks etc... </p>
|
<p>We're looking at Drools/Guvnor, possibly integrated with jBPM (as in this <a href="http://www.firstpartners.net/blog/technology/java/2008/06/05/jboss-business-rules-and-jbpm-workflow-presentation-dublin/" rel="nofollow noreferrer">presentation</a>), to add a workflow engine to our Spring/Java EE app, but we're still in the very early phases of trying it out.</p>
| 3,044
|
<p>The default <strong>asp.net</strong> membership provider uses a <code>.mdf</code> sql server database file in the <code>app_code</code> database.<br>
How scalable is this in terms of calling a flat file database instead of running it in a standard sql environment?<br>
Is this recommended only for small/medium traffic sites? </p>
|
<p>It's a reasonable trade off for any site that can run on one server. It's fairly reasonable for small to medium traffic sites.</p>
<p>When you grow to a point of a web farm, then you'll be better off with a separate server. Also, depending on how database dependent your application is, you may find better performance handing off SQL queries to a totally different server/processor to handle the database side.</p>
|
<p>I wouldn't recommend this for anything but a "learning" project.</p>
<p>For any real application, regardless of size, you don't know what type of "next feature" you will add. You want to have a real independent database in which you can delegate functionality to, in which you can set jobs to run independently, sit on a different HD, maybe splitting it into a different VM? </p>
<p>You can use SQL Express and still be "free', and it is better to do this seperation before the site grows and the DB is harder to move.</p>
| 7,961
|
<p>Is there a simple way in Perl that will allow me to determine if a given variable is numeric? Something along the lines of:</p>
<pre><code>if (is_number($x))
{ ... }
</code></pre>
<p>would be ideal. A technique that won't throw warnings when the <code>-w</code> switch is being used is certainly preferred.</p>
|
<p>Use <code>Scalar::Util::looks_like_number()</code> which uses the internal Perl C API's looks_like_number() function, which is probably the most efficient way to do this.
Note that the strings "inf" and "infinity" are treated as numbers.</p>
<h2>Example:</h2>
<pre><code>#!/usr/bin/perl
use warnings;
use strict;
use Scalar::Util qw(looks_like_number);
my @exprs = qw(1 5.25 0.001 1.3e8 foo bar 1dd inf infinity);
foreach my $expr (@exprs) {
print "$expr is", looks_like_number($expr) ? '' : ' not', " a number\n";
}
</code></pre>
<p>Gives this output:</p>
<pre><code>1 is a number
5.25 is a number
0.001 is a number
1.3e8 is a number
foo is not a number
bar is not a number
1dd is not a number
inf is a number
infinity is a number
</code></pre>
<h2>See also:</h2>
<ul>
<li><a href="http://perldoc.perl.org/Scalar/Util.html" rel="noreferrer">perldoc Scalar::Util</a></li>
<li><a href="http://perldoc.perl.org/perlapi.html#SV-Body-Allocation" rel="noreferrer">perldoc perlapi</a> for <code>looks_like_number</code></li>
</ul>
|
<p>if ( defined $x && $x !~ m/\D/ ) {}
or
$x = 0 if ! $x;
if ( $x !~ m/\D/) {}</p>
<p>This is a slight variation on Veekay's answer but let me explain my reasoning for the change.</p>
<p>Performing a regex on an undefined value will cause error spew and will cause the code to exit in many if not most environments. Testing if the value is defined or setting a default case like i did in the alternative example before running the expression will, at a minimum, save your error log.</p>
| 3,373
|
<p>What tools are there available for static analysis against C# code? I know about FxCop and StyleCop. Are there others? I've run across NStatic before but it's been in development for what seems like forever - it's looking pretty slick from what little I've seen of it, so it would be nice if it would ever see the light of day. </p>
<p>Along these same lines (this is primarily my interest for static analysis), tools for testing code for multithreading issues (deadlocks, race conditions, etc.) also seem a bit scarce. Typemock Racer just popped up so I'll be looking at that. Anything beyond this?</p>
<p>Real-life opinions about tools you've used are appreciated.</p>
|
<p><strong>Code violation detection Tools:</strong></p>
<ul>
<li><p><a href="https://msdn.microsoft.com/en-us/library/bb429476(v=vs.80).aspx" rel="noreferrer">FxCop</a>, excellent tool by Microsoft. Check compliance with .NET framework guidelines.</p>
<p><strong>Edit October 2010:</strong> No longer available as a standalone download. It is now included in the <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b&displaylang=en" rel="noreferrer">Windows SDK</a> and after installation can be found in <code>Program Files\Microsoft SDKs\Windows\ [v7.1] \Bin\FXCop\FxCopSetup.exe</code></p>
<p><strong>Edit February 2018</strong>: This functionality has now been integrated into Visual Studio 2012 and later as <a href="https://learn.microsoft.com/en-gb/visualstudio/code-quality/code-analysis-for-managed-code-overview" rel="noreferrer">Code Analysis</a></p>
</li>
<li><p><a href="http://sharptoolbox.com/tools/clocksharp" rel="noreferrer">Clocksharp</a>, based on code source analysis (to C# 2.0)</p>
</li>
<li><p><a href="http://www.mono-project.com/Gendarme" rel="noreferrer">Mono.Gendarme</a>, similar to FxCop but with an open source licence (based on <a href="http://mono-project.com/Cecil" rel="noreferrer">Mono.Cecil</a>)</p>
</li>
<li><p><a href="http://code.google.com/p/smokey/" rel="noreferrer">Smokey</a>, similar to FxCop and Gendarme, based on <a href="http://mono-project.com/Cecil" rel="noreferrer">Mono.Cecil</a>. No longer on development, the main developer works with Gendarme team now.</p>
</li>
<li><p><a href="http://www.coverity.com/html/coverity-prevent-for-c%23.html" rel="noreferrer">Coverity Prevent™ for C#</a>, commercial product</p>
</li>
<li><p><a href="http://www.programmingresearch.com/products/qacsharp/" rel="noreferrer">PRQA QA·C#</a>, commercial product</p>
</li>
<li><p><a href="http://www.viva64.com/en/pvs-studio/" rel="noreferrer">PVS-Studio</a>, commercial product</p>
</li>
<li><p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=0178e2ef-9da8-445e-9348-c93f24cc9f9d&displaylang=en" rel="noreferrer">CAT.NET</a>, visual studio addin that helps identification of security flaws <strong>Edit November 2019:</strong> Link is dead.</p>
</li>
<li><p><a href="http://submain.com/codeit.right" rel="noreferrer">CodeIt.Right</a></p>
</li>
<li><p><a href="http://research.microsoft.com/SpecSharp/" rel="noreferrer">Spec#</a></p>
</li>
<li><p><a href="http://research.microsoft.com/Pex/" rel="noreferrer">Pex</a></p>
</li>
<li><p><a href="https://www.sonarqube.org/" rel="noreferrer">SonarQube</a>, FOSS & Commercial options to support writing cleaner and safer code.</p>
</li>
</ul>
<p><strong>Quality Metric Tools:</strong></p>
<ul>
<li><a href="http://www.ndepend.com/" rel="noreferrer">NDepend</a>, great visual tool. Useful for code metrics, rules, diff, coupling and dependency studies.</li>
<li><a href="http://www.nitriq.com" rel="noreferrer">Nitriq</a>, free, can easily write your own metrics/constraints, nice visualizations. <strong>Edit February 2018:</strong> download links now dead. <strong>Edit June 17, 2019: Links not dead.</strong></li>
<li><a href="http://msquaredtechnologies.com/" rel="noreferrer">RSM Squared</a>, based on code source analysis</li>
<li><a href="http://www.semanticdesigns.com/Products/Metrics/CSharpMetrics.html" rel="noreferrer">C# Metrics</a>, using a full parse of C#</li>
<li><a href="http://www.campwoodsw.com/sourcemonitor.html" rel="noreferrer">SourceMonitor</a>, an old tool that occasionally gets updates</li>
<li><a href="https://archive.codeplex.com/?p=codemetrics" rel="noreferrer">Code Metrics</a>, a <a href="http://www.red-gate.com/products/reflector/" rel="noreferrer"><em>Reflector</em></a> add-in</li>
<li><a href="https://web.archive.org/web/20140310013820/http://www.1bot.com/index.html" rel="noreferrer">Vil</a>, old tool that doesn't support .NET 2.0. <strong>Edit January 2018:</strong> Link now dead</li>
</ul>
<p><strong>Checking Style Tools:</strong></p>
<ul>
<li><a href="https://github.com/StyleCop/StyleCop" rel="noreferrer">StyleCop</a>, Microsoft tool ( run from inside of Visual Studio or integrated into an MSBuild project). Also available <a href="https://visualstudiogallery.msdn.microsoft.com/cac2a05b-6eb6-4fa2-95b9-1f8d011e6cae" rel="noreferrer">as an extension</a> for Visual Studio 2015 and C#6.0</li>
<li><a href="https://code.google.com/p/agentsmithplugin/" rel="noreferrer">Agent Smith</a>, code style validation plugin for <em>ReSharper</em></li>
</ul>
<p><strong>Duplication Detection:</strong></p>
<ul>
<li><a href="http://www.harukizaemon.com/simian/index.html" rel="noreferrer">Simian</a>, based on source code. Works with plenty languages.</li>
<li><a href="http://www.semanticdesigns.com/Products/CloneDR" rel="noreferrer">CloneDR</a>, detects parameterized clones only on language boundaries (also handles many languages other than C#)</li>
<li><a href="https://github.com/terrajobst/clonedetective-vs" rel="noreferrer">Clone Detective</a> a Visual Studio plugin (which uses <a href="https://www.cqse.eu/en/products/conqat/overview/" rel="noreferrer">ConQAT</a> internally)</li>
<li><a href="http://www.getatomiq.com" rel="noreferrer">Atomiq</a>, based on source code, plenty of languages, cool "wheel" visualization</li>
</ul>
<p><strong>General Refactoring tools</strong></p>
<ul>
<li><a href="http://www.jetbrains.com/resharper/" rel="noreferrer">ReSharper</a> - Majorly cool C# code analysis and refactoring features</li>
</ul>
|
<p>I find the <a href="http://www.codeplex.com/reflectoraddins/Wiki/View.aspx?title=CodeMetrics&referringTitle=Home" rel="nofollow noreferrer">Code Metrics</a> and <a href="http://www.tom-carter.net/" rel="nofollow noreferrer">Dependency Structure Matrix</a> add-ins for Reflector very useful.</p>
| 5,955
|
<p>Best recommendations for accessing and manipulation of sqlite databases from JavaScript.</p>
|
<p>Well, if you are working on client side JavaScript, I think you will be out of luck... browsers tend to sandbox the JavaScript environment so you don't have access to the machine in any kind of general capacity like accessing a database.</p>
<p>If you are talking about an SQLite DB on the server end accessed from the client end, you could set up an AJAX solution that invokes some server side code to access it.</p>
<p>If you are talking about Rhino or some other server side JavaScript, you should look into the host language's API access into SQLite (such as the JDBC for Rhino).</p>
<p>Perhaps clarify your question a bit more...?</p>
|
<p>On a Mac? Take a look at Gus Meuller's JSTalk, which leverages Scripting Bridge and Patrick Geiller's JSCocoa.</p>
<p>Gus talks specifically about the Sqlite support here: <a href="http://gusmueller.com/blog/archives/2009/03/jstalk_extras.html" rel="nofollow noreferrer">http://gusmueller.com/blog/archives/2009/03/jstalk_extras.html</a> ...works great.</p>
| 8,732
|
<p>Is it possible to use the Asp.Net MVC framework within SharePoint sites?</p>
|
<p>In ScottGu's <a href="http://weblogs.asp.net/scottgu/archive/2008/02/12/asp-net-mvc-framework-road-map-update.aspx" rel="noreferrer">blog from February 2008</a>, he writes:</p>
<blockquote>
<p>Currently MVC doesn't directly
integrate with SharePoint. That is
something we'll be looking at
supporting in the future though.</p>
</blockquote>
<p>There's a project on CodePlex for getting ASP.NET MVC to work in SharePoint:
<a href="http://www.codeplex.com/SharePointMVC" rel="noreferrer">http://www.codeplex.com/SharePointMVC</a></p>
|
<p>I don't believe so, although you can upload standard ASPX files into SharePoint and have them operate I'm pretty sure that the URL rewritting is where it would come unstuck.</p>
| 9,631
|
<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 all) that my try/catch block won't catch it and instead stops execution as an unhandled exception.</p>
<p>The issue for me is that I can't replicate this issue anywhere else but in my full code. The call stack shows that the exception definitely occurs within my try/catch(Exception) block. The only thing I can think of is that there are a few ANTLR assembly calls that occur between my code and the code throwing the exception and this library does not have debugging enabled, so I can't step through it. I wonder if non-debuggable assemblies inhibit exception bubbling? The call stack looks like this; external assembly calls are in Antlr.Runtime:</p>
<pre>
Expl.Itinerary.dll!TimeDefLexer.mTokens() Line 1213 C#
Antlr3.Runtime.dll!Antlr.Runtime.Lexer.NextToken() + 0xfc bytes
Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.FillBuffer() + 0x22c bytes
Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.LT(int k = 1) + 0x68 bytes
Expl.Itinerary.dll!TimeDefParser.prog() Line 109 + 0x17 bytes C#
Expl.Itinerary.dll!Expl.Itinerary.TDLParser.Parse(string Text = "", Expl.Itinerary.IItinerary Itinerary = {Expl.Itinerary.MemoryItinerary}) Line 17 + 0xa bytes C#
</pre>
<p>The code snippet from the bottom-most call in Parse() looks like:</p>
<pre><code> try {
// Execution stopped at parser.prog()
TimeDefParser.prog_return prog_ret = parser.prog();
return prog_ret == null ? null : prog_ret.value;
}
catch (Exception ex) {
throw new ParserException(ex.Message, ex);
}
</code></pre>
<p>To me, a catch (Exception) clause should've captured any exception whatsoever. Is there any reason why it wouldn't?</p>
<p><strong>Update:</strong> I traced through the external assembly with Reflector and found no evidence of threading whatsoever. The assembly seems to just be a runtime utility class for ANTLR's generated code. The exception thrown is from the TimeDefLexer.mTokens() method and its type is NoViableAltException, which derives from RecognitionException -> Exception. This exception is thrown when the lexer cannot understand the next token in the stream; in other words, invalid input. This exception is SUPPOSED to happen, however it should've been caught by my try/catch block.</p>
<p>Also, the rethrowing of ParserException is really irrelevant to this situation. That is a layer of abstraction that takes any exception during parse and convert to my own ParserException. The exception handling problem I'm experiencing is never reaching that line of code. In fact, I commented out the "throw new ParserException" portion and still received the same result.</p>
<p>One more thing, I modified the original try/catch block in question to instead catch NoViableAltException, eliminating any inheritance confusion. I still received the same result.</p>
<p>Someone once suggested that sometimes VS is overactive on catching handled exceptions when in debug mode, but this issue also happens in release mode.</p>
<p>Man, I'm still stumped! I hadn't mentioned it before, but I'm running VS 2008 and all my code is 3.5. The external assembly is 2.0. Also, some of my code subclasses a class in the 2.0 assembly. Could a version mismatch cause this issue?</p>
<p><strong>Update 2:</strong> I was able to eliminate the .NET version conflict by porting relevant portions of my .NET 3.5 code to a .NET 2.0 project and replicate the same scenario. I was able to replicate the same unhandled exception when running consistently in .NET 2.0.</p>
<p>I learned that ANTLR has recently released 3.1. So, I upgraded from 3.0.1 and retried. It turns out the generated code is a little refactored, but the same unhandled exception occurs in my test cases.</p>
<p><strong>Update 3:</strong>
I've replicated this scenario in a <a href="http://www.explodingcoder.com/cms/files/TestAntlr-3.1.zip" rel="noreferrer">simplified VS 2008 project</a>. Feel free to download and inspect the project for yourself. I've applied all the great suggestions, but have not been able to overcome this obstacle yet.</p>
<p>If you can find a workaround, please do share your findings. Thanks again!</p>
<hr>
<p>Thank you, but VS 2008 automatically breaks on unhandled exceptions. Also, I don't have a Debug->Exceptions dialog. The NoViableAltException that is thrown is fully intended, and designed to be caught by user code. Since it is not caught as expected, program execution halts unexpectedly as an unhandled exception.</p>
<p>The exception thrown is derived from Exception and there is no multi-threading going on with ANTLR.</p>
|
<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 unhandled by user code" and a callstack that looks like this:</p>
<pre>
[External Code]
> TestAntlr-3.1.exe!TimeDefLexer.mTokens() Line 852 + 0xe bytes C#
[External Code]
TestAntlr-3.1.exe!TimeDefParser.prog() Line 141 + 0x14 bytes C#
TestAntlr-3.1.exe!TestAntlr_3._1.Program.ParseTest(string Text = "foobar;") Line 49 + 0x9 bytes C#
TestAntlr-3.1.exe!TestAntlr_3._1.Program.Main(string[] args = {string[0x00000000]}) Line 30 + 0xb bytes C#
[External Code]
</pre>
<p>If you right click in the callstack window and run turn on show external code you see this:</p>
<pre>
Antlr3.Runtime.dll!Antlr.Runtime.DFA.NoViableAlt(int s = 0x00000000, Antlr.Runtime.IIntStream input = {Antlr.Runtime.ANTLRStringStream}) + 0x80 bytes
Antlr3.Runtime.dll!Antlr.Runtime.DFA.Predict(Antlr.Runtime.IIntStream input = {Antlr.Runtime.ANTLRStringStream}) + 0x21e bytes
> TestAntlr-3.1.exe!TimeDefLexer.mTokens() Line 852 + 0xe bytes C#
Antlr3.Runtime.dll!Antlr.Runtime.Lexer.NextToken() + 0xc4 bytes
Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.FillBuffer() + 0x147 bytes
Antlr3.Runtime.dll!Antlr.Runtime.CommonTokenStream.LT(int k = 0x00000001) + 0x2d bytes
TestAntlr-3.1.exe!TimeDefParser.prog() Line 141 + 0x14 bytes C#
TestAntlr-3.1.exe!TestAntlr_3._1.Program.ParseTest(string Text = "foobar;") Line 49 + 0x9 bytes C#
TestAntlr-3.1.exe!TestAntlr_3._1.Program.Main(string[] args = {string[0x00000000]}) Line 30 + 0xb bytes C#
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x39 bytes
Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x2b bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x3b bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x81 bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x40 bytes
</pre>
<p>The debugger's message is telling you that an exception originating outside your code (from NoViableAlt) is going through code you own in TestAntlr-3.1.exe!TimeDefLexer.mTokens() without being handled. </p>
<p>The wording is confusing, but it does not mean the exception is uncaught. The debugger is letting you know that code you own mTokens()" needs to be robust against this exception being thrown through it.</p>
<p>Things to play with to see how this looks for those who didn't repro the problem:</p>
<ul>
<li>Go to Tools/Options/Debugging and
turn off "Enable Just My code
(Managed only)". or option.</li>
<li>Go to Debugger/Exceptions and turn off "User-unhandled" for
Common-Language Runtime Exceptions.</li>
</ul>
|
<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 .NET 2.0. </p>
<pre><code>AppDomain.CurrentDomain.UnhandledException
</code></pre>
<p>Is only intended to be used as a last chance logging saloon so you can log the exception before the program exits. It wont catch the exception as of 2.0 onwards (although in .NET 2.0 at least there is a config value you can modify to make it act like 1.1 but it isn't recommended practice to use this.).</p>
<p>Its worth noting that there are few exceptions that you <em>cannot</em> catch, such as StackOverflowException and OutOfMemoryException. Otherwise as other people have suggested it might be an exception in a background thread somewhere. Also I'm pretty sure you can't catch some/all unmanaged/native exceptions either.</p>
| 5,664
|
<p><strong>Definition:</strong></p>
<p><em>A palindrome is a word, phrase, number or other sequence of units that has the property of reading the same in either direction</em></p>
<p>How to check if the given string is a palindrome?</p>
<p>This was one of the FAIQ [Frequently Asked Interview Question] a while ago but that mostly using C.</p>
<p>Looking for solutions in any and all languages possible.</p>
|
<p><strong>PHP sample</strong>:</p>
<pre><code>$string = "A man, a plan, a canal, Panama";
function is_palindrome($string)
{
$a = strtolower(preg_replace("/[^A-Za-z0-9]/","",$string));
return $a==strrev($a);
}
</code></pre>
<p>Removes any non-alphanumeric characters (spaces, commas, exclamation points, etc.) to allow for full sentences as above, as well as simple words.</p>
|
<p>Another one from Delphi, which I think is a little more rigorous than the other Delphi example submitted. This can easily turn into a golfing match, but I've tried to make mine readable.</p>
<p><em>Edit0: I was curious about the performance characteristics, so I did a little test. On my machine, I ran this function against a 60 character string 50 million times, and it took 5 seconds.</em></p>
<pre><code>function TForm1.IsPalindrome(txt: string): boolean;
var
i, halfway, len : integer;
begin
Result := True;
len := Length(txt);
{
special cases:
an empty string is *never* a palindrome
a 1-character string is *always* a palindrome
}
case len of
0 : Result := False;
1 : Result := True;
else begin
halfway := Round((len/2) - (1/2)); //if odd, round down to get 1/2way pt
//scan half of our string, make sure it is mirrored on the other half
for i := 1 to halfway do begin
if txt[i] <> txt[len-(i-1)] then begin
Result := False;
Break;
end; //if we found a non-mirrored character
end; //for 1st half of string
end; //else not a special case
end; //case
end;
</code></pre>
<p>And here is the same thing, in C#, except that I've left it with multiple exit points, which I don't like.</p>
<pre><code>private bool IsPalindrome(string txt) {
int len = txt.Length;
/*
Special cases:
An empty string is *never* a palindrome
A 1-character string is *always* a palindrome
*/
switch (len) {
case 0: return false;
case 1: return true;
} //switch
int halfway = (len / 2);
//scan half of our string, make sure it is mirrored on the other half
for (int i = 0; i < halfway; ++i) {
if (txt.Substring(i,1) != txt.Substring(len - i - 1,1)) {
return false;
} //if
} //for
return true;
}
</code></pre>
| 7,523
|
<p>I'm writing a simple photo album app using ASP.NET Ajax.<br>
The app uses async Ajax calls to pre-load the next photo in the album, without changing the URL in the browser.</p>
<p>The problem is that when the user clicks the <strong>back</strong> button in the browser, the app doesn't go back to the previous photo, instead, it navigates to the home page of the application.</p>
<p>Is there a way to trick the browser into adding each Ajax call to the browsing history?</p>
|
<p><strong>Update: There is now the HTML5 History API (pushState, popState) which deprecates the HTML4 <code>hashchange</code> functionality. <a href="https://github.com/balupton/history.js" rel="nofollow noreferrer">History.js</a> provides cross-browser compatibility and an <a href="https://github.com/balupton/history.js/wiki/Intelligent-State-Handling" rel="nofollow noreferrer">optional</a> <code>hashchange</code> fallback for HTML4 browsers.</strong></p>
<p>The answer for this question will be more or less the same as my answers for these questions:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/3205900/how-to-show-ajax-requests-in-url/3276206#3276206">How to show Ajax requests in URL?</a></li>
<li><a href="https://stackoverflow.com/questions/3460041/how-does-gmail-handle-back-forward-in-rich-javascript/3460269#3460269">How does Gmail handle back/forward in rich JavaScript?</a></li>
</ul>
<p>In summary, you'll definitely want to check out these two projects which explain the whole hashchange process and adding ajax to the mix:</p>
<ul>
<li><p><a href="https://github.com/browserstate/history.js" rel="nofollow noreferrer">jQuery History</a> (using hashes to manage your pages state and bind to changes to update your page). </p></li>
<li><p><a href="https://github.com/balupton/jquery-ajaxy" rel="nofollow noreferrer">jQuery Ajaxy</a> (ajax extension for jQuery History, to allow for complete ajax websites while being completely unobtrusive and gracefully degradable).</p></li>
</ul>
|
<p>The 3.5 SP1 update has support for browser history and back button in ASP.NET ajax now.</p>
| 4,974
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.