instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>I'm trying to find the best way to speed up the delivery of the static images that compose the design of an mvc site. The images are not gzipped, nor cached in the server or on the client (with content expire). Options are:</p>
<ol>
<li>Find why images are not cached and gzipped direcly from IIS6</li>
<li>Write a specialized http handler</li>
<li>Register a special route for static images and write a bynary actionresult method</li>
</ol>
<p>What could be the best solution in terms of performance?</p>
|
<p>Best solution is to let IIS do it.</p>
<p><a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/502ef631-3695-4616-b268-cbe7cf1351ce.mspx?mfr=true" rel="nofollow noreferrer">IIS6 Compression</a> - most likely you need to <a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/502ef631-3695-4616-b268-cbe7cf1351ce.mspx?mfr=true" rel="nofollow noreferrer">specify file types to be compressed</a> like .jpg, .png, .gif types, etc.</p>
<p>Caching will come from making sure that the correct headers are being sent to the client from code, and i believe there is a setting you can set in IIS that enables it for static content, but i'm not sure on that one.</p>
|
<p>There's a nice library up on the MSDN Code Gallery that does this. It's called <a href="http://code.msdn.microsoft.com/fastmvc" rel="nofollow noreferrer">FastMVC</a>.</p>
| 3,777
|
<p>I'm using IIS in Windows 2003 Server for a SharePoint intranet. <br />External incoming requests will be using the host header <code>portal.mycompany.com</code> and be forced to use SSL.</p>
<p>I was wondering if there's a way to set up an alternate host header such as <br /><code>http://internalportal/</code> <br />which only accepts requests from the internal network, but doesn't force the users to use SSL.</p>
<p>Any recommendations for how to set this up?</p>
|
<p>Daniel, keep in mind that just because something is possbile in IIS, and via any number of off box solutions (like hardware load balancers and SSL) doesn't mean that it is supported by SharePoint, <strong>or</strong> that it is implemented in the same way.</p>
<p>You can do what you are asking for, however you should do it via SharePoint Central Administration, and "Create or Extend a Web Application" and then "Extend and Existing Application". </p>
<p>In this way you can create a <strong>new</strong> web site (in IIS) for accessing your existing SharePoint Web Application, one that can be accessed via a different hostheader, port, using SSL, Authentication mechanism, etc. </p>
<p>As a general rule, if you can do something in IIS AND in SharePoint, you should do it only in SharePoint.</p>
|
<p>Assuming that <a href="http://internalportal/" rel="nofollow noreferrer">http://internalportal/</a> wasn't accessible from outside the company, you could set up two websites in IIS. The first site, configured to use a host header value of 'portal.mycompany.com', would require SSL. The second site, configured to use a host header value of 'internalportal', would not require SSL. The host header value is configured under 'Web Site' -> 'Advanced'.</p>
<p>Having a hardware load balancer makes things much easier. The site on the load balancer is set up to require SSL, and your websites in IIS are setup not to require SSL.</p>
| 2,739
|
<p>There is a <a href="https://web.archive.org/web/20081014140251/http://stackoverflow.uservoice.com:80/pages/general/suggestions/16644" rel="nofollow noreferrer">request</a> to make the SO search default to an AND style functionality over the current OR when multiple terms are used.</p>
<p>The official response was:</p>
<blockquote>
<p>not as simple as it sounds; we use SQL Server 2005's <a href="https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2005/ms176078%28v=sql.90%29" rel="nofollow noreferrer">FREETEXT()</a> function, and I can't find a way to specify AND vs. OR -- can you?</p>
</blockquote>
<p>So, is there a way?</p>
<p>There are a <a href="https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2005/ms142519%28v=sql.90%29" rel="nofollow noreferrer">number of resources</a> on it I can find, but I am not an expert.</p>
|
<p>As far as I've seen, it is <strong>not</strong> possible to do AND when using FREETEXT() under SQL 2005 (nor 2008, afaik). </p>
<p>A FREETEXT query ignores Boolean, proximity, and wildcard operators by design. However you could do this: </p>
<pre><code>WHERE FREETEXT('You gotta love MS-SQL') > 0
AND FREETEXT('You gotta love MySQL too...') > 0
</code></pre>
<p>Or that's what I think :)</p>
<p>-- The idea is make it evaluate to Boolean, so you can use boolean operators. Don't know if this would give an error or not. I think it <em>should</em> work. But reference material is pointing to the fact that this is not possible by design. </p>
<p>The use of CONTAINS() instead of FREETEXT() could help.</p>
|
<p>I just started reading about freetext so bear with me. If what you are trying to do is allow searches for a tag, say VB, also find things tagged as VB6, Visual Basic, VisualBasic and VB.Net, wouldn't those values be set as synonyms in the DB's Thesaurus rather than query parameters?</p>
<p>If that is indeed the case, this <a href="http://msdn.microsoft.com/en-us/library/ms345187.aspx" rel="nofollow noreferrer">link on MSDN </a> explains how to add items to the Thesaurus.</p>
| 4,493
|
<p>I have wondered for some time, what a nice, clean solution for joining an array of strings might look like.
Example: I have ["Alpha", "Beta", "Gamma"] and want to join the strings into one, separated by commas – "Alpha, Beta, Gamma".</p>
<p>Now I know that most programming languages offer some kind of join method for this. I just wonder how these might be implemented.
When I took introductory courses, I often tried to go it alone, but never found a satisfactory algorithm. Everything seemed rather messy, the problem being that you can not just loop through the array, concatenating the strings, as you would add one too many commas (either before or after the last string).
I don’t want to check conditions in the loop. I don’t really want to add the first or the last string before/after the loop (I guess this is maybe the best way?).</p>
<p>Can someone show me an elegant solution? Or tell me exactly why there can’t be anything more elegant?</p>
|
<p>The most elegant solution i found for problems like this is something like this (in pseudocode)</p>
<pre><code>separator = ""
foreach(item in stringCollection)
{
concatenatedString += separator + item
separator = ","
}
</code></pre>
<p>You just run the loop and only after the second time around the separator is set. So the first time it won't get added. It's not as clean as I'd like it to be so I'd still add comments but it's better than an if statement or adding the first or last item outside the loop.</p>
|
<p>The following is no longer language-agnostic (but that doesn't matter for the discussion because the implementation is easily portable to other languages). I tried to implement Luke's (theretically best) solution in an imperative programming language. Take your pick; mine's C#. Not very elegant at all. However, (without any testing whatsoever) I could imagine that its performance is quite decent because the recursion is in fact tail recursive.</p>
<p>My challenge: give a better recursive implementation (in an imperative language). You say what “better” means: less code, faster, I'm open for suggestions.</p>
<pre><code>private static StringBuilder RecJoin(IEnumerator<string> xs, string sep, StringBuilder result) {
result.Append(xs.Current);
if (xs.MoveNext()) {
result.Append(sep);
return RecJoin(xs, sep, result);
} else
return result;
}
public static string Join(this IEnumerable<string> xs, string separator) {
var i = xs.GetEnumerator();
if (!i.MoveNext())
return string.Empty;
else
return RecJoin(i, separator, new StringBuilder()).ToString();
}
</code></pre>
| 8,278
|
<p>I use Visual Studio 2008. I haven't seen this behavior before and, as far as I know, I didn't change anything in the options.</p>
<p>When I press Start debugging all the possibly windows (watch 1 - 4), data sources, properties, registers (to be honest I have not even ever seen these windows before) appear in front of the code window and stay there after I stop the debugger.</p>
<p>Anyone has an idea what could be causing this ? (I am using CodeRush and Refactor for quite a while now)</p>
<p>When I close and restart visual studio all the windows are where they should be.</p>
<p>PS: Previously I have seen normal switching from normal to debug mode and back with some repositioning changes. That is the way it used to work. Now it is not. It has suddenly gone mad and when going to the debug mode it sometimes shows all possible IDE windows and sometimes not. When it does it no longer returns to the previous state. I cannot find this in the options anywhere.</p>
|
<p>Visual Studio <em>remembers</em> 2 sets of window layouts, normal mode and debugging mode. My solution is to arrange my normal windows exactly like I want them, then start debugging an application and once again arrange all of the windows the way I want, usually making it as similar to my <em>normal</em> layout as possible, then stopping the debugger and doing a File Exit so that VS saves my settings.</p>
<p>After doing that, it recalls my 2 different layouts each time.</p>
|
<p>I'm experiencing the same thing - whenever the debugger is running, switching focus back to the IDE immediately caused the debug panel to expand.</p>
<p>I ended up just pinning the debug panel so that it always appears when debugging, and just changing its height as needed.</p>
| 8,153
|
<p>I’m trying to have <a href="https://www.thingiverse.com/thing:2576121" rel="nofollow noreferrer">this bracket</a> printed, but I don’t know what settings I should use.</p>
<p><a href="https://i.stack.imgur.com/yTFRkm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yTFRkm.jpg" alt="Google Home Mini Invisible Mount"></a></p>
<p>The project details say 50% for infill, but is there a reason why I wouldn’t get 100% for making it sturdier? I imagine the developer used 50% because he used his own printer and wanted to preserve more material. The 3D printer service I’m using doesn’t charge more for 100%.</p>
<p>But I’m more concerned about the material I should select. Should I select PLA or ABS? The developer didn’t specify this.</p>
|
<p>For such a small item and the small load it will carry, even 50 percent is substantial. Keep in mind that one hundred percent infill is not necessarily stronger. If you need to know why, consider a 'net search for "why not use 100% infill" for more detailed information. The primary foundation for not using 100% infill is that the stress is better distributed over the structure of a non-100% part, while the completely filled part has more intra-layer stress failure. Another link suggests that there's a possibility of increased warping with full infill.</p>
<p>Because the load is small, it matters very little if you select PLA over ABS. PLA is more brittle compared to ABS and will crack or fracture or break under loads that might otherwise cause the same part in ABS to bend.</p>
<p>If you need yet more strength, select PETG or nylon, although I suspect either one would be more expensive from a service.</p>
<p>If you select ABS, you can use acetone smoothing later to make a shiny surface, but that's cosmetic, not structural. </p>
|
<p>You should use PLA at 215 °C (for better layer adhesion) with 35 percent infill and a shell thickness of 2 mm. Shell thickness is what's crucial here, not necessarily infill. The thicker the shell, the stronger the part. This has a much bigger influence on strength than infill does.</p>
| 754
|
<p>I'm trying to get the following bit of code to work in LINQPad but am unable to index into a var. Anybody know how to index into a var in LINQ?</p>
<pre><code>string[] sa = {"one", "two", "three"};
sa[1].Dump();
var va = sa.Select( (a,i) => new {Line = a, Index = i});
va[1].Dump();
// Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable<AnonymousType#1>'
</code></pre>
|
<p>As the comment says, you cannot apply indexing with <code>[]</code> to an expression of type <code>System.Collections.Generic.IEnumerable<T></code>. The IEnumerable interface only supports the method <code>GetEnumerator()</code>. However with LINQ you can call the extension method <code>ElementAt(int)</code>.</p>
|
<p>You can't apply an index to a var unless it's an indexable type:</p>
<pre><code>//works because under the hood the C# compiler has converted var to string[]
var arrayVar = {"one", "two", "three"};
arrayVar[1].Dump();
//now let's try
var selectVar = arrayVar.Select( (a,i) => new { Line = a });
//or this (I find this syntax easier, but either works)
var selectVar =
from s in arrayVar
select new { Line = s };
</code></pre>
<p>In both these cases <code>selectVar</code> is actually <code>IEnumerable<'a></code> - not an indexed type. You can easily convert it to one though:</p>
<pre><code>//convert it to a List<'a>
var aList = selectVar.ToList();
//convert it to a 'a[]
var anArray = selectVar.ToArray();
//or even a Dictionary<string,'a>
var aDictionary = selectVar.ToDictionary( x => x.Line );
</code></pre>
| 6,678
|
<p>Is it possible to embed a PowerPoint presentation (.ppt) into a webpage (.xhtml)?</p>
<p>This will be used on a local intranet where there is a mix of Internet Explorer 6 and Internet Explorer 7 only, so no need to consider other browsers.</p>
<hr>
<p>I've given up... I guess Flash is the way forward.</p>
|
<p>Google Docs can serve up PowerPoint (and PDF) documents in it's document viewer. You don't have to sign up for Google Docs, just upload it to your website, and call it from your page:</p>
<pre><code><iframe src="//docs.google.com/gview?url=https://www.yourwebsite.com/powerpoint.ppt&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>
</code></pre>
|
<p>The first few results on Google all sound like good options:</p>
<p><a href="http://www.pptfaq.com/FAQ00708.htm" rel="nofollow noreferrer">http://www.pptfaq.com/FAQ00708.htm</a></p>
<p><a href="http://www.webdeveloper.com/forum/showthread.php?t=86212" rel="nofollow noreferrer">http://www.webdeveloper.com/forum/showthread.php?t=86212</a></p>
| 6,100
|
<p>I am searching for a Linux software to control the 3000 mW laser engraver depicted below. It's a common model you'd find on AliExpress, Banggood, etc. under different brand names.</p>
<p>I have already tried <a href="https://github.com/AxelTB/nejePrint" rel="noreferrer">nejePrint</a>, <a href="https://github.com/LaserWeb/LaserWeb4/wiki" rel="noreferrer">LaserWeb</a>, and <a href="https://github.com/camrein/EzGraver" rel="noreferrer">EzGraver</a>, but they don't work. Any ideas?</p>
<p><a href="https://i.stack.imgur.com/kHoYY.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/kHoYY.jpg" alt="enter image description here"></a></p>
|
<p>A program that lists as functional with Linux is <a href="https://lightburnsoftware.com/" rel="noreferrer">Lightburn</a>. It's new to the laser engraving world and supports GRBL type controllers as well as Ruida brand and possibly a few others. If you can determine your controller, you're a step ahead of the game.</p>
<p>Directly from their site:</p>
<blockquote>
<p>LightBurn</p>
<p>LightBurn is layout, editing, and control software for your laser
cutter. With LightBurn you can:</p>
<ul>
<li><p>Import artwork in a variety of common vector graphic and image formats (including AI, PDF, SVG, DXF, PLT, PNG, JPG, GIF, BMP)</p></li>
<li><p>Arrange, edit, and even create new vector shapes within the editor, with powerful features like offsetting, boolean operations, welding,
and node editing</p></li>
<li><p>Apply settings like power, speed, number of passes, cut order, brightness & contrast, dithering mode, and much more</p></li>
<li><p>Send the result directly to your laser cutter</p></li>
</ul>
<p>LightBurn is a native application written for Windows, Mac OS, and
Linux.</p>
</blockquote>
<p><a href="https://i.stack.imgur.com/vnbTz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vnbTz.png" alt="lightburn logo"></a></p>
<p>I'm a satisfied Lightburn user, not a company representative.</p>
|
<p>I also have one, when you plug it on your linux computer, there is a CH340G usb-serial chip inside, a serial port should be available at /dev/ttyUSB0, and you can send a right BMP file via this serial port.</p>
<p>Maybe EzGraver would work?</p>
<p><a href="https://github.com/camrein/EzGraver" rel="nofollow noreferrer">https://github.com/camrein/EzGraver</a></p>
| 1,350
|
<p>A Windows Forms application of ours pulls records from a view on SQL Server through ADO.NET and a SOAP web service, displaying them in a data grid. We have had several cases with ~25,000 rows, which works relatively smoothly, but a potential customer needs to have many times that much in a single list.</p>
<p>To figure out how well we scale right now, and how (and how far) we can realistically improve, I'd like to implement a simulation: instead of displaying actual data, have the SQL Server send fictional, random data. The client and transport side would be mostly the same; the view (or at least the underlying table) would of course work differently. The user specifies the amount of fictional rows (e.g. 100,000).</p>
<p>For the time being, I just want to know how long it takes for the client to retrieve and process the data and is just about ready to display it.</p>
<p>What I'm trying to figure out is this: how do I make the SQL Server send such data?</p>
<p>Do I:</p>
<ol>
<li>Create a stored procedure that has to be run beforehand to fill an actual table?</li>
<li>Create a function that I point the view to, thus having the server generate the data 'live'?</li>
<li>Somehow replicate and/or randomize existing data?</li>
</ol>
<p>The first option sounds to me like it would yield the results closest to the real world. Because the data is actually 'physically there', the <code>SELECT</code> query would be quite similar performance-wise to one on real data. However, it taxes the server with an otherwise meaningless operation. The fake data would also be backed up, as it would live in one and the same database — unless, of course, I delete the data after each benchmark run.</p>
<p>The second and third option tax the server <em>while</em> running the actual simulation, thus potentially giving unrealistically slow results.</p>
<hr>
<p>In addition, I'm unsure how to create those rows, short of using a loop or cursor. I can use <code>SELECT top <n> random1(), random2(), […] FROM foo</code> if <code>foo</code> actually happens to have <code><n></code> entries, but otherwise I'll (obviously) only get as many rows as <code>foo</code> happens to have. A <code>GROUP BY newid()</code> or similar doesn't appear to do the trick.</p>
|
<p>For data for testing CRM type tables, I highly recommend <a href="http://www.fakenamegenerator.com" rel="nofollow noreferrer">fakenamegenerator.com</a>, you can get 40,000 fake names for free.</p>
|
<p>If you want results you can rely on you need to make the testing scenario as realistic as possible, which makes option 1 by far your best bet. As you point out if you get results that aren't good enough with the other options you won't be sure that it wasn't due to the different database behaviour.</p>
<p>How you generate the data will depend to a large degree on the problem domain. Can you take data sets from multiple customers and merge them into a single mega-dataset? If the data is time series then maybe it can be duplicated over a different range. </p>
| 5,757
|
<p>Python has this wonderful way of handling string substitutions using dictionaries:</p>
<pre><code>>>> 'The %(site)s site %(adj)s because it %(adj)s' % {'site':'Stackoverflow', 'adj':'rocks'}
'The Stackoverflow site rocks because it rocks'
</code></pre>
<p>I love this because you can specify a value once in the dictionary and then replace it all over the place in the string.</p>
<p>I've tried to achieve something similar in PHP using various string replace functions but everything I've come up with feels awkward.</p>
<p>Does anybody have a nice clean way to do this kind of string substitution in PHP?</p>
<p><strong><em>Edit</em></strong><br>
Here's the code from the sprintf page that I liked best. </p>
<pre><code><?php
function sprintf3($str, $vars, $char = '%')
{
$tmp = array();
foreach($vars as $k => $v)
{
$tmp[$char . $k . $char] = $v;
}
return str_replace(array_keys($tmp), array_values($tmp), $str);
}
echo sprintf3( 'The %site% site %adj% because it %adj%', array('site'=>'Stackoverflow', 'adj'=>'rocks'));
?>
</code></pre>
|
<pre><code>function subst($str, $dict){
return preg_replace(array_map(create_function('$a', 'return "/%\\($a\\)s/";'), array_keys($dict)), array_values($dict), $str);
}
</code></pre>
<p>You call it like so:</p>
<pre><code>echo subst('The %(site)s site %(adj)s because it %(adj)s', array('site'=>'Stackoverflow', 'adj'=>'rocks'));
</code></pre>
|
<p>Some of the user-contributed notes and functions in <a href="http://us3.php.net/sprintf" rel="nofollow noreferrer">PHP's documentation for sprintf</a> come quite close.</p>
<p>Note: search the page for "sprintf2".</p>
| 4,781
|
<p>I just wonder what options there are to properly measure/profile/optimize ASP.net 2.0 Web Parts, especially the ones for Sharepoint 2007?</p>
<p>As Web Parts are a layer on another layer of technology, getting resource usage, open handles and stuff only for the web part seems to be a bit difficult.</p>
<p>Does anyone know some good tools or practices for profiling and optimizing web parts?</p>
|
<p>Back when we started with SP2003, we used to worry about not closing connection in apps or web parts. We used the following query to check if the base number of connections (not counting the initial spike) would increase as the app is used on the development server:</p>
<p>SELECT hostname, sysdatabases.name , sysprocesses.status, last_batch from sysprocesses, sysdatabases where sysprocesses.dbid = sysdatabases.dbid and nt_username = '<strong>SP Service Account</strong>' and (hostname='<strong>WFE1</strong>' or hostname='<strong>WFE2</strong>') and sysprocesses.dbid = <strong>10</strong> order by last_batch desc</p>
<p>(replace the bolded values with those appropriate for your environment)</p>
<p>We haven't tried this since the upgrade to MOSS though.</p>
|
<p>I have found seperating out all the business logic in to a seperate DLL that is easily unit testable has been the easiest method for me. But to be honest there is really no good way that I have found, besides what I have just mentioned. The same has been true for me with Facebook applications recently. I think this is common for any application that runs inside of another platform. Especially when performance and testing where never a goal when the platform developers started to build the system.</p>
| 4,020
|
<p>I need to store products for an e-commerce solution in a database. Each product should have descriptive information, such as name, description etc.</p>
<p>I need any product to be localized to x number of languages.</p>
<p>What I've done so far, is to make any column that should be localized and <code>nvarchar(MAX)</code> and then i store an XML string like this:</p>
<pre><code><cultures>
<culture code="en-us">Super fast laptop</culture>
<culture code="da-dk">Super hurtig bærbar</culture>
</cultures>
</code></pre>
<p>And when I load it from the database, into my business logic objects, I parse the XML string to a <code>Dictionary<string, string></code> where the key is the culture/language code.</p>
<p>So when I want to display the name of a product, I do this:</p>
<pre><code>lblName.Text = product.Name["en-us"];
</code></pre>
<p>Does anyone have a better solution?</p>
|
<p>You should store the current language somewhere (in a <a href="http://www.yoda.arachsys.com/csharp/singleton.html" rel="nofollow noreferrer">singleton</a>, for instance) and in the product.Name property use the language setting to get the correct string. This way you only have to write the language specific code once for each field rather than thinking about languages everywhere the field is used. </p>
<p>For example, assuming your singleton is defined in the Localizer class that stores an enum corresponding to the current language:</p>
<pre><code>public class Product
{
private idType id;
public string Name
{
get
{
return Localizer.Instance.GetLocalString(id, "Name");
}
}
}
</code></pre>
<p>Where GetLocalString looks something like:</p>
<pre><code> public string GetLocalString(idType objectId, string fieldName)
{
switch (_currentLanguage)
{
case Language.English:
// db access code to retrieve your string, may need to include the table
// the object is in (e.g. "Products" "Orders" etc.)
db.GetValue(objectId, fieldName, "en-us");
break;
}
}
</code></pre>
|
<p>This is basically the approach we took with Microsoft Commerce Server 2002. Yeah indexed views will help your performance.</p>
| 4,818
|
<p>For example, to make a DIY cartesian 3d printer you <strong>could</strong> use/do the following:</p>
<ul>
<li><p>Create G-code using a program of your choice.</p></li>
<li><p>Load it into Universal G-code Sender (GRBL).</p></li>
<li><p>Pass it into an Arduino with GRBL.</p></li>
<li><p>The arduino can pass the instructions to the drivers through a GRBL arduino uno shield.</p></li>
<li><p>The drivers will control the steppers.</p></li>
</ul>
<p>If you want to make a DYI delta 3d printer, which point of this whole process needs to be altered in order for the delta printer to work properly? Is there an existing open source software for delta printers/cncs?</p>
<p>EDIT: This question could be asked about any kind of non-cartesian 3d printer, including Delta, SCARA, Polar, etc.</p>
|
<p>The short answer is that the handling of the non-cartesian design is done by the motion-control firmware running on the Arduino.</p>
<p>The long answer:</p>
<p>I don't believe GRBL supports non-cartesian designs, and it is not commonly used for printers. It is more often used for mills, routers, or laser machines. 3D printers will typically use a firmware such as Marlin, which supports several printer designs, including Delta machines.</p>
<p>At no point is the g-code itself changed. The motion control firmware running on the Arduino or other controller interprets the g-code and determines which way and when to step each motor to accomplish the motion.</p>
<p>With a simple cartesian machine, commands for the X-axis only relate to the X-axis motor, but for a non-cartesian machine the axis and motors have complex relationships. The firmware must be programmed and configured to control the motors correctly.</p>
<p>The g-code itself is never passed to the drivers. The commands to the driver are simple electrical signals to "enable" (to energize the motor power - even to just hold position), "direction" (which way to rotate the motor shaft), and "step" (which causes the motor to rotate by one step in the selected direction).</p>
|
<p>Every 3D printer or machine tool that is commanded through G-code must interpret the G-code in terms of the particular mechanism. Even a Cartesian machine in which there is a clear X, Y, and Z axis, each with independent actuators, interprets the G-code and adjusts for the scale factors, considers the current kinetic energy and the implicit changes in the kinetic energy, and constructs a move plan to implement the G-code. This involves considering the velocity limits, the acceleration, the jerk, and possible higher derivatives. This plan is passed to the motor drivers, and the mechanism responds.</p>
<p>A delta mechanism is really the same. The difference is that there is not a distinct X, Y, and Z axis, even though the commands in the G-code are given in Cartesian coordinates.</p>
<p>My second 3D printer is one I designed using standard hot ends and extruders. I'm using the reprap firmware, and haven't adequately studied the kinematics.</p>
<p>My first milling machine, however, was a delta machine with 3 additional degrees of freedom -- a machine style generically called a parallel-kinematics inverted Stewart platform. In my kinematics code, I plan a movement by breaking the Cartesian command into small enough segments that the non-linearity of the 6-axis movement space never exceeds the tiny error of the actuators. I developed a CPU-intensive but effective calibration system that estimates the errors that I introduced when building it, and so the mechanical performance is good enough. The machine itself is a 5'x6'x6' frame of welded steel, so it is pretty dimensionally stable.</p>
<p>A delta 3D printer is simpler because there is no control over the roll, pitch, and yaw of the hot end. Unfortunately, not being able to control also means that you are subject to whatever errors are introduced in the construction.</p>
<p>"Bed-leveling" of a delta printer consists of estimating some of the machine-unique parameters and compensating for their effects: cup, bowl, ripple, and tilt. Applying these adjustments is done in the kinematics code as a further modification of the G-code Cartesian parameters to the leg-space delta mechanism motions.</p>
<p>TL;DR</p>
<p>The G-code is not modified, but the parameters expressed in the G-code are adjusted and interpreted in light of the machine kinematics so that the intention of the G-code can be faithfully followed.</p>
| 867
|
<p>When I have overhangs in my model, Cura colors them red. However, I noticed if I make layer thickness thinner, the red area is reduced or disappears. </p>
<p>This could mean that thinner layer thickness is better for overhang, but it could also mean that a larger ratio of line width to layer thickness is better. It makes sense that if line width is 4X the layer thickness (such as 0.15 layers with 0.6 line width), overhang performance should be better than if line width is only 2X (such as 0.3 layers with the same 0.6 line width.</p>
<p>Is there a model that explains the optimum ratio of line thickness to layer height? Is only the ratio important, or is layer height also important by itself?</p>
|
<p>A wide line works if there is something below it to squeeze the filament against, but if you don't have a full layer below it, it will stay thinner and it will droop. I would not use extreme ratios on overhangs. Still, do a parametric test: a overhang tower (a compact one) at different line widths and layer heights. If you test 3 layer heights and 3 line widths, it's only 9 short prints.</p>
<p>However, as you can see in filament reviews, different materials behave differently. I think there is no <em>a priori</em> optimal value.</p>
|
<p>In terms of Cura's model for showing overhangs, I'm nearly sure it's just the ratio - rise over run, or rather run over rise. And indeed that's what makes sense mathematically:</p>
<p>At least some portion of the wall extrusion in layer N+1 needs to sit on top of the corresponding wall extrusion in layer N. For a given 3D surface slope, the "run" - the distance the cross-section moves from one layer to the next, which needs to be bounded by some fraction of the line width - varies proportionally to the "rise" - the layer height.</p>
| 1,663
|
<p>I assume it doesn't connect to anything (other than the satelite I guess), is this right? Or it does and has some kind of charge?</p>
|
<p>GPS, the Global Positioning System run by the United States Military, is free for civilian use, though the reality is that we're paying for it with tax dollars.</p>
<p>However, GPS on cell phones is a bit more murky. In general, it won't cost you anything to turn on the GPS in your cell phone, but when you get a location it usually involves the cell phone company in order to get it quickly with little signal, as well as get a location when the satellites aren't visible (since the gov't requires a fix even if the satellites aren't visible for emergency 911 purposes). It uses up some cellular bandwidth. This also means that for phones without a regular GPS receiver, you cannot use the GPS at all if you don't have cell phone service.</p>
<p>For this reason most cell phone companies have the GPS in the phone turned off except for emergency calls and for services they sell you (such as directions).</p>
<p>This particular kind of GPS is called assisted GPS (AGPS), and there are several levels of assistance used.</p>
<h2>GPS</h2>
<p>A normal GPS receiver listens to a particular frequency for radio signals. Satellites send time coded messages at this frequency. Each satellite has an atomic clock, and sends the current exact time as well.</p>
<p>The GPS receiver figures out which satellites it can hear, and then starts gathering those messages. The messages include time, current satellite positions, and a few other bits of information. The message stream is slow - this is to save power, and also because all the satellites transmit on the same frequency and they're easier to pick out if they go slow. Because of this, and the amount of information needed to operate well, it can take 30-60 seconds to get a location on a regular GPS.</p>
<p>When it knows the position and time code of at least 3 satellites, a GPS receiver can assume it's on the earth's surface and get a good reading. 4 satellites are needed if you aren't on the ground and you want altitude as well.</p>
<h2>AGPS</h2>
<p>As you saw above, it can take a long time to get a position fix with a normal GPS. There are ways to speed this up, but unless you're carrying an atomic clock with you all the time, or leave the GPS on all the time, then there's always going to be a delay of between 5-60 seconds before you get a location.</p>
<p>In order to save cost, most cell phones share the GPS receiver components with the cellular components, and you can't get a fix and talk at the same time. People don't like that (especially when there's an emergency) so the lowest form of GPS does the following:</p>
<ol>
<li>Get some information from the cell phone company to feed to the GPS receiver - some of this is gross positioning information based on what cellular towers can 'hear' your phone, so by this time they already phone your location to within a city block or so.</li>
<li>Switch from cellular to GPS receiver for 0.1 second (or some small, practically unoticable period of time) and collect the raw GPS data (no processing on the phone).</li>
<li>Switch back to the phone mode, and send the raw data to the phone company</li>
<li>The phone company processes that data (acts as an offline GPS receiver) and send the location back to your phone.</li>
</ol>
<p>This saves a lot of money on the phone design, but it has a heavy load on cellular bandwidth, and with a lot of requests coming it requires a lot of fast servers. Still, overall it can be cheaper and faster to implement. They are reluctant, however, to release GPS based features on these phones due to this load - so you won't see turn by turn navigation here.</p>
<p>More recent designs include a full GPS chip. They still get data from the phone company - such as current location based on tower positioning, and current satellite locations - this provides sub 1 second fix times. This information is only needed once, and the GPS can keep track of everything after that with very little power. If the cellular network is unavailable, then they can still get a fix after awhile. If the GPS satellites aren't visible to the receiver, then they can still get a rough fix from the cellular towers.</p>
<p>But to completely answer your question - it's as free as the phone company lets it be, and so far they do not charge for it at all. I doubt that's going to change in the future. In the higher end phones with a full GPS receiver you may even be able to load your own software and access it, such as with mologogo on a motorola iDen phone - the J2ME development kit is free, and the phone is only $40 (prepaid phone with $5 credit). Unlimited internet is about $10 a month, so for $40 to start and $10 a month you can get an internet tracking system. (Prices circa August 2008)</p>
<p>It's only going to get cheaper and more full featured from here on out...</p>
<p>Re: Google maps and such</p>
<p>Yes, Google maps and all other cell phone mapping systems require a data connection of some sort at varying times during usage. When you move far enough in one direction, for instance, it'll request new tiles from its server. Your average phone doesn't have enough storage to hold a map of the US, nor the processor power to render it nicely. iPhone would be able to if you wanted to use the storage space up with maps, but given that most iPhones have a full time unlimited data plan most users would rather use that space for other things.</p>
|
<p>There's 3 satellites at least that you must be able to receive from of the 24-32 out there, and they each broadcast a time from a synchronized atomic clock. The differences in those times that you receive at any one time tell you how long the broadcast took to reach you, and thus where you are in relation to the satellites. So, it sort of reads from something, but it doesn't connect to that thing. Note that this doesn't tell you your orientation, many GPSes fake that (and speed) by interpolating data points.</p>
<p>If you don't count the cost of the receiver, it's a free service. Apparently there's higher resolution services out there that are restricted to military use. Those are likely a fixed cost for a license to decrypt the signals along with a confidentiality agreement.</p>
<p>Now your device may support GPS tracking, in which case it might communicate, say via GPRS, to a database which will store the location the device has found itself to be at, so that multiple devices may be tracked. That would require some kind of connection.</p>
<p>Maps are either stored on the device or received over a connection. Navigation is computed based on those maps' databases. These likely are a licensed item with a cost associated, though if you use a service like Google Maps they have the license with NAVTEQ and others.</p>
| 5,371
|
<p>I am converting an old Makerbot Replicator 2 to Marlin Firmware and everything works. The printer heats up, auto bed levels, and starts the print. However, after a couple minutes (usually after the 1st or 2nd layer), the printer crashes and stops. It does not continue printing and I have to restart it again. It crashed for every single print, I have not had any successful prints yet.</p>
<p>Here is a video showing the issue:</p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/MzcrX3wcA-Q?start=0"></iframe>
</div></div></p>
<p>The camera was started right when the print started. After about 1.5 minutes, the printer crashes, and the lcd screen freezes.</p>
<p>Here are photos of a couple of prints that crashed:
<a href="https://i.stack.imgur.com/VHzNi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VHzNi.jpg" alt="Photos of sample prints" /></a></p>
<p>I have all of my code here: <a href="https://github.com/RosalieWessels/Marlin_MakerbotReplicator2" rel="nofollow noreferrer">https://github.com/RosalieWessels/Marlin_MakerbotReplicator2</a></p>
<p>My models are sliced with Cura and printed in PLA.</p>
<p>I tried hotend temperatures of 200, 210, and 220 degrees. My print speed is around 50 or 60 mm/s.</p>
<p>Here is a sample sliced file that was used:
<a href="https://filebin.net/df33a3jjwgemz0m8" rel="nofollow noreferrer">https://filebin.net/df33a3jjwgemz0m8</a></p>
<p>Thank you!</p>
|
<p>I see a couple likely culprits for a hardcrash like this</p>
<ul>
<li>problems with the power supply. If the power supply does not provide enough voltage an/or current to the board, this can lead to a lockup of the board.</li>
<li>temperature issues of the board. If the board overheats, it could fail to execute properly, leading to abort. make sure that the board is not overheating.</li>
<li>faulty firmware. recompile your firmware and reflash it.</li>
<li>faulty board.</li>
</ul>
|
<p>Few things to try,</p>
<p><strong>Check G-Code</strong> - Verify that the slicer is not the problem, slice using some other program / make a new default profile and re-slice.</p>
<p><strong>3D File</strong> - Also In parallel with the above point, I would get a standard test cube STL to start with. This will be a simple quick print to get a solid reference.</p>
<p><strong>Voltages</strong> - Get a Multi-meter on the Regulated Voltage rails, 5V Rail, 12V rail / 24V rail. See if at the moment of crash a voltage rail collapse, the most likely one would be the microcontroller rail, but you may be able to see the problem somewhere else.</p>
<p><strong>Current</strong> - If possible, measure the current draw of the printer either from the mains or after the AC/DC regulator. Its possible something is going horribly wrong and current limiting.</p>
<p><strong>Serial Port</strong> - Possibly connect the printer to a PC via its serial port and open a com port. See if the printer spits out an error code at the time of crash?</p>
<p><strong>End Stops</strong> - Double check that none of the End Stops are accidently being triggered (Although this should not crash the system, it might be part of the problem)</p>
<p><strong>Verify Sensor Readings</strong> - Check all end stops, check the bed temperature readings, check the nozzle temperature reading. Maybe a sensor has failed and is causing the controller to crash out.</p>
| 1,714
|
<p>I'm doing a little bit of work on a horrid piece of software built by Bangalores best.</p>
<p>It's written in mostly classic ASP/VbScript, but "ported" to ASP.NET, though most of the code is classic ASP style in the ASPX pages :(</p>
<p>I'm getting this message when it tries to connect to my local database:</p>
<p><strong>Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.</strong></p>
<pre><code>Line 38: MasterConn = New ADODB.Connection()
Line 39: MasterConn.connectiontimeout = 10000
Line 40: MasterConn.Open(strDB)
</code></pre>
<p>Anybody have a clue what this error means? Its connecting to my local machine (running SQLEXPRESS) using this connection string:</p>
<pre><code>PROVIDER=MSDASQL;DRIVER={SQL Server};Server=JONATHAN-PC\SQLEXPRESS\;DATABASE=NetTraining;Integrated Security=true
</code></pre>
<p>Which is the connection string that it was initially using, I just repointed it at my database.</p>
<p><strong>UPDATE:</strong></p>
<p>The issue was using "Integrated Security" with ADO. I changed to using a user account and it connected just fine.</p>
|
<p>I ran into this a long time ago with working in ASP. I found this knowledge base article and it helped me out. I hope it solves your problem.</p>
<p><a href="http://support.microsoft.com/kb/269495" rel="nofollow noreferrer">http://support.microsoft.com/kb/269495</a></p>
<p>If this doesn't work and everything checks out, then it is probably your connection string. I would try these steps next:</p>
<p>Remove:</p>
<pre><code>DRIVER={SQL Server};
</code></pre>
<p>Edit the Provider to this:</p>
<pre><code>Provider=SQLOLEDB;
</code></pre>
|
<p>As a side note, <a href="http://connectionstrings.com" rel="nofollow noreferrer">connectionstrings.com</a> is a great site so you don't have to remember all that connection string syntax.</p>
| 4,438
|
<p>I'm sorry if my question is so long and technical but I think it's so important other people will be interested about it</p>
<p>I was looking for a way to separate clearly some softwares internals from their representation in c++</p>
<p>I have a generic parameter class (to be later stored in a container) that can contain any kind of value with the the boost::any class</p>
<p>I have a base class (roughly) of this kind (of course there is more stuff)</p>
<pre><code>class Parameter
{
public:
Parameter()
template typename<T> T GetValue() const { return any_cast<T>( _value ); }
template typename<T> void SetValue(const T& value) { _value = value; }
string GetValueAsString() const = 0;
void SetValueFromString(const string& str) const = 0;
private:
boost::any _value;
}
</code></pre>
<p>There are two levels of derived classes:
The first level defines the type and the conversion to/from string (for example ParameterInt or ParameterString)
The second level defines the behaviour and the real creators (for example deriving ParameterAnyInt and ParameterLimitedInt from ParameterInt or ParameterFilename from GenericString)</p>
<p>Depending on the real type I would like to add external function or classes that operates depending on the specific parameter type without adding virtual methods to the base class and without doing strange casts</p>
<p>For example I would like to create the proper gui controls depending on parameter types:</p>
<pre><code>Widget* CreateWidget(const Parameter& p)
</code></pre>
<p>Of course I cannot understand real Parameter type from this unless I use RTTI or implement it my self (with enum and switch case), but this is not the right OOP design solution, you know.</p>
<p>The classical solution is the Visitor design pattern <a href="http://en.wikipedia.org/wiki/Visitor_pattern" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Visitor_pattern</a></p>
<p>The problem with this pattern is that I have to know in advance which derived types will be implemented, so (putting together what is written in wikipedia and my code) we'll have sort of: </p>
<pre><code>struct Visitor
{
virtual void visit(ParameterLimitedInt& wheel) = 0;
virtual void visit(ParameterAnyInt& engine) = 0;
virtual void visit(ParameterFilename& body) = 0;
};
</code></pre>
<p>Is there any solution to obtain this behaviour in any other way without need to know in advance all the concrete types and without deriving the original visitor?</p>
<hr>
<p><strong>Edit:</strong> <a href="https://stackoverflow.com/q/31913">Dr. Pizza's solution seems the closest to what I was thinking</a>, but the problem is still the same and the method is actually relying on dynamic_cast, that I was trying to avoid as a kind of (even if weak) RTTI method</p>
<p>Maybe it is better to think to some solution without even citing the visitor Pattern and clean our mind. The purpose is just having the function such:</p>
<pre><code>Widget* CreateWidget(const Parameter& p)
</code></pre>
<p>behave differently for each "concrete" parameter without losing info on its type </p>
|
<p>For a generic implementation of <a href="http://en.wikipedia.org/wiki/Visitor_pattern" rel="nofollow noreferrer">Vistor</a>, I'd suggest the <a href="http://loki-lib.sourceforge.net/index.php?n=Pattern.Visitor" rel="nofollow noreferrer">Loki Visitor</a>, part of the <a href="http://loki-lib.sourceforge.net/index.php?n=Main.HomePage" rel="nofollow noreferrer">Loki library</a>.</p>
|
<p>If I understand this correctly...</p>
<p>We had a object that could use different hardware options. To facilitate this we used a abstract interface of Device. Device had a bunch of functions that would be fired on certain events. The use would be the same but the various implementations of the Device would either have a fully-fleshed out functions or just return immediately. To make life even easier, the functions were void and threw exceptions on when something went wrong.</p>
| 5,186
|
<p><strong>What "Hidden Features" of JavaScript do you think every programmer should know?</strong></p>
<p>After having seen the excellent quality of the answers to the following questions I thought it was time to ask it for JavaScript.</p>
<ul>
<li><a href="https://stackoverflow.com/questions/954327/">Hidden Features of HTML</a></li>
<li><a href="https://stackoverflow.com/questions/628407">Hidden Features of CSS</a></li>
<li><a href="https://stackoverflow.com/questions/61401/">Hidden Features of PHP</a></li>
<li><a href="https://stackoverflow.com/questions/54929/">Hidden Features of ASP.NET</a></li>
<li><a href="https://stackoverflow.com/questions/9033/">Hidden Features of C#</a></li>
<li><a href="https://stackoverflow.com/questions/15496/">Hidden Features of Java</a></li>
<li><a href="https://stackoverflow.com/questions/101268/">Hidden Features of Python</a></li>
</ul>
<p>Even though JavaScript is arguably the most important Client Side language right now (just ask Google) it's surprising how little most web developers appreciate how powerful it really is.</p>
|
<p>You don't need to define any parameters for a function. You can just use the function's <code>arguments</code> array-like object.</p>
<pre><code>function sum() {
var retval = 0;
for (var i = 0, len = arguments.length; i < len; ++i) {
retval += arguments[i];
}
return retval;
}
sum(1, 2, 3) // returns 6
</code></pre>
|
<p>Well, it's not much of a feature, but it is very useful:</p>
<p>Shows selectable and formatted alerts:</p>
<pre><code>alert(prompt('',something.innerHTML ));
</code></pre>
| 8,621
|
<p>I can't seem to find Developer Express' version of the <code>LinkButton</code>. (The Windows Forms linkbutton, not the <code>ASP.NET</code> linkbutton.) <code>HyperLinkEdit</code> doesn't seem to be what I'm looking for since it looks like a TextEdit/TextBox.</p>
<p>Anyone know what their version of it is? I'm using the latest DevX controls: 8.2.1.</p>
|
<p>The control is called the HyperLinkEdit. You have to adjust the properties to get it to behave like the System.Windows.Forms control like so:</p>
<pre><code> control.BorderStyle = BorderStyles.NoBorder;
control.Properties.Appearance.BackColor = Color.Transparent;
control.Properties.AppearanceFocused.BackColor = Color.Transparent;
control.Properties.ReadOnly = true;
</code></pre>
|
<p>You should probably just use the standard ASP.Net LinkButton, unless it's really missing something you need.</p>
| 2,571
|
<p>In OpenSCAD, I am trying to make a linear_extrude on a shape imported from an svg. The svg file contains multiple path. I would like to scale each path separately. I have tried the following code, but the whole import is considered a single shape resulting in the image below.</p>
<pre><code>linear_extrude(height = 5, center = true, scale=1.2)
import(file = "xxx.svg", center = true, dpi = 96);
</code></pre>
<p><a href="https://i.stack.imgur.com/cg1Rq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cg1Rq.png" alt="result" /></a></p>
<p>How can I have each of the letters to have 'its own pyramid' ?</p>
<p>I know I could create one SVG per letter. But for simplicity sake I would like to have only one SVG file, as I want to create much more complex motives in the future. My final goal is to create stamps from SVG drawings.</p>
<p>Edit:
Alternative tried after Mick's comment (same result):</p>
<pre><code>module pyramidChildren(height){
for ( i= [0:1:$children-1])
linear_extrude(height = height, scale=1.5)
children(i);
}
pyramidChildren(5)
import(file = "xxx.svg", center = true, dpi = 96);
</code></pre>
<p>I have tried to use the basic svg (multiple paths) and also to group each path (with only itself) without changes in the result.</p>
|
<p>Lame solution: creating stepped pyramid with offset. I realized that scale will not worked for motives with holes inside. Offset seems then more appropriate than scale for my application (creation of stamps)</p>
<p>It takes ages to render, but it could be enough for simple patterns. Any better solution are still welcome...</p>
<pre><code>module buildPyramidalExtrude(height,maxOffset,nSlices){
heightIncrement = height/nSlices;
offsetIncrement = maxOffset/(nSlices-1);
for(i=[1:nSlices])
linear_extrude(height=i*heightIncrement)
offset(r = maxOffset-(i-1)*offsetIncrement)
children();
}
buildPyramidalExtrude(4,2.5,20)
import(file = "Farm/cow.svg", center = true);
</code></pre>
<p><a href="https://i.stack.imgur.com/pGUnC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pGUnC.png" alt="result" /></a></p>
|
<p>One option is to use <code>minkowski()</code> to combine the svg with a cone. On the positive side, it gives a rather nice result, but the downsides are:</p>
<ul>
<li>it's pretty slow</li>
<li>it fattens the bottom rather than shrinking the top, so depending on your needs you may have to invert the image, run <code>minkowski</code>, then invert again.</li>
</ul>
<p>Another option is to convert to grayscale <strong>png and apply a blur</strong> with an external tool, then to import using <code>surface()</code> (the gray blur will become a nice slope). That will both fatten the bottom and shrink the top, but keeping only the top half should give the desired result.</p>
| 1,810
|
<p>I just order myself an Ender 3 Pro which will come by the end of the week.
Before it arrives I want to be ready to flash a bootloader onto it.</p>
<p>I was wondering what other options there are to flashing except using an Arduino?</p>
<p>I have a bunch of ESP8266/ESP32 and a <a href="https://www.banggood.com/FT232RL-FTDI-USB-To-TTL-Serial-Converter-Adapter-Module-For-Arduino-p-917226.html?rmmds=myorder&cur_warehouse=CN" rel="nofollow noreferrer">USB to TTL</a>. Would it be possible to use these somehow instead of an Arduino to flash a bootloader to the Ender 3?
Or should I just go buy an Arduino?</p>
|
<p>What you need to is called a ICSP or ISP: <a href="https://en.wikipedia.org/wiki/In-system_programming" rel="noreferrer">in-circuit serial programmer or in-system programmer</a>, which excludes the USB to TTL device you own.</p>
<p>I've never used an ESP8266 as ICSP but it seems there are <a href="https://arduino.stackexchange.com/questions/44702/esp8266-as-isp-program-for-atmega16">some resources out there</a> reporting it is possible.
If you want to go the easiest way probably you want to buy an Arduino and follow the tons of tutorials out there, if you are looking to save some money then you might get around buying an ICSP like the very well known USBASP (just Google for that).</p>
|
<p>You can do AVR programming using USB-TTL adapters. This relies on bit-banging, i.e. emulating the programming protocol by using the serial control lines as general purpose IO.</p>
<p>But this has a few caveats:</p>
<ul>
<li>USB-TTL adapters limit the speed of control line changes. So the programming will be very slow, taking several minutes.</li>
<li>You need to have the RTS, DTR and CTS lines available on the USB-TTL adapter. Many of the cheap adapters do not have these signals available on pins, though you could solder to the chip directly.</li>
</ul>
<p>If those two are in order, go ahead and install <a href="https://www.nongnu.org/avrdude/" rel="nofollow noreferrer">avrdude</a>, take one of the serial port bitbang (<code>serbb</code> driver) example files and configure it with information on which serial adapter pins you've connected to the AVR chip. Then give <code>-i 1000</code> or similar delay value to <code>avrdude</code> to slow it down enough to work over the USB interface.</p>
<p>There is <a href="http://nerdralph.blogspot.com/2014/05/pl-2303hx-bit-bang-avr-programmer.html" rel="nofollow noreferrer">a blog post about doing it with PL2303 based adapter</a>, but the technique should work on other USB-TTL adapters also.</p>
| 1,508
|
<p>I would like to print multiple parts continuously (non-interactively), so
I can leave the printer alone for a longer time. So after finish, parts could be moved somehow out from the printing area, so the next can start.</p>
<p>Are there any methods of achieving that with standard desktop printers without having to use multiple printers?</p>
|
<p>The only thing I can think of off hand is an old mod for the early MakerBot machines. It first was released for the Thing-O'-Matic I believe, but is compatible with Replicator 1 machines (and its knock-offs). Here's the <a href="http://www.thingiverse.com/thing:4056" rel="noreferrer">Thingiverse page</a>, but look up Automatic Build Plate.</p>
<p>Essentially, you can use the Replicator G slicing program and there is a setting for "ABP" or Automatic Build Plate. This will basically tell the ABP to run its routine after the controller receives the response that the printing program is done and roll the finished part off the edge of the build plate, then start the same program over again.</p>
<p>Drawbacks:</p>
<ul>
<li>I don't think it's easily compatible with newer machines/slicers. But, it's open source</li>
<li>Pretty sure you have to use Replicator G, which is outdated now and may make your machine sound like it's going to fall apart (I know from experience)</li>
</ul>
<p>Going off of @Pete's answer about solenoids. It reminded me that someone integrated a <a href="http://www.thingiverse.com/thing:872617" rel="noreferrer">solenoid "ejector"</a> (aka Boxing Glove) for their machine.</p>
<p>Update (06/08/2016):</p>
<p>Forgot to mention that if you choose to create your own "Boxing Glove" or conveyor belt, some software such as Octo-Pi and Repetier-Host allow plugins. So, you could interface with your hardware via customized code and integrate the functionality directly into the slicing application for the full closed loop operation.</p>
|
<p>I Don't really think that it is possible without hardware modifications, or maybe some small parts that will fit in the bed of the printer all on the same time</p>
| 106
|
<p>I have a website that is perfectely centered aligned. The CSS code works fine. The problem doesn't really have to do with CSS. I have headers for each page that perfectely match eachother.</p>
<p>However, when the content gets larger, Opera and FireFox show a scrollbar at the left so you can scroll to the content not on the screen. This makes my site jump a few pixels to the left. Thus the headers are not perfectely aligned anymore.</p>
<p>IE always has a scrollbar, so the site never jumps around in IE. </p>
<p>Does anyone know a JavaScript/CSS/HTML solution for this problem?</p>
|
<p>I use </p>
<pre><code>html { overflow-y: scroll; }
</code></pre>
<p>To standardize the scrollbar behavior in IE and FF</p>
|
<p>Are you aligning with percentage widths or fixed widths? I'm also guessing you're applying a background to the body - I've had this problem myself.</p>
<p>It'll be much easier to help you if you upload the page so we can see the source code however.</p>
| 4,654
|
<p>I'm currently working on an application with a frontend written in Adobe Flex 3. I'm aware of <a href="http://code.google.com/p/as3flexunitlib/" rel="noreferrer">FlexUnit</a> but what I'd really like is a unit test runner for Ant/NAnt and a runner that integrates with the Flex Builder IDE (AKA Eclipse). Does one exist? </p>
<p>Also, are there any other resources on how to do Flex development "the right way" besides the <a href="http://labs.adobe.com/wiki/index.php/Cairngorm" rel="noreferrer">Cairngorm microarchitecture</a> example?</p>
|
<p>The <a href="http://code.google.com/p/dpuint/" rel="noreferrer">dpUint</a> testing framework has a test runner built with AIR which can be integrated with a build script.</p>
<p>There is also my <a href="http://developer.iconara.net/objectlib/flexunitautomation.html" rel="noreferrer">FlexUnit</a> automation kit which does more or less the same for FlexUnit. It has an Ant macro that makes it possible to run the tests as a part of an Ant script, for example:</p>
<pre><code><target name="run-tests" depends="compile-tests">
<flexunit swf="${build.home}/tests.swf" failonerror="true"/>
</target>
</code></pre>
|
<p>An alternative to FlexUnit is the <a href="http://www.asunit.org/" rel="nofollow noreferrer">AsUnit</a> testing tools. There are versions for actionscript 2 and 3. It also has good integration with <a href="http://www.projectsprouts.org/" rel="nofollow noreferrer">Project Sprouts</a>, which is a build tool for Flex and Flash similar to ant, however it uses ruby rake tasks and includes excellent dependency management along the lines of maven.</p>
<p>No IDE integration that I know of however.</p>
| 2,440
|
<p>What's the best way to copy a file from a network share to the local file system using a Windows batch file? Normally, I would use "net use *" but using this approach how can I get the drive letter?</p>
|
<p>Can you just use the full UNC path to the file?</p>
<pre><code>copy \\myserver\myshare\myfolder\myfile.txt c:\myfiles
</code></pre>
|
<p>You can also use <code>xcopy</code> and <code>robocopy</code>:</p>
<pre><code>xcopy "\\server\share\path" "destination"
</code></pre>
<pre><code>robocopy "\\server\share\path" "destination"
</code></pre>
| 6,879
|
<p>I would like to use an add-in like simple-modal or the dialog add-in in the UI kit. However, how do I use these or any other and get a result back. Basically I want the modal to do some AJAX interaction with the server and return the result for the calling code to do some stuff with.</p>
|
<p>Here is how the confirm window works on simpleModal:</p>
<pre><code>$(document).ready(function () {
$('#confirmDialog input:eq(0)').click(function (e) {
e.preventDefault();
// example of calling the confirm function
// you must use a callback function to perform the "yes" action
confirm("Continue to the SimpleModal Project page?", function () {
window.location.href = 'http://www.ericmmartin.com/projects/simplemodal/';
});
});
});
function confirm(message, callback) {
$('#confirm').modal({
close: false,
overlayId: 'confirmModalOverlay',
containerId: 'confirmModalContainer',
onShow: function (dialog) {
dialog.data.find('.message').append(message);
// if the user clicks "yes"
dialog.data.find('.yes').click(function () {
// call the callback
if ($.isFunction(callback)) {
callback.apply();
}
// close the dialog
$.modal.close();
});
}
});
}
</code></pre>
|
<p>Since the modal dialog is on the page, you're free to set any document variable you want. However all of the modal dialog scripts I've seen included a demo using the return value, so it's likely on that page.</p>
<p>(the site is blocked for me otherwise I'd look)</p>
| 7,272
|
<p>I have a MySQL table with approximately 3000 rows per user. One of the columns is a datetime field, which is mutable, so the rows aren't in chronological order.</p>
<p>I'd like to visualize the time distribution in a chart, so I need a number of individual datapoints. 20 datapoints would be enough.</p>
<p>I could do this:</p>
<pre><code>select timefield from entries where uid = ? order by timefield;
</code></pre>
<p>and look at every 150th row.</p>
<p>Or I could do 20 separate queries and use <code>limit 1</code> and <code>offset</code>. </p>
<p>But there must be a more efficient solution...</p>
|
<p>Michal Sznajder almost had it, but you can't use column aliases in a WHERE clause in SQL. So you have to wrap it as a derived table. I tried this and it returns 20 rows:</p>
<pre><code>SELECT * FROM (
SELECT @rownum:=@rownum+1 AS rownum, e.*
FROM (SELECT @rownum := 0) r, entries e) AS e2
WHERE uid = ? AND rownum % 150 = 0;
</code></pre>
|
<p><a href="https://stackoverflow.com/questions/3682/sql-distribution-of-table-in-time#3691">@Michal</a></p>
<p>For whatever reason, your example only works when the where @recnum uses a less than operator. I think when the where filters out a row, the rownum doesn't get incremented, and it can't match anything else.</p>
<p>If the original table has an auto incremented id column, and rows were inserted in chronological order, then this should work:</p>
<pre><code>select timefield from entries
where uid = ? and id % 150 = 0 order by timefield;
</code></pre>
<p>Of course that doesn't work if there is no correlation between the id and the timefield, unless you don't actually care about getting evenly spaced timefields, just 20 random ones.</p>
| 2,575
|
<p>I've recently started using Eclipse Ganymede CDT for C development and I couldn't like it more. I'm aware the learning curve could be sort of pronounced, therefore and with your help, my goal is to flatten it as much as possible. I'm looking for the best hacks, hints, tips, tricks, and best practices to really unleash the full power of the IDE.</p>
|
<p><strong>Accurate Indexing</strong></p>
<p>With CDT you should be sure to enable the "Full Indexing" option rather than the "Fast Indexing" default. It's not perceptibly slower on modern hardware and it does a much better job. In that vein, you should be sure to enable semantic highlighting. This isn't as important in C/C++ as it is in a language like Scala, but it's still extremely useful.</p>
<p><strong>Streamlined Editing</strong></p>
<p>Get used to using <kbd>Ctrl</kbd>+<kbd>O</kbd> and <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>H</kbd>. The former pops up an incrementally searchable outline view, while the latter opens the "Call Hierarchy" view and searches on the currently selected function. This is incredibly useful for tracing execution.</p>
<p><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd> (Open Type) isn't exactly an "editing" combo per se, but it is equally important in my workflow. The C++ Open Type dialog not only allows incremental filtering by type, but also selecting of definition (<code>.h</code>) or declaration (<code>.cpp</code>) and even filtering by element type (<code>typedef</code>, <code>struct</code>, <code>class</code>, etc).</p>
<p><strong>Task Oriented Programming</strong></p>
<p>Mylyn: never leave home without it. I just can't say enough about this tool. Every time I'm forced to do without it I find myself having to re-learn how to deal with all of the code noise. Very, very handy to have.</p>
<p><strong>Stripped Down Views</strong></p>
<p>The default Eclipse workspace layout is extremely inefficient both in space and in usability. Everyone has their favorite layout, take some time and find yours. I like to minimize (not necessarily close) everything except for Outline and keep the C/C++ Project Explorer docked in the sidebar configured to precisely hide the Outline when expanded. In this way I can always keep the editor visible while simultaneously reducing the space used by views irrelevant to the current task.</p>
|
<p><strong>If the Java Developer Tools aren't installed the Spellcheck won't work.</strong></p>
<p>The Spellcheck functionality is dependent upon the Java Development Tools being installed. This can be a perplexing issue if you just install the C Development Tools exclusively, because it gives no reason for the Spell Checker not working.</p>
| 9,469
|
<p>I have an application running under Windows XP, and I'm accessing the Processor and Memory performance counters. When I try to run the same code and access them on XP Embedded, the counters don't seem to be present. They are present in the image - I can see them all in perfmon. What's the missing piece here?</p>
|
<p>Have you added all the WMI components? As far as I know, you need all the WMI components to access the counters!</p>
<blockquote>
<p>The Performance Counter Windows Management Instrumentation (WMI) Provider component provides a bridge between the performance registry interface and the WMI interface. This component allows WMI clients to access performance counters through WMI scripts, and allows management applications built using WMI to access performance counters. Without this component, applications must directly use the registry interface or the performance data helper interface to access performance counters. </p>
</blockquote>
<p>Thank you TimK for the link (<a href="http://msdn.microsoft.com/en-us/library/aa939695.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa939695.aspx</a>)</p>
|
<p>Have you added all the WMI components? As far as I know, you need all the WMI components to access the counters!</p>
<blockquote>
<p>The Performance Counter Windows Management Instrumentation (WMI) Provider component provides a bridge between the performance registry interface and the WMI interface. This component allows WMI clients to access performance counters through WMI scripts, and allows management applications built using WMI to access performance counters. Without this component, applications must directly use the registry interface or the performance data helper interface to access performance counters. </p>
</blockquote>
<p>Thank you TimK for the link (<a href="http://msdn.microsoft.com/en-us/library/aa939695.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa939695.aspx</a>)</p>
| 8,064
|
<p>A plastic gear of an older DVD player broke. I always read about being 3D printing a "repair revolution". So I looked for a template to give to some printing service, but I found none (and nothing close to it).</p>
<p>Could you please explain me, what steps a layman should take to get the gear piece replaced using 3D printing?</p>
|
<p>If you have the remaining pieces of the gear and enough remains to determine certain measurements, one can either engineer the gear using a number of gear modeling designs, or one can take measurements directly from the parts and engineer a raw design.</p>
<p>If the gear you have is not particularly peculiar, it is possible to use a gear generator plug-in, template, or library to make the "foundation" of your gear. The modeling software would then be used to add the appropriate bosses and key ways required to complete the design.</p>
<p>If you are considering to create the part yourself, you have a wide selection of programs from which to choose. I'm fond of OpenSCAD, and it does have <a href="http://www.thingiverse.com/akaziuna/collections/openscad-gear-scripts" rel="noreferrer">a number of gear libraries</a>. Simple bosses and key ways are easily accomplished using <a href="http://www.openscad.org/" rel="noreferrer">OpenSCAD</a>.</p>
<p><a href="https://i.stack.imgur.com/jPb52.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/jPb52.jpg" alt="Thingiverse gear image"></a></p>
<p>Another package available on the internet which includes the option of using a gear generator is <a href="https://www.instructables.com/id/Gearing-up-in-TinkerCad/" rel="noreferrer">Tinkercad</a> which has a reputation of being easy to use. You'll find many tutorials for this program as well.</p>
<p>Tinkercad requires an "outside" program to generate the gear design which is then imported to the model workspace. Even a program as simple as Inkscape can create gear profiles to be imported into many design packages.</p>
<p>Fusion360 is available free for hobby or non-commercial use, but may not be the easiest to learn in a short time.</p>
<p>So many others as well. Use your favorite search engine for "<a href="https://www.google.com/#q=gear+generator+modeling+software" rel="noreferrer">gear generator modeling software</a>" or similar wording and be overloaded with links.</p>
|
<p>The only 'layman's' option is to find an existing design which solves your problem. If you are lucky, and the product you have has a common failure mode, someone else might have a) solved the same problem already, and b) posted their design online.</p>
<p>Sites such as <a href="http://www.thingiverse.com/search?q=dvd+gear&sa=" rel="nofollow noreferrer">thingiverse</a> have plenty of designs, but finding the right thing might be hard. If you find something, you can then look for someone to print it for you. Its not clear if you tried this already, but maybe the answer helps someone else. </p>
| 529
|
<p>I am trying to snoop on a log file that an application is writing to.</p>
<p>I have successfully hooked createfile with the detours library from MSR, but createfile never seems to be called with file I am interested in snooping on. I have also tried hooking openfile with the same results.</p>
<p>I am not an experienced Windows/C++ programmer, so my initial two thoughts were either that the application calls createfile before I hook the apis, or that there is some other API for creating files/obtaining handles for them.</p>
|
<p>You can use Sysinternal's <a href="http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx" rel="nofollow noreferrer">FileMon</a>.
It is an excellent monitor that can tell you exactly which file-related system calls are being
made and what are the parameters.</p>
<p>I think that this approach is much easier than hooking API calls and much less intrusive.</p>
|
<p><a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" rel="nofollow noreferrer">Process Monitor</a> from sysinternals could help too.</p>
| 3,475
|
<p>Flsun 3D Cube; Marlin 1.1.1; main board: Makerbase MKS Gen_L V1.0; running from either Repetier or OctoPrint.</p>
<p>I was recently obliged to replace the main board when it stopped powering the heated bed. I got the new main board - same make, version, etc - got everything setup just as it was before, but the bed still doesn't heat. Multimeter shows zero across the board's heat bed contacts, whether using G-code from the terminal (in both Repetier and Octoprint), G-code in the print file, or the control panel on the front of the printer. The thermistor works: if I shine a heat lamp on the bed, it registers the temp change.</p>
<p>Bad board? Something in the Merlin config I missed? Is the board smart enough to not power it on if the bed heater itself is bad?</p>
|
<p>Considering:</p>
<blockquote>
<p>Multimeter shows zero across the board's heat bed contacts</p>
</blockquote>
<p>this implies that </p>
<ul>
<li>If you measured <strong>resistance</strong>, the heated bed has no resistance. Basically this implies that the bed has a short. This might be the reason why it is not working. If you would power it as such you create a short. Instead of replacing the board, you need to replace the heated bed. Typical values for a heated bed of about 200 x 200 mm are in the order of 1.2 Ω (measurements between 0.9 and 1.5 Ω are reasonable to be expected).</li>
<li>If you measured <strong>voltage</strong>, the heated bed does not receive power for heating, or the power does not reach the bed (not turned on or broken wire?). It would then be wise to measure the resistance (of the bed and the wires). If the resistance is in the order of about 1.2 Ω (see above) for the bed, you could try to connect the heated bed directly to the PSU to see if it gets warm, if so, please disconnect immediately to prevent damage. From this experiment you can find whether the heated bed is broken (or the cables), or that the board is not functioning correctly, this is, however, strange as you tried 2 boards. A possible suspect could be the MOSFET that schedules the powering of the heated bed if you use an external MOSFET board that it.</li>
<li>If you measured <strong>current</strong>, then you found out that no power is delivered to the board, but you also might have broken your board in the process, as measuring current is a (close to) 0 Ω connection and has to be done <em>in line</em> of a circuit.</li>
</ul>
|
<p>Since the bed was warm when you connected to 12 V that means the bed and the wiring are good. It sounds like your multimeter is not too accurate, with a reading of 0.5 Ω (or you measured accidentally some other circuit), but no worries. </p>
<p>Since both boards do not power the bed, it seems like it could be a firmware setting. To help with that, a look at your config file, and possibly the <code>pins_ramps.h</code> file can help.</p>
<p>As a first check, your <code>mks_gen_L.h</code> file should look like this;</p>
<pre><code> #if HOTENDS > 2 || E_STEPPERS > 2
#error "MKS GEN L supports up to 2 hotends / E-steppers. Comment out this line to continue."
#endif
#define BOARD_NAME "MKS GEN L"
//
// Heaters / Fans
//
// Power outputs EFBF or EFBE
#define MOSFET_D_PIN 7
//
// CS Pins wired to avoid conflict with the LCD
// See https://www.thingiverse.com/asset:66604
//
#ifndef X_CS_PIN
#define X_CS_PIN 59
#endif
#ifndef Y_CS_PIN
#define Y_CS_PIN 63
#endif
#include "pins_RAMPS.h"
</code></pre>
<p>Now all you need to confirm is that your bed is hooked to D7.</p>
| 1,223
|
<p>I'm thinking of creating a small offline blog editor for personal use and I don't know how do the APIs work. Where can I find this information?</p>
<p>I'm particularly looking for the most common providers: Blogger, Wordpress, MovableType, Live Spaces (not sure if this has an API) etc.</p>
|
<p>See the following links:</p>
<p><a href="http://www.blogger.com/developers/api/1_docs/" rel="nofollow noreferrer">Blogger</a></p>
<p><a href="http://codex.wordpress.org/Plugin_API" rel="nofollow noreferrer">Wordpress</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb447732.aspx" rel="nofollow noreferrer">Live Spaces</a></p>
|
<p>The Blogger API link you provided says:</p>
<blockquote>
<p>This documentation is provided for
historical interest only. The Blogger
1.0 API is no longer supported and must not be used for new client
development. Please use our GData API
instead.</p>
</blockquote>
<p>So the correct one probably is: <a href="http://code.google.com/apis/blogger/" rel="nofollow noreferrer">http://code.google.com/apis/blogger/</a></p>
<p>Also, if more APIs are answered in this question, would you be kind enough to edit your answer to include them. Since I'm gonna vote it as the correct one.</p>
<p>Thank you.</p>
| 4,435
|
<p><a href="https://stackoverflow.com/questions/12073/what-is-the-best-xml-editor">https://stackoverflow.com/questions/12073/what-is-the-best-xml-editor</a> was a great question regarding XML editors on Windows. What about on OS X?</p>
<p>Oxygen is feature complete, but, it's a Java app and a bit clunky on OSX. It's also extremely expensive.</p>
<p>Anything Mac native and comparable in features for less than $300 ?</p>
<p>Thanks</p>
<p>Andrew</p>
|
<p><a href="http://www.editix.com/" rel="nofollow noreferrer">EditiX XML Editor</a> (starts at $60) or maybe <a href="http://www.oxygenxml.com/" rel="nofollow noreferrer">oXygen</a> ($299 is less than $300, right).</p>
<p>You'll find a big list of the optiosn over at <a href="http://xmacl.com/" rel="nofollow noreferrer">XMacL</a> if you want more choices.</p>
|
<p>Netbeans could be a good and free choice too.</p>
| 6,796
|
<p>I've gone back and forth between having an organized inbox and having an inbox with absolutely everything I've received in it. </p>
<p>Would you recommend leaving everything in an inbox, or organize it? If you organize it, is there any method to your madness or possibly an Outlook (2003) plug-in to aid in this task?</p>
<p>For what it's worth, I <em>feel</em> way more productive with everything in my inbox, grouped by date. I <em>feel</em> like a spend way more time doing inbox management any other way.</p>
|
<p>I would recommend following the <a href="http://video.google.com/videoplay?docid=973149761529535925" rel="nofollow noreferrer">inbox zero</a> approach advocated by 43 folders. Joel Spolsky apparently uses it and a lot of people feel it's a great way of decluttering and organising your email life :-).</p>
|
<p>The best place to start with getting control of your email is definitely Merlin Mann's excellent <a href="http://www.43folders.com/izero" rel="nofollow noreferrer">Inbox Zero</a> series. In particular his <a href="http://video.google.com/videoplay?docid=973149761529535925&hl=en" rel="nofollow noreferrer">Google Tech Talk video</a> is a great talk.</p>
| 5,904
|
<p>I'm trying to find out how much memory my own .Net server process is using (for monitoring and logging purposes).</p>
<p>I'm using:</p>
<pre><code>Process.GetCurrentProcess().PrivateMemorySize64
</code></pre>
<p>However, the Process object has several different properties that let me read the memory space used:
Paged, NonPaged, PagedSystem, NonPagedSystem, Private, Virtual, WorkingSet</p>
<p>and then the "peaks": which i'm guessing just store the maximum values these last ones ever took.</p>
<p>Reading through the MSDN definition of each property hasn't proved too helpful for me. I have to admit my knowledge regarding how memory is managed (as far as paging and virtual goes) is very limited.</p>
<p>So my question is obviously "which one should I use?", and I know the answer is "it depends".</p>
<p>This process will basically hold a bunch of lists in memory of things that are going on, while other processes communicate with it and query it for stuff. I'm expecting the server where this will run on to require lots of RAM, and so i'm querying this data over time to be able to estimate RAM requirements when compared to the sizes of the lists it keeps inside.</p>
<p>So... Which one should I use and why?</p>
|
<p>If you want to know how much the GC uses try:</p>
<pre><code>GC.GetTotalMemory(true)
</code></pre>
<p>If you want to know what your process uses from Windows (VM Size column in TaskManager) try:</p>
<pre><code>Process.GetCurrentProcess().PrivateMemorySize64
</code></pre>
<p>If you want to know what your process has in RAM (as opposed to in the pagefile) (Mem Usage column in TaskManager) try:</p>
<pre><code>Process.GetCurrentProcess().WorkingSet64
</code></pre>
<p>See <a href="http://web.archive.org/web/20051030010819/http://shsc.info/WindowsMemoryManagement" rel="noreferrer">here</a> for more explanation on the different sorts of memory.</p>
|
<p>Working set isn't a good property to use. From what I gather, it includes everything the process can touch, even libraries shared by several processes, so you're seeing double-counted bytes in that counter. Private memory is a much better counter to look at.</p>
| 5,099
|
<p>Is there any benefit in using a <code><blockquote></code> element over a <code><div></code>? I was looking at a website's markup to learn CSS and I couldn't figure out why the <code><blockquote></code> was being used.</p>
<p>EDIT: Yeah sorry I didn't clarify, it was used to hold the <code><div></code> tag with username as 'text' and an <code>input</code> tag. There was clearly no quote.</p>
|
<p>In theory, HTML should be as "semantic" as possible - meaning that every element should indicate something about its content. <code><h1></code><em>s</em> should enclose the most important headline; <code><p></code><em>s</em> should surround paragraphs; <code><em></code> should indicate emphasis, etc.</p>
<p>That way the code makes sense when you - or a screen reader, or whatever - look at it. This also helps for devices that don't understand all (or any) of your CSS rules.</p>
|
<p>As mentioned, <code><blockquote></code> is for quoting. Similarly you will use several <code><p></code> blocks for paragraphs within one <code><div></code> that holds page content or whatever. HTML5 proposal will have lot more block elements (i.e same as divs) which purpose will be to add a semantic info about it, such as header, footer, menu, etc.</p>
| 6,450
|
<p>When you use Zedgraph for linegraphs and set IsSmooth to true, the lines are nicely curved instead of having hard corners/angles.</p>
<p>While this looks much better for most graphs -in my humble opinion- there is a small catch. The smoothing algorithm makes the line take a little 'dive' or 'bump' before going upwards or downwards. </p>
<p>In most cases, if the datapoint are themselves smooth, this isn't a problem, but if your datapoints go from say 0 to 15, the 'dive' makes the line go under the x-axis, which makes it seems as though there are some datapoints below zero (which is not the case).</p>
<p>How can I fix this (prefably easily ;)</p>
|
<p>No simple answer for this. Keeping the tension near zero will be your simplest solution.</p>
<p>ZedGraph uses GDI's DrawCurve tension parameter to apply smoothness, which is probably Hermite Interpolation. You can try to implement your own Cosine Interpolation, which will keep local extremes because of its nature. You can look at the this link to see why:
<a href="http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/interpolation/" rel="nofollow noreferrer">http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/interpolation/</a></p>
<p>EDIT: Website is down. Here is a cached version of the page:
<a href="http://web.archive.org/web/20090920093601/http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/interpolation/" rel="nofollow noreferrer">http://web.archive.org/web/20090920093601/http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/interpolation/</a></p>
|
<p>You could try to alter the myCurve.Line.SmoothTension property up or down and see if that helps.</p>
| 8,543
|
<p>It seems like anything you can do with bytecode you can do just as easily and much faster in native code. In theory, you could even retain platform and language independence by distributing programs and libraries in bytecode then compiling to native code at installation, rather than JITing it.</p>
<p>So in general, when would you want to execute bytecode instead of native?</p>
|
<p>Hank Shiffman from SGI said (a long time ago, but it's till true):</p>
<blockquote>
<p>There are three advantages of Java
using byte code instead of going to
the native code of the system:</p>
<ol>
<li><p><strong>Portability</strong>: Each kind of computer has its unique instruction
set. While some processors include the
instructions for their predecessors,
it's generally true that a program
that runs on one kind of computer
won't run on any other. Add in the
services provided by the operating
system, which each system describes in
its own unique way, and you have a
compatibility problem. In general, you
can't write and compile a program for
one kind of system and run it on any
other without a lot of work. Java gets
around this limitation by inserting
its virtual machine between the
application and the real environment
(computer + operating system). If an
application is compiled to Java byte
code and that byte code is interpreted
the same way in every environment then
you can write a single program which
will work on all the different
platforms where Java is supported.
(That's the theory, anyway. In
practice there are always small
incompatibilities lying in wait for
the programmer.)</p></li>
<li><p><strong>Security</strong>: One of Java's virtues is its integration into the Web. Load
a web page that uses Java into your
browser and the Java code is
automatically downloaded and executed.
But what if the code destroys files,
whether through malice or sloppiness
on the programmer's part? Java
prevents downloaded applets from doing
anything destructive by disallowing
potentially dangerous operations.
Before it allows the code to run it
examines it for attempts to bypass
security. It verifies that data is
used consistently: code that
manipulates a data item as an integer
at one stage and then tries to use it
as a pointer later will be caught and
prevented from executing. (The Java
language doesn't allow pointer
arithmetic, so you can't write Java
code to do what we just described.
However, there is nothing to prevent
someone from writing destructive byte
code themselves using a hexadecimal
editor or even building a Java byte
code assembler.) It generally isn't
possible to analyze a program's
machine code before execution and
determine whether it does anything
bad. Tricks like writing
self-modifying code mean that the evil
operations may not even exist until
later. But Java byte code was designed
for this kind of validation: it
doesn't have the instructions a
malicious programmer would use to hide
their assault.</p></li>
<li><p><strong>Size</strong>: In the microprocessor world RISC is generally preferable
over CISC. It's better to have a small
instruction set and use many fast
instructions to do a job than to have
many complex operations implemented as
single instructions. RISC designs
require fewer gates on the chip to
implement their instructions, allowing
for more room for pipelines and other
techniques to make each instruction
faster. In an interpreter, however,
none of this matters. If you want to
implement a single instruction for the
switch statement with a variable
length depending on the number of case
clauses, there's no reason not to do
so. In fact, a complex instruction set
is an advantage for a web-based
language: it means that the same
program will be smaller (fewer
instructions of greater complexity),
which means less time to transfer
across our speed-limited network.</p></li>
</ol>
</blockquote>
<p>So when considering byte code vs native, consider which trade-offs you want to make between portability, security, size, and execution speed. If speed is the only important factor, go native. If any of the others are more important, go with bytecode.</p>
<p>I'll also add that maintaining a series of OS and architecture-targeted compilations of the same code base for every release can become very tedious. It's a huge win to use the same Java bytecode on multiple platforms and have it "just work."</p>
|
<p>Portability and platform independence are probably the most notable advantages of bytecode over native code. </p>
| 7,052
|
<p>I am developing an <a href="https://github.com/Stypox/image-to-gcode" rel="nofollow noreferrer">image to gcode program</a>, that would recognize edges and generate corresponding G-code to be sent to a plotter. I was able to detect edges using the <a href="https://en.wikipedia.org/wiki/Sobel_operator" rel="nofollow noreferrer">Sobel operator</a>; then the edges are converted to an <a href="https://en.wikipedia.org/wiki/Graph" rel="nofollow noreferrer">undirected graph</a> using a search heuristic of my creation. Converting a graph to functional gcode is not difficult: <a href="https://en.wikipedia.org/wiki/Depth-first_search" rel="nofollow noreferrer">depth first search</a> does the job. The issue is that using this method the generated paths for the plotter are far from optimal, since they contain many movements that could be removed or shortened just by printing paths in a different order. This can be seen clearly in the images below.</p>
<p>Is there an <strong>algorithm that can convert an undirected graph to optimal G-code paths</strong>? Otherwise, if there are none or the problem is NP complete, what heuristics can be used to generate almost-optimal gcode (e.g. the ones used in programs such as Inkscape)?</p>
<p>The graph on the left is converted to the gcode on the right using depth first search on the connected component of the graph. The white and red lines represent, respectively, the visible writes and the invisible movements of the plotter. The G-code can be found <a href="https://github.com/Stypox/image-to-gcode/blob/master/graph.nc" rel="nofollow noreferrer">here</a>.</p>
<p><a href="https://i.stack.imgur.com/iWVqxm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iWVqxm.png" alt="An example undirected graph, rendered by graphviz"></a>
<a href="https://i.stack.imgur.com/qLFq3m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qLFq3m.png" alt="The corresponding gcode, rendered by https://nraynaud.github.io/webgcode/"></a></p>
|
<p>Quote of comment of <a href="https://3dprinting.stackexchange.com/questions/11956/converting-an-undirected-graph-to-optimal-g-code-paths#comment21885_11956">R.. GitHub STOP HELPING ICE</a> on question reads: </p>
<blockquote>
<p>Pretty sure it is NP-complete (equivalent to travelling salesman problem), no? – </p>
</blockquote>
<p>This is correct; this is route optimization at its purest, and is by no means a new problem. You want to travel the shortest total distance between all vertices of what's essentially a totally-interconnected graph; there are no inherent limitations on going from anywhere, to anywhere. The TSP is the general-case statement of this problem, which your problem specializes only slightly by predefining certain movements along edges as being required in the final path (but those edges can be traversed in either direction and in any order.</p>
<p>What makes this complex on its face is the sheer number of possibilities that an exhaustive solution to the TSP like Held-Karp has to evaluate. You have no real constraints regarding which points to travel between; you can go from anywhere, to anywhere. Only a relatively small number of edges (your extrusion lines) are known requisites, and those can theoretically be traced in any order.</p>
<p>If I'm reading your graph right, you start near the top center, then go to the top left, then to the s-curve, then you jump to the main shape and start traversing it from the "right arm", turning downward through the "body" and "left foot" of the central shape, then up to the "right hip", through that leg to the foot, then back up to the "left shoulder", through that "arm", etc.</p>
<p>If I have that right, then you definitely have "endpoint detection", where you are identifying points in the graph that are part of only one line segment (and therefore will require a travel move to get to or from them), and are planning travel moves to and from those points. Very smart. I would be interested in knowing exactly how you choose the next one to travel to. Obviously the closest endpoint of an undrawn line is a natural choice, but your algorithm doesn't seem to be doing that. Right from the off it chooses a relatively further point to extrude and then comes back to the rest of the shape. That actually seems to be the most efficient move in the overall graph, because if you don't get it early you will very likely make a big move to get back to it later, but making that decision in a non-exhaustive way doesn't seem intuitive.</p>
<p>Anyway, your algorithm was doing pretty well at path choice, up until it finished drawing the "right leg". The most efficient move from there would be to go to the bottom of the "Y" looking shape to the right of the main figure and trace through that. When that's done, the closest undrawn line segment will be back at the left shoulder of the main figure, which will lead you to the small dots, and you'll end in this region with relatively small travel moves. Overall, I think that a "closest remaining endpoint" strategy would be near-optimal at every turn; when you reach the end of a drawn line, look for the endpoint that is closest to your current location. It would make most of the decisions your existing algorithm does, and a few better ones. It's not <em>always</em> the best choice (case in point, the dot at the upper left, which is never closest to the end of any other move and so will be ignored until it's the last one left) but more often than not it is.</p>
<p>My programmer savvy says you also have some recursive intersection tracing ("tree-walking"); the algorithm sees that there are multiple paths to draw from a single point, remembers that point and then picks a path. When it reaches an end of a chain of extruded lines, it goes back to the most recently-encountered intersection, re-evaluates available paths, and picks the next one until all paths from that intersection are drawn. Then you skip back to the previous intersection, and so on in a recursive LIFO fashion.</p>
<p>While that's also generally a smart way to approach it, it makes a couple obviously inefficient moves, such as from the "right foot" of the main figure back to the "shoulder" (which is the most recent intersection visited but not fully drawn by that point). The more efficient move is simply the closest remaining endpoint, the bottom of the wonky-looking Y to the right of the main figure.</p>
<p>How you choose intersection paths to prioritize is also key. In general, taking the route that will lead you to the closest intersection or endpoint will reduce the possible backtracking you have to do. However your algorithm seems to prefer the longest path from a fork (or the one with the most forks along it) and that turns out not to be a terrible way to do it in this particular graph.</p>
<p>Now, having drawn the "left arm" of the main figure, it is totally beyond me why your algorithm chose to cross the graph to draw the wonky Y, then cross back over to the left side. That is by far the least efficient move it makes and the one you're probably pointing to yourself. The most efficient path from the end of the left arm of the main figure given what's left to draw is straight-up closest-endpoint, filling in dots and lines on the left side, then making one move across the graph to the wonky Y. Closest-endpoint would actually have already filled in that Y as covered earlier, and you'd end your graph traversal in the left region of dots and small lines. You may have one or maybe two relatively inefficient moves between corners of this region on the left of the graph depending on the closest point calculation, but those are minor compared to the moves made across the graph. If your algorithm is producing deterministic results for this graph, I'd debug it and step through to that point, and figure out why on Earth it thought that sequence was preferable. Optimizing that decision may very well be the key to a near-optimal overall graph-walking strategy.</p>
|
<p>If you can save your plot as a dxf, you can use Repetrel to generate gcode with our "find nearest neighbor" optimizing. You can download it from <a href="http://hyrel3d.net" rel="nofollow noreferrer">http://hyrel3d.net</a> - the full install instructions start at <a href="http://hyrel3d.net/wiki/index.php/Installation_Overview" rel="nofollow noreferrer">http://hyrel3d.net/wiki/index.php/Installation_Overview</a></p>
<p>See the process in this video: <div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/YRsyEGHyt3k?start=0"></iframe>
</div></div></p>
<p>Disclaimer: I work for Hyrel 3D. Licensing only required on the actual printer, not the software install.</p>
<p>Note: This will generate gcode paths, but every printing move will have an E value of 1, so it's fine for lasering or ink-jetting, or running with the Hyrel native E calculations, but probably not useful for other 3d printers.</p>
| 1,579
|
<p>I have built a RepRap Prusa i2 a while back. It worked for a while, but then I moved the printer from place to place and after a while I noticed that the printer's bed is not heating anymore. The thermistor shows the temperature (room temperature), but the bed is not heating.
The wires are connected and the heated bed has a resistance. </p>
<p>Did anyone else confronted with this? Thanks!</p>
|
<h1>diagnosing a heated bed</h1>
<p>Switch the hot end and the heater bed wires on the board. See if there is a difference. (Note that it will not reach a thermal limit when plugged in this way! So don't leave it on too long!)</p>
<p>After that, if you see that your heat increases with the hot end's wires and the hot end being set on in software then you know the issue is likely with the board. At which point try updating / reflashing the board.</p>
<p>Alternatively, you can try a second board and see if it makes a difference.</p>
<p>If the bed does not heat up even using the heater cartridge connectors, then your heated build plate likely needs to be replaced. Or the wire needs to be replaced.</p>
<p>If you are running Ramps or a board that uses 2 hot end outputs you can likely reprogram it to use hot end heater 2 as the new output for your heated bed.</p>
|
<p>It's probably a fuse or the MOSFET fried?
Try checking for continuity on the fuse and voltage on the MOSFET.</p>
| 386
|
<p>I want to print the first 10000 prime numbers.
Can anyone give me the most efficient code for this?
Clarifications:</p>
<ol>
<li>It does not matter if your code is inefficient for n >10000.</li>
<li>The size of the code does not matter.</li>
<li>You cannot just hard code the values in any manner.</li>
</ol>
|
<p><a href="http://en.wikipedia.org/wiki/Sieve_of_Atkin" rel="noreferrer">The Sieve of Atkin</a> is probably what you're looking for, its upper bound running time is O(N/log log N).</p>
<p>If you only run the numbers 1 more and 1 less than the multiples of 6, it could be even faster, as all prime numbers above 3 are 1 away from some multiple of six.
<a href="http://primes.utm.edu/notes/faq/six.html" rel="noreferrer">Resource for my statement</a></p>
|
<pre><code>using System;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int n, i = 3, j, c;
Console.WriteLine("Please enter your integer: ");
n = Convert.ToInt32(Console.ReadLine());
if (n >= 1)
{
Console.WriteLine("First " + n + " Prime Numbers are");
Console.WriteLine("2");
}
for(j=2;j<=n;)
{
for(c=2;c<=i-1;c++)
{
if(i%c==0)
break;
}
if(c==i)
{
Console.WriteLine(i);
j++;
}
i++;
}
Console.Read();
}
}
}
</code></pre>
| 2,304
|
<p>I’ve got this proximity sensor which is a 5 V, it doesn’t say it can be used over 5 V. Can I use a buck converter or is it possible to wire it up direct to a 5 V source on the Ender 3 V2?</p>
<p>What I don’t understand is where to wire it direct to 5 V on the printer or if I use a buck converter then where does the 3rd wire go to on the printer?
If it goes to the signal wire on the Z endstop then which one is the signal wire?</p>
<p><a href="https://i.stack.imgur.com/0yHTW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0yHTW.jpg" alt="enter image description here" /></a></p>
|
<p>PLA is a forgiving filament, you can even print such filament without a heated bed. Although there are differences in quality between brands, PLA shouldn't need a raft to be printed. Hatchbox filament is not considered as a low quality type of filament; it is economical and has been around since 2013. A raft is a structured platform that is specifically used for high temperature and or high shrinkage types of filament, PLA is not such a filament and shouldn't need a raft. This implies that something is wrong with getting the filament sticking to the plate. Good adhesion requires a levelled bed, a correct initial nozzle to build plate distance (e.g. paper thickness) and possibly an adhesive like a glue stick, special adhesion spray, a textured bed or blue tape, etc.</p>
|
<p>Please try one (or more) of the following:</p>
<ol>
<li><p>Change the temperature of your heated bed (50 - 60 °C)</p>
</li>
<li><p>Check your nozzle height (0.15 - 0.25 mm is what I use)</p>
</li>
<li><p>Make sure your bed is level (Maybe use a leaving stick (or whatever those bubble things are called))</p>
</li>
<li><p>Use adhesion. Start with painter's tape (least damaging, easy to remove), then use a glue stick or even hair spray if necessary.</p>
</li>
<li><p>Be sure the bed is clean (I recommend glass cleaner 1-3 squirts and then a light scrub of a paper towel)</p>
</li>
</ol>
| 1,935
|
<p>I'd like to make a debug logging function with the same parameters as <code>printf</code>. But one that can be removed by the pre-processor during optimized builds.</p>
<p>For example:</p>
<pre><code>Debug_Print("Warning: value %d > 3!\n", value);
</code></pre>
<p>I've looked at variadic macros but those aren't available on all platforms. <code>gcc</code> supports them, <code>msvc</code> does not.</p>
|
<p>I still do it the old way, by defining a macro (XTRACE, below) which correlates to either a no-op or a function call with a variable argument list. Internally, call vsnprintf so you can keep the printf syntax:</p>
<pre><code>#include <stdio.h>
void XTrace0(LPCTSTR lpszText)
{
::OutputDebugString(lpszText);
}
void XTrace(LPCTSTR lpszFormat, ...)
{
va_list args;
va_start(args, lpszFormat);
int nBuf;
TCHAR szBuffer[512]; // get rid of this hard-coded buffer
nBuf = _vsnprintf(szBuffer, 511, lpszFormat, args);
::OutputDebugString(szBuffer);
va_end(args);
}
</code></pre>
<p>Then a typical #ifdef switch:</p>
<pre><code>#ifdef _DEBUG
#define XTRACE XTrace
#else
#define XTRACE
#endif
</code></pre>
<p>Well that can be cleaned up quite a bit but it's the basic idea.</p>
|
<p>Having come across the problem today, my solution is the following macro:</p>
<pre><code> static TCHAR __DEBUG_BUF[1024];
#define DLog(fmt, ...) swprintf(__DEBUG_BUF, fmt, ##__VA_ARGS__); OutputDebugString(__DEBUG_BUF)
</code></pre>
<p>You can then call the function like this:</p>
<pre><code> int value = 42;
DLog(L"The answer is: %d\n", value);
</code></pre>
| 3,604
|
<p>There is previous little on the google on this subject other than people asking this very same question.</p>
<p>How would I get started writing my own firewall?</p>
<p>I'm looking to write one for the windows platform but I would also be interested in this information for other operating systems too.
</p>
|
<p>For Windows 2000/XP there is an article with examples on CodeProject <a href="http://www.codeproject.com/KB/IP/drvfltip.aspx" rel="noreferrer">Developing Firewalls for Windows 2000/XP</a><br><br>For Vista I think you will need to use <a href="http://www.microsoft.com/whdc/device/network/wfp.mspx" rel="noreferrer">Windows Filtering Platform</a></p>
|
<p>The usual approach is to use API hooking. Google can teach you that. Just hook all important networking stuff, like <code>connect</code>'s and <code>listens</code>'s, and refuse what you want.</p>
| 3,896
|
<p>I have a string that has some Environment.Newline in it. I'd like to strip those from the string and instead, replace the Newline with something like a comma. </p>
<p>What would be, in your opinion, the best way to do this using C#.NET 2.0?</p>
|
<p>Why not:</p>
<pre><code>string s = "foobar\ngork";
string v = s.Replace(Environment.NewLine,",");
System.Console.WriteLine(v);
</code></pre>
|
<p>The best way is the builtin way: Use <code>string.Replace</code>. Why do you need alternatives?</p>
| 4,499
|
<p>I have a file (fasta file to be specific) that I would like to index, so that I can quickly locate any substring within the file and then find the location within the original fasta file.</p>
<p>This would be easy to do in many cases, using a Trie or substring array, unfortunately the strings I need to index are 800+ MBs which means that doing them in memory in unacceptable, so I'm looking for a reasonable way to create this index on disk, with minimal memory usage.</p>
<p>(edit for clarification)</p>
<p>I am only interested in the headers of proteins, so for the largest database I'm interested in, this is about 800 MBs of text.</p>
<p>I would like to be able to find an exact substring within O(N) time based on the input string. This must be useable on 32 bit machines as it will be shipped to random people, who are not expected to have 64 bit machines.</p>
<p>I want to be able to index against any word break within a line, to the end of the line (though lines can be several MBs long).</p>
<p>Hopefully this clarifies what is needed and why the current solutions given are not illuminating.</p>
<p>I should also add that this needs to be done from within java, and must be done on client computers on various operating systems, so I can't use any OS Specific solution, and it must be a programatic solution.</p>
|
<p>In some languages programmers have access to <strong><em>"direct byte arrays"</em></strong> or <strong><em>"<a href="http://en.wikipedia.org/wiki/Memory-mapped_file" rel="nofollow noreferrer">memory maps</a>"</em></strong>, which are provided by the OS. In java we have <strong><a href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/MappedByteBuffer.html" rel="nofollow noreferrer">java.nio.MappedByteBuffer</a></strong>. This allows one to work with the data as if it were a byte array in memory, when in fact it is on the disk. The size of the file one can work with is only limited by the OS's virtual memory capabilities, and is typically ~<4GB for 32-bit computers. 64-bit? In theory 16 exabytes (17.2 billion GBs), but I think modern CPUs are limited to a 40-bit (1TB) or 48-bit (128TB) address space.</p>
<p>This would let you easily work with the one big file.</p>
|
<p>I talked to a few co-workers and they just use VIM/Grep to search when they need to. Most of the time I wouldn't expect someone to search for a substring like this though.</p>
<p>But I don't see why MS Desktop search or spotlight or google's equivalent can't help you here.</p>
<p>My recommendation is splitting the file up --by gene or species, hopefully the input sequences aren't interleaved. </p>
| 7,662
|
<p>I currently use a DataTable to get results from a database which I can use in my code.</p>
<p>However, many example on the web show using a DataSet instead and accessing the table(s) through the collections method.</p>
<p>Is there any advantage, performance wise or otherwise, of using DataSets or DataTables as a storage method for SQL results?</p>
|
<p>It really depends on the sort of data you're bringing back. Since a DataSet is (in effect) just a collection of DataTable objects, you can return multiple distinct sets of data into a single, and therefore more manageable, object. </p>
<p>Performance-wise, you're more likely to get inefficiency from unoptimized queries than from the "wrong" choice of .NET construct. At least, that's been my experience.</p>
|
<p>A DataTable object represents tabular data as an in-memory, tabular cache of rows, columns, and constraints.
The DataSet consists of a collection of DataTable objects that you can relate to each other with DataRelation objects.</p>
| 2,442
|
<p>I just recently purchased a new MightyBoard (Rev G) for my Replicator that requires a new power supply. </p>
<p>The power supply for the Rev E was a 24 V/9.2 A which was necessary for the dual extruders and heated bed. I know I need a 24 V power supply, but should I be concerned about the amperage? What will a higher (or lower) rating affect on my machine?</p>
|
<p>I suggest looking at the maximum amperage draw for all components that could be on at one time, and then find a power supply that can supply at least 20% more current. You would never want to get a supply rated for lower current than your max draw, because then it will affect the torque or your motors, or the temperature to which your heaters can get. </p>
<p>Think of it like this: An outlet at home may be rated at 115V/20A. Your blender is not going to draw the full 20A; having a little extra never hurts. But if you try to run a large appliance (dryer, hot tub, etc.) on a smaller amp circuit, the breaker would blow because you are trying to draw more than it can supply. </p>
<p>The point is, get something rated for higher than you need, within reason. It will draw only what it needs.</p>
<p>Pro tip: Make sure to set the current limits on your stepper motor drivers for maximum performance!</p>
|
<p>A short, figurative answer from the electronical point of view:</p>
<p>A <strong>power supply</strong> (an an analogy you can view it as a water pump) as used by 3D printers is usually supplying a fixed <strong>voltage</strong> (a constant pressure going into your pipe system), in your case 24V.</p>
<p>The given <strong>amperage/current</strong> (the amount of water that actually flows) that is actually utilized at a given point in time is determined by whatever you hook up to your power supply (the system of tubes or pipes - imagine a valve like your tap/faucet). Now the amperage rating of your power supply gives how much current you can run through your electrical system (as is the flow of your tap/faucet by the pump if you had a limitless big, imigainative one).</p>
<p>The <strong>power</strong> that your supply can deliver is the product of voltage and amperage: P(power) = U(voltage)*I(current).</p>
<p><em>What you need to make sure is</em> that <strong>a) you deliver the correct voltage</strong>, because this is what your circuitry needs to be specifically designed for (image the pressure of your pump being too low or to high, - you either won't recieve any water in the second floor, or your tubing can't stand the pressure) and <strong>b) that you can supply <em>at least</em> the needed power</strong> (otherwise you get a problem once you open up all the taps/faucets in your house, because they don't supply as much water as demanded). If your power supply can give more current, that's fine, it might just not be used. And as mentioned by Thetravellingfool already, keep a certain plus for losses and as a reserve, because no pump likes to run constantly at it's limits either ;)</p>
| 262
|
<p>In <b>Prototype</b> I can show a "loading..." image with this code:</p>
<pre><code>var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars,
onLoading: showLoad, onComplete: showResponse} );
function showLoad () {
...
}
</code></pre>
<p>In <b>jQuery</b>, I can load a server page into an element with this:</p>
<pre><code>$('#message').load('index.php?pg=ajaxFlashcard');
</code></pre>
<p>but how do I attach a loading spinner to this command as I did in Prototype?</p>
|
<p>There are a couple of ways. My preferred way is to attach a function to the ajaxStart/Stop events on the element itself.</p>
<pre><code>$('#loadingDiv')
.hide() // Hide it initially
.ajaxStart(function() {
$(this).show();
})
.ajaxStop(function() {
$(this).hide();
})
;
</code></pre>
<p>The ajaxStart/Stop functions will fire whenever you do any Ajax calls.</p>
<p><strong>Update</strong>: As of jQuery 1.8, the documentation states that <code>.ajaxStart/Stop</code> should only be attached to <code>document</code>. This would transform the above snippet to:</p>
<pre><code>var $loading = $('#loadingDiv').hide();
$(document)
.ajaxStart(function () {
$loading.show();
})
.ajaxStop(function () {
$loading.hide();
});
</code></pre>
|
<p>You can always use <a href="http://malsup.com/jquery/block/#overview" rel="nofollow noreferrer">Block UI jQuery plugin</a> which does everything for you, and it even blocks the page of any input while the ajax is loading. In case that the plugin seems to not been working, you can read about the right way to use it <a href="https://stackoverflow.com/questions/29796115/jquery-blockui-not-working">in this answer.</a> Check it out.</p>
| 9,397
|
<p>What are the most user-friendly color combinations for Web 2.0 websites, such as background, button colors, etc.? </p>
|
<p><a href="http://www.colorschemer.com/online.html" rel="noreferrer">ColorSchemer</a> will suggest good schemes for you.</p>
<p>If you want to try something out on your own, try <a href="http://www.colorcombos.com/" rel="noreferrer">Color Combinations</a>.</p>
|
<p><a href="http://useit.mondosearch.com/cgi-bin/MsmFind.exe?QUERY=color" rel="nofollow noreferrer">search for color on useit</a> </p>
<p><a href="http://www.boxesandarrows.com/search?q=color" rel="nofollow noreferrer">search for color on boxesandarrows</a></p>
<p>There has been loads of research on this sort of stuff and most of it is conflicting a couple of good jump off points are listed above.</p>
<p>Generally lighter backgrounds and good contrast are favoured by all researchers but the details get niggly.</p>
| 4,799
|
<p>Given the following example, why do I have to explicitly use the statement <code>b->A::DoSomething()</code> rather than just <code>b->DoSomething()</code>?</p>
<p>Shouldn't the compiler's overload resolution figure out which method I'm talking about?</p>
<p>I'm using Microsoft VS 2005. (Note: using virtual doesn't help in this case.)</p>
<pre><code>class A
{
public:
int DoSomething() {return 0;};
};
class B : public A
{
public:
int DoSomething(int x) {return 1;};
};
int main()
{
B* b = new B();
b->A::DoSomething(); //Why this?
//b->DoSomething(); //Why not this? (Gives compiler error.)
delete b;
return 0;
}
</code></pre>
|
<p>The two “overloads” aren't in the same scope. By default, the compiler only considers the smallest possible name scope until it finds a name match. Argument matching is done <em>afterwards</em>. In your case this means that the compiler sees <code>B::DoSomething</code>. It then tries to match the argument list, which fails.</p>
<p>One solution would be to pull down the overload from <code>A</code> into <code>B</code>'s scope:</p>
<pre><code>class B : public A {
public:
using A::DoSomething;
// …
}
</code></pre>
|
<p>When searching up the inheritance tree for the function to use, C++ uses the name without arguments, once it has found any definition it stops, then examines the arguments. In the example given, it stops in class B. In order to be able to do what you are after, class B should be defined like this:</p>
<pre><code>class B : public A
{
public:
using A::DoSomething;
int DoSomething(int x) {return 1;};
};
</code></pre>
| 9,756
|
<p>When building a VS 2008 solution with 19 projects I sometimes get:</p>
<pre><code>The "GenerateResource" task failed unexpectedly.
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.IO.MemoryStream.set_Capacity(Int32 value)
at System.IO.MemoryStream.EnsureCapacity(Int32 value)
at System.IO.MemoryStream.WriteByte(Byte value)
at System.IO.BinaryWriter.Write(Byte value)
at System.Resources.ResourceWriter.Write7BitEncodedInt(BinaryWriter store, Int32 value)
at System.Resources.ResourceWriter.Generate()
at System.Resources.ResourceWriter.Dispose(Boolean disposing)
at System.Resources.ResourceWriter.Close()
at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(IResourceWriter writer)
at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(String filename)
at Microsoft.Build.Tasks.ProcessResourceFiles.ProcessFile(String inFile, String outFile)
at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass)
at Microsoft.Build.Tasks.GenerateResource.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) C:\Windows\Microsoft.NET\Framework\v3.5
</code></pre>
<p>Usually happens after VS has been running for about 4 hours; the only way to get VS to compile properly is to close out VS, and start it again.</p>
<p>I'm on a machine with 3GB Ram. TaskManager shows the devenv.exe working set to be 578060K, and the entire memory allocation for the machine is 1.78GB. It should have more than enough ram to generate the resources.</p>
|
<p>From <a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/5154ef26-ccfe-44d5-a322-6804b61ac774/systemoutofmemoryexception?forum=clr" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/vstudio/en-US/5154ef26-ccfe-44d5-a322-6804b61ac774/systemoutofmemoryexception?forum=clr</a>:</p>
<p>Try deleting the .suo file and re-opening the solution.</p>
|
<p>I have already passed by this erros sometimes. All you must do is delete all files in the obj path. After that clean and rebuild your solution and it´s done.</p>
| 3,580
|
<p>I saw many questions asking 'how' to unit test in a specific language, but no question asking 'what', 'why', and 'when'.</p>
<ul>
<li>What is it?</li>
<li>What does it do for me?</li>
<li>Why should I use it?</li>
<li>When should I use it (also when not)?</li>
<li>What are some common pitfalls and misconceptions</li>
</ul>
|
<p>Unit testing is, roughly speaking, testing bits of your code in isolation with test code. The immediate advantages that come to mind are:</p>
<ul>
<li>Running the tests becomes automate-able and repeatable</li>
<li>You can test at a much more granular level than point-and-click testing via a GUI</li>
</ul>
<p>Note that if your test code writes to a file, opens a database connection or does something over the network, it's more appropriately categorized as an integration test. Integration tests are a good thing, but should not be confused with unit tests. Unit test code should be short, sweet and quick to execute.</p>
<p>Another way to look at unit testing is that you write the tests first. This is known as Test-Driven Development (TDD for short). TDD brings additional advantages:</p>
<ul>
<li>You don't write speculative "I might need this in the future" code -- just enough to make the tests pass</li>
<li>The code you've written is always covered by tests</li>
<li>By writing the test first, you're forced into thinking about how you want to call the code, which usually improves the design of the code in the long run.</li>
</ul>
<p>If you're not doing unit testing now, I recommend you get started on it. Get a good book, practically any xUnit-book will do because the concepts are very much transferable between them. </p>
<p>Sometimes writing unit tests can be painful. When it gets that way, try to find someone to help you, and resist the temptation to "just write the damn code". Unit testing is a lot like washing the dishes. It's not always pleasant, but it keeps your metaphorical kitchen clean, and you really want it to be clean. :)</p>
<hr>
<p>Edit: One misconception comes to mind, although I'm not sure if it's so common. I've heard a project manager say that unit tests made the team write all the code twice. If it looks and feels that way, well, you're doing it wrong. Not only does writing the tests usually speed up development, but it also gives you a convenient "now I'm done" indicator that you wouldn't have otherwise.</p>
|
<p>Unit-testing and TDD in general enables you to have shorter feedback cycles about the software you are writing. Instead of having a large test phase at the very end of the implementation, you incrementally test everything you write. This increases code quality very much, as you immediately see, where you might have bugs.</p>
| 2,377
|
<p>I'm having trouble getting the following to work in SQL Server 2k, but it works in 2k5:</p>
<pre><code>--works in 2k5, not in 2k
create view foo as
SELECT usertable.legacyCSVVarcharCol as testvar
FROM usertable
WHERE rsrcID in
( select val
from
dbo.fnSplitStringToInt(usertable.legacyCSVVarcharCol, default)
)
--error message:
Msg 170, Level 15, State 1, Procedure foo, Line 4
Line 25: Incorrect syntax near '.'.
</code></pre>
<p>So, legacyCSVVarcharCol is a column containing comma-separated lists of INTs. I realize that this is a huge WTF, but this is legacy code, and there's nothing that can be done about the schema right now. Passing "testvar" as the argument to the function doesn't work in 2k either. In fact, it results in a slightly different (and even weirder error):</p>
<pre><code>Msg 155, Level 15, State 1, Line 8
'testvar' is not a recognized OPTIMIZER LOCK HINTS option.
</code></pre>
<p>Passing a hard-coded string as the argument to fnSplitStringToInt works in both 2k and 2k5.</p>
<p>Does anyone know why this doesn't work in 2k? Is this perhaps a known bug in the query planner? Any suggestions for how to make it work? Again, I realize that the real answer is "don't store CSV lists in your DB!", but alas, that's beyond my control.</p>
<p>Some sample data, if it helps:</p>
<pre><code>INSERT INTO usertable (legacyCSVVarcharCol) values ('1,2,3');
INSERT INTO usertable (legacyCSVVarcharCol) values ('11,13,42');
</code></pre>
<p>Note that the data in the table does not seem to matter since this is a syntax error, and it occurs even if usertable is completely empty.</p>
<p>EDIT: Realizing that perhaps the initial example was unclear, here are two examples, one of which works and one of which does not, which should highlight the problem that's occurring:</p>
<pre><code>--fails in sql2000, works in 2005
SELECT t1.*
FROM usertable t1
WHERE 1 in
(Select val
from
fnSplitStringToInt(t1.legacyCSVVarcharCol, ',')
)
--works everywhere:
SELECT t1.*
FROM usertable t1
WHERE 1 in
( Select val
from
fnSplitStringToInt('1,4,543,56578', ',')
)
</code></pre>
<p>Note that the only difference is the first argument to fnSplitStringToInt is a column in the case that fails in 2k and a literal string in the case that succeeds in both.</p>
|
<p>Passing column-values to a table-valued user-defined function is not supported in SQL Server 2000, you can only use constants, so the following (simpler version) would also fail:</p>
<pre><code>SELECT *, (SELECT TOP 1 val FROM dbo.fnSplitStringToInt(usertable.legacyCSVVarcharCol, ','))
FROM usertable
</code></pre>
<p>It will work on SQL Server 2005, though, as you have found out.</p>
|
<p>I don't think functions can have default values in functions in SS2K.</p>
<p>What happens when you run this SQL in SS2K?</p>
<pre><code>select val
from dbo.fnSplitStringToInt('1,2,3', default)
</code></pre>
| 4,603
|
<p>I read that the best way of removing ABS was to let the temperature at the hot end to drop to around 190deg c then a sharp pull. This worked really well. I am trying to print with PLA but no matter what temperature I drop the hot end to I get left with a length of PLA in the feeder tube. OK I can heat the hot end and poke the excess down with a wire but that is a pain. I think the technique is right but the temperature is wrong. Any help great fully appreciated.</p>
|
<p>One resource you can use is called the <a href="https://rigid.ink/blogs/news/how-to-use-3d-printer-cleaning-filament" rel="nofollow noreferrer">nylon cleaning method</a>. It works by setting nylon filament temperatures, pushing nylon filament into the nozzle until only nylon is extruding, then cooling the hot end to a specific temperature. The page linked suggests a hard yank, but I disagree. Brutality is not a recommended action for 3D printers, in my opinion. When I use the NCM and the hot end reaches the correct cooler temperature, I use pliers and lever them against a suitable surface. The lever action is slower, yet the mechanical advantage is increased, making removal easier.</p>
<p>Some 3D printer users disagree with the expense of nylon, which is, on the surface, excessive. I've found that I am able to see light through the hot-end after using this method, however, so I find the expense justified by a completely clean filament path.</p>
<p>The above linked page also includes the modification of this method for use with the same type of filament to be cleaned, in your case PLA.</p>
<p>Consider that you should be able to use ABS to pull PLA from the nozzle. Heat the nozzle to the lower end of your ABS filament temperature and push or extrude until you get the ABS color. Allow the hot end to cool to the low end of PLA temperatures and reverse the extruder/pull out the filament.</p>
<p>If you use contrasting color filament (for example, white PLA, black ABS) you should be able to see the ABS collecting the other color as you remove it. Eventually, you would have no contrasting color, indicating that the previous filament has been removed.</p>
|
<p>In line w/ Fred.U's answer, I've been pretty comfortable with the following sequence. Assume a cold start with a filament in the feeder (and cold gunk in the hotend).<br>
1) bring the hotend up to 5 degreesC over your usual extrusion temp for the filament currently in place.<br>
2) If the filament doesn't pull out easily (possible clump at the end), push the filament down and hold it there so the end fully softens/melts. Then remove the filament.<br>
3) Load the new filament desired and push it down until the new material flows freely out of the nozzle. </p>
| 813
|
<p>At home we have a proxy server. At work we don't. Firefox irritates in this regard: whenever I launch it, it defaults to the proxy server. If I do Tools>Options>Settings and select "No proxy", no problem. However, if I shutdown Firefox and restart it, I have to do the Tools>Options>Settings thing all over again because the "No proxy" setting doesn't "stick". </p>
<p>How do I make it stick? Alternatively, can someone suggest a bit of javascript that I can assign to a button on my toolbar which will toggle between the two states?</p>
|
<p>Use <a href="http://foxyproxy.mozdev.org/" rel="nofollow noreferrer">FoxyProxy</a>, much more flexible to configure</p>
|
<p>I used a local automatic proxy configuration script for years with great success. The trick was identifying from the URL or IP address where I was.</p>
<p>/Allan</p>
| 9,496
|
<p>I have an application which extracts data from an XML file using XPath. If a node in that XML source file is missing I want to return the value "N/A" (much like the Oracle NVL function). The trick is that the application doesn't support XSLT; I'd like to do this using XPath and XPath alone.</p>
<p>Is that possible?</p>
|
<p>It can be done but only if the return value when the node does exist is <em>the string value of the node, not the node itself</em>. The XPath</p>
<pre><code>substring(concat("N/A", /foo/baz), 4 * number(boolean(/foo/baz)))
</code></pre>
<p>will return the string value of the <code>baz</code> element if it exists, otherwise the string "N/A".</p>
<p>To generalize the approach:</p>
<pre><code>substring(concat($null-value, $node),
(string-length($null-value) + 1) * number(boolean($node)))
</code></pre>
<p>where <code>$null-value</code> is the null value string and <code>$node</code> the expression to select the node. Note that if <code>$node</code> evaluates to a node-set that contains more than one node, the string value of the <em>first</em> node is used.</p>
|
<p>It can be done with XPath 1.0. Say you have</p>
<pre><code><foo>
<bar/>
</foo>
</code></pre>
<p>If you want to test if <code>foo</code> has a <code>baz</code> child,</p>
<pre><code>substring("N/A", 4 * number(boolean(/foo/baz)))
</code></pre>
<p>will return "N/A" if the expression <code>/foo/baz</code> returns an empty node-set, otherwise it returns an empty string.</p>
| 6,159
|
<p>I'm developing an application for Windows Mobile Devices using Visual Studio .NET 2008 whose UI requires the use of a ComboBox control. Unfortunately, for devices with neither a hardware fullsize keyboard nor a touchscreen interface, there is no way to move (tab) from the ComboBox control to another control on the same form (say, specifying a product in the ComboBox and then moving to a text field to add a quantity).</p>
<p>I've tried creating an event handler for the ComboBox's KeyPress event and setting the focus to the next control manually whenever the user presses the Right or Left directional key but unfortunately the event handler does not capture those key presses.</p>
<p>Any ideas? I have a strong suspicion that this is being over-engineered and that there exists a better control more suited to what I need to do; I find it a bit inconceivable that tabbing out of a Combo Box control could be that difficult.</p>
<p>Thanks!</p>
<p>EDIT: Apparently I can capture the KeyDown and KeyUp events on the ComboBox, which allows me to set the focus or tab to the next control. Still over-engineered - still looking for ideas!</p>
|
<p>I believe directionals are only captured on <code>KeyDown</code> and <code>KeyUp</code>, not on <code>KeyPress</code>.</p>
<p>Alternatively to using a ComboBox, you could use several RadioButtons if the numer of ListItems is static and relatively small.</p>
|
<p><a href="http://msdn.microsoft.com/en-us/library/bb985500.aspx#GeneralRules" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb985500.aspx#GeneralRules</a> provides UI navigation rules. </p>
| 7,534
|
<p>It's really quite annoying as they are not part of the project.</p>
|
<p>The Visual Studio Web Deployment addin lets you exclude folders and more.
<a href="http://msdn.microsoft.com/en-us/asp.net/aa336619.aspx" rel="nofollow noreferrer">VS2005</a>
<a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=0AA30AE8-C73B-4BDD-BB1B-FE697256C459&displaylang=en" rel="nofollow noreferrer">VS2008</a></p>
<p>Also a decent writeup on the <a href="http://www.codedigest.com/Articles/VisualStudio/126_Web_Deployment_Project_for_Visual_Studio_2005_and_2008.aspx" rel="nofollow noreferrer">Web Deployment addin</a></p>
|
<p>The Visual Studio Web Deployment addin lets you exclude folders and more.
<a href="http://msdn.microsoft.com/en-us/asp.net/aa336619.aspx" rel="nofollow noreferrer">VS2005</a>
<a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=0AA30AE8-C73B-4BDD-BB1B-FE697256C459&displaylang=en" rel="nofollow noreferrer">VS2008</a></p>
<p>Also a decent writeup on the <a href="http://www.codedigest.com/Articles/VisualStudio/126_Web_Deployment_Project_for_Visual_Studio_2005_and_2008.aspx" rel="nofollow noreferrer">Web Deployment addin</a></p>
| 7,308
|
<p>I have a table with more than a millon rows. This table is used to index <code>tiff</code> images. Each image has fields like <code>date</code>, <code>number</code>, etc. I have users that index these images in batches of 500. I need to know if it is better to first insert 500 rows and then perform 500 updates or, when the user finishes indexing, to do the 500 inserts with all the data. A very important thing is that if I do the 500 inserts at first, this time is free for me because I can do it the night before. </p>
<p>So the question is: is it better to do inserts or inserts and updates, and why? I have defined a <code>id</code> value for each image, and I also have other indices on the fields.</p>
|
<p>Updates in Sql server result in ghosted rows - i.e. Sql crosses one row out and puts a new one in. The crossed out row is deleted later.</p>
<p>Both inserts and updates can cause page-splits in this way, they both effectively 'add' data, it's just that updates flag the old stuff out first.</p>
<p>On top of this updates need to look up the row first, which for lots of data can take longer than the update.</p>
<p>Inserts will just about always be quicker, especially if they are either in order or if the underlying table doesn't have a clustered index.</p>
<p>When inserting larger amounts of data into a table look at the current indexes - they can take a while to change and build. Adding values in the middle of an index is always slower.</p>
<p>You can think of it like appending to an address book: Mr Z can just be added to the last page, while you'll have to find space in the middle for Mr M.</p>
|
<p>I'm not a database guy, but I imagine doing the inserts in one shot would be faster because the updates require a lookup whereas the inserts do not.</p>
| 6,322
|
<p>I have two separate mercurial repositories. At this point it makes sense that they "become one" because I want to work on the two projects simultaneously.</p>
<p>I'd really like the two projects to each be a subdirectory in the new repository.</p>
<ol>
<li>How do I merge the two projects?</li>
<li>Is this a good idea, or should I
keep them separate?</li>
</ol>
<p>It seems I ought to be able to push from one repository to the other... Maybe this is really straight forward?</p>
|
<p>I was able to combine my two repositories in this way:</p>
<ol>
<li>Use <code>hg clone first_repository</code> to clone one of the repositories.</li>
<li>Use <code>hg pull -f other_repository</code> to pull the code in from the other repository.</li>
</ol>
<p>The <code>-f</code> (force) flag on the pull is the key -- it says to ignore the fact that the two repositories are not from the same source.</p>
<p>Here are <a href="https://www.mercurial-scm.org/wiki/MergingUnrelatedRepositories" rel="nofollow noreferrer">the docs</a> for this feature.</p>
|
<p>If you aren't using the same code across the projects, keep them separate. You can set <em>your</em> personal repository of each of those projects to be just a directory apart. Why mix all the branches, merges, and commit comments when you don't have to.</p>
<p><strong>About your edit:</strong> Pushing from One repository to Another. You can always use the <a href="https://www.mercurial-scm.org/wiki/TransplantExtension" rel="nofollow noreferrer"><code>transplant</code></a> command. Although, all this is really side stepping your <em>desire</em> to combine the two, so you might feel uncomfortable using my suggestions. Then you can use the forest extension, or something.</p>
<pre><code>hg transplant -s REPOSITORY lower_rev:high_rev
</code></pre>
| 3,391
|
<p>BuildTak is great because the printed plastic really sticks to it, it pretty much solved all the problems I had with prints detaching from the buildplate during printing.</p>
<p>However, it does sometimes cause the opposite problem of prints sticking too much and just not detaching from the build plate.</p>
<p>I'm specifically not asking how to prevent this from happening - I'm asking what to do after I made a mistake and now have a print that isn't coming loose.</p>
|
<p>I would do as fred_dot_u initially suggested, by increasing the bed temp (or using a hair dryer) to heat the BuildTak. Then, use a small fan to quickly cool the platform (or at least quicker than room temperature). An ice pack on the build plate/part could also work. This drastic fluctuation between the build platform (or BuildTak) and the part should make it easier to remove the part.</p>
<p>This works because the <a href="https://en.wikipedia.org/wiki/Temperature_coefficient" rel="noreferrer">temperature coefficient</a> is going to be different between the build plate, BuildTak, and the 3D printed part. So, each part rises and falls in temperature at different rates. When objects are heated and cooled, they expand and contract (respectively). Essentially, as each object expands and contracts at different rates, the objects begin to separate.</p>
<p>A good example is if you've ever placed a jar into the fridge/freezer to make it easier to open. Typically the jar is glass and the lid is either plastic or metal. You'll notice that the lid is significantly easier to open, as opposed to its original state, because the lid and the jar physically react differently to temperature changes.</p>
<p>Also, <a href="https://all3dp.com/6-ways-remove-3d-prints-build-platform/" rel="noreferrer">here is a good article</a> explaining a few different ways to remove a stuck part. (for prosperity sake, here's a quick list):</p>
<ul>
<li>Brute force. Just try to yank on it until it pries off.</li>
<li>Sharp objects. Try using a small blade to get under a corner of the part and wiggle the part a bit. Careful not to break the blade and send it flying.</li>
<li>Utilize temperature difference. I already explained this above.</li>
<li>Use solvents. I didn't know this, but apparently there are solvents in the market that are targeted for 3D printing maintenance. Essentially its just an alcohol-based liquid...</li>
<li>Use floss. Another cool idea that's related to using a sharp object, using dental floss. Basically, any small object that you can remotely wiggle under the part and give you more leverage to yank on it.</li>
<li>Invest in a flexible build platform. I've personally heard some mixed reviews on these (in present day of 2016). But material science is getting better every year, so who knows what will be available soon.</li>
</ul>
|
<p>If you have a heated bed, bring the bed up to a reasonable temperature, then do as best as you can to create rapid cooling. If you can remove the bed, heated or not, consider to place it in a freezer or refrigerator. Obviously, if the bed is heated, you'll want to handle the bed carefully and not place it on anything in the freezer that could be damaged while it cools.</p>
<p>Unrealistically, pour liquid nitrogen over the bed. This may crack the bed and/or the model, as well as be all the more dangerous for unprotected users.</p>
| 294
|
<p>I need to create a batch file which starts multiple console applications in a Windows .cmd file. This can be done using the start command.</p>
<p>However, the command has a path in it. I also need to pass paramaters which have spaces as well. How to do this?</p>
<p>E.g. batch file</p>
<pre><code>start "c:\path with spaces\app.exe" param1 "param with spaces"
</code></pre>
|
<p>Actually, his example won't work (although at first I thought that it would, too). Based on the help for the Start command, the first parameter is the name of the newly created Command Prompt window, and the second and third should be the path to the application and its parameters, respectively. If you add another "" before path to the app, it should work (at least it did for me). Use something like this:</p>
<pre><code>start "" "c:\path with spaces\app.exe" param1 "param with spaces"
</code></pre>
<p>You can change the first argument to be whatever you want the title of the new command prompt to be. If it's a Windows app that is created, then the command prompt won't be displayed, and the title won't matter.</p>
|
<p>Surrounding the path and the argument with spaces inside quotes as in your example should do. The command may need to handle the quotes when the parameters are passed to it, but it usually is not a big deal.</p>
| 9,828
|
<p>I want to get my databases under version control.</p>
<p>I'll always want to have at least <em>some</em> data in there (as <a href="https://stackoverflow.com/users/80/alumb">alumb</a> mentions: user types and administrators). I'll also often want a large collection of generated test data for performance measurements.</p>
<p>How would I apply version control to my database?</p>
|
<p>Martin Fowler wrote my favorite article on the subject, <a href="http://martinfowler.com/articles/evodb.html" rel="noreferrer">http://martinfowler.com/articles/evodb.html</a>. I choose not to put schema dumps in under version control as <em>alumb</em> and others suggest because I want an easy way to upgrade my production database.</p>
<p>For a web application where I'll have a single production database instance, I use two techniques:</p>
<h1>Database Upgrade Scripts</h1>
<p>A sequence database upgrade scripts that contain the DDL necessary to move the schema from version N to N+1. (These go in your version control system.) A _version_history_ table, something like</p>
<pre><code>create table VersionHistory (
Version int primary key,
UpgradeStart datetime not null,
UpgradeEnd datetime
);
</code></pre>
<p>gets a new entry every time an upgrade script runs which corresponds to the new version.</p>
<p>This ensures that it's easy to see what version of the database schema exists and that database upgrade scripts are run only once. Again, these are <strong>not</strong> database dumps. Rather, each script represents the <strong>changes</strong> necessary to move from one version to the next. They're the script that you apply to your production database to "upgrade" it.</p>
<h1>Developer Sandbox Synchronization</h1>
<ol>
<li>A script to backup, sanitize, and shrink a production database. Run this after each upgrade to the production DB.</li>
<li>A script to restore (and tweak, if necessary) the backup on a developer's workstation. Each developer runs this script after each upgrade to the production DB.</li>
</ol>
<p><em>A caveat: My automated tests run against a schema-correct but empty database, so this advice will not perfectly suit your needs.</em></p>
|
<p>An alternative to version controlling your database is to use a version-controlled database, of which there are now several.</p>
<p><a href="https://www.dolthub.com/blog/2021-09-17-database-version-control/" rel="nofollow noreferrer">https://www.dolthub.com/blog/2021-09-17-database-version-control/</a></p>
<p>These products don't apply version control on top of another type of database -- they are their own database engines that support version control operations. So you need to migrate to them or start building on them in the first place.</p>
<p>I write one of them, DoltDB, which combines the interfaces of MySQL and Git. Check it out here:</p>
<p><a href="https://github.com/dolthub/dolt" rel="nofollow noreferrer">https://github.com/dolthub/dolt</a></p>
| 2,264
|
<p>I am a fresh graduate student in 3D metal printing. My undergraduate major is mechanical engineering. Later research will focus on the process of metal 3D printing. I hope that you can recommend some excellent 3D metal printing books for learning.</p>
|
<p>This is a free ebook that I have perused briefly which it looks interesting, and it is free (did I say that already?)</p>
<ul>
<li><a href="https://www.mdpi.com/books/pdfview/book/384" rel="nofollow noreferrer">3D Printing of metals</a>
<ul>
<li>Manoj Gupta</li>
<li>ISBN 978-3-03842-591-5 (Pbk); </li>
<li>ISBN 978-3-03842-592-2 (PDF)</li>
</ul></li>
</ul>
<p>Three other books that <em>might</em> be of interest are:</p>
<ul>
<li><a href="https://www.designnews.com/materials-assembly/free-e-book-3d-printing-metals-design-engineers-explained/200976711359482" rel="nofollow noreferrer">3D Printing with Metals for Design Engineers, Explained</a>
<ul>
<li>Ann R. Thryft</li>
<li>Downloadable free ebook, but some sort of sign up is required</li>
</ul></li>
<li><a href="https://www.springer.com/gp/book/9783319551272" rel="nofollow noreferrer">Additive Manufacturing of Metals: The Technology, Materials, Design and Production</a>,
<ul>
<li>Yang, L., Hsu, K., Baughman, B., Godfrey, D., Medina, F., Menon, M., Wiener, S. </li>
<li>ISBN 978-3-319-55128-9</li>
</ul></li>
<li><a href="https://rads.stackoverflow.com/amzn/click/com/3319582046" rel="nofollow noreferrer" rel="nofollow noreferrer">Additive Manufacturing of Metals: From Fundamental Technology to Rocket Nozzles, Medical Implants, and Custom Jewelry (Springer Series in Materials Science)</a>
<ul>
<li>Although, as the title contains a (rather obvious) mis-spelling, it does not bode well for the rest of the book.</li>
<li>John O. Milewski</li>
<li>ISBN-13: 978-3319582047</li>
<li>ISBN-10: 3319582046</li>
</ul></li>
</ul>
|
<p>Just wanted to add that ultimately you get a lot more quick practical knowledge from your machine's manufacturer or DMLS service provider so don't forget to look at publications from the industry leaders. They have incentive to make sure you succeed when using their products. Just beware the salesmanship.</p>
<p>For example Stratasys:
<a href="https://www.stratasysdirect.com/resources/design-guidelines/direct-metal-laser-sintering" rel="nofollow noreferrer">https://www.stratasysdirect.com/resources/design-guidelines/direct-metal-laser-sintering</a></p>
<p>I believe there's also a very similar guide from Xometry and others. Gpi also had some good insights on some of the more exotic materials.</p>
| 1,461
|
<p>One way to give PLA prints a smooth finish is treatment with chloroform vapours (or other solvents, as mentioned in <a href="https://3dprinting.stackexchange.com/a/36/674">this</a> answer). This method is even featured on <a href="https://ultimaker.com/en/tips-tricks/17897-vapor-treating" rel="nofollow noreferrer">Ultimaker website</a>. I would like to try it on some of my prints. </p>
<p>What are the practical concerns I should be aware of using chloroform vapours? I am looking for advice concerning vaporisation temperature, time of exposition that makes for a nice finish, and any other experiences. </p>
<p><strong>Caution!</strong>
<a href="https://en.wikipedia.org/wiki/Chloroform" rel="nofollow noreferrer">Chloroform</a> is a moderately toxic chemical! I only approach this method as I have an access to a well-equipped chemical laboratory with a <a href="https://en.wikipedia.org/wiki/Fume_hood" rel="nofollow noreferrer">fume hood</a>.</p>
<p><strong>Disclamer:</strong>
The question is not about the safety issues using chloroform vapours. It is about how obtain the best post-processing results with least trial-and-error.</p>
|
<p><a href="https://www.reddit.com/r/3Dprinting/comments/25ej7d/does_anyone_have_experience_with_pla_thf_vapor/" rel="nofollow noreferrer">This Reddit post</a> seems to have some good trial and error dialog.</p>
<p><a href="http://www.thingiverse.com/thing:73120" rel="nofollow noreferrer">This Thingiverse post</a>, along with many other references online, suggest that the results are very similar to that of an Acetone treatment with ABS. I'm not familiar with the inner workings of how it works, but the general advice is to be conscious of what you're working with. A heat-induced vapor treatment seems to yield the best surface finish, but can be tricky to track down proper exposure times. It seems that the time required to achieve a desirable surface finish depends on the size and openness of the features on the object. By openness, I mean how evenly the vapor is able attach itself to the surface of the object as compared to other features. Some this variability may be reduced by streamlining the process. Perhaps if you found a way to rotate either the part or the vapor container during the process. This could ensure contact is made in small corners/features. Other variables to consider may be:</p>
<ul>
<li>If a gradual reduction of exposure is necessary (as is with most heat treatment operations);</li>
<li>How much temperature effects time. Most pages I've read mention 100C as the temp to vaporize the chemical;</li>
<li>Size of the "vaporization chamber" in accordance with how much of the chemical is available. I've used a gallon paint can lined with lightly dabbed paper towel with Acetone for part between 1"^3 to about 4"^3.</li>
</ul>
<p>That's all I can think of, currently, that could potentially have the most impact on the process. Just as with 3D printing, there's not an easy way to definitively know how your parts will turn out. The sheer difference in the shape of your parts could throw out any "proven process" you come up with. Hopefully this gives you an idea of what things to look out for in starting out.</p>
<p><em>Here's information about safety, before OP added disclaimer</em>
<s>As with any chemical, <strong>always</strong> refer to the MSDS <sup>(Material Safety Data Sheet)</sup>! Whichever supplier you acquire the chloroform from, should ship an MSDS with the product. If one is not shipped, you should be able to request one. If they don't have one, don't use the product and don't purchase from them.</p>
<p>In most cases, you can get away with finding any MSDS online, but I'd recommend trying to get one directly from your supplier as they might theoretically have a different "strand" of the chemical. Therefore, reactions and safety precautions may be different than what you will find online.</p>
<p>A quick search yields <a href="http://www.sciencelab.com/msds.php?msdsId=9927133" rel="nofollow noreferrer">this MSDS</a> which states that chloroform does have "carcinogenic effects" along with some other long-term, undesirable effects. As with any other MSDS it continues to go over best-practices and extremity limits.
</s></p>
|
<p>Beside vaporizing with heat, you can use an atomizer and do cold vapor. The time is around 1-5 minutes at 45ºC for a 10x10x20 mm piece like a Marvin or a bot. I have done only gangster tests with it, so I have no larger piece info.</p>
<p>Passive vapor polish does not work with chloroform since it tends to crack. It needs a fast flash on the outside only.</p>
| 198
|
<p>What's the easiest way to profile a PHP script?</p>
<p>I'd love tacking something on that shows me a dump of all function calls and how long they took but I'm also OK with putting something around specific functions.</p>
<p>I tried experimenting with the <a href="http://php.net/microtime" rel="noreferrer">microtime</a> function:</p>
<pre><code>$then = microtime();
myFunc();
$now = microtime();
echo sprintf("Elapsed: %f", $now-$then);
</code></pre>
<p>but that sometimes gives me negative results. Plus it's a lot of trouble to sprinkle that all over my code.</p>
|
<p>You want <a href="http://www.xdebug.org/" rel="noreferrer">xdebug</a> I think. Install it on the server, turn it on, pump the output through <a href="http://kcachegrind.sourceforge.net/html/Home.html" rel="noreferrer">kcachegrind</a> (for linux) or <a href="http://sourceforge.net/projects/wincachegrind/" rel="noreferrer">wincachegrind</a> (for windows) and it'll show you a few pretty charts that detail the exact timings, counts and memory usage (but you'll need another extension for that).</p>
<p>It rocks, seriously :D</p>
|
<p>XDebug is not stable and it's not always available for particular php version. For example on some servers I still run php-5.1.6, -- it's what comes with RedHat RHEL5 (and btw still receives updates for all important issues), and recent XDebug does not even compile with this php. So I ended up with switching to <a href="http://www.nusphere.com/products/php_debugger.htm" rel="nofollow">DBG debugger</a>
Its <a href="http://www.nusphere.com/products/php_profiler.htm" rel="nofollow">php benchmarking</a> provides timing for functions, methods, modules and even lines.</p>
| 4,142
|
<p>I was just wondering if there is an elegant way to set the maximum CPU load for a particular thread doing intensive calculations.
<br/><br/>Right now I have located the most time consuming loop in the thread (it does only compression) and use <code>GetTickCount()</code> and <code>Sleep()</code> with hardcoded values. It makes sure that the loop continues for a certain period and then sleeps for a certain minimum time. It more or less does the job, i.e. guarantees that the thread will not use more than 50% of CPU. <br>However, behavior is dependent on the number of CPU cores (huge disadvantage) and simply ugly (smaller disadvantage :)). <br>Any ideas?</p>
|
<p>I am not aware of any API to do get the OS's scheduler to do what you want (even if your thread is idle-priority, if there are no higher-priority ready threads, yours will run). However, I think you can improvise a fairly elegant throttling function based on what you are already doing. Essentially (I don't have a Windows dev machine handy):</p>
<p>Pick a default amount of time the thread will sleep each iteration. Then, on each iteration (or on every nth iteration, such that the throttling function doesn't itself become a significant CPU load),</p>
<ol>
<li>Compute the amount of CPU time your thread used since the last time your throttling function was called (I'll call this dCPU). You can use the <a href="http://msdn.microsoft.com/en-us/library/ms683237.aspx" rel="noreferrer">GetThreadTimes()</a> API to get the amount of time your thread has been executing.</li>
<li>Compute the amount of real time elapsed since the last time your throttling function was called (I'll call this dClock).</li>
<li>dCPU / dClock is the percent CPU usage (of one CPU). If it is higher than you want, increase your sleep time, if lower, decrease the sleep time.</li>
<li>Have your thread sleep for the computed time.</li>
</ol>
<p>Depending on how your watchdog computes CPU usage, you might want to use <a href="http://msdn.microsoft.com/en-us/library/ms683213(VS.85).aspx" rel="noreferrer">GetProcessAffinityMask()</a> to find out how many CPUs the system has. dCPU / (dClock * CPUs) is the percentage of total CPU time available.</p>
<p>You will still have to pick some magic numbers for the initial sleep time and the increment/decrement amount, but I think this algorithm could be tuned to keep a thread running at fairly close to a determined percent of CPU.</p>
|
<p>You may be able to change the priority of a thread, but changing the maximum utilization would either require polling and hacks to limit how many things are occurring, or using OS tools that can set the maximum utilization of a process.
However, I don't see any circumstance where you would want to do this.</p>
| 2,418
|
<p>It's 2008, and I'm still torn on this one. So I'm developing a web method that needs a complex type passed into it and returned from it. The two options I'm toying with are:</p>
<ol>
<li><p>Pass and return <em>actual</em> business objects with both data and behavior. When wsdl.exe is run, it will automatically create proxy classes that contain just the data portion, and these will be automatically converted to and from my real business objects on the server side. On the client side, they will only get to use the dumb proxy type, and they will have to map them into some real business objects as they see fit. A big drawback here is that if I "own" both the server and client side, and I want to use the same set of real business objects, I can run into certain headaches with name conflicts, etc. (Since the real objects and the proxies are named the same.)</p></li>
<li><p>Forget trying to pass "real" business objects. Instead, just create simple DataTransfer objects which I will map back and forth to my real business objects manually. They still get copied to new proxy objects by wsdl.exe anyway, but at least I'm not tricking myself into thinking that web services can natively handle objects with business logic in them.</p></li>
</ol>
<p>By the way - Does anyone know how to tell wsdl.exe to <em>not</em> make a copy of the object? Shouldn't we be able to just tell it, "Hey, use this existing type right over here. Don't copy it!"</p>
<p>Anyway, I've kinda settled on #2 for now, but I'm curious what you all think. I have a feeling there are <em>way</em> better ways to do this in general, and I may not even be totally accurate on all my points, so please let me know what your experiences have been.</p>
<p><strong>Update</strong>: I just found out that VS 2008 has an option to reuse existing types when adding a "Service Reference", rather than creating brand new identical type in the proxy file. Sweet.</p>
|
<p>I'd do a hybrid. I would use an object like this</p>
<pre><code>public class TransferObject
{
public string Type { get; set; }
public byte[] Data { get; set; }
}
</code></pre>
<p>then i have a nice little utility that serializes an object then compresses it.</p>
<pre><code>public static class CompressedSerializer
{
/// <summary>
/// Decompresses the specified compressed data.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="compressedData">The compressed data.</param>
/// <returns></returns>
public static T Decompress<T>(byte[] compressedData) where T : class
{
T result = null;
using (MemoryStream memory = new MemoryStream())
{
memory.Write(compressedData, 0, compressedData.Length);
memory.Position = 0L;
using (GZipStream zip= new GZipStream(memory, CompressionMode.Decompress, true))
{
zip.Flush();
var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
result = formatter.Deserialize(zip) as T;
}
}
return result;
}
/// <summary>
/// Compresses the specified data.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="data">The data.</param>
/// <returns></returns>
public static byte[] Compress<T>(T data)
{
byte[] result = null;
using (MemoryStream memory = new MemoryStream())
{
using (GZipStream zip= new GZipStream(memory, CompressionMode.Compress, true))
{
var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Serialize(zip, data);
}
result = memory.ToArray();
}
return result;
}
}
</code></pre>
<p>Then you'd just pass the transfer object that would have the type name. So you could do something like this</p>
<pre><code>[WebMethod]
public void ReceiveData(TransferObject data)
{
Type originType = Type.GetType(data.Type);
object item = CompressedSerializer.Decompress<object>(data.Data);
}
</code></pre>
<p>right now the compressed serializer uses generics to make it strongly typed, but you could make a method easily to take in a Type object to deserialize using originType above, all depends on your implementation.</p>
<p>hope this gives you some ideas. Oh, and to answer your other question, wsdl.exe doesn't support reusing types, WCF does though.</p>
|
<blockquote>
<p><strong>Darren</strong> wrote: I'd do a hybrid. I would use an object like this...</p>
</blockquote>
<p>Interesting idea... passing a serialized version of the object instead of the (wsdl-ed) object itself. In a way, I like its elegance, but in another way, it seems to defeat the purpose of exposing your web service to potential third parties or partners or whatever. How would they know what to pass? Would they have to rely purely on documentation? It also loses some of the "heterogeneous client" aspect, since the serialization is very .Net specific. I don't mean to be critical, I'm just wondering if what you're proposing is also meant for these types of use cases. I don't see anything wrong with using it in a closed environment though.</p>
<p>I should look into WCF... I've been avoiding it, but maybe it's time.</p>
| 3,404
|
<p>Word 2007 saves its documents in .docx format which is really a zip file with a bunch of stuff in it including an xml file with the document.</p>
<p>I want to be able to take a .docx file and drop it into a folder in my asp.net web app and have the code open the .docx file and render the (xml part of the) document as a web page.</p>
<p>I've been searching the web for more information on this but so far haven't found much. My questions are:</p>
<ol>
<li>Would you (a) use XSLT to transform the XML to HTML, or (b) use xml manipulation libraries in .net (such as XDocument and XElement in 3.5) to convert to HTML or (c) other?</li>
<li>Do you know of any open source libraries/projects that have done this that I could use as a starting point? </li>
</ol>
<p>Thanks!</p>
|
<p>Try this <a href="http://blog.maartenballiauw.be/post/2008/01/11/Preview-Word-files-(docx)-in-HTML-using-ASPNET-OpenXML-and-LINQ-to-XML.aspx" rel="nofollow noreferrer">post</a>? I don't know but might be what you are looking for.</p>
|
<p>I'm using Interop. It is somewhat problamatic but works fine in most of the case.</p>
<pre><code>using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Word;
</code></pre>
<p>This one returns the list of html converted documents' path</p>
<pre><code>public List<string> GetHelpDocuments()
{
List<string> lstHtmlDocuments = new List<string>();
foreach (string _sourceFilePath in Directory.GetFiles(""))
{
string[] validextentions = { ".doc", ".docx" };
if (validextentions.Contains(System.IO.Path.GetExtension(_sourceFilePath)))
{
sourceFilePath = _sourceFilePath;
destinationFilePath = _sourceFilePath.Replace(System.IO.Path.GetExtension(_sourceFilePath), ".html");
if (System.IO.File.Exists(sourceFilePath))
{
//checking if the HTML format of the file already exists. if it does then is it the latest one?
if (System.IO.File.Exists(destinationFilePath))
{
if (System.IO.File.GetCreationTime(destinationFilePath) != System.IO.File.GetCreationTime(sourceFilePath))
{
System.IO.File.Delete(destinationFilePath);
ConvertToHTML();
}
}
else
{
ConvertToHTML();
}
lstHtmlDocuments.Add(destinationFilePath);
}
}
}
return lstHtmlDocuments;
}
</code></pre>
<p>And this one to convert doc to html.</p>
<pre><code>private void ConvertToHtml()
{
IsError = false;
if (System.IO.File.Exists(sourceFilePath))
{
Microsoft.Office.Interop.Word.Application docApp = null;
string strExtension = System.IO.Path.GetExtension(sourceFilePath);
try
{
docApp = new Microsoft.Office.Interop.Word.Application();
docApp.Visible = true;
docApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;
object fileFormat = WdSaveFormat.wdFormatHTML;
docApp.Application.Visible = true;
var doc = docApp.Documents.Open(sourceFilePath);
doc.SaveAs2(destinationFilePath, fileFormat);
}
catch
{
IsError = true;
}
finally
{
try
{
docApp.Quit(SaveChanges: false);
}
catch { }
finally
{
Process[] wProcess = Process.GetProcessesByName("WINWORD");
foreach (Process p in wProcess)
{
p.Kill();
}
}
Marshal.ReleaseComObject(docApp);
docApp = null;
GC.Collect();
}
}
}
</code></pre>
<p>The killing of the word is not fun, but can't let it hanging there and block others, right?</p>
<p>In the web/html i render html to a iframe.</p>
<p>There is a dropdown which contains the list of help documents. Value is the path to the html version of it and text is name of the document.</p>
<pre><code>private void BindHelpContents()
{
List<string> lstHelpDocuments = new List<string>();
HelpDocuments hDoc = new HelpDocuments(Server.MapPath("~/HelpDocx/docx/"));
lstHelpDocuments = hDoc.GetHelpDocuments();
int index = 1;
ddlHelpDocuments.Items.Insert(0, new ListItem { Value = "0", Text = "---Select Document---", Selected = true });
foreach (string strHelpDocument in lstHelpDocuments)
{
ddlHelpDocuments.Items.Insert(index, new ListItem { Value = strHelpDocument, Text = strHelpDocument.Split('\\')[strHelpDocument.Split('\\').Length - 1].Replace(".html", "") });
index++;
}
FetchDocuments();
}
</code></pre>
<p>on selected index changed, it is renedred to frame</p>
<pre><code> protected void RenderHelpContents(object sender, EventArgs e)
{
try
{
if (ddlHelpDocuments.SelectedValue == "0") return;
string strHtml = ddlHelpDocuments.SelectedValue;
string newaspxpage = strHtml.Replace(Server.MapPath("~/"), "~/");
string pageVirtualPath = VirtualPathUtility.ToAbsolute(newaspxpage);//
documentholder.Attributes["src"] = pageVirtualPath;
}
catch
{
lblGError.Text = "Selected document doesn't exist, please refresh the page and try again. If that doesn't help, please contact Support";
}
}
</code></pre>
| 7,884
|
<p>This page from Adobe says to add a "wmode" parameter and set its value to "transparent": <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14201" rel="nofollow noreferrer">http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_1420</a></p>
<p>This works flawlessly in IE. The background renders correctly in Firefox and Safari, however as soon as you use the browser's scroll bar then mouse over the Flash control you must click once to activate the control. You can see this behavior if you try to hit the play button in Adobe's example.</p>
<p>Anyone know a way around this?</p>
|
<p>On another note; setting the wmode to transparent has a few kinks. For instance it can break the scrolling (the flash stays in the same place disregarding the scroll) in some older versions of Firefox (pre 2.0). I've also had issues with ALT-key combinations in textfields not working when wmode is transparent.</p>
<p>Also, if you need to place html-content above flash-content (not a good idea generally, but there are cases when it's useful) wmode=transparent is the way to go.</p>
|
<p>Enabling windowless mode (wmode=) makes embedded flash act and render just like other elements. Without that, it's rendered in a seperate step and just overlaid on the browser's window.</p>
<p>Could the flash element be losing focus? Sounds like input focus is moved to the scollbar, then you have to move it back.</p>
<p>Also you weren't clear whether the focus issue was only in FF or also in IE.</p>
| 2,848
|
<p>Every method I write to encode a string in Java using 3DES can't be decrypted back to the original string. Does anyone have a simple code snippet that can just encode and then decode the string back to the original string?</p>
<p>I know I'm making a very silly mistake somewhere in this code. Here's what I've been working with so far:</p>
<p>** note, I am not returning the BASE64 text from the encrypt method, and I am not base64 un-encoding in the decrypt method because I was trying to see if I was making a mistake in the BASE64 part of the puzzle.</p>
<pre><code>public class TripleDESTest {
public static void main(String[] args) {
String text = "kyle boon";
byte[] codedtext = new TripleDESTest().encrypt(text);
String decodedtext = new TripleDESTest().decrypt(codedtext);
System.out.println(codedtext);
System.out.println(decodedtext);
}
public byte[] encrypt(String message) {
try {
final MessageDigest md = MessageDigest.getInstance("md5");
final byte[] digestOfPassword = md.digest("HG58YZ3CR9".getBytes("utf-8"));
final byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24);
for (int j = 0, k = 16; j < 8;)
{
keyBytes[k++] = keyBytes[j++];
}
final SecretKey key = new SecretKeySpec(keyBytes, "DESede");
final IvParameterSpec iv = new IvParameterSpec(new byte[8]);
final Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, key, iv);
final byte[] plainTextBytes = message.getBytes("utf-8");
final byte[] cipherText = cipher.doFinal(plainTextBytes);
final String encodedCipherText = new sun.misc.BASE64Encoder().encode(cipherText);
return cipherText;
}
catch (java.security.InvalidAlgorithmParameterException e) { System.out.println("Invalid Algorithm"); }
catch (javax.crypto.NoSuchPaddingException e) { System.out.println("No Such Padding"); }
catch (java.security.NoSuchAlgorithmException e) { System.out.println("No Such Algorithm"); }
catch (java.security.InvalidKeyException e) { System.out.println("Invalid Key"); }
catch (BadPaddingException e) { System.out.println("Invalid Key");}
catch (IllegalBlockSizeException e) { System.out.println("Invalid Key");}
catch (UnsupportedEncodingException e) { System.out.println("Invalid Key");}
return null;
}
public String decrypt(byte[] message) {
try
{
final MessageDigest md = MessageDigest.getInstance("md5");
final byte[] digestOfPassword = md.digest("HG58YZ3CR9".getBytes("utf-8"));
final byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24);
for (int j = 0, k = 16; j < 8;)
{
keyBytes[k++] = keyBytes[j++];
}
final SecretKey key = new SecretKeySpec(keyBytes, "DESede");
final IvParameterSpec iv = new IvParameterSpec(new byte[8]);
final Cipher decipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
decipher.init(Cipher.DECRYPT_MODE, key, iv);
//final byte[] encData = new sun.misc.BASE64Decoder().decodeBuffer(message);
final byte[] plainText = decipher.doFinal(message);
return plainText.toString();
}
catch (java.security.InvalidAlgorithmParameterException e) { System.out.println("Invalid Algorithm"); }
catch (javax.crypto.NoSuchPaddingException e) { System.out.println("No Such Padding"); }
catch (java.security.NoSuchAlgorithmException e) { System.out.println("No Such Algorithm"); }
catch (java.security.InvalidKeyException e) { System.out.println("Invalid Key"); }
catch (BadPaddingException e) { System.out.println("Invalid Key");}
catch (IllegalBlockSizeException e) { System.out.println("Invalid Key");}
catch (UnsupportedEncodingException e) { System.out.println("Invalid Key");}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
</code></pre>
|
<p>Your code was fine except for the Base 64 encoding bit (which you mentioned was a test), the reason the output may not have made sense is that you were displaying a raw byte array (doing toString() on a byte array returns its internal Java reference, not the String representation of the <strong>contents</strong>). Here's a version that's just a teeny bit cleaned up and which prints "kyle boon" as the decoded string:</p>
<pre><code>import java.security.MessageDigest;
import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class TripleDESTest {
public static void main(String[] args) throws Exception {
String text = "kyle boon";
byte[] codedtext = new TripleDESTest().encrypt(text);
String decodedtext = new TripleDESTest().decrypt(codedtext);
System.out.println(codedtext); // this is a byte array, you'll just see a reference to an array
System.out.println(decodedtext); // This correctly shows "kyle boon"
}
public byte[] encrypt(String message) throws Exception {
final MessageDigest md = MessageDigest.getInstance("md5");
final byte[] digestOfPassword = md.digest("HG58YZ3CR9"
.getBytes("utf-8"));
final byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24);
for (int j = 0, k = 16; j < 8;) {
keyBytes[k++] = keyBytes[j++];
}
final SecretKey key = new SecretKeySpec(keyBytes, "DESede");
final IvParameterSpec iv = new IvParameterSpec(new byte[8]);
final Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, key, iv);
final byte[] plainTextBytes = message.getBytes("utf-8");
final byte[] cipherText = cipher.doFinal(plainTextBytes);
// final String encodedCipherText = new sun.misc.BASE64Encoder()
// .encode(cipherText);
return cipherText;
}
public String decrypt(byte[] message) throws Exception {
final MessageDigest md = MessageDigest.getInstance("md5");
final byte[] digestOfPassword = md.digest("HG58YZ3CR9"
.getBytes("utf-8"));
final byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24);
for (int j = 0, k = 16; j < 8;) {
keyBytes[k++] = keyBytes[j++];
}
final SecretKey key = new SecretKeySpec(keyBytes, "DESede");
final IvParameterSpec iv = new IvParameterSpec(new byte[8]);
final Cipher decipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
decipher.init(Cipher.DECRYPT_MODE, key, iv);
// final byte[] encData = new
// sun.misc.BASE64Decoder().decodeBuffer(message);
final byte[] plainText = decipher.doFinal(message);
return new String(plainText, "UTF-8");
}
}
</code></pre>
|
<pre><code>import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.spec.IvParameterSpec;
import java.util.Base64;
import java.util.Base64.Encoder;
/**
*
* @author shivshankar pal
*
* this code is working properly. doing proper encription and decription
note:- it will work only with jdk8
*
*
*/
public class TDes {
private static byte[] key = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02,
0x02, 0x02, 0x02, 0x02, 0x02, 0x02 };
private static byte[] keyiv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00 };
public static String encode(String args) {
System.out.println("plain data==> " + args);
byte[] encoding;
try {
encoding = Base64.getEncoder().encode(args.getBytes("UTF-8"));
System.out.println("Base64.encodeBase64==>" + new String(encoding));
byte[] str5 = des3EncodeCBC(key, keyiv, encoding);
System.out.println("des3EncodeCBC==> " + new String(str5));
byte[] encoding1 = Base64.getEncoder().encode(str5);
System.out.println("Base64.encodeBase64==> " + new String(encoding1));
return new String(encoding1);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public static String decode(String args) {
try {
System.out.println("encrypted data==>" + new String(args.getBytes("UTF-8")));
byte[] decode = Base64.getDecoder().decode(args.getBytes("UTF-8"));
System.out.println("Base64.decodeBase64(main encription)==>" + new String(decode));
byte[] str6 = des3DecodeCBC(key, keyiv, decode);
System.out.println("des3DecodeCBC==>" + new String(str6));
String data=new String(str6);
byte[] decode1 = Base64.getDecoder().decode(data.trim().getBytes("UTF-8"));
System.out.println("plaintext==> " + new String(decode1));
return new String(decode1);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "u mistaken in try block";
}
private static byte[] des3EncodeCBC(byte[] key, byte[] keyiv, byte[] data) {
try {
Key deskey = null;
DESedeKeySpec spec = new DESedeKeySpec(key);
SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("desede");
deskey = keyfactory.generateSecret(spec);
Cipher cipher = Cipher.getInstance("desede/ CBC/PKCS5Padding");
IvParameterSpec ips = new IvParameterSpec(keyiv);
cipher.init(Cipher.ENCRYPT_MODE, deskey, ips);
byte[] bout = cipher.doFinal(data);
return bout;
} catch (Exception e) {
System.out.println("methods qualified name" + e);
}
return null;
}
private static byte[] des3DecodeCBC(byte[] key, byte[] keyiv, byte[] data) {
try {
Key deskey = null;
DESedeKeySpec spec = new DESedeKeySpec(key);
SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("desede");
deskey = keyfactory.generateSecret(spec);
Cipher cipher = Cipher.getInstance("desede/ CBC/NoPadding");//PKCS5Padding NoPadding
IvParameterSpec ips = new IvParameterSpec(keyiv);
cipher.init(Cipher.DECRYPT_MODE, deskey, ips);
byte[] bout = cipher.doFinal(data);
return bout;
} catch (Exception e) {
System.out.println("methods qualified name" + e);
}
return null;
}
}
</code></pre>
| 4,057
|
<p>I'm trying to draw a graph on an ASP webpage. I'm hoping an API can be helpful, but so far I have not been able to find one. </p>
<p>The graph contains labeled nodes and unlabeled directional edges.
The ideal output would be something like <a href="http://en.wikipedia.org/wiki/Image:6n-graf.svg" rel="noreferrer">this</a>. </p>
<p>Anybody know of anything pre-built than can help?</p>
|
<p>Definitely <a href="http://graphviz.org" rel="nofollow noreferrer">graphviz</a>. The image on the wikipedia link you are pointing at was made in graphviz. From its description page the graph description file looked like this:</p>
<pre><code>graph untitled {
graph[bgcolor="transparent"];
node [fontname="Bitstream Vera Sans", fontsize="22.00", shape=circle, style="bold,filled" fillcolor=white];
edge [style=bold];
1;2;3;4;5;6;
6 -- 4 -- 5 -- 1 -- 2 -- 3 -- 4;
2 -- 5;
}
</code></pre>
<p>If that code were saved into a file input.dot, the command they would have used to actually generate the graph would probably have been:</p>
<pre><code>neato -Tsvg input.dot > graph.svg
</code></pre>
|
<p>You might be able to pull this off with <a href="http://code.google.com/apis/chart/" rel="nofollow noreferrer">Google's Chart API</a>. It is very easy to get started with.</p>
| 9,467
|
<p>I'm just looking for different opinions.
Do you consider OpenID a good "Single Sign On" solution?</p>
<p>The way it works seems to be a little bit confusing for an average user and there could be problems related to "putting all your eggs in the same basket".</p>
<p>Anyway, have anyone tried to implement his own OpenId solution within the context of an Intranet where there are many different applications (Wordpress, Elgg, Media Wiki, ..)??</p>
<p>I consider it could be a great solution to solve the "Digital Identity" problem but I don't know if it will work with the "login once and surf the Intranet" problem.</p>
<p>Opinions? </p>
|
<p>Also, SSO (as you mentioned) usually implies that I only have to login once (presumably to my workstation) and then from there on, I don't need to sign-in anywhere.</p>
<p>OpenID of course doesn't solve that problem. For example, if I use OpenID to sign in to StackOverflow, it doesn't mean I don't need to sign in to another website again using the same openID.</p>
|
<p>Actually, in the case of StackOverflow, a separate account would have saved me a lot of trouble. I decided to use my WordPress.com OpenID, since that's where I'm hosting my blog, but it turned out that WordPress.com have serious problems with their OpenID service, and most of the time I am not able to log on to StackOverflow at all. Of course, I can use a different OpenID provider to log on with, but then I will have a different identity on the site.</p>
<p>I guess you could say WordPress.com is to blame for this, but the problem reimains the same. By using OpenID you are depending on another site's service to function. Any problems on the third party's site will in effect also disable your site.</p>
<p>As an alternative solution i tried signing in with my Yahoo OpenID, but then I got some random string as the user name, and as DrPizza already pointed out, I would have to edit my personal details anyway.</p>
<p>OpenID is a nice idea, but it's still not something I would rely on with the current state of things.</p>
| 4,206
|
<p>Acetone can be used to smooth ABS prints. What safety precautions should be taken during its use?</p>
|
<p>There are a few main safety precautions you should consider.</p>
<ul>
<li><strong><a href="http://sinkhacks.com/building-acetone-vapor-bath-smoothing-3d-printed-parts/" rel="nofollow">Make sure the area is well-ventilated.</a></strong> Acetone is flammable. A buildup of acetone gas could quickly get concentrated, meaning that a single spark could lead to disaster. Using a fan is good; angle it towards an open window. This is also to prevent exposure to acetone because of its toxicity.</li>
<li><strong><a href="http://www.sciencelab.com/msds.php?msdsId=9927062" rel="nofollow">Be prepared to fight a fire.</a></strong> Should vapor ignite, you may need to fight the fire. If it is large enough, then you should clearly evacuate the area. If it appears to be small, use dry chemical powder to snuff out the fire. Alcohol foam, water spray, and/or fog may be used on slightly larger fires. Acetone is not likely to cause a large inferno to rip through the building. But there's always the chance of a small fire. Be careful.</li>
<li><strong><a href="https://rivercitylabs.org/acetone-smoothing-chamber-3d-printing/" rel="nofollow">Create a vapor chamber.</a></strong> This is another way to stop a potential fire from spreading. It can also reduce contamination.</li>
<li><strong>Wear gloves.</strong> This can minimize any potential transfer toxic effects. However, skin exposure is unlikely to cause major issues.</li>
</ul>
<p>Acetone is toxic, as I mentioned before, but it is not highly toxic. Exposure via <a href="http://ccohs.ca/oshanswers/chemicals/chem_profiles/acetone.html" rel="nofollow">the eyes and nose/mouth</a> is the main risk. Skin effects may occur (e.g. mild irritation), but they are minor and generally arise only after long-term exposure (hence the recommendation of gloves in some cases).</p>
<p>Acetone exposure is only a serious problem when a person is repeatedly exposed to levels <a href="http://www.cdc.gov/niosh/idlh/67641.html" rel="nofollow">greater than 1,000 ppm</a> (severe effects only arise at much higher levels). It seems unlikely, given a proper ventilation system, that this will be an issue</p>
<p>In addition to all this, basic safety precautions such as wearing a ventilator mask and goggles should definitely be taken. When working with any such chemicals with the potential for bodily harm, these should absolutely be used.</p>
|
<p>You can smooth a print with acetone using different approaches which require different precautions. In general, you should have ventilated area and use gloves (or wash your hands after the procedure). </p>
<h2>Applying Acetone Directly</h2>
<p>Using the print in acetone for several seconds or you can apply acetone with a brush. There is a low possibility of fire. See this video, <a href="https://www.youtube.com/watch?v=r3nJbU9OInk" rel="nofollow noreferrer">(4) MakerBot Replicator - Model Finishing Tricks - Acetone Wash</a>. </p>
<h2>Cold Acetone Vapor</h2>
<p>This process takes several hours and gives you best control of the process. Because no external heat is used there is low chance of fire. See this video, <a href="https://www.youtube.com/watch?v=h2lm6FuaAWI" rel="nofollow noreferrer">Cold Acetone Vapor Finishing for 3D Printing</a>.</p>
<h2>Hot Acetone Vapor</h2>
<p>This approach takes minutes to smooth the print and there is high chance of ignition. I would never use it inside a building. See this video, <a href="https://www.youtube.com/watch?v=5sblh0bBHoQ" rel="nofollow noreferrer">Make your 3D Printed parts look professional with Acetone and a Rice cooker! - 2014</a>.</p>
| 105
|
<p>Is there anyway to have a sort of virtual static member in C++?</p>
<p>For example:</p>
<pre><code>class BaseClass {
public:
BaseClass(const string& name) : _name(name) {}
string GetName() const { return _name; }
virtual void UseClass() = 0;
private:
const string _name;
};
class DerivedClass : public BaseClass {
public:
DerivedClass() : BaseClass("DerivedClass") {}
virtual void UseClass() { /* do something */ }
};
</code></pre>
<p>I know this example is trivial, but if I have a vector of complex data that is going to be always the same for all derived class but is needed to be accessed from base class methods?</p>
<pre><code>class BaseClass {
public:
BaseClass() {}
virtual string GetName() const = 0;
virtual void UseClass() = 0;
};
class DerivedClass : public BaseClass {
public:
DerivedClass() {}
virtual string GetName() const { return _name; }
virtual void UseClass() { /* do something */ }
private:
static const string _name;
};
string DerivedClass::_name = "DerivedClass";
</code></pre>
<p>This solution does not satify me because I need reimplement the member _name and its accessor GetName() in every class. In my case I have several members that follows _name behavior and tenths of derived classes.</p>
<p>Any idea?</p>
|
<p>Here is one solution: </p>
<pre><code>struct BaseData
{
const string my_word;
const int my_number;
};
class Base
{
public:
Base(const BaseData* apBaseData)
{
mpBaseData = apBaseData;
}
const string getMyWord()
{
return mpBaseData->my_word;
}
int getMyNumber()
{
return mpBaseData->my_number;
}
private:
const BaseData* mpBaseData;
};
class Derived : public Base
{
public:
Derived() : Base(&sBaseData)
{
}
private:
static BaseData sBaseData;
}
BaseData Derived::BaseData = { "Foo", 42 };
</code></pre>
|
<p>It sounds as if you're trying to avoid having to duplicate the code at the leaf classes, so why not just derive an intermediate base class from the base class. this intermediate class can hold the static data, and have all your leaf classes derive from the intermediate base class. This presupposes that one static piece of data held over all the derived classes is desired, which seems so from your example.</p>
| 5,476
|
<p>When an <code>AutoCompleteExtender</code> is displayed in IE6 it seems to ignore z-index and renders below any select controls (like <strong>dropdownlists</strong>) in IE6.</p>
<pre><code><asp:TextBox ID="TextBox1" runat="server" />
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
TargetControlID="TextBox1" EnableCaching="true" CompletionSetCount="5"
FirstRowSelected="true" ServicePath="~/Services/Service1.asmx" ServiceMethod="GetSuggestion" />
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Text="Item 1" Value="0" />
<asp:ListItem Text="Item 2" Value="1" />
</asp:DropDownList>
</code></pre>
<p>How do I make it render above <strong>dropdownlists</strong>?</p>
|
<p>Nothing renders below select controls in IE6. It's one of the many "features" microsoft bestowed upon us when they gifted IE to the world</p>
<p>You have to hide them, then re-show them.</p>
<p>Observe the <a href="http://code.google.com/p/nucleus-plugins/source/browse/lightbox2/trunk/lightbox2/js/lightbox.js#205" rel="nofollow noreferrer">standard lightbox script</a> - which does exactly this</p>
<p>(note that link is just to the first thing I found on google which had the source to lightbox.js as a demonstration. It's got nothing to do with anything else)</p>
|
<p>Nothing renders below select controls in IE6. It's one of the many "features" microsoft bestowed upon us when they gifted IE to the world</p>
<p>You have to hide them, then re-show them.</p>
<p>Observe the <a href="http://code.google.com/p/nucleus-plugins/source/browse/lightbox2/trunk/lightbox2/js/lightbox.js#205" rel="nofollow noreferrer">standard lightbox script</a> - which does exactly this</p>
<p>(note that link is just to the first thing I found on google which had the source to lightbox.js as a demonstration. It's got nothing to do with anything else)</p>
| 6,711
|
<p>I encounter an error of the form: "The model item passed into the dictionary is of type FooViewData but this dictionary requires a model item of type bar" even though I am passing in an object of the correct type (bar) for the typed user control.</p>
|
<p>What @MattMitchell said is probably the reason you're seeing this error.</p>
<p>If you want to know <em>why</em>; it is because when you pass null as the controlData parameter when using RenderUserControl(), the framework will try to pass the view data from the current view context onto the user control instead (see UserControlExtensions.DoRendering method in System.Web.Mvc).</p>
|
<p>What has probably happened is that the object provided when rendering the user control is actually null.</p>
| 2,744
|
<p>I want to send email from a Ruby application. Is there a call in the core language to do this or is there a library I should use? What's the best way to do this?</p>
|
<p>If you don't want to use <a href="http://wiki.rubyonrails.org/rails/pages/ActionMailer" rel="nofollow noreferrer">ActionMailer</a> you can use <a href="http://www.ruby-doc.org/stdlib/libdoc/net/smtp/rdoc/index.html" rel="nofollow noreferrer">Net::SMTP</a> (for the actual sending) together with <a href="https://github.com/mikel/tmail" rel="nofollow noreferrer">tmail</a> for easily creating emails (with multiple parts, etc.).</p>
|
<p>You might also consider taking a look at the <a href="http://wiki.rubyonrails.org/rails/pages/ActionMailer" rel="nofollow noreferrer">ActionMailer</a> component that ships as part of, but is not dependent on Rails.</p>
| 8,281
|
<p>How can I open a cmd window in a specific location without having to navigate all the way to the directory I want?</p>
|
<p>This might be what you want: </p>
<pre><code>cmd /K "cd C:\Windows\"
</code></pre>
<p>Note that in order to change drive letters, you need to use <code>cd /d</code>. For example:</p>
<pre><code>C:\Windows\System32\cmd.exe /K "cd /d H:\Python\"
</code></pre>
<p><a href="http://ss64.com/nt/cd.html" rel="noreferrer">(documentation)</a></p>
|
<p>For a better experience using a terminal in windows system, <a href="http://cmder.net/" rel="nofollow noreferrer">cmder</a> may help for a shortcut usage:</p>
<ol>
<li>Download <a href="http://cmder.net/" rel="nofollow noreferrer">cmder</a> into your system</li>
<li>Make shortcut</li>
<li>type <code>path_of_the_cmder</code> <code>/START</code> <code>target_path_wish_to_run</code></li>
</ol>
<p>For an instance:</p>
<p><strong><code>TARGET</code></strong> -> <code>C:\Users\<username>i\AppData\Roaming\cmder\Cmder.exe /START C:\SOURCE\</code></p>
| 8,597
|
<p>How effective is merging when folders and projects have been renamed in your solution?</p>
|
<p>We've had lots of success with TFS 2005 when it comes to file deletes/renames, with a few very specific exceptions, namely:</p>
<ol>
<li>Files which have been renamed in both source and target branches (this is usually trivially solved with a click on "Ignore server changes");</li>
<li>Files which have been renamed in the target branch but deleted in the source branch. I recall one case where the merge would not work no matter what we tried, and we were forced to "revert" the change on the source branch and re-do after the merge.</li>
</ol>
<p>Supposedly TFS 2008 solves a lot of these issues, but honestly aside from occasional merge hickups TFS is stable, and hierarchical merges are a lot simpler and quicker than with SVN.</p>
|
<p>We've had lots of problems with TFS 2005 and deletes in general. I haven't determined the cause yet, but a number of my team members have run into problems merging in changes that involved a renamed or deleted folder. This seems particularly true if there was a lot of refactoring (and renaming, and re-renaming) in the branch where the renames occurred. I haven't figured out the reason or reproduction steps, as I haven't been personally involved in any of the situations where it didn't work.</p>
<p>I've seen some other general deletion problems like this:
1 in Branch A, reduce permissions in subdirectory 1 to read-only
2. Create Branch B (branched from A to B) (check in)
3. Delete Branch B (check in)
4. Create a new branch from A, give it the same name as branch B
5. Get a weird permissions error related to TFS still "seeing" the read-only permissions on the deleted branch B.</p>
<p>Only way we've found to avoid it is to insert step 2a: rename Branch B to _Branch B (check in)</p>
<p>Overall, TFS has been great for us, but there's something flakey going on with deletes, renames, and merges. We hope to upgrade to 2008 soon, and I am hoping that it addresses our issues.</p>
| 9,725
|
<p>I want to use a real IDE for editing javascript files in combination with Firebug. In the 'Add editor' dialog for Firebug I'm allowed to specify executable and arguments. So the question is really how do I open a file in Eclipse/Netbeans from the command line. </p>
<p>Extra points for allowing me to choose between opening a new Eclipse/netbeans instance and reusing an already running one.</p>
|
<p>Not an exact answer I'm afraid, but this information might help.</p>
<p><a href="http://help.eclipse.org/help21/index.jsp?topic=/org.eclipse.platform.doc.user/tasks/running_eclipse.htm" rel="nofollow noreferrer">Eclipse Help - Running Eclipse</a><br>
<a href="http://ajaxian.com/archives/fireclipse-debug-from-ff-straight-into-eclipse" rel="nofollow noreferrer">Fireclipse: Debug from FF straight into Eclipse</a></p>
|
<p>I havent tried this yet but looks interesting <a href="http://code.google.com/p/jsdt/wiki/newFeatures" rel="nofollow noreferrer">Javascript Debug Toolkit 2.0.0</a></p>
<p>Also I have heard that <a href="http://www.aptana.com/" rel="nofollow noreferrer">aptana</a> is pretty good</p>
| 8,293
|
<p>I'm working on a system with four logical CPS (two dual-core CPUs if it matters). I'm using make to parallelize twelve trivially parallelizable tasks and doing it from cron.</p>
<p>The invocation looks like:</p>
<pre><code>make -k -j 4 -l 3.99 -C [dir] [12 targets]
</code></pre>
<p>The trouble I'm running into is that sometimes one job will finish but the next one won't startup even though it shouldn't be stopped by the load average limiter. Each target takes about four hours to complete and I'm wondering if this might be part of the problem.</p>
<p>Edit: Sometimes a target does fail but I use the -k option to have the rest of the make still run. I haven't noticed any correlation with jobs failing and the next job not starting.</p>
|
<p>I'd drop the '-l'</p>
<p>If all you plan to run the the system is this build I <em>think</em> the -j 4 does what you want.</p>
<p>Based on my memory, if you have anything else running (crond?), that can push the load average over 4.</p>
<p><a href="http://sunsite.ualberta.ca/Documentation/Gnu/make-3.79/html_chapter/make_5.html#SEC47" rel="nofollow noreferrer">GNU make ref</a></p>
|
<p>Does make think one of the targets is failing? If so, it will stop the make after the running jobs finish. You can use -k to tell it to continue even if an error occurs.</p>
| 5,589
|
<p>I know the minimum layer height will effect how detailed of an item you can print and the amount of time it takes to print something, but is it necessary to have an extremely low minimum layer height if you plan to print only larger objects?</p>
|
<p>I believe the <a href="http://manual.slic3r.org/first-print/first-layer">Slic3r Manual</a> summarizes this quite nicely:</p>
<blockquote>
<p>A thicker layer height will provide more flow, and consequently more heat, making the extrusion adhere to the bed more. It also gives the benefit of giving more tolerance for the levelness of the bed. It is recommended to raise the first layer height to match the diameter of the nozzle, e.g. a first layer height of 0.35mm for a 0.35mm nozzle.</p>
</blockquote>
<p>In other words, larger layer heights for the first layer typically gives better adhesion, and makes inaccurate bed leveling (and auto leveling) still work.</p>
|
<p>In short: no.</p>
<p>Smaller layers will make your prints look nicer. That said, in my experience, most printers can handle roughly the same layer heights, no matter what the manufacturer says it can do. With a little tinkering, you can get any printer to do what you tell it to do.</p>
<p>That said, for larger prints, you really won't want to lower the layer height too much. Typically, the quality difference you see in a print that's, say, .2 mm layer height (typical) vs .1mm layer height (typically high quality) is not that much different.</p>
<p>Note that lowering your layer height increases the number of layers in your object, so it'll take longer to print and have more opportunities to fail along the way. For anything of significant size (150 mm + or so) it's really not worth the extra risk, I'd say.</p>
| 84
|
<p>I'm trying to the the flv Flash player <a href="http://www.jeroenwijering.com/?item=JW_FLV_Player" rel="nofollow noreferrer">from here</a> in a windows forms application. I currently have it playing 1 .flv file with no problems but I really need to be able to play multiple files. Has anyone had experienace of using the playlists that this control offers or is there a better way to do this?</p>
|
<p>Can you get the control to run the way you want it in a webpage/browser? If yes (and the problem is with winforms, I'd just embed it in a browser control. If no, I'd as the creators directly.</p>
|
<p>Hmm I ran into this same problem as well. The prob is that loadmovie method doesnt seem to clear the last movie. And so far I haven't found any technique to load a new movie into the same flash player.</p>
| 6,515
|
<p>Is there any reason not to use the bitwise operators &, |, and ^ for "bool" values in C++? </p>
<p>I sometimes run into situations where I want exactly one of two conditions to be true (XOR), so I just throw the ^ operator into a conditional expression. I also sometimes want all parts of a condition to be evaluated whether the result is true or not (rather than short-circuiting), so I use & and |. I also need to accumulate Boolean values sometimes, and &= and |= can be quite useful.</p>
<p>I've gotten a few raised eyebrows when doing this, but the code is still meaningful and cleaner than it would be otherwise. Is there any reason NOT to use these for bools? Are there any modern compilers that give bad results for this?</p>
|
<p><code>||</code> and <code>&&</code> are boolean operators and the built-in ones are guaranteed to return either <code>true</code> or <code>false</code>. Nothing else.</p>
<p><code>|</code>, <code>&</code> and <code>^</code> are bitwise operators. When the domain of numbers you operate on is just 1 and 0, then they are exactly the same, but in cases where your booleans are not strictly 1 and 0 – as is the case with the C language – you may end up with some behavior you didn't want. For instance:</p>
<pre><code>BOOL two = 2;
BOOL one = 1;
BOOL and = two & one; //and = 0
BOOL cand = two && one; //cand = 1
</code></pre>
<p>In C++, however, the <code>bool</code> type is guaranteed to be only either a <code>true</code> or a <code>false</code> (which convert implicitly to respectively <code>1</code> and <code>0</code>), so it's less of a worry from this stance, but the fact that people aren't used to seeing such things in code makes a good argument for not doing it. Just say <code>b = b && x</code> and be done with it.</p>
|
<p>IIRC, many C++ compilers will warn when attempting to cast the result of a bitwise operation as a bool. You would have to use a type cast to make the compiler happy.</p>
<p>Using a bitwise operation in an if expression would serve the same criticism, though perhaps not by the compiler. Any non-zero value is considered true, so something like "if (7 & 3)" will be true. This behavior may be acceptable in Perl, but C/C++ are very explicit languages. I think the Spock eyebrow is due diligence. :) I would append "== 0" or "!= 0" to make it perfectly clear what your objective was.</p>
<p>But anyway, it sounds like a personal preference. I would run the code through lint or similar tool and see if it also thinks it's an unwise strategy. Personally, it reads like a coding mistake.</p>
| 4,416
|
<p>I'm having some internationalisation woes:</p>
<p>My UTF-8 string fields are being rendered in the browser as ???? after being returned from the database.</p>
<p>After retrieval from the database using Hibernate, the String fields are presented correctly on inspection using the eclipse debugger.</p>
<p>However Struts2/Tiles is rendering these strings as ???? in the HTML sent to the browser.</p>
<p>The charset directive is present in the HTML header:
</p>
<p>Perhaps I need to add something to my struts2 or tiles configurations?</p>
|
<p>You could try something like this.</p>
<p>It's taken from sun's page on <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/doc/WebI18N5.html" rel="nofollow noreferrer">Character Sets and Encodings</a>.
I think this has to be the very first line in your jsp.</p>
<pre><code><%@ page contentType="text/html; charset=UTF-8" %>
</code></pre>
|
<p>Try setting the lang attribute on the <html/> element.</p>
<p>HTML example:</p>
<pre>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="ja">
</pre>
<p>XHTML example:</p>
<pre>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
</pre>
| 7,991
|
<p>I have a vb6 form with an ocx control on it. The ocx control has a button on it that I want to press from code. How do I do this?</p>
<p>I have:</p>
<pre><code>Dim b As CommandButton
Set b = ocx.GetButton("btnPrint")
SendMessage ocx.hwnd, WM_COMMAND, GetWindowLong(b.hwnd, GWL_ID), b.hwnd
</code></pre>
<p>but it doesn't seem to work.</p>
|
<p>I believe the following will work:</p>
<pre><code>Dim b As CommandButton
Set b = ocx.GetButton("btnPrint")
b = True
</code></pre>
<p><code>CommandButton</code>s actually have two functions. One is the usual click button and the other is a toggle button that acts similar to a <code>CheckBox</code>. The default property of the <code>CommandButton</code> is actually the <code>Value</code> property that indicates whether a button is toggled. By setting the property, the <code>Click</code> event is generated. This is done even if the button is not styled as a <code>ToggleButton</code> and therefore doesn't change its state.</p>
|
<p>Do you have access to the OCX code? You shouldn't really be directly invoking the click of a button. You should refactor the code so that the OCX button click code calls a function, e.g.</p>
<pre><code>CMyWindow::OnLButtonDown()
{
this->FooBar();
}
</code></pre>
<p>Then from your VB6 app, directly call the FooBar method. If you can't directly call functions from VB6 you can wrap the FooBar() method with a windows message proc function, e.g.</p>
<pre><code>#define WM_FOOBAR WM_APP + 1
</code></pre>
<p>Then use <code>SendMessage</code> in the VB6, like <code>SendMessage(WM_FOOBAR, ...)</code></p>
| 6,237
|
<p>I am working with Ender 3 Pro and in menu it has an option to cooldown. Is there any need to cooldown 3D printer before shutdown or can I just shutdown without cooldown? </p>
|
<p>Depending on what material you print it it most likely a good idea to let the hotend cool down before shutting off the printer (fan). </p>
<p>For example if you shut down the printer right after you print a PLA part, at 190 - 220 degrees Celsius, your hot end will still be that hot and will suffer heat creep without the fan running. The next time you fire up your printer the hotend will be jammed and you will need to clear it before starting a print. </p>
<p>This is obviously situation dependent but in most cases you should let your hot end get below the TG (glass transition temperature) of the material before turning off the printer.</p>
|
<p>That option you are referring to, is meant to manually shut down power to the heated bed and hotend, there is no timed cool down period other than you timing it. This is a handy option if you fiddled with either the bed or the hotend; e.g. to insert new filament.</p>
<p>A cool down period can be very useful depending on the printer. Those cold-end cooling fans usually are very noisy, so people cut them of (that is not always possible/wise, but is being done out there), disable them after printing or shutting down power of the printer as a whole. Some type of hotends are prone to have heat creep up the hotend and soften the filament so that it can clog up the hotend. I've seen this happen on Ultimaker printers where the cooling fan was not spinning because some fine strings where sucked up.</p>
<p>To minimize the noise level of such cold end cooling fans you can put them on a relay switch and have e.g. OctoPrint schedule the print to be on for e.g. 2 minutes after a print failed or finished, works perfectly, and then you have your cooling down schedule/period.</p>
| 1,356
|
<p>So I'm making my friend a Monado sword replica and I've printed the handle in 2 pieces as to fill it with electronics and then superglue the 2 halves together.</p>
<p>I seem to have put too much on and it's leaked out and spread as shown in the picture..</p>
<p>Does anyone know how to get the dried glue off?
<a href="https://i.stack.imgur.com/h0LGa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h0LGa.jpg" alt="enter image description here" /></a></p>
<p>Thanks,</p>
<p>(PS. The glue is called "NO NONSENSE SUPERGLUE")</p>
|
<p>In agreement with what Akriss said, pretty much all "super" glue is CA (cyanoacrylate) glue, which is soluble in acetone. PLA itself is does not dissolve in or react with acetone, but the pigments, additives, etc. likely do, so you should wipe with a paper towel or cloth (the latter might be better to avoid getting fibers stuck on the glue) soaked in acetone rather than pouring it over the piece or submerging it, to limit the effects. Also, test first on a scrap piece printed with the same filament to ensure the results aren't unacceptably bad.</p>
|
<p>I've used Acetone before. However that said I've not had the need to remove it from PLA. Not sure how PLA reacts to Acetone.</p>
<p>A link that may be of use.
<a href="https://www.art-us.com/how-to-get-super-glue-off-almost-anything/" rel="nofollow noreferrer">https://www.art-us.com/how-to-get-super-glue-off-almost-anything/</a></p>
| 1,799
|
<p>I find working on the command line in Windows frustrating, primarily because the console window is wretched to use compared to terminal applications on linux and OS X such as "rxvt", "xterm", or "Terminal". Major complaints:</p>
<ol>
<li><p>No standard copy/paste. You have to turn on "mark" mode and it's only available from a multi-level popup triggered by the (small) left hand corner button. Then copy and paste need to be invoked from the same menu</p></li>
<li><p>You can't arbitrarily resize the window by dragging, you need to set a preference (back to the multi-level popup) each time you want to resize a window</p></li>
<li><p>You can only make the window so big before horizontal scroll bars enter the picture. Horizontal scroll bars suck.</p></li>
<li><p>With the cmd.exe shell, you can't navigate to folders with \\netpath notation (UNC?), you need to map a network drive. This sucks when working on multiple machines that are going to have different drives mapped</p></li>
</ol>
<p>Are there any tricks or applications, (paid or otherwise), that address these issue?</p>
|
<p>Sorry for the self-promotion, I'm the author of another Console Emulator, not mentioned here.</p>
<p><a href="http://www.fosshub.com/ConEmu.html" rel="nofollow noreferrer">ConEmu</a> is opensource console emulator with tabs, which represents multiple consoles and simple GUI applications as one customizable GUI window.</p>
<p>Initially, the program was designed to work with <a href="http://www.farmanager.com/" rel="nofollow noreferrer">Far Manager</a> (my favorite shell replacement - file and archive management, command history and completion, powerful editor). But ConEmu can be used with any other console application or simple GUI tools (like PuTTY for example). ConEmu is a live project, open to suggestions.</p>
<p>A brief excerpt from the long list of options:</p>
<ul>
<li>Latest versions of ConEmu may set up itself as <a href="https://superuser.com/a/509710/139371">default terminal for Windows</a></li>
<li>Use any font installed in the system, or copied to a folder of the program (ttf, otf, fon, bdf)</li>
<li>Run selected tabs as Administrator (Vista+) or as selected user</li>
<li>Windows 7 Jump lists and Progress on taskbar</li>
<li>Integration with <a href="http://www.dosbox.com/" rel="nofollow noreferrer">DosBox</a> (useful in 64bit systems to run DOS applications)</li>
<li>Smooth resize, maximized and fullscreen window modes</li>
<li>Scrollbar initially hidden, may be revealed by mouseover or checkbox in settings</li>
<li>Optional settings (e.g. pallette) for selected applications</li>
<li>User friendly text and block selection (from keyboard or mouse), copy, paste, text search in console</li>
<li>ANSI X3.64 and Xterm 256 color</li>
</ul>
<p>Far Manager users will acquire shell style drag-n-drop, thumbnails and tiles in panles, tabs for editors and viewers, true colors and font styles (italic/bold/underline).</p>
<p>PS. Far Manager supports UNC paths (\\server\share\...)</p>
|
<p>Take a look at <a href="http://www.jpsoft.com" rel="nofollow noreferrer">Take Command</a>.</p>
<blockquote>
<p>Take Command is a comprehensive interactive GUI and command line environment that makes using the Windows command prompt and creating batch files easy and far more powerful.</p>
</blockquote>
<p>(Take Command is, however, "not free".)</p>
| 8,606
|
<p>Within an application, I've got Secret Keys uses to calculate a hash for an API call. In a .NET application it's fairly easy to use a program like Reflector to pull out information from the assembly to include these keys.</p>
<p>Is obfuscating the assembly a good way of securing these keys?</p>
|
<p>Probably not.</p>
<p>Look into cryptography and Windows' built-in information-hiding mechanisms (DPAPI and storing the keys in an ACL-restricted registry key, for example). That's as good as you're going to get for security you need to keep on the same system as your application.</p>
<p>If you are looking for a way to stop someone physically sitting at the machine from getting your information, forget it. If someone is determined, and has unrestricted access to a computer that is not under your control, there is no way to be 100% certain that the data is protected under all circumstances. Someone who is determined will get at it if they want to.</p>
|
<p>I wouldn't think so, as obfuscating (as I understand it at least) will simply mess around with the method names to make it hard (but not impossible) to understand the code. This won't change the data of the actual key (which I'm guessing you have stored in a constant somewhere). </p>
<p>If you just want to make it somewhat harder to see, you could run a simple cipher on the plaintext (like ROT-13 or something) so that it's at least not stored in the clear in the code itself. But that's certainly not going to stop any determined hacker from accessing your key. A stronger encryption method won't help because you'd still need to store the key for THAT in the code, and there's nothing protecting that.</p>
<p>The only really secure thing I can think of is to keep the key outside of the application somehow, and then restrict access to the key. For instance, you could keep the key in a separate file and then protected the file with an OS-level user-based restriction; that would probably work. You could do the same with a database connection (again, relying on the user-based access restriction to keep non-authorized users out of the database). </p>
<p>I've toyed with the idea of doing this for my apps but I've never implemented it. </p>
| 5,333
|
<p>I work on communication devices for people with disabilities that prevent them from speaking. This can be anything from a board with symbols on, to a relatively sophisticated app. </p>
<p>Some potential users also have sight issues and have to distinguish symbols by feel (these particular users have cognitive disabilities and so braile isn't useful) . Currently the solution is to, by hand, stick items onto the buttons. Like this: </p>
<p><a href="https://i.stack.imgur.com/cFS0d.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cFS0d.png" alt="enter image description here"></a></p>
<p>This is effective, but takes a very long time. </p>
<p>There exists open symbol libraries <a href="http://straight-street.com/" rel="nofollow noreferrer">like this</a>, that include nice svg images like <a href="https://www.dropbox.com/s/e5emeku99xxmeub/traffic%20lights.svg?dl=0" rel="nofollow noreferrer">this one</a> (not uploaded, because SO doesn't like svg, but here's the screenshot: </p>
<p><a href="https://i.stack.imgur.com/746CY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/746CY.png" alt="enter image description here"></a></p>
<p>A friend converted some of these images into 3d prints like so: </p>
<p><a href="https://i.stack.imgur.com/Cv41n.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cv41n.jpg" alt="enter image description here"></a></p>
<p>This was amazing, and useful, but I understand quite time-intensive for him - and there are thousands of these symbols.</p>
<p>Here's what I want to know: given that SVG is a relatively simple structure and the symbols are very simple, what are the steps for writing the script that says: "Take the svg, map it to a plane, raise everything that is black by 2mm, everything that is gray by 1mm and add height for the rest of the colours according to this table" ? </p>
<p>Bonus points for something that I can reasonably get going on a set of 10000 svg files and come back to later...</p>
|
<p>If you install inkscape, pstoedit and ghostscript version 9.21 (not the latest as pstoedit is incompatible) you can get the file into a format that openscad can
import using two commands in a cmd file </p>
<pre><code>"C:\Program Files\Inkscape\inkscape" -E "traffic lights.eps" "traffic lights.svg"
"C:\Program Files\pstoedit\pstoedit" -dt -f dxf:-polyaslines "traffic lights.eps" "traffic lights.dxf"
</code></pre>
<p>then in openscad</p>
<pre><code>linear_extrude(3) import ("traffic lights.dxf");
</code></pre>
<p>will import gives me </p>
<p><a href="https://i.stack.imgur.com/3BM0c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3BM0c.png" alt="openscad"></a></p>
<p>With a thickness of 3mm - you can see the model needs some scaling but its seems possible although - I can't see an option to scale based on color - </p>
|
<p>Nothing thats works via scripting BUT is really simple and easy.</p>
<ol>
<li>register on tinkercad.com (I know register is a bummer but its a great tool)</li>
<li>open a new design</li>
<li>import *.svg file</li>
<li>adjust height or size of the converted object</li>
<li>download .stl</li>
</ol>
<p>Thats going to take a while for 1000 files but its so simple, printing the stuff will take forever, so you´ve got some time :P</p>
<p>Edit: Maybe edit the topic to something like "SVG to STL conversion" which would make the thread more likely to be found.</p>
| 759
|
<p>So, I have 2 database instances, one is for development in general, another was copied from development for unit tests.</p>
<p>Something changed in the development database that I can't figure out, and I don't know how to see what is different.</p>
<p>When I try to delete from a particular table, with for example:</p>
<pre><code>delete from myschema.mytable where id = 555
</code></pre>
<p>I get the following normal response from the unit test DB indicating no row was deleted:</p>
<blockquote>
<p>SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty table. SQLSTATE=02000</p>
</blockquote>
<p>However, the development database fails to delete at all with the following error:</p>
<blockquote>
<p>DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0440N No authorized routine named "=" of type "FUNCTION" having compatible arguments was found. SQLSTATE=42884</p>
</blockquote>
<p>My best guess is there is some trigger or view that was added or changed that is causing the problem, but I have no idea how to go about finding the problem... has anyone had this problem or know how to figure out what the root of the problem is?</p>
<p>(note that this is a DB2 database)</p>
|
<p>Hmm, applying the great oracle to this question, I came up with:</p>
<p><a href="http://bytes.com/forum/thread830774.html" rel="nofollow noreferrer">http://bytes.com/forum/thread830774.html</a></p>
<p>It seems to suggest that another table has a foreign key pointing at the problematic one, when that FK on the other table is dropped, the delete should work again. (Presumably you can re-create the foreign key as well)</p>
<p>Does that help any?</p>
|
<p>You might have an open transaction on the dev db...that gets me sometimes on SQL Server</p>
| 7,634
|
<p>I've been trying to implement unit testing and currently have some code that does the following:</p>
<ol>
<li>query external database, loading
into a feed table </li>
<li>query a view,
which is a delta of my feed and data
tables, updating data table to match
feed table</li>
</ol>
<p>my unit testing strategy is this:</p>
<p>I have a testing database that I am free to manipulate.</p>
<ol>
<li>in setUP(), load some data into my testing db</li>
<li>run my code, using my testing db as the source</li>
<li>inspect the data table, checking for counts and the existence/non existence of certain records</li>
<li>clear testing db, loading in a different set of data</li>
<li>run code again</li>
<li>inspect data table again</li>
</ol>
<p>Obviously I have the data sets that I load into the source db set up such that I know certain records should be added,deleted,updated, etc.</p>
<p>It seems like this is a bit cumbersome and there should be an easier way? any suggestions?</p>
|
<p>Is it your intent to test the view which generates the deltas, or to test that your code correctly adds, deletes and updates in response to the view?</p>
<p>If you want to test the view, you could use a tool like <a href="http://dbunit.sourceforge.net/" rel="noreferrer">DBUnit</a> to populate your feed and data tables with various data whose delta you've manually calculated. Then, for each test you would verify that the view returns a matching set.</p>
<p>If you want to test how your code responds to diffs detected by the view, I would try to abstract away database access. I imagine an java method to which you can pass a result set (or list of POJO/DTO's) and returns a list of parameter Object arrays (again, or POJO's) to be added. Other methods would parse the diff list for items to be removed and updated. You could then create a mock result set or pojo's, pass them to your code and verify the correct parameters are returned. All without touching a database.</p>
<p>I think the key is to break your process into parts and test each of those as independently as possible.</p>
|
<p>I use DbUnit, but also I work very hard to not to have to test against the DB.
Tests that go against the database should only exist for the purpose of testing the database interface.
So I have Mock Db Connections that I can set the data for use in all the rest of my tests.</p>
| 6,980
|
<p>I am going to be using Subversion for source control on a new J2EE web application. What directory structure will you recommend for organizing code, tests and documentation?</p>
|
<p>I usually have</p>
<pre>
Project Directory
src - actual source
doc - documentation
lib - libraries referenced from source
dep - installation files for dependencies that don't fit in lib
db - database installation script
</pre>
<p>In work with Visual Studio, I'm not sure if this works the same in the java world. But i usually put stuff in different project folders in src. For each source project there's a separate test project. Build files go in the main project directory. I usually put a README there too documenting how to setup the project if it needs more than just checking out.</p>
<p>EDIT: This is the structure for a single working checkout of the project. It will be duplicated for each branch/tag in your revision control system (remember, in most SVN system, copies are cheap). The above example under Subversion would look like:</p>
<pre><code>/project
/trunk
/src
/doc
/...
/branches
/feature1
/src
/doc
/...
/feature2
/src
/doc
/...
</code></pre>
|
<p>I use Eclipse for creating J2EE web applications and this will create the following project structure:</p>
<pre><code>WebAppName\
\lib
\src
\tests
etc...
</code></pre>
<p>I would then create an SVN folder on our trunk called WebAppNameProject. Within this folder I would create folders called WebAppNameSource, Documentation etc. Within the WebAppNameSource folder I would place the project source generated by Eclipse. Thus I would have the following folder structure in SVN:</p>
<pre><code>\svn\trunk\WebAppNameProject
\WebAppNameSource
\lib
\src
\tests
etc...
\Documentation
</code></pre>
<p>Hope this helps.</p>
| 6,284
|
<p>How do I suspend a whole process (like the Process Explorer does when I click Suspend) in C#.</p>
<p>I'm starting the Process with Process.Start, and on a certain event, I want to suspend the process to be able to do some investigation on a "snapshot" of it.</p>
|
<p>Here's my suggestion:</p>
<pre><code> [Flags]
public enum ThreadAccess : int
{
TERMINATE = (0x0001),
SUSPEND_RESUME = (0x0002),
GET_CONTEXT = (0x0008),
SET_CONTEXT = (0x0010),
SET_INFORMATION = (0x0020),
QUERY_INFORMATION = (0x0040),
SET_THREAD_TOKEN = (0x0080),
IMPERSONATE = (0x0100),
DIRECT_IMPERSONATION = (0x0200)
}
[DllImport("kernel32.dll")]
static extern IntPtr OpenThread(ThreadAccess dwDesiredAccess, bool bInheritHandle, uint dwThreadId);
[DllImport("kernel32.dll")]
static extern uint SuspendThread(IntPtr hThread);
[DllImport("kernel32.dll")]
static extern int ResumeThread(IntPtr hThread);
[DllImport("kernel32", CharSet = CharSet.Auto,SetLastError = true)]
static extern bool CloseHandle(IntPtr handle);
private static void SuspendProcess(int pid)
{
var process = Process.GetProcessById(pid); // throws exception if process does not exist
foreach (ProcessThread pT in process.Threads)
{
IntPtr pOpenThread = OpenThread(ThreadAccess.SUSPEND_RESUME, false, (uint)pT.Id);
if (pOpenThread == IntPtr.Zero)
{
continue;
}
SuspendThread(pOpenThread);
CloseHandle(pOpenThread);
}
}
public static void ResumeProcess(int pid)
{
var process = Process.GetProcessById(pid);
if (process.ProcessName == string.Empty)
return;
foreach (ProcessThread pT in process.Threads)
{
IntPtr pOpenThread = OpenThread(ThreadAccess.SUSPEND_RESUME, false, (uint)pT.Id);
if (pOpenThread == IntPtr.Zero)
{
continue;
}
var suspendCount = 0;
do
{
suspendCount = ResumeThread(pOpenThread);
} while (suspendCount > 0);
CloseHandle(pOpenThread);
}
}
</code></pre>
|
<p>See this CodeProject article for the win32 basics : <a href="http://www.codeproject.com/KB/threads/pausep.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/threads/pausep.aspx</a>. This sample code makes use of the ToolHelp32 library from the SDK, so I would recommend turning this sample code into an unmanaged C++/CLI library with a simple interface like "SuspendProcess(uint processID).</p>
<p>Process.Start will return you a Process object, from which you can get the process id, and then pass this to your new library based on the above.</p>
<p>Dave</p>
| 9,674
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.