instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>My current development project has two aspects to it. First, there is a public website where external users can submit and update information for various purposes. This information is then saved to a local SQL Server at the colo facility.</p>
<p>The second aspect is an internal application which employees use to manage those same records (conceptually) and provide status updates, approvals, etc. This application is hosted within the corporate firewall with its own local SQL Server database.</p>
<p>The two networks are connected by a hardware VPN solution, which is decent, but obviously not the speediest thing in the world.</p>
<p>The two databases are similar, and share many of the same tables, but they are not 100% the same. Many of the tables on both sides are very specific to either the internal or external application.</p>
<p>So the question is: when a user updates their information or submits a record on the public website, how do you transfer that data to the internal application's database so it can be managed by the internal staff? And vice versa... how do you push updates made by the staff back out to the website?</p>
<p>It is worth mentioning that the more "real time" these updates occur, the better. Not that it has to be instant, just reasonably quick.</p>
<p>So far, I have thought about using the following types of approaches:</p>
<ol>
<li>Bi-directional replication</li>
<li>Web service interfaces on both sides with code to sync the changes as they are made (in real time).</li>
<li>Web service interfaces on both sides with code to asynchronously sync the changes (using a queueing mechanism).</li>
</ol>
<p>Any advice? Has anyone run into this problem before? Did you come up with a solution that worked well for you?</p>
|
<p>This is a pretty common integration scenario, I believe. Personally, I think an asynchronous messaging solution using a queue is ideal. </p>
<p>You should be able to achieve near real time synchronization without the overhead or complexity of something like replication. </p>
<p>Synchronous web services are not ideal because your code will have to be very sophisticated to handle failure scenarios. What happens when one system is restarted while the other continues to publish changes? Does the sending system get timeouts? What does it do with those? Unless you are prepared to lose data, you'll want some sort of transactional queue (like MSMQ) to receive the change notices and take care of making sure they get to the other system. If either system is down, the changes (passed as messages) will just accumulate and as soon as a connection can be established the re-starting server will process all the queued messages and catch up, making system integrity much, much easier to achieve.</p>
<p>There are some open source tools that can really make this easy for you if you are using .NET (especially if you want to use MSMQ).</p>
<ol>
<li><a href="http://www.nservicebus.com/" rel="noreferrer">nServiceBus</a> by Udi Dahan</li>
<li><a href="http://code.google.com/p/masstransit/" rel="noreferrer">Mass Transit</a> by Dru Sellers and Chris Patterson</li>
</ol>
<p>There are commercial products also, and if you are considering a commercial option see <a href="http://www.thefreakparade.com/2008/06/esbs-for-the-microsoft-net-platform/" rel="noreferrer">here</a> for a list of of options on .NET. Of course, WCF can do async messaging using MSMQ bindings, but a tool like nServiceBus or MassTransit will give you a very simple Send/Receive or Pub/Sub API that will make your requirement a very straightforward job.</p>
<p>If you're using Java, there are any number of open source service bus implementations that will make this kind of bi-directional, asynchronous messaging a snap, like Mule or maybe just ActiveMQ.</p>
<p>You may also want to consider reading <a href="http://www.udidahan.com/" rel="noreferrer">Udi Dahan'</a>s blog, listening to some of his podcasts. Here are <a href="https://stackoverflow.com/questions/13211/good-reads-for-distributed-systems#13244">some more good resources</a> to get you started.</p>
|
<p>I'd say just have a job that copies the data in the pub database input table into a private database pending table. Then once you update the data on the private side have it replicated to the public side. If you don't have any of the replicated data on the public side updated it should be a fairly easy transactional replication solution. </p>
| 3,442
|
<p>What's the best way to combine results sets from disparate data sources in SSRS?</p>
<p>In my particular example, I need to write a report that pulls data from SQL Server and combines it with another set of data that comes from a DB2 database. In the end, I need to join these separate data sets together so I have one combined dataset with data from both sources combined on to the same rows. (Like an inner join if both tables were coming from the same SQL DB). I know that you can't do this "out of the box" in SSRS 2005. I'm not excited about having to pull the data into a temporary table on my SQL box because users need to be able to run this report on demand and it seems like having to use SSIS to get the data into the table on demand will be slow and hard to manage with multiple users trying to get at the report simultaneously. Are there any other, more elegant solutions out there?</p>
<p>I know that the linked server solution mentioned below would technically work, however, for some reason our DBAs will simply not allow us to use linked servers.</p>
<p>I know that you can add two different data sets to a report, however, I need to be able to join them together. Anybody have any ideas on how to best accomplish this?</p>
|
<p>We had to do something similar (i.e. inner join 2 data sources from different servers). I believe the best way is to write your own custom Data Extension. It's not very difficult and it would give you the ability to do this and more.</p>
|
<p>You could attach both the MSSQL tables and the DB2 tables to a Jet database and bind your report to the Jet database. I don't know the implications of the single threaded nature of Jet, or how much work would be delegated to the backing stores.</p>
| 5,575
|
<p>I might be missing something really obvious. I'm trying to write a custom Panel where the contents are laid out according to a couple of dependency properties (I'm assuming they <em>have</em> to be DPs because I want to be able to animate them.)</p>
<p>However, when I try to run a storyboard to animate both of these properties, Silverlight throws a Catastophic Error. But if I try to animate just one of them, it works fine. And if I try to animate one of my properties and a 'built-in' property (like Opacity) it also works. But if I try to animate both my custom properties I get the Catastrophic error.</p>
<p>Anyone else come across this?</p>
<p>edit:</p>
<p>The two DPs are ScaleX and ScaleY - both doubles. They scale the X and Y position of children in the panel. Here's how one of them is defined:</p>
<pre><code> public double ScaleX
{
get { return (double)GetValue(ScaleXProperty); }
set { SetValue(ScaleXProperty, value); }
}
/// <summary>
/// Identifies the ScaleX dependency property.
/// </summary>
public static readonly DependencyProperty ScaleXProperty =
DependencyProperty.Register(
"ScaleX",
typeof(double),
typeof(MyPanel),
new PropertyMetadata(OnScaleXPropertyChanged));
/// <summary>
/// ScaleXProperty property changed handler.
/// </summary>
/// <param name="d">MyPanel that changed its ScaleX.</param>
/// <param name="e">DependencyPropertyChangedEventArgs.</param>
private static void OnScaleXPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
MyPanel _MyPanel = d as MyPanel;
if (_MyPanel != null)
{
_MyPanel.InvalidateArrange();
}
}
public static void SetScaleX(DependencyObject obj, double val)
{
obj.SetValue(ScaleXProperty, val);
}
public static double GetScaleX(DependencyObject obj)
{
return (double)obj.GetValue(ScaleXProperty);
}
</code></pre>
<p>Edit: I've tried it with and without the call to InvalidateArrange (which is absolutely necessary in any case) and the result is the same. The event handler doesn't even get called before the Catastrophic error kicks off.</p>
|
<p>It's a documented bug with Silverlight 2 Beta 2. You can't animate two custom dependancy properties on the same object.</p>
|
<p>I would try commenting out the InvalidateArrange in the OnPropertyChanged and see what happens.</p>
| 8,776
|
<p>What is the best open source java workflow framework (e.g. OSWorkflow, jBPM, XFlow etc.)?</p>
|
<p><a href="http://eprints.qut.edu.au/archive/00014320/" rel="nofollow noreferrer">Here's an article</a> that compares kBPM, OpenWFE, and Enhydra Shark that looks like it has some good, thorough info.</p>
|
<p>I'll cast a vote for jBPM. We used it on a larg-ish ETL platform in-house and it seemed to work quite well. I don't have anything to compare it to, however.</p>
| 9,092
|
<p>Is there any performance to be gained these days from compiling java to native code, or do modern hotspot compilers end up doing this over time anyway?</p>
|
<p>There was a similar discussion here recently, for the question <a href="https://stackoverflow.com/questions/48144/what-are-advantages-of-bytecode-over-native-code">What are advantages of bytecode over native code?</a>. You can find interesting answers in that thread.</p>
|
<p>Tried Hello-World in with six different implementations just to check the overhead
and the difference was staggering. Java was off the charts while the compiled languages did equally well. I could proved all the evidence (in a reproducible) if needed.</p>
| 7,430
|
<p>My <a href="http://rads.stackoverflow.com/amzn/click/B007KG0ZYI" rel="noreferrer">12V DC 30A Power Supply 360W Power Supply</a> is really cheap, and it's worked well for setting up the motors; but now that I'm on to the heated bed, which uses considerably more Ampage than that of just the motors, I'll confess, I'm getting frightened to continue using it; if the summer was a bit longer, maybe it wouldn't bother me, but we're getting into the cold months, and now I'm afraid of ending up using too much ampage just trying to heat the bed in the winter months...(and I don't mean my bed). Is there anything I should look out for in terms of using the either the cheap power supply I already have, or are there certain specs on a new not-so-cheap power supply that I ought to be using instead? </p>
|
<p>A MK2 heatbed will draw around 12A. The motors and hotend draw only very little power (around 2A, 5A peak), so the 30A supply you have has significant headroom (it is often recommended to derate a power supply by 20%, so a 30A supply would be good for 24A - you're still well under that). It should work fine, even given its dubious provenance.</p>
<p>Winter versus summer should not make a big difference. The largest power draw is during the heat up phase. In winter, the bed will use slightly more power to stay warm, but regardless of whether it is summer or winter the peak power draw during heat up will be the same.</p>
<p>The cheapness of these supplies tends to be reflected in more output ripple (but for heating the bed and running the motors you don't need a very stable voltage) and improper filtering. This may inject noise back into the mains, possibly affecting other equipment nearby. Should this occur, you can just stop using the power supply. However, in my experience, they can deliver the rated power just fine. They're not completely horrible.</p>
<p>Your biggest concern should be whether the wires that lead to your heated bed can handle the current and whether the screw terminals are properly tightened. During the first use, you should check that the power supply does not get extremely hot. If it's so hot it's impossible to touch for more than 1-2 seconds you should not use it.</p>
|
<p>I've used a similar cheap psu before. It'll work without blowing up but my heatbed struggled to get up to 60c, swapped psus with one I had lying around from a desktop and there was a huge difference. </p>
| 382
|
<p>I am writing an application that needs to bring window of an external app to the foreground, and not necessarily steal focus (there is a setting the user can toggle to steal/not steal focus).</p>
<p>What is the best way to go about this using the win32 API? I have tried SetForeground() but it always steals focus and does not consistenly work.</p>
<p>What is the best way to go about this? Any thoughts?</p>
|
<p>SetForegroundWindow is supposed to steal focus and there are certain cases where it will fail.</p>
<blockquote>
<p>The SetForegroundWindow function puts the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window</p>
</blockquote>
<p>Try capturing the focus with <a href="http://msdn.microsoft.com/en-us/library/ms646262.aspx" rel="noreferrer">SetCapture</a> prior to making the call. Also look into different ways of bringing the window to the front: SetForeGroundWindow, SetActiveWindow, even simulating a mouse click can do this.</p>
|
<p>You could use FindWindow to get the HWND of the window, then use the BringWindowToTop function found in the Win32 API.</p>
| 2,511
|
<p>I've recently acquired a Flashforge Adventurer 3 and am having difficulty printing with ABS. The initial layers seem to lay and stay pretty well, though after a few more moments, one side will peel up from the heated platform. I'd like to know if anyone has optimal and tested temperatures for the use of ABS on my printer for the nozzle and platform?</p>
<p>I've used FlashPrint for slicing my objects using the following options:</p>
<ul>
<li>Supports: Disable,</li>
<li>Raft: enable,</li>
<li>Resolution: Standard,</li>
<li>Layer Heights: 0.18 mm,</li>
<li>First Layer Height: 0.27 mm,</li>
<li>Perimeter Shells: 2,</li>
<li>Top Solid Layers: 4,</li>
<li>Bottom Solid Layers: 3,</li>
<li>Fill Density: 15 %, Hexagon, Every 2 Layers,</li>
<li>Print Speed: 60 mm/s,</li>
<li>Travel Speed: 80 mm/s,</li>
<li>Extruder: 225 °C,</li>
<li>Platform: 70 °C,</li>
<li>Cooling Fan Controls: Automatic,</li>
<li>Nozzle Dia.: 0.4 mm</li>
</ul>
|
<p>The most commonly used print temperature range for ABS is 220 to 240 °C with the major bulk around 230 °C. Some filaments are blended with inhibitors or PC, increasing their print temperature to up to 260 °C. Note that the color of the filament just as the brand can have an impact on the print temperature!</p>
<p>The most commonly used bed temperature for ABS start at least at 80 °C. <a href="https://www.matterhackers.com/articles/printing-tips-&-tricks:-abs-bed-adhesion" rel="nofollow noreferrer">MatterHackers</a> suggest 85-90 °C.</p>
<p>If your bed is particularly bad at getting adhesion, you might want to clean the bed of residues and fingerprints and relevel the bed. If that is not enough and you use a glass bed, a slurry of ABS in Acetone could come in handy. If you have a glass bed, the slurry is pretty much the best option.</p>
<p>Print cooling is a bane on ABS - the stuff shrinks too fast if cooled, resulting in the parts breaking loose!</p>
|
<p><em>Note that some of the other advice is general advice which is not applicable to the Adventurer 3.</em></p>
<p>Temperature control is somewhat limited on Adventurer 3. The maximum bed temperature is 100 °C. There is no "glass bed". My Adventurer 3 is struggling to get the bed temperature to 98 °C. (The room temperature is 16 °C at the moment). I'm using Blu Stik glue on the bed to hold the print. Another possible problem is loss of heat out the side when the filament reel cover is off. The cover of mine is off because the reel of ABS does not fit in the bay. I've seen designs for filament bay covers with a hole in them to feed the filament in on Thingiverse. I'm considering building a box to put the printer in to keep the ambient temperature high. </p>
| 1,249
|
<p>I would like to create a case or a box which has two holes for incoming and exiting water. I want the box to be opened and closed. Therefore it is good to be something like a treasure box.</p>
<p>Is there a way to design the lid of the box to prevent water from leaking around the areas where the box and the lid are meeting without using glue?</p>
<p><a href="https://i.stack.imgur.com/HYo0p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HYo0p.png" alt="enter image description here" /></a></p>
|
<p>"Completely" is always relative, but for water at the pressures involved it's probably achievable. Normally you need some sort of <em>gasket</em> (material that can bend/compress to slight imperfections in the mating surfaces), and a means of holding the two surfaces tight against the gasket, to get such a seal.</p>
<p>With 3D printing, it's plausible that the print itself could be sufficiently non-rigid to achieve this, if you have a way of keeping the lid and box pressed tightly against each other - bolts through the lid, clips around the edges, etc. But it's unlikely to work well.</p>
<p>I would either print I suitable gasket in TPU, or cut one from some suitable material if you don't have the capability to print with TPU. Either way you still need to design your box and lid so that they're pressed tightly against the gasket.</p>
<p>One possible frame challenge would be doing a round box instead, with a circular threaded lid. It's likely that you could achieve a decent seal for your purposes without any gasket just by tightening the threads, and if not, you still have a really good setup for use with an added gasket.</p>
|
<p>I know this sounds obvious, but given the box has holes in the top – does it only need to be watertight when it's the right way up? If not, you could just do something like:</p>
<p><a href="https://i.stack.imgur.com/JXft9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JXft9.jpg" alt="enter image description here" /></a></p>
<p>Assuming that won't work, I think a really good seal would be hard with just something like PLA, because the printing texture alone means there will always be tiny gaps between the mating surfaces. In some cases, those grooves will actually act as capillaries (if you've ever tried to use a sharpie marker on a print, you can imagine what I mean).</p>
<p>If the lid fits snugly, then just lining it with something like plumber's thread tape would probably do a good job.</p>
<p>If it needs to work straight out of the printer, then I would try something like this (obviously I've exaggerated the detail):</p>
<p><a href="https://i.stack.imgur.com/P5Fuc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P5Fuc.jpg" alt="enter image description here" /></a></p>
<p>The idea being something like the plastic seal you see on some types of refrigerator door, which has a thin wall with a free edge that allows it to flex.</p>
<p>NB in all these cases, sharp corners will cause problems – it will be easier to get a seal if you put a radius (say, 5mm) on the vertical edges of the box.</p>
| 1,764
|
<p>I am experiencing a minor layer separation when printing a body for a tipping-bucket rain gauge, which is basically a hollow tube with thin walls (3 mm). I am using <strong>Prusa I3 MK2</strong> and a <strong>Fillamentum ABS</strong> white plastic. The model has been sliced in <strong>Siplify 3D</strong> with the following settings:</p>
<ul>
<li>layer height: 0.2 mm</li>
<li>perimeter shells: 3 layers (almost entirely
fills up the wall)</li>
<li>extruder temperature: 230 °C</li>
<li>printing speed: default - 50 mm/s, outline - 35 mm/s, infill - 35 mm/s</li>
</ul>
<p>Is it possible to prevent the irregular and layer separation by adjusting some of the settings, and not significantly increasing the printing time, which is already 13 hours?</p>
<p>PICTURES:</p>
<p><a href="https://i.stack.imgur.com/vNvWx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vNvWx.jpg" alt="enter image description here"></a></p>
<p><a href="https://i.stack.imgur.com/93hzZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/93hzZ.jpg" alt="enter image description here"></a></p>
|
<p>The best thing you can do for a large ABS print is to have an enclosure heated to 50C or better. For example, see <a href="https://www.3dhubs.com/talk/thread/enclosed-vs-open-printers" rel="nofollow noreferrer">this</a>, <a href="https://www.reddit.com/r/3Dprinting/comments/2ynb78/heated_build_enclosure_temperatures/?st=j6dk32oh&sh=2a550305" rel="nofollow noreferrer">this</a>, <a href="http://www.shapingbits.com/3d-printing-guide/abs-3d-printing/" rel="nofollow noreferrer">this</a>, and other search results.</p>
|
<p>increasing the temperature by 5 to 10° as well as, increasing the layer thickness to "0.3" or "0.35" may assist ,additionally increasing the flow rate of the filament, by a small margin at most 10%. These options should improve the quality of the print as they improve the layer adhesion, however none of these options will completely solve the problem.</p>
<p>alternatively you can repair the current print. In order to do this you will need to use something cot such as a soldering iron with a variable temperature, to melt and rejoined the layers. similarly you can use a 3d pen to apply additional plastic across the sections of separation in order to repair it.</p>
| 668
|
<p>In a flow definition, I am trying to access a bean that has a dot in its ID</p>
<p>(example: <code><evaluate expression="bus.MyServiceFacade.someAction()" /></code></p>
<p>However, it does not work. SWF tries to find a bean "bus" instead.</p>
<p>Initially, I got over it by using a helper bean to load the required bean, but the solution is inelegant and uncomfortable. The use of alias'es is also out of the question since the beans are part of a large system and I cannot tamper with them.</p>
<p>In a nutshell, none of the solution allowed me to refernce the bean directly by using its original name. Is that even possible in the current SWF release?</p>
|
<p>I was able to do this by using both the bean accessor (<code>@</code>) symbol and single-quotes around the name of the bean.</p>
<p>Using your example: <code>#{@'bus.MyServiceFacade'.someAction()}</code></p>
|
<p>In my experience, anything with a getter method can be accessed via dot notation. In your example, whatever object is being represented by the <code>bus</code> bean needs to have a <code>getServiceFacade</code> method and that the object returned by <code>getServiceFacade</code> would need to have a <code>getSomeAction</code> method.</p>
| 8,821
|
<p>For example which is better:</p>
<pre><code>select * from t1, t2 where t1.country='US' and t2.country=t1.country and t1.id=t2.id
</code></pre>
<p>or</p>
<pre><code>select * from t1, t2 where t1.country'US' and t2.country='US' and t1.id=t2.id
</code></pre>
<p>better as in less work for the database, faster results.</p>
<p><strong>Note:</strong> Sybase, and there's an index on both tables of <code>country+id</code>.</p>
|
<p>I don't think there is a global answer to your question. It depends on the specific query. You would have to compare the execution plans for the two queries to see if there are significant differences.</p>
<p>I personally prefer the first form:</p>
<p>select * from t1, t2 where t1.country='US' and t2.country=t1.country and t1.id=t2.id </p>
<p>because if I want to change the literal there is only one change needed.</p>
|
<p>I'd lean towards only including your constant in the code once. There might be a performance advantage one way or the other, but it's probably so small the maintenance advantage of only one parameter trumps it.</p>
| 9,833
|
<p>I am sure a responsive UI is something that everyone strives for and the reccomended way to do stuff is to use the BackgroundWorker for this. </p>
<p>Do you find it easy to work with ? Do you use it often ? Or do you have your own frameworks for lengthy tasks and reporting process.</p>
<p>I have found that I am using it quite a lot and even using its delegates wherever I need some sort of progress reporting.</p>
|
<p>Multithreaded programming is hard to grasp in the beginning (and veterans still fail sometimes) and BackgroundWorker makes it a bit easier to use. I like the fact that BackgroundWorker has functionality which is easy to implement but even easier to wrongly implement in a subtle way, like cancellation.
I use it if I have and need a progress update, so I can display a meaningful progress bar. </p>
<p>If not, I use a Thread (or borrow from the ThreadPool), because I don't need all the functionality of BackgroundWorker and am proficient enough with threads to start a Thread and wait for it to stop.</p>
<p>As for delegates for non-related tasks, I use those of the Thread classes, like plain <code>void ThreadStart()</code>, or I create my own.</p>
|
<p>My biggest issue with the background worker class is that there really is no way to know when the worker has finished due to cancellation. The BackgroundWorker does not expose the thread it uses so you can't use the standard techniques for synchronizing thread termination (join, etc.). You also can't just wait in a loop on the UI thread for it to end because the RunWorkerCompleted event will never end up firing. The hack I've always had to use is to simply set a flag and then start a timer that will continue checking for the background worker to end. But it's very messy and complicates the business logic.</p>
<p>So it is great as long as you don't need to support deterministic cancellation.</p>
| 7,240
|
<p>I'd like to start moving our application business layers into a collection of REST web services. However, most of our Intranet has been built using Classic ASP and most of the developers where I work keep programming in Classic ASP. Ideally, then, for them to benefit from the advantages of a unique set of web APIs, it would have to be called from Classic ASP pages.</p>
<p>I haven't the slightest idea how to do that. </p>
|
<p>You could use a combination of JQuery with JSON calls to consume REST services from the client</p>
<p>or</p>
<p>if you need to interact with the REST services from the ASP layer you can use</p>
<p>MSXML2.ServerXMLHTTP</p>
<p>like:</p>
<pre><code>Set HttpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
HttpReq.open "GET", "Rest_URI", False
HttpReq.send
</code></pre>
|
<p>All you need is an HTTP client. In .Net, WebRequest works well. For classic ASP, you will need a specific component like <a href="http://web.archive.org/web/20140829190201/http://www.coalesys.com/products/httpclient/features/default.asp" rel="nofollow noreferrer">this one</a>.</p>
| 3,238
|
<p>I am using the <code>ODBC</code> connector to access a MySQL db from Visual Studio 2008 and I'm facing performance problems when dealing with crystal reports and to solve this I need a native connector to visual studio. If someone has had a similar problem and knows a solution or tools (freeware preferable), I would be really grateful.</p>
|
<p>You want <a href="http://www.mysql.com/products/connector/net/" rel="noreferrer">Connector/Net</a></p>
<p><strong>Update:</strong> This link should take you to a more recent version:
<a href="http://dev.mysql.com/downloads/connector/net/5.2.html" rel="noreferrer">http://dev.mysql.com/downloads/connector/net/5.2.html</a></p>
|
<p>Connector/Net <em>is</em> the native provider you are looking for. If you're having trouble using it then you should open a new question asking how to get it working with crystal reports. I don't use crystal reports, so I can't help you there myself.</p>
| 6,328
|
<p>I'm not talking about bug tracking software (like Bugzilla or Jira). I'm looking for something that:</p>
<ol>
<li>Stores test specifications in text format</li>
<li>Combines test specs into test coverage scenarios</li>
<li>Keeps track of the progress through testing scenarios </li>
<li>Links test specs with bug reports stored in Bugzilla</li>
<li>Generates progress reports</li>
<li>Is centrally managed on its own (i.e. is not a hack/extension on top of something else)</li>
</ol>
|
<p>TestLink is a pretty nice open source test tracking tool with the features you need, and is still under active development. Take a look at <a href="http://testlink.org/" rel="nofollow noreferrer">http://testlink.org/</a></p>
|
<p>I have personally used Trac (<a href="http://trac.edgewall.org/" rel="nofollow noreferrer">http://trac.edgewall.org/</a>) which combines a simple issue tracker with Wiki functionality. Solved the need I had on my project.</p>
| 8,804
|
<p>Normally I would just use:</p>
<pre><code>HttpContext.Current.Server.UrlEncode("url");
</code></pre>
<p>But since this is a console application, <code>HttpContext.Current</code> is always going to be <code>null</code>.</p>
<p>Is there another method that does the same thing that I could use?</p>
|
<p>Try this!</p>
<pre><code>Uri.EscapeUriString(url);
</code></pre>
<p>Or</p>
<pre><code>Uri.EscapeDataString(data)
</code></pre>
<p>No need to reference System.Web.</p>
<p><strong>Edit:</strong> Please see <a href="https://stackoverflow.com/a/34189188/7391">another</a> SO answer for more...</p>
|
<p>Best thing is to Add Reference to System.web..dll</p>
<p>and use
var EncodedUrl=System.Web.HttpUtility.UrlEncode("URL_TEXT");</p>
<p>You can find the File at <a href="http://originaldll.com/download/11019.dll" rel="nofollow noreferrer">System.web.dll</a></p>
| 3,553
|
<p>I have a small to medium project that is in C++/CLI. I really hate the syntax extensions of C++/CLI and I would prefer to work in C#. Is there a tool that does a decent job of translating one to the other?</p>
<p><strong>EDIT:</strong> When I said Managed c++ before I apparently meant c++/CLI</p>
|
<p>You can only translate Managed C++ code (and C++/CLI code) to C# if the C++ code is pure managed. If it is not -- i.e. if there is native code included in the sources -- tools like .NET Reflector won't be able to translate the code for you.</p>
<p>If you do have native C++ code mixed in, then I'd recommend trying to move the native code into a separate DLL, replace your calls to DLL functions by easily identifiable stub functions, compile your project as a pure .NET library, then use .NET reflector to de-compile into C# code. Then you can replace the calls to the stub functions by p-invoke calls to your native DLL.</p>
<p>Good luck! I feel for you!</p>
|
<p>Such projects are often done in c++/cli because C# isn't really an elegant option for the task. e.g. if you have to interface with some native C++ libraries, or do very high performance stuff in low level C. So just make sure whoever chose c++/cli didn't have a good reason to do it before doing the switch.</p>
<p>Having said that, I'm highly skeptical there's something that does what you ask, for the simple reason that not all C++/cli code is translatable to C# (and probably vice versa too).</p>
| 9,953
|
<p>I have an ASP.NET web page that displays a variety of fields that need to be updated best on certain conditions, button clicks and so on. We've implemented AJAX, using the ASP.NET Update Panel to avoid visible postbacks.</p>
<p>Originally there was only <em>one</em> area that needed this ability ... that soon expanded to other fields. Now my web page has multiple UpdatePanels. </p>
<p>I am wondering if it would be best to just wrap the entire form in a single UpdatePanel, or keep the individual UpdatePanels.</p>
<p>What are the best practices for using the ASP.NET UpdatePanel?</p>
|
<p>Multiple panels are much better. One of the main reasons for using UpdatePanels at all is to reduce the traffic and to only send the pieces that you need back and forth across the wire. By only using one update panel, you're pretty much doing a full post back every time, you're just using a little Javascript to update the page without a flicker.</p>
<p>If there are pieces of the page that need to be updated together, there are ways to trigger other panels to update when one does.. but you should definitely be using multiple update panels.</p>
|
<p>Not sure about the best practices, but in my experience multiple panels work well, and reduce the amount of data being sent at one time - resulting in an increase in response time overall. Multiple panels also reduce the complexity of each server call.</p>
| 9,814
|
<p>I am attempting to use the .Net System.Security.SslStream class to process the server side of a SSL/TLS stream with client authentication.</p>
<p>To perform the handshake, I am using this code:</p>
<pre><code>SslStream sslStream = new SslStream(innerStream, false, RemoteCertificateValidation, LocalCertificateSelectionCallback);
sslStream.AuthenticateAsServer(serverCertificate, true, SslProtocols.Default, false);
</code></pre>
<p>Unfortunately, this results in the SslStream transmitting a CertificateRequest containing the subjectnames of all certificates in my CryptoAPI Trusted Root Store.</p>
<p>I would like to be able to override this. It is not an option for me to require the user to install or remove certificates from the Trusted Root Store.</p>
<p>It looks like the SslStream uses SSPI/SecureChannel underneath, so if anyone knows how to do the equivalent with that API, that would be helpful, too.</p>
<p>Any ideas?</p>
|
<p>It does not look like this is currently possible using the .NET libraries. </p>
<p>I solved it by using the Mono class library implementation of System.Security.SslStream, which gives better access to overriding the servers behavior during the handshake.</p>
|
<p>It is not the validation part I want to change. The problem is in the initial handshake, the server transmits the message informing the client that client authentication is required (that is the CertificateRequest message). As part of this message, the server sends the names of CAs that it will accept as issuers of the client certificate. It is that list which per default contains all the Trusted Roots in the store.</p>
<p>But if is possible to override the certificate root store for a single application, that would probably fix the problem. Is that what you mean? And if so, how do I do that?</p>
| 7,741
|
<p>I have a one to many relationship between two tables. The many table contains a clob column. The clob column looks like this in hibernate:</p>
<pre><code>@CollectionOfElements(fetch = EAGER)
@JoinTable(name = NOTE_JOIN_TABLE, joinColumns = @JoinColumn(name = "note"))
@Column(name = "substitution")
@IndexColumn(name = "listIndex", base = 0)
@Lob
private List<String> substitutions;
</code></pre>
<p>So basically I may have a Note with some subsitutions, say <code>"foo"</code> and <code>"fizzbuzz"</code>. So in my main table I could have a Note with id 4 and in my <code>NOTE_JOIN_TABLE</code> I would have two rows, <code>"foo"</code> and <code>"fizzbuzz"</code> that both have a relationship to the Note.</p>
<p>However, when one of these is inserted into the DB <strong>the larger substitution values are cropped to be as long as the shortest.</strong> So in this case I would have <code>"foo"</code> and <code>"fiz"</code> in the DB instead of <code>"foo"</code> and <code>"fizzbuzz"</code>.</p>
<p>Do you have any idea why this is happening? I have checked and confirmed they aren't being cropped anywhere in our code, it's defintely hibernate.</p>
|
<p>To follow up with jodonnell's comment, a Web service connection can be made in just about any server-side language. It is just that the API example they provided was in Java probably because PlanPlusOnline is written in Java. If you have a URL for the service, and an access key, then all you really need to do is figure out how to traverse the XML returned. If you can't do Java, then I suggest PHP because it could be already installed, and have the proper modules loaded. This link might be helpful:</p>
<p><a href="http://www.onlamp.com/pub/a/php/2007/07/26/php-web-services.html" rel="nofollow noreferrer">http://www.onlamp.com/pub/a/php/2007/07/26/php-web-services.html</a></p>
|
<p>Are you trying to implement a client to a web service hosted somewhere else? If so, Java's not necessary. You can do web service clients in <a href="http://www.dotnetjunkies.ddj.com/Tutorial/4D13CEFA-D0FD-44BE-8749-8D17B5757564.dcik" rel="nofollow noreferrer">.NET</a>, <a href="http://sourceforge.net/projects/nusoap/" rel="nofollow noreferrer">PHP</a>, <a href="http://raa.ruby-lang.org/project/soap4r" rel="nofollow noreferrer">Ruby</a>, or pretty much any modern web technology out there. All you need is a WSDL document to provide metadata about how to invoke the services.</p>
| 7,672
|
<p>I've been wanting to teach myself Lisp for a while. However, all the interpreters of which I've heard involve some flavor of emacs.
Are there any command line interpreters, such that I could type this into the command line:</p>
<blockquote>
<p>lispinterpret sourcefile.lisp</p>
</blockquote>
<p>just like I can run perl or python.</p>
<p>While I'd also like to become more familiar with Emacs (if only not to be frustrated when I work with somebody who uses Emacs), I'd rather decouple learning Emacs from learning Lisp.</p>
<p>Edit: I actually want to follow SICP which uses Scheme, so an answer about Scheme would be more useful. I'm just not that familiar with the differences.</p>
|
<p>You could also try <a href="http://www.plt-scheme.org/" rel="noreferrer">DrScheme</a>, which whilst not exactly a standalone interpreter, isn't emacs :)</p>
<p>It's basically a simple IDE that has an area to type in code that can be executed as a file, and then another area that is the running interpreter that you can interact with.</p>
<p>(Also, find the UC Berkeley CS61A podcasts and listen to them, as well as reading SICP)</p>
|
<p>Another good dialect of lisp is <a href="http://www.google.com/url?sa=t&ct=res&cd=1&url=http%3A%2F%2Fwww.cons.org%2Fcmucl%2F&ei=04CjSMesMIKWsAPkreiEDw&usg=AFQjCNEaD4T5bkSLBKWylon98jBsL7-IGA&sig2=W3p2EItQZ4NdWN8YCzPbRg" rel="nofollow noreferrer">cmucl</a>. They used to love to brag about being the "fastest" lisp.</p>
| 3,103
|
<p>I would like to add a DataGridViewTextBoxCell cell to a DataGridViewCell control, but as well as being able to type in the text cell as normal it must also contain a '...' button that once clicks brings up the OpenFileDialog window to allow the user to select a file. Once selected, the text cell will be populated with the full file path.</p>
<p>What is the best way to go about this?</p>
<p>Thanks</p>
|
<p><a href="http://msdn.microsoft.com/en-au/library/7tas5c80.aspx" rel="nofollow noreferrer">This</a> MSDN article explains how to add a custom control to a <code>DataGridView</code>.</p>
<p>You should be able to make a <code>UserControl</code> that has a textbox and button on it and embed that in the <code>DataGridView</code>.</p>
|
<p>You will need to create your own column and cell classes in order to do this. I would suggest using <strong>.NET</strong> Reflector to look at the implementation details of the DataGridViewTextBox as a starting point and then customizing to add display of a button at the end of it. Check out these tutorials to get started...</p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa730882(VS.80).aspx" rel="nofollow noreferrer">MSDN Article</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms180996.aspx" rel="nofollow noreferrer">MSDN Reference</a></p>
| 8,868
|
<p>I am working on a project that requires an enclosure that I am thinking to prototype using a 3D printer (which is pretty easy and overall awesome).</p>
<p>My question is simply whether this same model can be used later on for mass production (i.e. mold injection)? What adjustment (if any) need to be done to model between prototype and mass.prod. stages? What areas in design to look out for that can make model viable for 3D printing non-viable for mass production?</p>
|
<p>I respectfully disagree with the hard no answer. There are many casting methods, some of which are not compatible with 3D printed parts and at least one that definitely is. See investment casting, aka lost wax casting. (Ref 1) Also search YouTube for "investment casting using 3D printing". Formlabs, the company that makes the Form 2 and Form 3 3D printers, sells a 3d printable resin specifically for investment casting. (Ref 2).</p>
<p>There is a whole world of casting, so I will describe, as an example, a very simple process that will make a replica of your 3D printed part. I will briefly address the steps necessary for making multiple copies at the end of my answer. First you need to add a cylindrical extension to the shape that will create a sprue. See the two models shown in the image below. Next make a foil cup a little larger than your 3D printed part and place your part in the cup, suspended by the sprue. Pour liquid plaster of Paris (POP) into the cup, covering the 3D printed part, with just the top of the sprue sticking out. Once the POP has hardened, you can remove the 3D printed part by dissolving it in an organic solvent (acetone for acrylic) or by heating the part to several hundred degrees C so it will burn out (convert to gasses). You will now have a block of POP with a void shaped like your 3D printed part plus a cylindrical hole to the outside that acts as a sprue. Once you have heated the POP to drive out any remaining water, you're ready to cast. Fill the void (via the sprue hole) with, for example, copper powder and heat it to well above its melting point. Once everything has cooled, lightly tap the POP with a small hammer or equivalent, to remove it, leaving your final part plus the sprue. You can remove any remaining POP with some warm baking soda and patience. The final step is to cut or saw off the sprue shape. </p>
<p>Please understand that the process described above is just to give you a basic idea of the process. There are many alternate or additional steps that may produce a better final product. Also, the process described should work of the rook model shown on the left of the image below, but not the model on the right, which has a small hole through the middle. There are ways to solve that issue, but as I said before, there is a whole world of this stuff.</p>
<p>Casting is a way to create parts out of materials that you otherwise could not 3D print directly (on a home budget). For mass production, you would need to start with an inverse of the final shape. For example, a cylindrical slug with a rook-shaped void. Then you would use the investment casting process to create a mold out of a rigid material that you could use to, for example, create rubber copies of the original part that could, in turn, be used as the "wax" for copies in the final material.</p>
<p>I urge you to experiment, maybe following one of the tutorials on YouTube. Good luck.
<a href="https://i.stack.imgur.com/xii6A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xii6A.png" alt="enter image description here"></a></p>
<p>Ref 1 - Investment Casting
<a href="https://en.wikipedia.org/wiki/Investment_casting" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Investment_casting</a></p>
<p>Ref 2 - FormLabs 3D printable casting resin
<a href="https://support.formlabs.com/s/article/Using-Castable-Resin?language=en_US" rel="nofollow noreferrer">https://support.formlabs.com/s/article/Using-Castable-Resin?language=en_US</a></p>
|
<p>That's a hard No.</p>
<p>Models used in industrial injection molding are very specific to the process sometimes even the machine. When they build those molds they have to include constructs like spurs and runners; things to get the molten plastic to where it needs to go. Further the wall thickness of an injection molded part can only be so thick, because the plastic will contract when cooled, which will distort the final part if it is too thick.</p>
| 1,616
|
<p>I'm trying to determine, based on the result of this call, if it was successful. The <code>successFunction</code> doesn't get called, so I'm assuming it was not. How do I know what went wrong?</p>
<pre><code>xmlRequest = $.post("/url/file/", { 'id' : object.id }, successFunction, 'json');
</code></pre>
<p>Do I use the xmlRequest object?</p>
|
<p>You can use:</p>
<pre><code>$.ajax({
url:"/url/file/",
dataType:"json"
data:{ 'id' : object.id }
error:function(request){alert(request.statusText)}
success:successFunction
})
</code></pre>
|
<p>You could use the $.ajaxComplete() and/or $.ajaxError() methods to attach function to those events. I would also recommend using the Firefox browser with the Firebug pluging, you can get a lot of information about the requests and responses.</p>
| 8,201
|
<p>How do you <a href="http://svnbook.red-bean.com/en/1.8/svn.branchmerge.html" rel="noreferrer">branch and merge</a> with Apache Subversion using the TortoiseSVN client? </p>
|
<p>My easy click-by-click instructions (<strong>specific to TortoiseSVN</strong>) are in Stack Overflow question <em><a href="https://stackoverflow.com/questions/1461922">What is the simplest way to do branching and merging using TortoiseSVN?</a></em>.</p>
|
<p>You can also try <em><a href="http://www.codeproject.com/KB/work/XTortoiseSVN.aspx" rel="nofollow noreferrer">Version Control for the Standalone Programmer - Part 1</a></em> or perhaps <em><a href="http://www.kenegozi.com/Blog/2007/07/30/merging-with-tortoisesvn.aspx" rel="nofollow noreferrer">Merging with TortoiseSVN</a></em>.</p>
| 2,253
|
<p>I have a System.Diagnostics.Process object in a program targeted at the .Net framework 3.5</p>
<p>I have redirected both <code>StandardOutput</code> and <code>StandardError</code> pipes and I'm receiving data from them asynchronously. I've also set an event handler for the Exited event.</p>
<p>Once I call <code>Process.Start()</code> I want to go off and do other work whilst I wait for events to be raised.</p>
<p>Unfortunately it appears that, for a process which returns a large amount of information, the Exited event is fired before the last <code>OutputDataReceived</code> event.</p>
<p>How do I know when the last <code>OutputDataReceived</code> has been received? Ideally I would like the <code>Exited</code> event to be the last event I receive.</p>
<p>Here is an example program:</p>
<pre><code>using System;
using System.Diagnostics;
using System.Threading;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string command = "output.exe";
string arguments = " whatever";
ProcessStartInfo info = new ProcessStartInfo(command, arguments);
// Redirect the standard output of the process.
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
// Set UseShellExecute to false for redirection
info.UseShellExecute = false;
Process proc = new Process();
proc.StartInfo = info;
proc.EnableRaisingEvents = true;
// Set our event handler to asynchronously read the sort output.
proc.OutputDataReceived += new DataReceivedEventHandler(proc_OutputDataReceived);
proc.ErrorDataReceived += new DataReceivedEventHandler(proc_ErrorDataReceived);
proc.Exited += new EventHandler(proc_Exited);
proc.Start();
// Start the asynchronous read of the sort output stream. Note this line!
proc.BeginOutputReadLine();
proc.BeginErrorReadLine();
proc.WaitForExit();
Console.WriteLine("Exited (Main)");
}
static void proc_Exited(object sender, EventArgs e)
{
Console.WriteLine("Exited (Event)");
}
static void proc_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine("Error: {0}", e.Data);
}
static void proc_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
Console.WriteLine("Output data: {0}", e.Data);
}
}
}
</code></pre>
<p>When running this program you will notice that "Exited (Event)" appears in a completely variable location within the output. You may need to run it a few times and, obviously, you will need to replace "output.exe" with a program of your choice that produces a suitably large amount of output.</p>
<p>So, the question again: How do I know when the last <code>OutputDataReceived</code> has been received? Ideally I would like the <code>Exited</code> event to be the last event I receive.</p>
|
<p>The answer to this is that <a href="https://msdn.microsoft.com/en-us/library/system.diagnostics.datareceivedeventhandler%28v=vs.110%29.aspx" rel="noreferrer"><code>e.Data</code> will be set to <code>null</code></a>:</p>
<pre><code>static void proc_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
if( e.Data == null ) _exited.Set();
}
</code></pre>
|
<p>It will be more comfortable if e.Data set to null, but actually, the value will be an empty string. Please note the first value also could be Empty string. The real answer is once you receive some value other than Empty string, then look for next Empty string. I am using Visual Studio 2019.</p>
| 8,881
|
<p>I want to create my Rails application with MySQL, because I like it so much. How can I do that in the latest version of Rails instead of the default SQLite?</p>
|
<p>Normally, you would create a new Rails app using</p>
<pre><code>rails ProjectName
</code></pre>
<p>To use MySQL, use</p>
<pre><code>rails new ProjectName -d mysql
</code></pre>
|
<p><strong>Use following command to create new app for API with mysql database</strong></p>
<pre><code>rails new <appname> --api -d mysql
adapter: mysql2
encoding: utf8
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
</code></pre>
| 2,566
|
<p>There seem to be many ways to define <a href="http://en.wikipedia.org/wiki/Singleton_pattern" rel="noreferrer">singletons</a> in Python. Is there a consensus opinion on Stack Overflow?</p>
|
<p>I don't really see the need, as a module with functions (and not a class) would serve well as a singleton. All its variables would be bound to the module, which could not be instantiated repeatedly anyway. </p>
<p>If you do wish to use a class, there is no way of creating private classes or private constructors in Python, so you can't protect against multiple instantiations, other than just via convention in use of your API. I would still just put methods in a module, and consider the module as the singleton.</p>
|
<p>In cases where you don't want the metaclass-based solution above, and you don't like the simple function decorator-based approach (e.g. because in that case static methods on the singleton class won't work), this compromise works:</p>
<pre><code>class singleton(object):
"""Singleton decorator."""
def __init__(self, cls):
self.__dict__['cls'] = cls
instances = {}
def __call__(self):
if self.cls not in self.instances:
self.instances[self.cls] = self.cls()
return self.instances[self.cls]
def __getattr__(self, attr):
return getattr(self.__dict__['cls'], attr)
def __setattr__(self, attr, value):
return setattr(self.__dict__['cls'], attr, value)
</code></pre>
| 5,182
|
<p>I've been having some trouble parsing various types of XML within flash (specifically FeedBurner RSS files and YouTube Data API responses). I'm using a <code>URLLoader</code> to load a XML file, and upon <code>Event.COMPLETE</code> creating a new XML object. 75% of the time this work fine, and every now and again I get this type of exception:</p>
<pre><code>TypeError: Error #1085: The element type "link" must be terminated by the matching end-tag "</link>".
</code></pre>
<p>We think the problem is that The XML is large, and perhaps the <code>Event.COMPLETE</code> event is fired before the XML is actually downloaded from the <code>URLLoader</code>. The only solution we have come up with is to set off a timer upon the Event, and essentially "wait a few seconds" before beginning to parse the data. Surely this can't be the best way to do this.</p>
<p>Is there any surefire way to parse XML within Flash?</p>
<p><strong>Update Sept 2 2008</strong> We have concluded the following, the excption is fired in the code at this point:</p>
<pre><code>data = new XML(mainXMLLoader.data);
// calculate the total number of entries.
for each (var i in data.channel.item){
_totalEntries++;
}
</code></pre>
<p>I have placed a try/catch statement around this part, and am currently displaying an error message on screen when it occurs. My question is how would an incomplete file get to this point if the <code>bytesLoaded == bytesTotal</code>?</p>
<hr>
<p>I have updated the original question with a status report; I guess another question could be is there a way to determine wether or not an <code>XML</code> object is properly parsed before accessing the data (in case the error is that my loop counting the number of objects is starting before the XML is actually parsed into the object)?</p>
<hr>
<p>@Theo: Thanks for the ignoreWhitespace tip. Also, we have determined that the event is called before its ready (We did some tests tracing <code>mainXMLLoader.bytesLoaded + "/" + mainXMLLoader.bytesLoaded</code></p>
|
<p>Have you tried checking that the bytes loaded are the same as the total bytes?</p>
<pre><code>URLLoader.bytesLoaded == URLLoader.bytesTotal
</code></pre>
<p>That should tell you if the file has finished loading, it wont help with the compleate event firing to early, but it should tell you if its a problem with the xml been read.</p>
<p>I am unsure if it will work over domains, as my xml is always on the same site.</p>
|
<p>As you mentioned in your question, the problem is very likely that your program is looking at the XML before it has actually been completely downloaded, I don't know that there's a surefire way to "parse" the XML because the parsing portion of your code is more than likely fine, it's simply a matter of whether or not it has actually downloaded.</p>
<p>You could try to use the ProgressEvent.PROGRESS event to continually monitor the XML as it downloads and then as Re0sless suggested, check the bytesLoaded vs the bytesTotal and have your XML parse begin when the two numbers are equal instead of using the Event.COMPLETE event. </p>
<p>You should be able to get the bytesLoaded and bytesTotal numbers just fine regardless of domains, if you can access the file you can access its byte information.</p>
| 3,850
|
<p>I am trying to create a rather simple effect on a set of images. When an image doesn't have the mouse over it, I'd like it to have a simple, gray border. When it does have an image over it, I'd like it to have a different, "selected", border.</p>
<p>The following CSS works great in Firefox:</p>
<pre class="lang-css prettyprint-override"><code>.myImage a img
{
border: 1px solid grey;
padding: 3px;
}
.myImage a:hover img
{
border: 3px solid blue;
padding: 1px;
}
</code></pre>
<p>However, in IE, borders do not appear when the mouse isn't hovered over the image. My Google-fu tells me there is a bug in IE that is causing this problem. Unfortunately, I can't seem to locate a way to fix that bug.</p>
|
<p>Try using a different colour. I'm not sure IE understands 'grey' (instead, use 'gray').</p>
|
<p>IE has problems with the :hover pseudo-class on anything other than anchor elements so you need to change the element the hover is affecting to the anchor itself. So, if you added a class like "image" to your anchor and altered your markup to something like this:</p>
<pre><code><div class="myImage"><a href="..." class="image"><img .../></a></div>
</code></pre>
<p>You could then alter your CSS to look like this:</p>
<pre class="lang-css prettyprint-override"><code>.myImage a.image
{
border: 1px solid grey;
padding: 3px;
}
.myImage a.image:hover
{
border: 3px solid blue;
padding: 1px;
}
</code></pre>
<p>Which should mimic the desired effect by placing the border on the anchor instead of the image. Just as a note, you may need something like the following in your CSS to eliminate the image's default border:</p>
<pre class="lang-css prettyprint-override"><code>.myImage a img {
border: none;
}
</code></pre>
| 8,933
|
<p>I have a WCF service which includes UI components, which forces me to be in STA mode.</p>
<p>How do I set the service behaviour to STA-mode?</p>
<hr>
<p>The service uses a reference to a WPF DLL file which opens a UI window (used as view port) for picture analysis. When the service is trying to create an instance of that item (inherits from window) it throws an exception:</p>
<blockquote>
<p>The calling thread must be an STA</p>
</blockquote>
|
<p>I'm doing something similar to you.</p>
<p>My solution was to route all calls through an STA thread queue. I used a threadsafe collection from the new <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=348F73FD-593D-4B3C-B055-694C50D2B0F3&displaylang=en" rel="nofollow noreferrer">parallel framework</a> to queue up Actions I wanted to run on a STA thread. I then had X number of STA threads that continually checked the queue for new actions to execute. </p>
|
<p>I would investigate using the [STAThread] attribute to switch the threading model.
e.g.</p>
<pre><code>[STAThread]
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[] { new Host() };
ServiceBase.Run(ServicesToRun);
}
</code></pre>
<p><a href="http://msdn.microsoft.com/en-us/library/system.stathreadattribute.aspx" rel="nofollow noreferrer">Description of the STAThread attribute</a></p>
<p>But I'm confused why you're using UI components in a web service at all. Can you explain a bit more about why you're trying to do this?</p>
| 7,200
|
<p>I've tried several things already,</p>
<pre><code>std::stringstream m;
m.empty();
m.clear();
</code></pre>
<p>both of which don't work.</p>
|
<p>For all the standard library types the member function <code>empty()</code> is a query, not a command, i.e. it means "are you empty?" not "please throw away your contents".</p>
<p>The <code>clear()</code> member function is inherited from <code>ios</code> and is used to clear the error state of the stream, e.g. if a file stream has the error state set to <code>eofbit</code> (end-of-file), then calling <code>clear()</code> will set the error state back to <code>goodbit</code> (no error).</p>
<p>For clearing the contents of a <code>stringstream</code>, using:</p>
<pre><code>m.str("");
</code></pre>
<p>is correct, although using:</p>
<pre><code>m.str(std::string());
</code></pre>
<p>is technically more efficient, because you avoid invoking the <code>std::string</code> constructor that takes <code>const char*</code>. But any compiler these days should be able to generate the same code in both cases - so I would just go with whatever is more readable.</p>
|
<p>These do not discard the data in the stringstream in gnu c++</p>
<pre><code> m.str("");
m.str() = "";
m.str(std::string());
</code></pre>
<p>The following does empty the stringstream for me:</p>
<pre><code> m.str().clear();
</code></pre>
| 4,106
|
<p>The default check-in action for a work-item is "resolve". I'd like to set it to "associate" so that this work item isn't automaticaly closed if I check-in stuff too fast. How can I do that?</p>
|
<p>Yup, the check-in action can only be associated to a state transition (i.e. Active to Resolved). In my blog post that <a href="https://stackoverflow.com/questions/62294/how-to-modify-the-defaul-check-in-action-in-tfs#62376">Fredrick</a> linked to (<a href="http://www.woodwardweb.com/vsts/top_tfs_tip_3_r.html" rel="nofollow noreferrer">http://www.woodwardweb.com/vsts/top_tfs_tip_3_r.html</a>) I talk about how to remove that. You'll need to customize the work item for everyone in your team project to make this happen. For help on that see </p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms243849(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms243849(VS.80).aspx</a></p>
|
<p>Unlike previous versions, in VS2015 the registry key solution seems to work in the cases we need!</p>
<p>I just went to</p>
<pre><code>HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\TeamFoundation\SourceControl\Behavior
</code></pre>
<p>and changed <code>ResolveAsDefaultCheckinAction</code> from <code>True</code> to <code>False</code>.</p>
| 8,768
|
<p>I'm able to connect to and read an excel file no problem. But when importing data such as zipcodes that have leading zeros, how do you prevent excel from guessing the datatype and in the process stripping out leading zeros?</p>
|
<p>I believe you have to set the option in your connect string to force textual import rather than auto-detecting it.</p>
<pre><code>Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=c:\path\to\myfile.xlsx;
Extended Properties=\"Excel 12.0 Xml;IMEX=1\";
</code></pre>
<p>Your milage may vary depending on the version you have installed. The IMEX=1 extended property tells Excel to treat intermixed data as text.</p>
|
<p>I think the way to do this would be to format the source excel file such that the column is formatted as Text instead of General. Select the entire column and right click and select format cells, select text from the list of options.</p>
<p>I think that would explicitly define that the column content is text and should be treated as such.</p>
<p>Let me know if that works.</p>
| 4,289
|
<p>We're using WatiN for testing our UI, but one page (which is unfortunately not under our teams control) takes forever to finish loading. Is there a way to get WatiN to click a link on the page before the page finishes rendering completely?</p>
|
<p>Here's the code we found to work:</p>
<pre><code>IE browser = new IE(....);
browser.Button("SlowPageLoadingButton").ClickNoWait();
Link continueLink = browser.Link(Find.ByText("linktext"));
continueLink.WaitUntilExists();
continueLink.Click();
</code></pre>
|
<p>You should be able to leave out the call to WaitUntilExists() since WatiN does this internally when you call a method or property on an element (like the link.Click() in you rexample).</p>
<p>HTH,
Jeroen van Menen
Lead dev WatiN</p>
| 7,140
|
<p>I cleaned up my Flashforge Creator Dual tonight, and loaded some transparent ABS prepping for a print. The filament extruded fine, then started to wiggle, then became fine again. Hot end is 0.4 mm and was heated to 230C. What sort of steps should I take to troubleshoot the issue? Has anyone seen this before?</p>
<p><a href="https://i.stack.imgur.com/ffssj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ffssj.jpg" alt="Photo of extruded filament exhibiting wiggles"></a></p>
|
<p>No, that's not (entirely) true. There might be some loss of quality if you print multiple objects at once, because when the printhead "hops" from one object to another it might leave a mark or ooze out some material. Also, a large number of retractions in a short period of time might lead to inconsistent extrusion.</p>
<p>However, none of this is particular to "filling out the board" as it happens even if you print only two objects at a time (or even when you're printing only one object with multiple islands).</p>
<p>It all depends on your printer (and in particular how well it handles retractions). If you're willing to do a small amount of cleanup afterwards (to remove the strings and blobs) then printing multiple objects at a time is completely viable.</p>
|
<p>Just to add to the other answers already here, I've also had problems with layer adhesion when filling up the print bed on an extrusion printer. The longer the print head spends working on details around a single layer, the more chance the layer has to cool off before the next layer gets started. I've started to suspect that layers that take longer to print end up with less adhesion to the next layer.</p>
| 425
|
<p>The code in <a href="https://stackoverflow.com/questions/17181/test-cases-vs-assertion-statement">this question</a> made me think</p>
<pre><code>assert(value>0); //Precondition
if (value>0)
{
//Doit
}
</code></pre>
<p>I never write the if-statement. Asserting is enough/all you <em>can</em> do.
"Crash early, crash often"</p>
<p><a href="https://rads.stackoverflow.com/amzn/click/com/0735619670" rel="nofollow noreferrer" rel="nofollow noreferrer">CodeComplete</a> states:</p>
<ul>
<li>The assert-statement makes the application Correct </li>
<li>The if-test makes the application Robust</li>
</ul>
<p>I don't think you've made an application more robust by correcting invalid input values, or skipping code:</p>
<pre><code>assert(value >= 0 ); //Precondition
assert(value <= 90); //Precondition
if(value < 0) //Just in case
value = 0;
if (value > 90) //Just in case
value = 90;
//Doit
</code></pre>
<p>These corrections are based on assumptions you made about the outside world.
Only the caller knows what "a valid input value" is for your function, and he must check its validity before he calls your function.</p>
<p>To paraphrase <a href="https://rads.stackoverflow.com/amzn/click/com/0735619670" rel="nofollow noreferrer" rel="nofollow noreferrer">CodeComplete</a>:
"Real-world programs <em>become</em> too messy when we <em>don't</em> rely solely on assertions."</p>
<p>Question: Am I wrong, stuborn, stupid, too non-defensive...</p>
|
<p>The problem with trusting just Asserts, is that they may be turned off in a production environment. To quote the wikipedia article:</p>
<blockquote>
<p>Most languages allow assertions to be
enabled or disabled globally, and
sometimes independently. Assertions
are often enabled during development
and disabled during final testing and
on release to the customer. Not
checking assertions avoiding the cost
of evaluating the assertions while,
assuming the assertions are free of
side effects, still producing the same
result under normal conditions. Under
abnormal conditions, disabling
assertion checking can mean that a
program that would have aborted will
continue to run. This is sometimes
preferable.
<a href="http://en.wikipedia.org/wiki/Assertion_(computing)" rel="noreferrer">Wikipedia</a></p>
</blockquote>
<p>So if the correctness of your code relies on the Asserts to be there you may run into serious problems. Sure, if the code worked during testing it should work during production... Now enter the second guy that works on the code and is just going to fix a small problem...</p>
|
<p>A problem with assertions is that they can (and usually will) be compiled out of the code, so you need to add both walls in case one gets thrown away by the compiler.</p>
| 8,006
|
<p>Has anyone been able to get xinc to run correctly under OpenBSD's chrooted default Apache? I'd like to keep our development server running fully chrooted just like our Production server so that we make sure our code runs just fine chrooted.</p>
|
<p>Have you posted the issue on the Xinc <a href="http://code.google.com/p/xinc/issues/list" rel="nofollow noreferrer">bug tracker</a>? Xinc itself should run fine as it runs both as a daemon and as a web app. As you alluded to, the issue may be that the daemon is not running in a chroot'ed environment where as the web interface is, leading to either side not grabbing the files.</p>
|
<p>Having never used xinc myself, I can only hint as to how I usually get to chrooting apps.</p>
<p>First step would be to gather information on everything the app needs to run; this I usually accomplish by running <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=systrace&sektion=1" rel="nofollow noreferrer">systrace(1)</a> and <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=ldd&sektion=1" rel="nofollow noreferrer">ldd(1)</a> to find out what is needed to run the software.</p>
<p>Go through the output of</p>
<pre><code>systrace -A -d. <app>
ldd <app>
</code></pre>
<p>and make sure that everything the app touches and needs (quite a lot of apps touch stuff it doesn't actually need) is available in the chroot environment. You might need to tweak configs and environment variables a bit. Also, if there is an option to have the app log to syslog, I usually do that and create a syslog socket (see the -a option of <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=syslogd&sektion=8" rel="nofollow noreferrer">syslogd(8)</a>) in order to decrease the places the app needs write access to.</p>
<p>What I just described is a generic way to make just about any program run in a chroot environment (however, if you need to import half the userland and some suid commands, you might want to just not do chroot :). For apps running under Apache (I'm sure you're aware that the OpenBSD <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=httpd&sektion=8" rel="nofollow noreferrer">httpd(8)</a> is slightly different) you have the option (once the program has started; any dynamic libraries still needs to be present in the jail) of using apache to access the files, allowing the use of <a href="http://httpd.apache.org/docs/1.3/configuring.html" rel="nofollow noreferrer">httpd.conf</a> to import resources in the chroot environment without actually copying them.</p>
<p>Also useful (if slightly outdated) is <a href="http://www.phpbuilder.com/manual/en/install.unix.openbsd.php" rel="nofollow noreferrer">this</a> link, outlining some gotchas in chrooted PHP on OpenBSD.</p>
| 3,087
|
<p>I am working on a program that needs to create a multiple temporary folders for the application. These will not be seen by the user. The app is written in VB.net. I can think of a few ways to do it such as incremental folder name or random numbered folder names, but I was wondering, how other people solve this problem?</p>
|
<p><strong>Update:</strong> Added File.Exists check per comment (2012-Jun-19)</p>
<p>Here's what I've used in VB.NET. Essentially the same as presented, except I usually didn't want to create the folder immediately. </p>
<p>The advantage to use <a href="http://msdn.microsoft.com/en-us/library/system.io.path.getrandomfilename.aspx" rel="noreferrer">GetRandomFilename</a> is that it doesn't create a file, so you don't have to clean up if your using the name for something other than a file. Like using it for folder name.</p>
<pre><code>Private Function GetTempFolder() As String
Dim folder As String = Path.Combine(Path.GetTempPath, Path.GetRandomFileName)
Do While Directory.Exists(folder) or File.Exists(folder)
folder = Path.Combine(Path.GetTempPath, Path.GetRandomFileName)
Loop
Return folder
End Function
</code></pre>
<p><strong>Random</strong> Filename Example:</p>
<p>C:\Documents and Settings\username\Local Settings\Temp\u3z5e0co.tvq</p>
<hr>
<p>Here's a variation using a Guid to get the temp folder name. </p>
<pre><code>Private Function GetTempFolderGuid() As String
Dim folder As String = Path.Combine(Path.GetTempPath, Guid.NewGuid.ToString)
Do While Directory.Exists(folder) or File.Exists(folder)
folder = Path.Combine(Path.GetTempPath, Guid.NewGuid.ToString)
Loop
Return folder
End Function
</code></pre>
<p><strong>guid</strong> Example:</p>
<p>C:\Documents and Settings\username\Local Settings\Temp\2dbc6db7-2d45-4b75-b27f-0bd492c60496</p>
|
<p>The advantage to using System.IO.Path.GetTempFileName is that it will be a file in the user's local (i.e., non-roaming) path. This is exactly where you would want it for permissions and security reasons.</p>
| 3,737
|
<p><strong>Can anyone recommend a tool for quickly posting test messages onto a JMS queue?</strong></p>
<p><strong>Description</strong>:</p>
<ol>
<li>The tool should allow the user to enter some data, perhaps an XML
payload, and then submit it to a queue.</li>
<li>I should be able to test consumer without producer.</li>
</ol>
|
<p>This answer doesn't apply to all JMS brokers, but if you happen to be using <a href="http://activemq.apache.org/" rel="noreferrer">Apache ActiveMQ</a>, the web-based admin console (by default at <a href="http://localhost:8161/admin" rel="noreferrer">http://localhost:8161/admin</a>) allows you to manually send text messages to topics or queues. It's handy for debugging.</p>
|
<p>I'm a brazilian developer and I made a Java program for Post HTTP and JMS Messages his available for download at: <a href="https://sites.google.com/site/felipeglino/softwares/posttool" rel="nofollow">https://sites.google.com/site/felipeglino/softwares/posttool</a></p>
<p>In thath page you can found english instructions.</p>
| 5,881
|
<p>Here is the scenario:</p>
<p>I'm writing an app that will watch for any changes in a specific directory. This directory will be flooded with thousands of files a minute each with an "almost" unique GUID. The file format is this:</p>
<p>GUID.dat where GUID == xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
(the internal contents aren't relevant, but it's just text data)</p>
<p>My app will be a form that has one single text box that shows all the files that are being added and deleted in real time. Every time a new file comes in I have to update the textbox with this file, BUT I must first make sure that this semi-unique GUID is really unique, if it is, update the textbox with this new file.</p>
<p>When a file is removed from that directory, make sure it exists, then delete it, update textbox accordingly.</p>
<p>The problem is that I've been using the .NET filewatcher and it seems that there is an internal buffer that gets blown up every time the (buffersize + 1)-th file comes in. I also tried to keep an internal List in my app, and just add every single file that comes in, but do the unique-GUID check later, but no dice.</p>
|
<p>A couple of things that I have in my head:</p>
<ul>
<li>If the guid is <em>not</em> unique, would it not overwrite the file with the same name, or is the check based on a lookup which does some external action (e.g. check the archive)? (i.e. is this a YAGNI moment?)</li>
<li>I've used FileSystemWatcher before with pretty good success, can you give us some ideas as to <em>how</em> your actually doing things?</li>
<li>When you say "no dice" when working with your custom list, what was the problem? And how were you checking for file system changes without FileSystemWatcher?!</li>
</ul>
<p>Sorry no answer as yet, just would like to know more about the problem :)</p>
|
<p>I suggest you take a look at the <a href="http://msdn.microsoft.com/en-us/library/bb762118(VS.85).aspx" rel="nofollow noreferrer">SHChangeNotify</a> API call, which can notify you of all kinds of shell events. To monitor file creation and deletion activity, you may want to pay special attention to the SHCNE_CREATE and SHCNE_DELETE arguments.</p>
| 4,858
|
<p>I want to swap two integers, and I want to know which of these two implementations will be faster:
The obvious way with a temp variable:</p>
<pre><code>void swap(int* a, int* b)
{
int temp = *a;
*a = *b;
*b = temp;
}
</code></pre>
<p>Or the xor version that I'm sure most people have seen:</p>
<pre><code>void swap(int* a, int* b)
{
*a ^= *b;
*b ^= *a;
*a ^= *b;
}
</code></pre>
<p>It seems like the first uses an extra register, but the second one is doing three loads and stores while the first only does two of each. Can someone tell me which is faster and why? The why being more important.</p>
|
<p>The XOR method fails if a and b point to the same address. The first XOR will clear all of the bits at the memory address pointed to by both variables, so once the function returns (*a == *b == 0), regardless of the initial value.</p>
<p>More info on the Wiki page:
<a href="http://en.wikipedia.org/wiki/XOR_swap_algorithm" rel="noreferrer">XOR swap algorithm</a></p>
<p>Although it's not likely that this issue would come up, I'd always prefer to use the method that's guaranteed to work, not the clever method that fails at unexpected moments.</p>
|
<p>I just placed both swaps (as macros) in hand written quicksort I've been playing with. The XOR version was much faster (0.1sec) then the one with the temporary variable (0.6sec). The XOR did however corrupt the data in the array (probably the same address thing Ant mentioned).<p>
As it was a fat pivot quicksort, the XOR version's speed is probably from making large portions of the array the same. I tried a third version of swap which was the easiest to understand and it had the same time as the single temporary version.
<pre><code>
acopy=a;
bcopy=b;
a=bcopy;
b=acopy;
</code></pre><p>
[I just put an if statements around each swap, so it won't try to swap with itself, and the XOR now takes the same time as the others (0.6 sec)]</p>
| 5,752
|
<p>I'm working on an exceedingly large codebase, and recently upgraded to GCC 4.3, which now triggers this warning:</p>
<blockquote>
<p>warning: deprecated conversion from string constant to ‘char*’</p>
</blockquote>
<p>Obviously, the correct way to fix this is to find every declaration like</p>
<pre><code>char *s = "constant string";
</code></pre>
<p>or function call like:</p>
<pre><code>void foo(char *s);
foo("constant string");
</code></pre>
<p>and make them <code>const char</code> pointers. However, that would mean touching 564 files, minimum, which is not a task I wish to perform at this point in time. The problem right now is that I'm running with <a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Werror" rel="nofollow noreferrer">-Werror</a>, so I need some way to stifle these warnings. How can I do that?</p>
|
<p>I believe passing <a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-write-strings" rel="nofollow noreferrer">-Wno-write-strings</a> to GCC will suppress this warning.</p>
|
<blockquote>
<p>The problem right now is that I'm running with -Werror</p>
</blockquote>
<p>This is your real problem, IMO. You can try some automated ways of moving from (char *) to (const char *) but I would put money on them not just working. You will have to have a human involved for at least some of the work.
For the short term, just ignore the warning (but IMO leave it on, or it'll never get fixed) and just remove the -Werror.</p>
| 8,434
|
<p>What are the options? How popular are they? Do these IDEs give similar/better functionality compared to visual studio?</p>
|
<p>Yes - you can try using SharpDevelop:</p>
<p><a href="http://www.icsharpcode.net/OpenSource/SD/" rel="nofollow noreferrer">http://www.icsharpcode.net/OpenSource/SD/</a></p>
<p>Or you can just use notepad, or notepad++</p>
<p><a href="http://notepad-plus.sourceforge.net/" rel="nofollow noreferrer">http://notepad-plus.sourceforge.net/</a></p>
<p>Then compile on the command line.</p>
<p><strong>Edit</strong>: If you're looking for a free solution - try Visual Studio C# Express Edition:</p>
<p><a href="http://www.microsoft.com/express/vcsharp/" rel="nofollow noreferrer">http://www.microsoft.com/express/vcsharp/</a></p>
|
<p>Check out the mono project. <a href="http://www.mono-project.com/" rel="nofollow noreferrer">http://www.mono-project.com/</a><br>
It's the '.NET for linux' project.<br>
They also have an ide based on eclipse as part of the whole thing. Never used it before but I've used eclipse for java and some php work, and eclipse is pretty good</p>
<p><strong>Edit</strong>: the ide is called MonoDevelop. Seen at <a href="http://www.monodevelop.com/" rel="nofollow noreferrer">http://www.monodevelop.com/</a></p>
| 6,028
|
<p>I am calling, through reflection, a method which may cause an exception. How can I pass the exception to my caller without the wrapper reflection puts around it?<br>
I am rethrowing the InnerException, but this destroys the stack trace.<br>
Example code:</p>
<pre><code>public void test1()
{
// Throw an exception for testing purposes
throw new ArgumentException("test1");
}
void test2()
{
try
{
MethodInfo mi = typeof(Program).GetMethod("test1");
mi.Invoke(this, null);
}
catch (TargetInvocationException tiex)
{
// Throw the new exception
throw tiex.InnerException;
}
}
</code></pre>
|
<p>In <strong>.NET 4.5</strong> there is now the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.runtime.exceptionservices.exceptiondispatchinfo" rel="noreferrer"><code>ExceptionDispatchInfo</code></a> class.</p>
<p>This lets you capture an exception and re-throw it without changing the stack-trace:</p>
<pre><code>using ExceptionDispatchInfo =
System.Runtime.ExceptionServices.ExceptionDispatchInfo;
try
{
task.Wait();
}
catch(AggregateException ex)
{
ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
}
</code></pre>
<p>This works on any exception, not just <code>AggregateException</code>.</p>
<p>It was introduced due to the <code>await</code> C# language feature, which unwraps the inner exceptions from <code>AggregateException</code> instances in order to make the asynchronous language features more like the synchronous language features.</p>
|
<p>This is just a nice clean, modern implementation of some of the other ideas here, tested in .NET 6:</p>
<pre><code>public static class ExceptionExtensions
{
[DoesNotReturn]
public static void Rethrow(this Exception ex)
=> ExceptionDispatchInfo.Capture(ex).Throw();
}
</code></pre>
<p>I wanted the value of the <code>PropertyName</code> property on <code>myObject</code> but this will work just as well when using reflection to call methods (as per OP's problem) or anything else that results in you wanting to re-throw an inner exception.</p>
<pre><code>try
{
object? value = myObject.GetType().GetProperty("PropertyName")?.GetValue(myObject);
}
catch (TargetInvocationException ex)
{
(ex.InnerException ?? ex).Rethrow();
}
</code></pre>
| 8,159
|
<p>It occurs to me that I'm never really thinking about layer height when I calibrate my z-probe offset. This is obviously an oversight, because I'll want my nozzle to start higher for 0.3mm layers than for 0.1mm layers.</p>
<p>After this realization comes the question: Do I need to recalibrate every time I switch to a different layer height? Or can slicers store a reference layer height + probe offset and just deduce the proper starting height for every print? Or is it smartest to keep the 1st layer height constant throughout my prints to spare myself this frustration?</p>
<p>If it matters, my printer is the Printrbot Simple Metal, and my goto slicer is Cura.</p>
|
<p>All modern slicers adjust the nozzle position for the first layer in accordance with your chosen layer height. You can see this in your gcode if you slice files with different layer heights. <em>Before you add special slicer settings and offsets,</em> if you print 0.1mm layers, the nozzle will start at Z=0.1mm, and if you print 0.3mm layers, the nozzle will start at Z=0.3mm.</p>
<p>There are two reasons this is more complex and less reliable than it seems:</p>
<p><strong>Different slicers assume different initial tramming gaps.</strong> And your actual tramming gap may not match that assumption. If the slicer thinks your nozzle is leveled at Z=0 with a real physical gap of 0.1mm to start with, that means gcode Z=0.1mm is actually a 0.2mm gap that must be filled with plastic. So the slicer must compensate by starting lower than the nominal layer height. </p>
<p>So what works perfectly for one slicer won't necessarily work correctly for another slicer. And if you tram with a thinner object than the slicer expects (say a post-it note instead of business card) then your first layer will be off. This is why I personally prefer physical build plate leveling mid-print using screws while watching the strands go down. It bypasses all the assumptions about tramming gaps and just gives you the correct result. (Or you can do the same thing with babystepping in firmware that supports that.)</p>
<p>The other issue is that <strong>people use lots of weird, ad hoc slicer tricks to get their first layer to stick</strong>. Things like printing the first layer much hotter, or at half speed, or squashed way down and over-extruded, or at 60% layer height, or at 200% extrusion width, will all affect the extrusion volume calibration and the space-filling behavior of the molten plastic flowing onto the bed. The slicer doesn't really have the ability to understand "your" first-layer adhesion recipe. </p>
<p>The combination of incorrect/unknown tramming gap and person-specific first-layer settings is why the slicer can't always get the first layer height and extrusion volume correct across all layer heights. Within some fairly reasonable assumptions, the slicer is smart enough to always correctly relate extruder flow and nozzle position so it fills the space between the nozzle and whatever surface you're printing onto. But if you break those assumptions, it may perform differently for different settings. </p>
|
<p>The first layer is usually squished more to help with the adhesion. On top of that with ABS there's a bit of deformation even if the print doesn't lift. So spare yourself the frustration, FDM 3d printers aren't that precise themselves for you to care about this.</p>
| 307
|
<p>Can someone explain the mechanics of a jump table and why is would be needed in embedded systems?</p>
|
<p>A jump table can be either an array of pointers to functions or an array of machine code jump instructions. If you have a relatively static set of functions (such as system calls or virtual functions for a class) then you can create this table once and call the functions using a simple index into the array. This would mean retrieving the pointer and calling a function or jumping to the machine code depending on the type of table used.</p>
<p>The benefits of doing this in embedded programming are:</p>
<ol>
<li>Indexes are more memory efficient than machine code or pointers, so there is a potential for memory savings in constrained environments.</li>
<li>For any particular function the index will remain stable and changing the function merely requires swapping out the function pointer.</li>
</ol>
<p>If does cost you a tiny bit of performance for accessing the table, but this is no worse than any other virtual function call.</p>
|
<p>Jump tables, more often known as a Branch table, are usually used only by the machine.</p>
<p>The compiler creates a list of all labels in a assembly program and links all labels to a a memory location. A jump table pretty much is a reference card to where, a function or variable or what ever the label maybe, is stored in memory. </p>
<p>So as a function executes, on finishing it jumps back to it's previous memory location or jumps to the next function, etc. </p>
<p>And If your talking about what I think you are, you don't just need them in embedded systems but in any type of compiled/interpreted environment. </p>
<p>Brian Gianforcaro</p>
| 7,039
|
<p>We have a number of web-apps running on IIS 6 in a cluster of machines. One of those machines is also a state server for the cluster. We do not use sticky IP's.</p>
<p>When we need to take down the state server machine this requires the entire cluster to be offline for a few minutes while it's switched from one machine to another.</p>
<p>Is there a way to switch a state server from one machine to another with zero downtime?</p>
|
<p>You could use <a href="http://msdn.microsoft.com/en-us/library/dd187409.aspx" rel="nofollow noreferrer">Velocity</a>, which is a distributed caching technology from Microsoft. You would install the cache on two or more servers. Then you would <a href="http://blogs.msdn.com/velocity/archive/2008/10/29/changes-to-session-state-provider-configuration-web-config-for-ctp2.aspx" rel="nofollow noreferrer">configure your web app</a> to store session data in the Velocity cache. If you needed to reboot one of your servers, the entire state for your cluster would still be available. </p>
|
<p>You could use the SQL server option to store state. I've used this in the past and it works well as long as the ASPState table it creates is in memory. I don't know how well it would scale as an on-disk table.</p>
<p>If SQL server is not an option for whatever reason, you could use your load balancer to create a virtual IP for your state server and point it at the new state server when you need to change. There'd be no downtime, but people who are on your site at the time would lose their session state. I don't know what you're using for load balancing, so I don't know how difficult this would be in your environment.</p>
| 9,105
|
<p>Specifically, what commands do I run from the terminal?</p>
|
<p>Without a home directory</p>
<pre><code>sudo useradd myuser
</code></pre>
<p>With home directory</p>
<pre><code>sudo useradd -m myuser
</code></pre>
<p>Then set the password</p>
<pre><code>sudo passwd myuser
</code></pre>
<p>Then set the shell</p>
<pre><code>sudo usermod -s /bin/bash myuser
</code></pre>
|
<p>There's basicly 2 commands to do this...</p>
<ul>
<li>useradd</li>
<li>adduser (which is a frendlier front end to useradd)</li>
</ul>
<p>You have to run them has root.
Just read their manuals to find out how to use them.</p>
| 5,917
|
<p>I am making a DIY 3D printer based on the prusa mini. So, I doubt is if RAMPS can only control 4 stepper motors as it has slots for 5 stepper motor slots and one will not be used in my case, if I can in what order should I connect the drivers and also ho will Marlin figure out which slot the extruder is connected? Sorry for the lack of knowledge if fit is really obvious :|</p>
|
<p>Generally, a timing belt is a complicated device and many things depend on its internal construction and materials (it may be damaged when bound in wrong direction, or when cut, and when overtighten of course, etc.). There is also physics and math applicable, based on <a href="https://en.wikipedia.org/wiki/Mersenne%27s_laws" rel="nofollow noreferrer">Mersenne's laws</a>.</p>
<p>Some vendors provide calculators (online or as phone apps), which can calculate tension (force in Newtons or lbs) or the frequency (Hz). Therefore often the advice is to tension the belt until some (bass) sound is present - and professionals would tune belts with a sound tuner. There are also hints that belts should be possible to connect with fingers with slight or significant pressure (so not consistent). There is also visual guideline: when you slowly move the carriage with hand, the belt should remain straight. (Slowly, because belt is elastic and may behave different when moving carriage stronger and faster against friction of pulley.)</p>
<p>I would suggest to read <a href="https://www.3dprintingspot.com/post/3d-printer-belt-tension-everything-that-you-need-to-know" rel="nofollow noreferrer">this article on 3dprintingspot.com</a> for many practical suggestions.</p>
|
<p>Mine came from the factory tight enough that it doesn't sag at all, but not so tight that it feels hard or stiff or difficult to deflect a bit with gentle pressure. With the bed pushed all the way to the back, I can push the y-axis belt to the side about 1/8" with gentle pressure, and it feels like that's about as far as it's going to go even if I were to push harder. Seems to work really well without a lot of unnecessary force.</p>
| 1,823
|
<p>When coding web services, how do you structure your return values? How do you handle error conditions (expected ones and unexpected ones)? If you are returning something simple like an int, do you just return it, or embed it in a more complex object? Do all of the web methods within one service return an instance of a single class, or do you create a custom return value class for each method?</p>
|
<p>I like the Request/Response object pattern, where you encapsulate your arguments into a single [Operation]Request class, which has simple public properties on it.</p>
<p>Something like AddCustomerRequest, which would return AddCustomerResponse.</p>
<p>The response can include information on the success/failure of the operation, any messages that might be used by the UI, possibly the ID of the customer that was added, for example.</p>
<p>Another good pattern is to make these all derive from a simple IMessage interface, where your general end-point is something like Process(params IMessage[] messages)... this way you can pass in multiple operations in the same web request.</p>
|
<p>Soap faults are a standard practice where the calling application is a Soap client. There are cases, such as a COM client using XMLHTTP, where the Soap is parsed as XML and Soap faults cannot be easily handled. Can't vote yet but another +1 for @Ben Scheirman.</p>
| 6,070
|
<p>So I'm refactoring my code to implement more OOP. I set up a class to hold page attributes.</p>
<pre><code>class PageAtrributes
{
private $db_connection;
private $page_title;
public function __construct($db_connection)
{
$this->db_connection = $db_connection;
$this->page_title = '';
}
public function get_page_title()
{
return $this->page_title;
}
public function set_page_title($page_title)
{
$this->page_title = $page_title;
}
}
</code></pre>
<p>Later on I call the set_page_title() function like so</p>
<pre><code>function page_properties($objPortal) {
$objPage->set_page_title($myrow['title']);
}
</code></pre>
<p>When I do I receive the error message:</p>
<blockquote>
<p>Call to a member function set_page_title() on a non-object</p>
</blockquote>
<p>So what am I missing?</p>
|
<p>It means that <code>$objPage</code> is not an instance of an object. Can we see the code you used to initialize the variable?</p>
<p>As you expect a specific object type, you can also make use of <a href="http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration" rel="noreferrer">PHPs type-hinting feature<sup><em>Docs</em></sup></a> to get the error when your logic is violated:</p>
<pre><code>function page_properties(PageAtrributes $objPortal) {
...
$objPage->set_page_title($myrow['title']);
}
</code></pre>
<p>This function will only accept <code>PageAtrributes</code> for the first parameter.</p>
|
<p>I realized that I wasn't passing <strong>$objPage</strong> into <strong>page_properties()</strong>. It works fine now.</p>
| 7,817
|
<p>Flat files and relational databases give us a mechanism to serialize structured data. XML is superb for serializing un-structured tree-like data.</p>
<p>But many problems are best represented by graphs. A thermal simulation program will, for instance, work with temperature nodes connected to each others through resistive edges.</p>
<p>So what is the best way to serialize a graph structure? I know XML can, to some extent, do it---in the same way that a relational database can serialize a complex web of objects: it usually works but can easily get ugly.</p>
<p>I know about the dot language used by the graphviz program, but I'm not sure this is the best way to do it. This question is probably the sort of thing academia might be working on and I'd love to have references to any papers discussing this.</p>
|
<p>How do you represent your graph in memory?<br>
Basically you have two (good) options:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Adjacency_list" rel="noreferrer">an adjacency list representation</a></li>
<li><a href="http://en.wikipedia.org/wiki/Adjacency_matrix" rel="noreferrer">an adjacency matrix representation</a></li>
</ul>
<p>in which the adjacency list representation is best used for a sparse graph, and a matrix representation for the dense graphs.</p>
<p>If you used suchs representations then you could serialize those representations instead.</p>
<p>If it has to be <em>human readable</em> you could still opt for creating your own serialization algorithm. For example you could write down the matrix representation like you would do with any "normal" matrix: just print out the columns and rows, and all the data in it like so:</p>
<pre><code> 1 2 3
1 #t #f #f
2 #f #f #t
3 #f #t #f
</code></pre>
<p>(this is a non-optimized, non weighted representation, but can be used for directed graphs)</p>
|
<p>On a less academic, more practical note, in <a href="http://cubictest.openqa.org" rel="nofollow noreferrer">CubicTest</a> we use <a href="http://xstream.codehaus.org/" rel="nofollow noreferrer">Xstream</a> (Java) to serialize tests to and from xml. Xstream handles graph-structured object relations, so you might learn a thing or two from looking at it's source and the resulting xml. You're right about the <em>ugly</em> part though, the generated xml files don't look pretty.</p>
| 7,499
|
<p>Does anyone know how bash handles sending data through pipes?</p>
<pre><code>cat file.txt | tail -20
</code></pre>
<p>Does this command print all the contents of file.txt into a buffer, which is then read by tail? Or does this command, say, print the contents of file.txt line by line, and then pause at each line for tail to process, and then ask for more data? </p>
<p>The reason I ask is that I'm writing a program on an embedded device that basically performs a sequence of operations on some chunk of data, where the output of one operation is send off as the input of the next operation. I would like to know how linux (bash) handles this so please give me a general answer, not specifically what happens when I run "cat file.txt | tail -20".</p>
<p>EDIT: Shog9 pointed out a relevant Wikipedia Article, this didn't lead me directly to the article but it helped me find this: <a href="http://en.wikipedia.org/wiki/Pipeline_%28Unix%29#Implementation" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Pipeline_%28Unix%29#Implementation</a> which did have the information I was looking for.</p>
<hr>
<p>I'm sorry for not making myself clear. Of course you're using a pipe and of course you're using stdin and stdout of the respective parts of the command. I had assumed that was too obvious to state.</p>
<p>What I'm asking is how this is handled/implemented. Since both programs cannot run at once, how is data sent from stdin to stdout? What happens if the first program generates data significantly faster than the second program? Does the system just run the first command until either it's terminated or it's stdout buffer is full, and then move on to the next program, and so on in a loop until no more data is left to be processed or is there a more complicated mechanism?</p>
|
<p>I decided to write a slightly more detailed explanation.</p>
<p>The "magic" here lies in the operating system. Both programs do start up at roughly the same time, and run at the same time (the operating system assigns them slices of time on the processor to run) as every other simultaneously running process on your computer (including the terminal application and the kernel). So, before any data gets passed, the processes are doing whatever initialization necessary. In your example, tail is parsing the '-20' argument and cat is parsing the 'file.txt' argument and opening the file. At some point tail will get to the point where it needs input and it will tell the operating system that it is waiting for input. At some other point (either before or after, it doesn't matter) cat will start passing data to the operating system using stdout. This goes into a buffer in the operating system. The next time tail gets a time slice on the processor after some data has been put into the buffer by cat, it will retrieve some amount of that data (or all of it) which leaves the buffer on the operating system. When the buffer is empty, at some point tail will have to wait for cat to output more data. If cat is outputting data much faster than tail is handling it, the buffer will expand. cat will eventually be done outputting data, but tail will still be processing, so cat will close and tail will process all remaining data in the buffer. The operating system will signal tail when their is no more incoming data with an EOF. Tail will process the remaining data. In this case, tail is probably just receiving all the data into a circular buffer of 20 lines, and when it is signalled by the operating system that there is no more incoming data, it then dumps the last twenty lines to its own stdout, which just gets displayed in the terminal. Since tail is a much simpler program than cat, it will likely spend most of the time waiting for cat to put data into the buffer.</p>
<p>On a system with multiple processors, the two programs will not just be sharing alternating time slices on the same processor core, but likely running at the same time on separate cores.</p>
<p>To get into a little more detail, if you open some kind of process monitor (operating system specific) like 'top' in Linux you will see a whole list of running processes, most of which are effectively using 0% of the processor. Most applications, unless they are crunching data, spend most of their time doing nothing. This is good, because it allows other processes to have unfettered access to the processor according to their needs. This is accomplished in basically three ways. A process could get to a sleep(n) style instruction where it basically tells the kernel to wait n milliseconds before giving it another time slice to work with. Most commonly a program needs to wait for something from another program, like 'tail' waiting for more data to enter the buffer. In this case the operating system will wake up the process when more data is available. Lastly, the kernel can preempt a process in the middle of execution, giving some processor time slices to other processes. 'cat' and 'tail' are simple programs. In this example, tail spends most of it's time waiting for more data on the buffer, and cat spends most of it's time waiting for the operating system to retrieve data from the harddrive. The bottleneck is the speed (or slowness) of the physical medium that the file is stored on. That perceptible delay you might detect when you run this command for the first time is the time it takes for the read heads on the disk drive to seek to the position on the harddrive where 'file.txt' is. If you run the command a second time, the operating system will likely have the contents of file.txt cached in memory, and you will not likely see any perceptible delay (unless file.txt is very large, or the file is no longer cached.)</p>
<p>Most operations you do on your computer are IO bound, which is to say that you are usually waiting for data to come from your harddrive, or from a network device, etc.</p>
|
<p>cat will just print the data to standard out, which happens to be redirected to the standard in of tail. This can be seen in the man page of bash.</p>
<p>In other words, there is no pausing going on, tail is just reading from standard in and cat is just writing to standard out.</p>
| 3,960
|
<p>I would like to secure my hotend thermistor in a more reliable way (now it is just thermistor plugged in the hotend :D). I want to have a stainless steel tip for it to fix it inside hotend with a screw (The same approach as used for the heating cartridge). I have thermistors, but I cannot find any tips to buy separately.</p>
<p>Maybe you have some links for this kind of stainless-steel tips? Or some keywords I can use to search them?</p>
|
<p>The two most important things you can do are:</p>
<ul>
<li>Provide adequate cooling to solidify the plastic quickly</li>
<li>Minimize layer height</li>
</ul>
<p>Cooling is really obvious. You need the plastic to solidify before it has a chance to sag. PLA in particular has to shed a lot of heat before it is fully solid. A fan and air guide setup using a "squirrel-cage" radial blower around the nozzle is optimal. A little 30mm or 40mm axial fan will not provide optimal performance. </p>
<p>Low layer height when slicing is less obvious, but is extremely effective. When you use thinner layers, two things happen:</p>
<ul>
<li>There is less melted plastic per pass and a higher surface area to volume ratio, so the fresh material cools faster. </li>
<li>A larger percentage of each strand in the overhang is supported by the previous strand. If you do 0.2mm thick by 0.4mm wide, half of each strand is unsupported. But if you do 0.1mm thick by 0.4mm wide, only a quarter of each strand is unsupported. </li>
</ul>
<p>When you combine these two effects, it is possible to exceed 70 degree overhangs with good surface quality. </p>
<p>Another lesser factor is printing shells/perimeters inside-out rather than outside-in. This helps anchor the outermost strand a little better as the overhang is built. This is pretty minor though. </p>
|
<p>There's an answer <a href="https://3dprinting.stackexchange.com/questions/519/how-to-improve-face-that-are-printed-on-support?answertab=oldest#tab-top">here</a> that holds some of the same concepts. Regarding your questions: </p>
<ul>
<li><strong>Does lowering the temperature help? Raising it?</strong> : Yes, lowering the temperature can help. I've found that it is best to stay closer to the lower end of the material's melting point and just a bit above the point. Not only does this help with potential over extrusion, but also shortens the time it takes for the material to cool (refer to the link above). <em>However</em>, this could cause clogging if your temperature is too low. Keep an eye on your drive gear to see if there is too much friction while at lower temperatures. Increasing may keep the drive gear from "eating" your filament.</li>
<li><strong>Does speeding up or slowing down the print head help?</strong> : I prefer to print slower, most of the time, to allow the material to cool a bit more to avoid curling/warping (I primarily print with ABS, so it matters more). You might be able to give and take between temperature and speed. Consider if your nozzle is cooler and your speed is up, bridging gaps might yield the same results as if you proportionately swap these two values. This concept may only matter if you are in a pinch to get the part done. Again, I prefer slowing my machine down as it allows current/previous layers to cool more before continuing. This can be especially helpful with overhangs when paired with lowering your nozzle temperature.</li>
<li><strong>Does increasing/decreasing the extrusion diameter, or layer height help</strong> - I assume that extrusion diameter equals layer height (not difference in nozzle diameter, aka swapping nozzles). I'm not completely sure, but I think this depends on the part as well as slicing engine settings. For me, MakerWare is pretty good about proportionately adjusting extrusion steps with layer height, so I see an equal change in the width of the extrusion. I would think that in general, a larger layer height would yield a larger extrusion width. This would be helpful when printing overhangs, but may not be helpful when printing bridges (a larger strand will retain heat longer than a smaller one).</li>
</ul>
<p>Hopefully this helps, please comment if you need more information/clarification.</p>
| 210
|
<p>When I print large prints close to (but not exceeding) the maximum dimensions of the heated build platform on my Anet A8, the brim or skirt or the print itself is printed outside the heated bed, while there is some space left at the opposite sites. It appears as if the print is not in the center.</p>
<ul>
<li>Why is the print not centered on the bed?<br><em>It was centered in the slicer before generating the G-code.</em></li>
<li>How can I center the print to make it fit on the heated build platform?</li>
</ul>
|
<p>When centered in the slicer correctly, without offsets defined in the slicer, the printer is most probably incorrectly configured! Luckily you can do something about that! Basically, you will have to calibrate the printer for a new center.</p>
<h2>Printer origin?</h2>
<p>First of all, the firmware determines where your origin of the printer is. This implies that you need to properly set bed dimensions and offset values from the end stop switches in the firmware (usually not necessary out-of-the-box, but important when a newer or different firmware version is uploaded). These offsets determine where the origin of the bed plate is located. For Marlin firmware it is very common (for most printers) to have the origin specified at the front left corner (when facing the printer). From the <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/Configuration.h" rel="nofollow noreferrer">configuration of Marlin</a> we find the origin is e.g. in the front-left corner. Note that this can be rotated 180 degrees in certain printers, so the aft-right. Also be aware that there are a few printers that have the origin in the center, e.g. Delta's and a few Cartesian printers. Marlin definition (edited snippet) of a common bed layout:</p>
<pre>
* +-- BACK ---+
* | |
* L | (+) | R
* E | | I
* F | (-) N (+) | G
* T | | H
* | (-) | T
* | |
* O-- FRONT --+
* (0,0)
* .(-Xh, -Yh)
</pre>
<h2>How do I find the physical origin of the printer?</h2>
<p>This can be tested by instructing the head/nozzle to go to e.g. (0, 0, 15) using a <a href="/q/10573">terminal/console</a> or a simple G-code file with a move to that coordinate that you print from SD card (e.g. <code>G1 X0 Y0 Z15 F500</code>); <em>note a Z of 15 is chosen for safety!</em>. When this is performed, the nozzle should be at the (elevated, so X, Y) origin as defined by your firmware. Usually this is at the left front corner of your build plate (there may be clips there, so therefore the elevated value), but this may be different depending on the firmware settings or firmware brand.</p>
<p>Next step is to configure the slicer as such that this coincides with the actual origin. Incorrect slicer settings can cause the slicer to assume the origin is at a different position than your actual position. In Ultimaker Cura, the "Origin at center" is notoriously known for this when the physical origin is not in the center, but in a corner. When the slicer is properly instructed, but the origin is still not at the corner of the build plate (<strong>beware!</strong> in some printers the origin is in the middle of the plate) you might have incorrect endstop to origin offsets.</p>
<h2>Determine the offset first!</h2>
<p>To quantify the offset of the center as it is known by the printer software (firmware) it is advised to print a large square that is a few percentage smaller than the maximum size of the bed. E.g. you can create a square hull at e.g. 90 % of the dimensions of the bed (parametric designs are very useful for this purpose, see e.g. <a href="https://www.thingiverse.com/thing:2280529/" rel="nofollow noreferrer">this design</a>). There are many things (<code>.stl</code> models) to be found on the internet. If it includes a cross, even better as some platforms have a mark in the center of the bed.</p>
<p><em>Example of a bed center calibration model</em><br>
<a href="https://i.stack.imgur.com/9eM3Wm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9eM3Wm.jpg" alt="bed center calibration model" /></a></p>
<p>Once printed, measure the distance from every edge from the build platform to the printed square. If you fail to print the square, please check the level of the platform; <strong>this is also an excellent test for the level of your bed!</strong>
The measurements should give you a notion of the offset of the bed. E.g. for the X-axis you measure a distance of 12 mm on the left and 8 mm on the right (when facing the printer) you can easily deduce that the center is (12 - 8)/2 = 2 mm to the right (positive X direction). This implies that the printer manufacturer has done a lousy job by delivering you a printer with an offset bed; better said incorrectly configured in their firmware. Note this is not uncommon!</p>
<h2>How to fix this!</h2>
<p>Once you quantified the offset, you want to be sure that your next print prints in the middle of the bed. How to proceed? Basically there are a couple of solutions you can use, each with its own advantages and disadvantages.</p>
<ol>
<li><p>A simple solution (i.e. if the printer support this) is to adjust the position of the endstops. Alternatively you can print alternate endstop holders to match the position change as measured from the calibration print.</p>
</li>
<li><p>Another simple and popular solution is applying an <strong>offset in the slicer</strong>. You could do that in the printer options some of the available slicers. If such options are not available, you could add <strong>G-code commands in the start code</strong> to create the offset (e.g. <code>G1</code> X-2 moves to the left and <code>G92 X0</code> resets the X origin). Note that this is a quick fix and should be applied wisely. The printer does not know where the actual center is! You merely changed if after the homing sequence. Exchanging <code>.gcode</code> with fellow enthusiasts with the same printer may have adverse effects.</p>
</li>
</ol>
<p>A far better solution is to fix the center in the firmware so that the printer knows the <strong>actual</strong> center. This requires some extra effort by uploading firmware (files including configuration settings) to the printer or send G-code commands. The latter option will be discussed first.</p>
<ol start="3">
<li>A prerequisite of this method is that it requires the <a href="https://reprap.org/wiki/G-code" rel="nofollow noreferrer">G-code command</a> <code>[M206](https://reprap.org/wiki/G-code#M206:_Offset_axes)</code> to be supported by your firmware; note that not all 3D printer firmware solutions are able to use this G-code command for axes offset definition. E.g. the stock Anet A8 runs a modified Repetier version that does not support <code>M206</code>, it would be time to upload a new firmware like e.g. <a href="https://github.com/MarlinFirmware/Marlin" rel="nofollow noreferrer">Marlin Firmware</a> making this particular printer safer as the stock firmware does not include thermal runaway protection! See question: "<a href="/q/8466/">What is Thermal Runaway Protection?</a>". To send G-code commands to a printer you have the option to hook up your computer to the printer over USB and use a 3D printer program that support sending commands to the printer (this is called a terminal; i.e. an interface to the printer). Programs like <a href="http://www.pronterface.com/" rel="nofollow noreferrer">PronterFace</a>, <a href="https://www.repetier.com/" rel="nofollow noreferrer">Repetier-Host</a>, <a href="https://octoprint.org/" rel="nofollow noreferrer">OctoPrint</a>, and probably many more have such an interface. A simple alternative that works also is creating a text file (with <code>.gcode</code> extension) with the commands on separate lines and executing the "print". The following codes need to be sent: <code>M206</code> e.g. <code>M206 X-2 Y2</code> (move center left and to the back, note to use integer values, float values are not allowed!) and store this new center with <code>M500</code>.</li>
</ol>
<p>The final, best solution is to set it fixed in the firmware. This requires an upload of a more recent configured version of an applicable firmware. See e.g. question: "<a href="/q/5848">How to upload firmware to reprap printer?</a>". Note that there are different methods to upload a firmware to the board, it is best to search the internet for the applicable method for your board.</p>
<ol start="4">
<li>To do that you will have to be comfortable with computer software and tools to build source files and upload binary code to the printer. This depends on the type of firmware you choose and therefore cannot be described for each firmware in detail. Various sources on the internet describe this process. Generally speaking, it requires you to set the bed and offset values/positions correctly. For Marlin Firmware this comes down to changing the settings in the <a href="https://github.com/MarlinFirmware/Marlin/blob/1.1.x/Marlin/Configuration.h" rel="nofollow noreferrer">configuration file</a>, this is similar in other firmware software solutions:</li>
</ol>
<pre>
// The size of the print bed
#define X_BED_SIZE 220
#define Y_BED_SIZE 220
// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS -35 ; used to be -33, so 2 mm shift to left now
#define Y_MIN_POS -8 ; used to be -10, so 2 mm shift to the back
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
#define Z_MAX_POS 240
</pre>
|
<p>As to <strong>why</strong> this happens, particularly with a budget printer the end-stop mountings may not be particularly precisely located, or the moving part may actuate the endstop slightly differently in each build. In my case, replacing the hot end (and thus the whole carriage) gave me an offset of some cm. With this upgrade, it was impossible to retain the stock calibration since the extruder dimensions are quite different.</p>
<p>As to <strong>how to fix it</strong>, the easiest way for me was to modify the 'start g-code'. This fix only applies to the particular slicer, means that what I slice for my A8 won't be centred on the work maker-club Prusa, but doesn't need me to mess about with firmware or apply a per-model update.</p>
<p>After the Z-home operation, I already have a pre-extrude step. Prior to this, I set the actual position of what I want my homed point to be, using <code>G92</code></p>
<pre><code>M82 ; absolute extrusion mode
G28 ; home all
G92 X17 Y-12 ; re-define origin
G92 E0.0 ; reset extruder distance position
</code></pre>
| 959
|
<p>I have a struts-based webapp, and I would like the default "welcome" page to be an action. The only solutions I have found to this seem to be variations on making the welcome page a JSP that contains a redirect to the action. For example, in <code>web.xml</code>:</p>
<pre><code><welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</code></pre>
<p>and in <code>index.jsp</code>:</p>
<pre><code><%
response.sendRedirect("/myproject/MyAction.action");
%>
</code></pre>
<p>Surely there's a better way!</p>
|
<p>Personally, I'd keep the same setup you have now, but change the redirect for a forward. That avoids sending a header back to the client and having them make another request.</p>
<p>So, in particular, I'd replace the </p>
<pre><code><%
response.sendRedirect("/myproject/MyAction.action");
%>
</code></pre>
<p>in index.jsp with</p>
<pre><code><jsp:forward page="/MyAction.action" />
</code></pre>
<p>The other effect of this change is that the user won't see the URL in the address bar change from "<a href="http://server/myproject" rel="noreferrer">http://server/myproject</a>" to "<a href="http://server/myproject/index.jsp" rel="noreferrer">http://server/myproject/index.jsp</a>", as the forward happens internally on the server.</p>
|
<p>This works as well reducing the need of a new servlet or jsp</p>
<pre><code><welcome-file-list>
<welcome-file>/MyAction.action</welcome-file>
</welcome-file-list>
</code></pre>
| 6,045
|
<p>I'd like to be able to write a PHP class that behaves like an array and uses normal array syntax for getting & setting.</p>
<p>For example (where Foo is a PHP class of my making):</p>
<pre><code>$foo = new Foo();
$foo['fooKey'] = 'foo value';
echo $foo['fooKey'];
</code></pre>
<p>I know that PHP has the _get and _set magic methods but those don't let you use array notation to access items. Python handles it by overloading __getitem__ and __setitem__.</p>
<p>Is there a way to do this in PHP? If it makes a difference, I'm running PHP 5.2.</p>
|
<p>If you extend <code>ArrayObject</code> or implement <code>ArrayAccess</code> then you can do what you want.</p>
<ul>
<li><a href="http://php.net/arrayobject" rel="noreferrer">ArrayObject</a></li>
<li><a href="http://php.net/arrayaccess" rel="noreferrer">ArrayAccess</a></li>
</ul>
|
<p>Nope, casting just results in a normal PHP array -- losing whatever functionality your ArrayObject-derived class had. Check this out:</p>
<pre><code>class CaseInsensitiveArray extends ArrayObject {
public function __construct($input = array(), $flags = 0, $iterator_class = 'ArrayIterator') {
if (isset($input) && is_array($input)) {
$tmpargs = func_get_args();
$tmpargs[0] = array_change_key_case($tmpargs[0], CASE_LOWER);
return call_user_func_array(array('parent', __FUNCTION__), $tmp args);
}
return call_user_func_array(array('parent', __FUNCTION__), func_get_args());
}
public function offsetExists($index) {
if (is_string($index)) return parent::offsetExists(strtolower($index));
return parent::offsetExists($index);
}
public function offsetGet($index) {
if (is_string($index)) return parent::offsetGet(strtolower($index));
return parent::offsetGet($index);
}
public function offsetSet($index, $value) {
if (is_string($index)) return parent::offsetSet(strtolower($index, $value));
return parent::offsetSet($index, $value);
}
public function offsetUnset($index) {
if (is_string($index)) return parent::offsetUnset(strtolower($index));
return parent::offsetUnset($index);
}
}
$blah = new CaseInsensitiveArray(array(
'A'=>'hello',
'bcD'=>'goodbye',
'efg'=>'Aloha',
));
echo "is array: ".is_array($blah)."\n";
print_r($blah);
print_r(array_keys($blah));
echo $blah['a']."\n";
echo $blah['BCD']."\n";
echo $blah['eFg']."\n";
echo $blah['A']."\n";
</code></pre>
<p>As expected, the array_keys() call fails. In addition, is_array($blah) returns false. But if you change the constructor line to:</p>
<pre><code>$blah = (array)new CaseInsensitiveArray(array(
</code></pre>
<p>then you just get a normal PHP array (is_array($blah) returns true, and array_keys($blah) works), but all of the functionality of the ArrayObject-derived subclass is lost (in this case, case-insensitive keys no longer work). Try running the above code both ways, and you'll see what I mean.</p>
<p>PHP should either provide a native array in which the keys are case-insensitive, or make ArrayObject be castable to array without losing whatever functionality the subclass implements, or just make all array functions accept ArrayObject instances.</p>
| 9,083
|
<p>I installed a BLTouch bed leveling probe on my printer which uses Marlin 2.0.5.3.</p>
<p>Now the printer seems to be of two minds when it comes to finding the origin. Homing XY moves to the lower left as it always has, but homing Z moves not only to Z=0, but also to the center of the build plate. The printer knows this is (100,100,0) and is not mistakenly thinking it is (0,0,0).</p>
<p>This causes some issues such as now the nozzle wipe at the beginning of a print happens right in the center of where the print is supposed to be.</p>
<p>Is this expected behavior?</p>
|
<p>This is a consequence of enabling <code>Z_SAFE_HOMING</code>:</p>
<blockquote>
<p>Z Safe Homing prevents Z from homing when the probe (or nozzle) is outside bed area by moving to a defined XY point (by default, the middle of the bed) before Z Homing when homing all axes with <code>G28</code>. As a side-effect, X and Y homing are required before Z homing. If stepper drivers time out, X and Y homing will be required again.</p>
<p>Enable this option if a probe (not an endstop) is being used for Z homing. Z Safe Homing isn’t needed if a Z endstop is used for homing, but it may also be enabled just to have XY always move to some custom position after homing.</p>
</blockquote>
<p>My default Cura start G-code contained this sequence:</p>
<pre><code>G28 X0 Y0 ;move X/Y to min endstops
G28 Z0 ;move Z to min endstops
</code></pre>
<p>I changed this to</p>
<pre><code>G28 ;safe homing
G90 ;absolute positioning
G0 X0 Y0 ; move to bottom-left corner for nozzle wipe
</code></pre>
<p>However any oozing will still happen at the center of the build plate, which is a problem.</p>
|
<p>I had the same problem, solved it by inserting</p>
<pre><code>// Move X and Y to 0 after homing
process_subcommands_now_P("G1 X0 Y0 F5000");
</code></pre>
<p>at the end of <code>G28.cpp</code>, just before <code>ui.refresh();</code></p>
<p>This moves the print head to X0, Y0 and leaves Z untouched after the homing procedure. This way any oozing that might happen while the extruder heats up will be outside of the bed.</p>
| 1,686
|
<p>I have a product, X, which we deliver to a client, C every month, including bugfixes, enhancements, new development etc.) Each month, I am asked to err "guarantee" the quality of the product.</p>
<p>For this we use a number of statistics garnered from the tests that we do, such as:</p>
<ul>
<li>reopen rate (number of bugs reopened/number of corrected bugs tested)</li>
<li>new bug rate (number of new, including regressions, bugs found during testing/number of corrected bugs tested)</li>
<li>for each new enhancement, the new bug rate (the number of bugs found for this enhancement/number of mandays)</li>
</ul>
<p>and various other figures.</p>
<p>It is impossible, for reasons we shan't go into, to test everything every time.</p>
<p>So, my question is:</p>
<p>How do I estimate the number and type of bugs that remain in my software?
What testing strategies do I have to follow to make sure that the product is good?</p>
<p>I know this is a bit of an open question, but hey, I also know that there are no simple solutions.</p>
<p>Thanks.</p>
|
<p>I don't think you can ever really estimate the number of bugs in your app. Unless you use a language and process that allows formal proofs, you can never really be sure. Your time is probably better spent setting up processes to minimize bugs than trying to estimate how many you have.</p>
<p>One of the most important things you can do is have a good QA team and good work item tracking. You may not be able to do full regression testing every time, but if you have a list of the changes you've made to the app since the last release, then your QA people (or person) can focus their testing on the parts of the app that are expected to be affected.</p>
<p>Another thing that would be helpful is unit tests. The more of your codebase you have covered the more confident you can be that changes in one area didn't inadvertently affected another area. I've found this quite useful, as sometimes I'll change something and forget that it would affect another part of the app, and the unit tests showed the problem right away. Passed unit tests won't guarantee that you haven't broken anything, but they can help increase confidence that changes you make are working.</p>
<p>Also, this is a bit redundant and obvious, but make sure you have good bug tracking software. :)</p>
|
<p>How long is a piece of string? Ultimately what makes a quality product? Bugs gives some indication yes, but many other factors are involved, Unit Test coverage is a key factor in IMO. But in my experience the main factor that effects whether a product can be deemed quality or not, is good understanding of the problem that is being solved. Often what happens is, the 'problem' that the product is meant to solve is not understood correctly and developers end up inventing the solution to a problem they have flesh out in their head, and not the real problem, thus 'bugs' are made. I am a strong proponent of iterative <a href="http://en.wikipedia.org/wiki/Agile_software_development" rel="nofollow noreferrer">Agile</a> development, that way the product is constantly access against the 'problem' and the product does not stray to far from its goal.</p>
| 3,596
|
<p>I'm interested in writing eclipse plugins where do I start? </p>
<p>What resources have helped you?</p>
<p>I'm looking for:<br>
1. Tutorials<br>
2. Sites devoted to plugin development<br>
3. Books </p>
|
<p>You can find a good step by step detailed tutorial here:</p>
<p><a href="http://www.eclipsepluginsite.com/" rel="nofollow noreferrer">http://www.eclipsepluginsite.com/</a></p>
<p>Other tutorials:</p>
<p><a href="http://www.ibm.com/developerworks/opensource/library/os-eclipse-snippet/index.html?ca=dgr-lnxw16RichEclipse" rel="nofollow noreferrer">http://www.ibm.com/developerworks/opensource/library/os-eclipse-snippet/index.html?ca=dgr-lnxw16RichEclipse</a></p>
<p><a href="http://www.vogella.de/articles/EclipsePlugIn/article.html" rel="nofollow noreferrer">http://www.vogella.de/articles/EclipsePlugIn/article.html</a></p>
<p>A decent book, that I've used is "<a href="https://rads.stackoverflow.com/amzn/click/com/0321228472" rel="nofollow noreferrer" rel="nofollow noreferrer">Eclipse: Building Commercial-Quality Plug-Ins</a>".</p>
|
<p>Here's all the books available for developing Eclipse Plugins:
<a href="http://www.eclipseplugincentral.com/books-index-req-view_subcat-sid-4.html" rel="nofollow noreferrer">http://www.eclipseplugincentral.com/books-index-req-view_subcat-sid-4.html</a></p>
| 7,083
|
<p>Any ideas on how to implement tab completion for a .NET (C#) Console Application?
And I mean within an application that is run and then loops for user input (like if you run ftp.exe without any arguments), like this: </p>
<pre><code> string line = string.Empty;
while (line != "exit")
{
//do something here
Console.ReadLine();
}
</code></pre>
<p>I know I probably couldn't actually use readline, but I would like to be able to do tab completion at that same point where you retrieve input from the user.</p>
|
<p>Take a look at this code from the Mono project
<a href="http://tirania.org/blog/archive/2008/Aug-26.html" rel="noreferrer">http://tirania.org/blog/archive/2008/Aug-26.html</a>
I played with it some the other day.
It does a lot of command line editingy, but I don't think it does line completion.</p>
|
<p><a href="https://github.com/tonerdo/readline" rel="nofollow noreferrer">https://github.com/tonerdo/readline</a> is what you need.
great lib available as a nuget from the talented dev tonerdo.</p>
<p><em>pasted from the site:</em></p>
<blockquote>
<p>...<br/>
<strong>ReadLine</strong> is a GNU Readline like library built in pure C#
It can serve as a drop in replacement for the inbuilt <code>Console.ReadLine()</code> and brings along with it some of the terminal goodness you get from unix shells, like command history navigation and tab auto completion.<br/>
...</p>
</blockquote>
| 6,843
|
<p>I'm looking for a wordpress-like blog interface to put inside a Joomla hosted site. The admin interface of Joomla is quirky enough and hard enough to use that daily updates are infeasible. </p>
<p>What I am looking for is an easy-to-use posting interface that supports multiple users with different accounts/names, a tagging scheme, and easy find by date/user/tag functionality.</p>
<p>In particular I'm looking for a relatively easy-to-deploy, out-of-the-box solution, and would prefer not to hack rss feeds together or write too much custom code. I know there are <a href="http://extensions.joomla.org/component/option,com_mtree/task,listcats/cat_id,1759/Itemid,35/" rel="nofollow noreferrer">several extensions</a> out there but they all receive largely mixed reviews... Has anyone used any of these? Or has anyone had experience putting something like this together?</p>
|
<p>Well you could do this - have a wordpress installation. Get the users to post there and then use the RSS feed from it (or the XML RPC Blogging API) to update the Joomla installation. You will have to write the update piece once, but then all the headache is gone.</p>
|
<p>After doing a bit more research I decided to go with the open source <a href="http://www.joomlify.com/" rel="nofollow noreferrer">MojoBlog</a>. It was quite easy to install and configure and after a few stalls and hang ups that were resolved via perusal of their forums I was up and running. The edit interface is not ideal but it much better than Joomla admin, and it has multi-user-support, tag categorization, modules for viewing by tag, date, etc. Think it will suffice for my needs in the short term.</p>
| 8,937
|
<p>I am writing a C program in Linux. Commands like execv() require a path in the form of a C string. Is there a command that will return the current path in the form of a C-style string?</p>
|
<p><a href="http://www.opengroup.org/onlinepubs/009695399/functions/getcwd.html" rel="nofollow noreferrer">getcwd()</a>:</p>
<blockquote>
<h3><em>SYNOPSIS</em></h3>
<pre><code>#include <unistd.h>
char *getcwd(char *buf, size_t size);
</code></pre>
<h3><em>DESCRIPTION</em></h3>
<p>The <em>getcwd()</em> function shall place an absolute pathname of the current working directory in the array pointed to by <em>buf, and return buf</em>. The pathname copied to the array shall contain no components that are symbolic links. The <em>size</em> argument is the size in bytes of the character array pointed to by the <em>buf</em> argument. If <em>buf</em> is a null pointer, the behavior of getcwd() is unspecified.</p>
<h3><em>RETURN VALUE</em></h3>
<p>Upon successful completion, <em>getcwd()</em> shall return the <em>buf</em> argument. Otherwise, <em>getcwd()</em> shall return a null pointer and set <em>errno</em> to indicate the error. The contents of the array pointed to by <em>buf</em> are then undefined....</p>
</blockquote>
|
<p>You need to grab the environment variable PWD (present working directory).</p>
<p>I'm not sure what the library it is in, but it is a standard Linux header.</p>
<p>I was thinking of <a href="http://www.opengroup.org/onlinepubs/000095399/functions/getenv.html" rel="nofollow noreferrer">getenv()</a> which would help if you also need to run system commands and need the various bin paths located in PATH.</p>
| 6,925
|
<p>In a C# (feel free to answer for other languages) loop, what's the difference between <code>break</code> and <code>continue</code> as a means to leave the structure of the loop, and go to the next iteration?</p>
<p>Example:</p>
<pre><code>foreach (DataRow row in myTable.Rows)
{
if (someConditionEvalsToTrue)
{
break; //what's the difference between this and continue ?
//continue;
}
}
</code></pre>
|
<p><code>break</code> will exit the loop completely, <code>continue</code> will just <strong>skip</strong> the current iteration.</p>
<p>For example:</p>
<pre><code>for (int i = 0; i < 10; i++) {
if (i == 0) {
break;
}
DoSomeThingWith(i);
}
</code></pre>
<p>The break will cause the loop to exit on the first iteration - <code>DoSomeThingWith</code> will never be executed. This here:</p>
<pre><code>for (int i = 0; i < 10; i++) {
if(i == 0) {
continue;
}
DoSomeThingWith(i);
}
</code></pre>
<p>Will not execute <code>DoSomeThingWith</code> for <code>i = 0</code>, but the loop will <strong>continue</strong> and <code>DoSomeThingWith</code> will be executed for <code>i = 1</code> to <code>i = 9</code>.</p>
|
<p>As for other languages:</p>
<pre class="lang-vb prettyprint-override"><code> 'VB
For i=0 To 10
If i=5 then Exit For '= break in C#;
'Do Something for i<5
next
For i=0 To 10
If i=5 then Continue For '= continue in C#
'Do Something for i<>5...
Next
</code></pre>
| 2,816
|
<p>I am looking for a simple system to manage inbound emails from a support mailbox for a group with about 3 support people. I've looked at <a href="http://otrs.org/" rel="nofollow noreferrer">OTRS</a> which seems to have the features that we need. Unfortunately, so far the UI still looks like a confusing mess.</p>
<p>Are there any good FOSS tools that would meet this need? I've heard murmurings that something called fooogzeeebugzo might have similar features, but it seems quite expensive for such simple needs.</p>
|
<p>I have to agree, Fogbugz is probably the best out there. I have used both the hosted version and the purchased version which I hosted. It is top-notch.</p>
|
<p>We use FogBugz...er, "fooogzeeebugzo"...and while it may be a bit expensive for your needs, it works very well.</p>
| 6,205
|
<p>How can I find the high water mark (the historical maximum number of concurrent users) in an <strong>oracle database (9i)</strong>.</p>
|
<p>This should do the trick:</p>
<pre><code>SELECT sessions_highwater FROM v$license;
</code></pre>
|
<pre><code>select max_utilization from v$resource_limit where resource_name = 'sessions';
</code></pre>
<p>A good overview of Oracle system views can be found <a href="http://www.adp-gmbh.ch/ora/misc/dynamic_performance_views.html" rel="nofollow noreferrer">here</a>.</p>
| 2,963
|
<p>Is there a Windows equivalent of the Unix command, <em>nice</em>?</p>
<p>I'm specifically looking for something I can use at the command line, and <strong>not</strong> the "Set Priority" menu from the task manager.</p>
<p>My attempts at finding this on Google have been thwarted by those who can't come up with better adjectives.</p>
|
<p>If you want to set priority when launching a process you could use the built-in <a href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/start" rel="noreferrer">START</a> command:</p>
<pre class="lang-batch prettyprint-override"><code>START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/WAIT] [/B] [command/program] [parameters]
</code></pre>
<p>Use the low through belownormal options to set priority of the launched command/program. Seems like the most straightforward solution. No downloads or script writing. The other solutions probably work on already running procs though.</p>
|
<p>Maybe you want to consider using <a href="http://www.donationcoder.com/Software/Mouser/proctamer/index.html" rel="noreferrer">ProcessTamer</a> that "automatize" the process of downgrading or upgrading process priority based in your settings. </p>
<p>I've been using it for two years. It's very simple but really effective!</p>
| 2,619
|
<p>Is there an IDE that I can load on a Blackberry, E71, or an iPhone?</p>
|
<p>Apple released iPhone SDK for XCode a while back, check out developer.apple.com and Nokia also release their own SDK check out forum.nokia.com</p>
<p>But for pure Java Midlet goodness, i would recommend Netbeans (netbeans.org) their netbeans mobile application editor is a gem, second to none.</p>
<p>To answer your question, i don't think any phone is powerful enough to compile and test the code on themselves, so no ...</p>
|
<p>Not that I know of, typically you'll develop apps on a desktop machine (PC/MAC whatever) and download/control the application on the phone. Also I don't think Java is available on a standard (non-cracked) iPhone.</p>
| 6,213
|
<p>I need to retrieve all rows from a table where 2 columns combined are all different. So I want all the sales that do not have any other sales that happened on the same day for the same price. The sales that are unique based on day and price will get updated to an active status.</p>
<p>So I'm thinking:</p>
<pre><code>UPDATE sales
SET status = 'ACTIVE'
WHERE id IN (SELECT DISTINCT (saleprice, saledate), id, count(id)
FROM sales
HAVING count = 1)
</code></pre>
<p>But my brain hurts going any farther than that.</p>
|
<pre><code>SELECT DISTINCT a,b,c FROM t
</code></pre>
<p>is <em>roughly</em> equivalent to: </p>
<pre><code>SELECT a,b,c FROM t GROUP BY a,b,c
</code></pre>
<p>It's a good idea to get used to the GROUP BY syntax, as it's more powerful. </p>
<p>For your query, I'd do it like this:</p>
<pre><code>UPDATE sales
SET status='ACTIVE'
WHERE id IN
(
SELECT id
FROM sales S
INNER JOIN
(
SELECT saleprice, saledate
FROM sales
GROUP BY saleprice, saledate
HAVING COUNT(*) = 1
) T
ON S.saleprice=T.saleprice AND s.saledate=T.saledate
)
</code></pre>
|
<p>I want to select the distinct values from one column 'GrondOfLucht' but they should be sorted in the order as given in the column 'sortering'. I cannot get the distinct values of just one column using</p>
<pre><code>Select distinct GrondOfLucht,sortering
from CorWijzeVanAanleg
order by sortering
</code></pre>
<p>It will also give the column 'sortering' and because 'GrondOfLucht' AND 'sortering' is not unique, the result will be ALL rows.</p>
<p>use the GROUP to select the records of 'GrondOfLucht' in the order given by 'sortering</p>
<pre><code>SELECT GrondOfLucht
FROM dbo.CorWijzeVanAanleg
GROUP BY GrondOfLucht, sortering
ORDER BY MIN(sortering)
</code></pre>
| 7,802
|
<p>I just updated my Maker Select Plus from the stock (I believe RepRap-based) firmware to Advi3pp, which is Marlin based. The printer starts up and everything seems okay, but I haven't actually tried a print yet and there was a message during the upgrade about deleting incompatible settings. </p>
<p>What do I need to do to recalibrate the printer following the firmware upgrade?</p>
|
<p>If it is Marlin based or RepRap based, many parameters are stored in EEPROM memory. A G-code command <a href="https://reprap.org/wiki/G-code#M502:_Read_parameters_from_.22configuration.h.22" rel="nofollow noreferrer">M502: Read parameters from "configuration.h"</a> would reset all parameters that can be changed to their default value as defined in your configuration file. Don't forget to follow the <code>M502</code> command with a <code>M500</code> command to store the loaded parameters to EEPROM. This would overwrite all previous settings.</p>
<p><sub><em>From the linked source, <code>M502</code>:</em></sub></p>
<blockquote>
<p>This command resets all tunable parameters to their default values, as set in the firmware. This doesn't reset any parameters stored in the EEPROM, so it must be followed with M500 if you want to do that.</p>
</blockquote>
<p>You can send these commands over a terminal interface to the printer using applications such as Pronterface, OctoPrint, Repetier-Host, and probably many more, or store the commands in a G-code file (e.g. a text file with a <code>.g</code> extension) and print the file using an SD card.</p>
|
<p>Looks like I don't need to do anything. I printed a 20 mm calibration cube, and aside from some elephant footing it came out as clean and as close to the model dimensions as anything else I've ever put through the machine, with no changes. </p>
<p>So I'll recommend this as a first step to anyone else: start a 20 mm cube going, watch it closely early on to be sure you're getting adequate extrusion and bed adhesion. If it fails here you may need to adjust settings. When it's done, measure it and see where you are. You might not need to do anything else.</p>
| 1,348
|
<p>Are there any safety risks inherent to PLA plastics used for 3D printing?</p>
<p>The material safety data sheet of some PLA plastics indicates low risks at a toxicological level, but I'd like to make sure some other factor isn't overlooked.
(<a href="https://printparts.com/datasheets/PLA-MSDS.pdf" rel="nofollow noreferrer">1</a>, <a href="https://www.nhh.com.hk/en/3dprinting/document/pla_classic/MSDS_PLA_Classic.pdf" rel="nofollow noreferrer">2</a>, <a href="http://wwwassets.e-ci.com/PDF/SDS/CI-D-07-PLA-3D-Printing-Filament.pdf" rel="nofollow noreferrer">3</a>)</p>
<blockquote>
<hr>
SECTION 11: TOXICOLOGICAL INFORMATION
<hr>
PRINCIPLE ROUTES OF EXPOSURE: Eye contact, Skin contact, Inhalation, Ingestion.
ACUTE TOXICITY: None noted during use.
<p>LOCAL EFFECTS: Product dust may be irritating to eyes, skin and
respiratory system. Particles, like other inert materials, are
mechanically irritating to eyes. Ingestion may cause gastrointestinal
irritation, nausea, vomiting and diarrhea.</p>
<p>SPECIFIC EFFECTS: May cause skin irritation and/or dermatitis.
Ingestion may cause gastrointestinal irritation, nausea, vomiting and
diarrhea. Inhalation of dust may cause shortness of breath, tightness
of the chest, a sore throat and cough. Burning produces irritant
fumes.</p>
<p>CHRNOIC TOXICITY: None noted during use.</p>
<p>REPRODUCTIVE TOXICITY: No data is available on the product itself.<br />
CARCINOGENIC EFFECTS: None of the components of this product are
listed as carcinogens by IARC, NTP, or OSHA.</p>
</blockquote>
|
<p>Extrusion of PLA through a nozzle can cause microparticles to be generated (referenced as "dust" in your document) which can be temporarily airborne. If ingested through breathing for an extended period of time, this can cause respiratory distress. Your document claims "no acute toxicity" from this.</p>
<p>My personal experience is that:</p>
<ul>
<li>Different plastics at different temperatures emit a variable amount of this dust.</li>
<li>A cloth mask effectively blocks it.</li>
<li>The dust settles very quickly, in both time and distance.</li>
<li>The effects (for me at least) are irritation only (well described in your document), and disappear completely in a time proportional to the length of exposure, but not more than a day or so.</li>
<li>PLA is not near as bad as other plastics like ABS. But either of these burns is much worse.</li>
</ul>
<p>The paper <a href="https://www.sciencedirect.com/science/article/pii/S2214785320391902" rel="nofollow noreferrer">"Review on particle emissions during fused deposition modeling of acrylonitrile butadiene styrene and polylactic acid polymers"</a> goes into this in greater detail.<br />
There are probably others.</p>
|
<p>If you are concerned about inhalation (and I think you should be), you should use a hierarchy of controls to mitigate the risk.</p>
<p>NIOSH (part of the CDC) have a <a href="https://www.cdc.gov/niosh/docs/2020-115/default.html" rel="nofollow noreferrer">good document outlining how to mitigate the risks of 3D printing particulate emissions.</a></p>
<p>Note that the smell you experience may be VOCs, not particles. Both are important to block. To do so, use a respirator with both particulate and organic vapour filters, in addition to an air purification/local exhaust ventilation system. The ‘carbon filters’ often seen in 3D printers do almost nothing for particulates, only nuisance levels of vapours.</p>
| 2,180
|
<p>How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby?</p>
|
<p>This explanation is based on a commented <a href="http://gist.github.com/4069" rel="noreferrer">Ruby script</a> from a friend of mine. If you want to improve the script, feel free to update it at the link.</p>
<p>First, note that when Ruby calls out to a shell, it typically calls <code>/bin/sh</code>, <em>not</em> Bash. Some Bash syntax is not supported by <code>/bin/sh</code> on all systems.</p>
<p>Here are ways to execute a shell script:</p>
<pre><code>cmd = "echo 'hi'" # Sample string that can be used
</code></pre>
<ol>
<li><p><code>Kernel#`</code> , commonly called backticks – <code>`cmd`</code></p>
<p>This is like many other languages, including Bash, PHP, and Perl.</p>
<p>Returns the result (i.e. standard output) of the shell command.</p>
<p>Docs: <a href="http://ruby-doc.org/core/Kernel.html#method-i-60" rel="noreferrer">http://ruby-doc.org/core/Kernel.html#method-i-60</a></p>
<pre><code>value = `echo 'hi'`
value = `#{cmd}`
</code></pre></li>
<li><p>Built-in syntax, <code>%x( cmd )</code></p>
<p>Following the <code>x</code> character is a delimiter, which can be any character.
If the delimiter is one of the characters <code>(</code>, <code>[</code>, <code>{</code>, or <code><</code>,
the literal consists of the characters up to the matching closing delimiter,
taking account of nested delimiter pairs. For all other delimiters, the
literal comprises the characters up to the next occurrence of the
delimiter character. String interpolation <code>#{ ... }</code> is allowed.</p>
<p>Returns the result (i.e. standard output) of the shell command, just like the backticks.</p>
<p>Docs: <a href="https://docs.ruby-lang.org/en/master/syntax/literals_rdoc.html#label-Percent+Strings" rel="noreferrer">https://docs.ruby-lang.org/en/master/syntax/literals_rdoc.html#label-Percent+Strings</a></p>
<pre><code>value = %x( echo 'hi' )
value = %x[ #{cmd} ]
</code></pre></li>
<li><p><code>Kernel#system</code></p>
<p>Executes the given command in a subshell. </p>
<p>Returns <code>true</code> if the command was found and run successfully, <code>false</code> otherwise.</p>
<p>Docs: <a href="http://ruby-doc.org/core/Kernel.html#method-i-system" rel="noreferrer">http://ruby-doc.org/core/Kernel.html#method-i-system</a></p>
<pre><code>wasGood = system( "echo 'hi'" )
wasGood = system( cmd )
</code></pre></li>
<li><p><code>Kernel#exec</code></p>
<p>Replaces the current process by running the given external command.</p>
<p>Returns none, the current process is replaced and never continues.</p>
<p>Docs: <a href="http://ruby-doc.org/core/Kernel.html#method-i-exec" rel="noreferrer">http://ruby-doc.org/core/Kernel.html#method-i-exec</a></p>
<pre><code>exec( "echo 'hi'" )
exec( cmd ) # Note: this will never be reached because of the line above
</code></pre></li>
</ol>
<p>Here's some extra advice:
<code>$?</code>, which is the same as <code>$CHILD_STATUS</code>, accesses the status of the last system executed command if you use the backticks, <code>system()</code> or <code>%x{}</code>.
You can then access the <code>exitstatus</code> and <code>pid</code> properties:</p>
<pre><code>$?.exitstatus
</code></pre>
<p>For more reading see:</p>
<ul>
<li><a href="http://www.elctech.com/blog/i-m-in-ur-commandline-executin-ma-commands" rel="noreferrer">http://www.elctech.com/blog/i-m-in-ur-commandline-executin-ma-commands</a></li>
<li><a href="http://blog.jayfields.com/2006/06/ruby-kernel-system-exec-and-x.html" rel="noreferrer">http://blog.jayfields.com/2006/06/ruby-kernel-system-exec-and-x.html</a></li>
<li><a href="http://tech.natemurray.com/2007/03/ruby-shell-commands.html" rel="noreferrer">http://tech.natemurray.com/2007/03/ruby-shell-commands.html</a></li>
</ul>
|
<p>Here's a cool one that I use in a ruby script on OS X (so that I can start a script and get an update even after toggling away from the window):</p>
<pre><code>cmd = %Q|osascript -e 'display notification "Server was reset" with title "Posted Update"'|
system ( cmd )
</code></pre>
| 2,441
|
<p>How do I delimit a Javascript data-bound string parameter in an anchor <code>OnClick</code> event?</p>
<ul>
<li>I have an anchor tag in an ASP.NET Repeater control.</li>
<li>The <code>OnClick</code> event of the anchor contains a call to a Javascript function.</li>
<li>The Javascript function takes a string for its input parameter.</li>
<li>The string parameter is populated with a data-bound value from the Repeater.</li>
</ul>
<p>I need the "double quotes" for the <code>Container.DataItem</code>.<br />
I need the 'single quotes' for the <code>OnClick</code>.</p>
<p>And I still need <em>one more delimiter</em> (triple quotes?) for the input string parameter of the Javascript function call.</p>
<p>Since I can't use 'single quotes' again, how do I ensure the Javascript function knows the input parameter is a string and not an integer?</p>
<p>Without the extra quotes around the input string parameter, the Javascript function thinks I'm passing in an integer.</p>
<p>The anchor:</p>
<pre><code><a id="aShowHide" onclick='ToggleDisplay(<%# DataBinder.Eval(Container.DataItem, "JobCode") %>);' >Show/Hide</a>
</code></pre>
<p>And there is my Javascript:</p>
<pre><code><script language="JavaScript" type="text/javascript">
/* Shows/Hides the Jobs Div */
function ToggleDisplay(jobCode)
{
/* Each div has its ID set dynamically ('d' plus the JobCode) */
var elem = document.getElementById('d' + jobCode);
if (elem)
{
if (elem.style.display != 'block')
{
elem.style.display = 'block';
elem.style.visibility = 'visible';
}
else
{
elem.style.display = 'none';
elem.style.visibility = 'hidden';
}
}
}
</script>
</code></pre>
|
<p>I had recently similar problem and the only way to solve it was to use plain old HTML codes for single (<code>&#39;</code>) and double quotes (<code>&#34;</code>). </p>
<p>Source code was total mess of course but it worked.</p>
<p>Try</p>
<pre><code><a id="aShowHide" onclick='ToggleDisplay(&#34;<%# DataBinder.Eval(Container.DataItem, "JobCode") %>&#34;);'>Show/Hide</a>
</code></pre>
<p>or</p>
<pre><code><a id="aShowHide" onclick='ToggleDisplay(&#39;<%# DataBinder.Eval(Container.DataItem, "JobCode") %>&#39;);'>Show/Hide</a>
</code></pre>
|
<p>Try putting the extra text inside the server-side script block and concatenating.</p>
<pre><code>onclick='<%# "ToggleDisplay(""" & DataBinder.Eval(Container.DataItem, "JobCode") & """);" %>'
</code></pre>
<p>Edit: I'm pretty sure you could just use double quotes outside the script block as well.</p>
| 2,413
|
<p>Is there such thing as a 3D printer with a very large diameter nozzle, that can make low fidelity, large and fast prints? I'm picturing a soft serve ice-cream machine on a gantry, with a hopper. You feed it shredded plastic, and it prints bricks, or boards.</p>
|
<p>Yes these exist. 3D printers using pellets is not uncommon for industry, but for the user at home this might be a different question. Pellets are the pre-fabricate before it is extruded into filament (small balls/cylinders of plastic).</p>
<p><a href="https://i.stack.imgur.com/0RIoy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0RIoy.png" alt="enter image description here" /></a><br>
<em>Random image showing a variety of pellets in different colors</em></p>
<p>There are even processes to turn used plastic into pellets, so if you combine it all this should be very doable. The problem is to get a consistent type of waste plastic to feed your machine. The size of the nozzle doesn't matter, as long as your shredding, compressing and heating process can keep up with the flow you need. It would be an excellent idea to get rid of plastic waste and turning these into building bricks e.g. for insulation of heat.</p>
<hr />
<p><em>I've seen prototype printers printing PEEK from pallets having a nozzle (slot) diameter of several millimeters.</em></p>
|
<p>You can certainly get large nozzles, but the material for extrusion still needs to be consistent. So any chunked plastic would have to be melted and that will produce an erratic flow at the extruder.</p>
<p>By reforming your shredded plastic into a consistent string of filament, then the printer has a steady supply of material to use. There are already filament extruders for the small shop, but they're still expensive for the home user. The main problems are getting consistent thickness of filament, and minimising contaminants. Also colours tend to be lost and muddied. These might be economical if you have a print farm and are consuming a spool a day on average.</p>
<p>On a large scale, there are "3d printers" that can place a special quick-drying concrete and produce small buildings as homes in a matter of days. However they're fed a special mixture of smooth cement and accelerators to set the concrete ready for the next layer.</p>
<p><a href="https://i.stack.imgur.com/y1vWs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y1vWs.jpg" alt="Tecla 3d printed house" /></a></p>
| 2,054
|
<p>We are using VS 2008 Team System with the automated test suite, and upon running tests the test host "randomly" locks up. I actually have to kill the VSTestHost process and re-run the tests to get something to happen, otherwise all tests sit in a "pending" state.</p>
<p>Has anyone experience similar behavior and know of a fix? We have 3 developers here experiencing the same behavior.</p>
|
<p>When you say lock up, do you mean VS is actually hung, or do the tests not run?</p>
<p>The easiest way to track down what is going on would be to look at a dump of the hung process. If you are on Vista, just right-click on the process and choose to create a memory dump. If you are on Windows XP, and don't have the <a href="http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx" rel="nofollow noreferrer">Debugging Tools for Windows</a> installed, you can get a memory dump using ntsd.exe. You'll need the process ID, which you can get from Task Manager by adding the PID column to the Processes tab display.</p>
<p>Once you have that, run the following commands:</p>
<pre><code>ntsd -p <PID>
.dump C:\mydump.dmp
</code></pre>
<p>You can then either inspect that dump using <a href="http://blogs.msdn.com/johan/archive/2007/11/13/getting-started-with-windbg-part-i.aspx" rel="nofollow noreferrer">WinDBG and SOS</a> or if you can post the dump somewhere I'd be happy to take a look at it.</p>
<p>In any case, you'll want to likely take two dumps about a minute apart. That way if you do things like !runaway you can see which threads are working which will help you track down why it is hanging.</p>
<p>One other question - are you on VS2008 SP1?</p>
|
<p>When you say lock up, do you mean VS is actually hung, or do the tests not run?</p>
<p>The easiest way to track down what is going on would be to look at a dump of the hung process. If you are on Vista, just right-click on the process and choose to create a memory dump. If you are on Windows XP, and don't have the <a href="http://www.microsoft.com/whdc/DevTools/Debugging/default.mspx" rel="nofollow noreferrer">Debugging Tools for Windows</a> installed, you can get a memory dump using ntsd.exe. You'll need the process ID, which you can get from Task Manager by adding the PID column to the Processes tab display.</p>
<p>Once you have that, run the following commands:</p>
<pre><code>ntsd -p <PID>
.dump C:\mydump.dmp
</code></pre>
<p>You can then either inspect that dump using <a href="http://blogs.msdn.com/johan/archive/2007/11/13/getting-started-with-windbg-part-i.aspx" rel="nofollow noreferrer">WinDBG and SOS</a> or if you can post the dump somewhere I'd be happy to take a look at it.</p>
<p>In any case, you'll want to likely take two dumps about a minute apart. That way if you do things like !runaway you can see which threads are working which will help you track down why it is hanging.</p>
<p>One other question - are you on VS2008 SP1?</p>
| 7,351
|
<p>Is there something like the Python descriptor protocol implemented in other languages? It seems like a nice way to increase modularity/encapsulation without bloating your containing class' implementation, but I've never heard of a similar thing in any other languages. Is it likely absent from other languages because of the lookup overhead?</p>
|
<p>I've not heard of a direct equivalent either. You could probably achieve the same effect with macros, especially in a language like Lisp which has extremely powerful macros.</p>
<p>I wouldn't be at all surprised if other languages start to incorporate something similar because it is so powerful.</p>
|
<p>Ruby and C# both easily let you create accessors by specifying getter/setter methods for an attribute, much like in Python. However, this isn't designed to naturally let you write the code for these methods in another class the way that Python allows. In practice, I'm not sure how much this matters, since every time I've seen an attribute defined through the descriptor protocol its been implemented in the same class.</p>
<p>EDIT: Darn my dyslexia (by which I mean careless reading). For some reason I've always read "descriptor" as "decorator" and vice versa, even when I'm the one typing both of them. I'll leave my post intact since it has valid information, albeit information which has absolutely nothing to do with the question.</p>
<p>The term "decorator" itself is actually the name of a design pattern described in the famous "Design Patterns" book. The Wikipedia article contains many examples in different programming languages of decorator usage: <a href="http://en.wikipedia.org/wiki/Decorator_pattern" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Decorator_pattern</a></p>
<p>However, the decorators in that article object-oriented; they have classes implementing a predefined interface which lets another existing class behave differently somehow, etc. Python decorators act in a functional way by replacing a function at runtime with another function, allowing you to effectively modify/replace that function, insert code, etc.</p>
<p>This is known in the Java world as Aspect-Oriented programming, and the AspectJ Java compiler lets you do these kinds of things and compile your AspectJ code (which is a superset of Java) into Java bytecode.</p>
<p>I'm not familiar enough with C# or Ruby to know what their version of decorators would be.</p>
| 5,443
|
<p>I'm learning objective-C and Cocoa and have come across this statement:</p>
<blockquote>
<p>The Cocoa frameworks expect that global string constants rather than string literals are used for dictionary keys, notification and exception names, and some method parameters that take strings.</p>
</blockquote>
<p>I've only worked in higher level languages so have never had to consider the details of strings that much. What's the difference between a string constant and string literal?</p>
|
<p>In Objective-C, the syntax <code>@"foo"</code> is an <strong>immutable</strong>, <strong>literal</strong> instance of <code>NSString</code>. It does not make a constant string from a string literal as Mike assume.</p>
<p>Objective-C compilers typically <em>do</em> intern literal strings within compilation units — that is, they coalesce multiple uses of the same literal string — and it's possible for the linker to do additional interning across the compilation units that are directly linked into a single binary. (Since Cocoa distinguishes between mutable and immutable strings, and literal strings are always also immutable, this can be straightforward and safe.)</p>
<p><strong>Constant</strong> strings on the other hand are typically declared and defined using syntax like this:</p>
<pre><code>// MyExample.h - declaration, other code references this
extern NSString * const MyExampleNotification;
// MyExample.m - definition, compiled for other code to reference
NSString * const MyExampleNotification = @"MyExampleNotification";
</code></pre>
<p>The point of the syntactic exercise here is that you can make <em>uses of</em> the string efficient by ensuring that there's only one instance of that string in use <em>even across multiple frameworks</em> (shared libraries) in the same address space. (The placement of the <code>const</code> keyword matters; it guarantees that the pointer itself is guaranteed to be constant.)</p>
<p>While burning memory isn't as big a deal as it may have been in the days of 25MHz 68030 workstations with 8MB of RAM, comparing strings for equality can take time. Ensuring that most of the time strings that are equal will also be pointer-equal helps.</p>
<p>Say, for example, you want to subscribe to notifications from an object by name. If you use non-constant strings for the names, the <code>NSNotificationCenter</code> posting the notification could wind up doing a lot of byte-by-byte string comparisons when determining who is interested in it. If most of these comparisons are short-circuited because the strings being compared have the same pointer, that can be a big win.</p>
|
<p>Let's use C++, since my Objective C is totally non-existent.</p>
<p>If you stash a string into a constant variable:</p>
<pre><code>const std::string mystring = "my string";
</code></pre>
<p>Now when you call methods, you use my_string, you're using a string constant:</p>
<pre><code>someMethod(mystring);
</code></pre>
<p>Or, you can call those methods with the string literal directly:</p>
<pre><code>someMethod("my string");
</code></pre>
<p>The reason, presumably, that they encourage you to use string constants is because Objective C doesn't do "interning"; that is, when you use the same string literal in several places, it's actually a different pointer pointing to a separate copy of the string.</p>
<p>For dictionary keys, this makes a huge difference, because if I can see the two pointers are pointing to the same thing, that's much cheaper than having to do a whole string comparison to make sure the strings have equal value.</p>
<p><strong>Edit:</strong> Mike, in C# strings are immutable, and literal strings with identical values all end pointing at the same string value. I imagine that's true for other languages as well that have immutable strings. In Ruby, which has mutable strings, they offer a new data-type: symbols ("foo" vs. :foo, where the former is a mutable string, and the latter is an immutable identifier often used for Hash keys).</p>
| 4,532
|
<p>I was just about to start using my 3D printers heated bed to warm a chemical reaction in a container and was thinking it would be great to be able to get the bed stepping back and forth to stir the pot.
Can anyone already up to speed in programming G-code walk me through a quick and dirty way to get the X-axis on my old Printrbot metal doing a couple of micro-steps either way in an endless loop? Or suggest some software out there that could achieve the same effect? </p>
|
<p>Basically you need to write a G-code file yourself. This is a plain text file with a <code>.g</code> extension.</p>
<p>You need to home the printer with <code>G28</code>, then move the Y axis all the way forward (for a Prusa style printer) with <code>G1 F1500 Y{ymax}</code> (where <code>{ymax}</code> is the length of the bed). Now raise the head with a similar command <code>G1 F500 Z{zmax}</code> (where <code>{zmax}</code> is the height of the printer volume).</p>
<p>Heating the bed is done with <a href="https://reprap.org/wiki/G-code#M190:_Wait_for_bed_temperature_to_reach_target_temp" rel="nofollow noreferrer"><code>M190 S60</code></a> (set and wait to reach 60 °C).</p>
<p>You can now rock the Y axis by moving it fast, e.g. with <code>G1 F5000 Y{ymax-5}</code>, <code>G1 Y{ymax-1}</code>, <code>Y{ymax-5}</code>, <code>Y{ymax-1}</code>, etc.</p>
|
<p>Never mind, figured the quickest dirtiest way myself - created a tall thin cylinder shape model in Blender and positioned it in Repetier so the printer head will be clear of the table as it moves. Then just broke off the filament that was currently in the printer so it will stop feeding once the current piece gets to the end of the feeder wheel. - not an endless loop but should give me a good 10 or 20 minutes of agitation before I need to restart the print if necessary.</p>
| 1,647
|
<p>Here is the sample code for my accordion:</p>
<pre><code><mx:Accordion x="15" y="15" width="230" height="599" styleName="myAccordion">
<mx:Canvas id="pnlSpotlight" label="SPOTLIGHT" height="100%" width="100%" horizontalScrollPolicy="off">
<mx:VBox width="100%" height="80%" paddingTop="2" paddingBottom="1" verticalGap="1">
<mx:Repeater id="rptrSpotlight" dataProvider="{aSpotlight}">
<sm:SmallCourseListItem
viewClick="PlayFile(event.currentTarget.getRepeaterItem().fileID);"
Description="{rptrSpotlight.currentItem.fileDescription}"
FileID = "{rptrSpotlight.currentItem.fileID}"
detailsClick="{detailsView.SetFile(event.currentTarget.getRepeaterItem().fileID,this)}"
Title="{rptrSpotlight.currentItem.fileTitle}"
FileIcon="{iconLibrary.getIcon(rptrSpotlight.currentItem.fileExtension)}" />
</mx:Repeater>
</mx:VBox>
</mx:Canvas>
</mx:Accordion>
</code></pre>
<p>I would like to include a button in each header like so:</p>
<p><img src="https://i.stack.imgur.com/EN3kP.jpg" alt="wishful" onclick="alert('xss')"></p>
|
<p>Thanks, I got it working using <a href="http://code.google.com/p/flexlib/" rel="nofollow noreferrer">FlexLib</a>'s CanvasButtonAccordionHeader.</p>
|
<p>You will have to create a custom header renderer, add a button to it and position it manually. Try something like this:</p>
<pre><code><mx:Accordion>
<mx:headerRenderer>
<mx:Component>
<AccordionHeader xmlns="mx.containers.accordionClasses.*">
<mx:Script>
<![CDATA[
import mx.controls.Button;
private var extraButton : Button;
override protected function createChildren( ) : void {
super.createChildren();
if ( extraButton == null ) {
extraButton = new Button();
addChild(extraButton);
}
}
override protected function updateDisplayList( unscaledWidth : Number, unscaledHeight : Number ) : void {
super.updateDisplayList(unscaledWidth, unscaledHeight);
extraButton.setActualSize(unscaledHeight - 6, unscaledHeight - 6);
extraButton.move(unscaledWidth - extraButton.width - 3, (unscaledHeight - extraButton.height)/2);
}
]]>
</mx:Script>
</AccordionHeader>
</mx:Component>
</mx:headerRenderer>
<mx:HBox label="1"><Label text="Text 1"/></HBox>
<mx:HBox label="1"><Label text="Text 2"/></HBox>
<mx:HBox label="1"><Label text="Text 3"/></HBox>
</mx:Accordion>
</code></pre>
| 3,274
|
<p>From what I understand, when you hook up the <a href="http://rads.stackoverflow.com/amzn/click/B007KG0ZYI">Switching Power Supply 12v Dc 30a 360w</a> to the wall outlet, you have to be <strong>very careful</strong>; careful not to get the wires mixed up; careful not to have anyone or anything touch the leads (in fact the first proper project I intend to print out will be <a href="http://www.thingiverse.com/thing:31659">a casing to fit around the switching power supply</a>), or just order one from someone. </p>
<p>Now there are three wires that go into the US wall of particular concern, and these wires come out of a standard PC cable with the female end cut off, and they hook the power supply. Like the external casing, these three wires are also insulated, and when you take the insulation off the bare wires and connect it to the power supply, you have to use Electrical connectors of some sort to connect them to the power supply's screw leads.</p>
<p>I bought some electrical connectors just for this purpose, but I'm not entirely certain they will be good for this purpose, so I thought I'd check here first.</p>
<p><a href="https://i.stack.imgur.com/RTAFs.jpg"><img src="https://i.stack.imgur.com/RTAFs.jpg" alt="Picture of GE Electrical Connectors 50956, 40 piece set"></a></p>
<p>There are specifications on the back:</p>
<pre><code>╬──────────────────╬──────────────────────╬─────────────╬───────────╬
╬ ╬ AWG ╬ Wire Size ╬ Stud Size ╬
╬──────────────────╬──────────────────────╬─────────────╬───────────╬
╬ Spade Terminals ╬
╬──────────────────╬──────────────────────╬─────────────╬───────────╬
╬ YF1.25-35 (red) ╬ 22-16 ╬ 0.5-1.5 ╬ 3.7 ╬
╬──────────────────╬──────────────────────╬─────────────╬───────────╬
╬ Ring Terminals ╬
╬──────────────────╬──────────────────────╬─────────────╬───────────╬
╬ YF1.25-4 (red) ╬ 22-16 ╬ .5-1.5 ╬ 4.3 ╬
╬──────────────────╬──────────────────────╬─────────────╬───────────╬
╬ Butt Splice ╬
╬──────────────────╬──────────────────────╬─────────────╬───────────╬
╬ BF-1.2SS (red) ╬ 22-16 ╬ .5-1.5 ╬ n/a ╬
╬──────────────────╬──────────────────────╬─────────────╬───────────╬
</code></pre>
<p>Not sure if I should use ring or spade terminals, and I don't know what wire size to use; and I don't know what wire grade is inside a standard PC power cord or even if these are safe connectors to use for this.</p>
|
<p>It is okay to just use bare wires in the type of screw connector found on your power supply. They're designed for it; they have a little plate under the screw that prevents the wires from being frayed by the screw.</p>
<p>If you want neater wire termination, you should use one of the spade type ones. Pick the smallest size that fits your wires.</p>
<p>PC power cords are generally fitted with an IEC C13 plug, and those are rated for 10A (meaning also the wires themselves will be able to carry at least that much current). This is fine for any home 3D printer which usually draws a fraction of that.</p>
|
<p>The block on the supply will accept the bare wire</p>
<p><a href="https://i.imgur.com/RvlyTNR.jpg" rel="nofollow noreferrer"><img src="https://i.imgur.com/RvlyTNR.jpg" alt="enter image description here"></a></p>
<p>you <em>could</em> use the yellow in the middle on the right, but the screw on the block essentially does its own crimp.</p>
| 150
|
<p>I'm looking for a pre-written component (w/source) for a Delphi project that I'm working on, to generate mind-maps / concept-maps similar to these:</p>
<p><a href="http://en.wikipedia.org/wiki/Image:MindMeister_screenshot_OS_X.jpg" rel="noreferrer">http://en.wikipedia.org/wiki/Image:MindMeister_screenshot_OS_X.jpg</a>
<a href="http://en.wikipedia.org/wiki/Image:XMIND_2008_in_Windows_Vista.png" rel="noreferrer">http://en.wikipedia.org/wiki/Image:XMIND_2008_in_Windows_Vista.png</a></p>
<p>Any ideas?</p>
|
<p>As a former Delphi developer, I sympathize. It used to be that you could find a free component with source for just about anything. You probably know about the <a href="http://delphi.icm.edu.pl/" rel="nofollow noreferrer">Delphi Super Page</a> (my old go-to source for everything Delphi). I looked; no mind-mapping components, there. (Of course, the site has not been updated in about 2 years).</p>
<p>I do have a suggestion, though, but it's not optimal: <a href="http://staruml.sourceforge.net/en/" rel="nofollow noreferrer">StarUML</a> was written in Delphi, and it contains custom components for creating UML diagrams. The source is available for download, and it seems to me that the UML primitives (boxes, lines, clouds and such) could be adapted to your purpose. The web site is <a href="http://staruml.sourceforge.net/en/" rel="nofollow noreferrer">http://staruml.sourceforge.net/en/</a>.</p>
<p>I know it's not ideal, but at least you would not have to start from scratch. </p>
<p>Good luck!</p>
|
<p>JVCL : Demo called
JvDesignerDemo</p>
| 3,440
|
<p>I work in a Windows environment and would prefer to deploy code to IIS. At the same time I would like to code in Python.</p>
<p>Having read that IIS can run fastCGI application, I went to the IIS site where it describes in detail how to get PHP up and running but not much about anything else.</p>
<p>Does anyone have experience getting a <strong>Python</strong> framework <strong>running under IIS</strong> using something other that plain old CGI?</p>
<p>If so can you explain to direct me to some instructions on setting this up?</p>
|
<p>There shouldn't be any need to use FastCGI. There exists a <a href="https://github.com/hexdump42/isapi-wsgi" rel="noreferrer">ISAPI extension for WSGI</a>.</p>
|
<p>We can use iiswsgi framework to setup WSGI over IIS since it is compatible with IIS web server's FastCGI protocol.It's bundled with distutils for building, distribution and installing packages with the help of Microsoft Web Deploy and Web Platform Installer. </p>
<p>For more info refer the following link:</p>
<p><a href="https://pypi.python.org/pypi/iiswsgi#serving-python-wsgi-applications-natively-from-iis" rel="nofollow">Serving Python WSGI applications natively from IIS</a></p>
| 6,948
|
<p>After a year of printing smaller models, I finally went to print something that would take up most of the build plate from left to right and realized that my nozzle cannot reach "true" X home.</p>
<p>As seen in this picture:
<a href="https://i.stack.imgur.com/h4oFv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h4oFv.jpg" alt="enter image description here" /></a>
the X-axis endstop does not allow a true X0, thus losing me precious mm of print space! I over-exaggerate, but truly is there any way to shift the X-axis more to the left or the Y axis/build plate more to the right to gain full bed usage?</p>
<p>Additional photo showing that the actual hotend plate is hitting the endstop:
<a href="https://i.stack.imgur.com/b5NRV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b5NRV.jpg" alt="enter image description here" /></a></p>
<p>Is this an Ender 3 problem in general that I have missed in my internet searches on this or is it just a manufacturing lottery that I unfortunately lost?</p>
|
<p>The rated build space for the Ender 3 takes into account the few mm of inaccessible bed width at the Xmin side, along with a similar strip at the Xmax where the hotend carriage runs into the bracket that holds the wheels for that side's Z frame. If your slicer has an Ender 3 profile, the space it allows you to use will print on the Ender 3 (unless you have bull clips holding a glass build surface in place; then they'll interfere, but mainly on the Ymin and Ymax edges).</p>
<p>Don't forget, even though your actual bed is 235 mm square, the <em>usable</em> build volume is rated as only 200 mm square (by 225 mm high).</p>
|
<p>You do have hit the true home. You will have to physically move the endstop to alter that position. Your problem is, that the endstop-home is on the build area - and that is printer dependant. My Ender 3 has about 4 mm diagonal distance from the bed in its physical home, for which I accounted via a firmware swap, including a "virtual" firmware home.</p>
| 1,839
|
<p>Why is it so hard to do this in Java? If you want to have any kind of module system you need to be able to load JAR files dynamically. I'm told there's a way of doing it by writing your own <code>ClassLoader</code>, but that's a lot of work for something that should (in my mind at least) be as easy as calling a method with a JAR file as its argument.</p>
<p>Any suggestions for simple code that does this?</p>
|
<p>The reason it's hard is security. Classloaders are meant to be immutable; you shouldn't be able to willy-nilly add classes to it at runtime. I'm actually very surprised that works with the system classloader. Here's how you do it making your own child classloader:</p>
<pre><code>URLClassLoader child = new URLClassLoader(
new URL[] {myJar.toURI().toURL()},
this.getClass().getClassLoader()
);
Class classToLoad = Class.forName("com.MyClass", true, child);
Method method = classToLoad.getDeclaredMethod("myMethod");
Object instance = classToLoad.newInstance();
Object result = method.invoke(instance);
</code></pre>
<p>Painful, but there it is.</p>
|
<p>I personally find that <a href="http://download.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html" rel="nofollow">java.util.ServiceLoader</a> does the job pretty well. You can get an example <a href="http://java.sun.com/developer/technicalArticles/javase/extensible/" rel="nofollow">here</a>.</p>
| 8,576
|
<p>I've occasionally had issues with excess filament residue getting stuck to the print bed. <a href="https://3dprinting.stackexchange.com/questions/78/how-can-i-stop-my-print-bed-tape-from-sticking-to-the-filament">There are ways to prevent this</a>, but sometimes even these precautions aren't enough. Over time, residue can build up. I've observed this in some printers, though not others.</p>
<p>Are there any techniques to best clean print beds? In the past, I've used various typical cleaning supplies, with different degrees of success. However, I don't know if this will lead to damage to the printer over time.</p>
<p>The printer I'm using has a glass print bed, which I occasionally partially cover with blue painter's tape during printing.</p>
|
<ul>
<li><p>If you are printing with ABS (or PLA), acetone will dissolve it. Simply pour
some on the bed and wipe it off (beware, acetone can damage beds that have a coating or a plastic sheet over them, be sure to test this first).</p>
</li>
<li><p>Heating the bed back up may make the plastic softer and easier to
remove.</p>
</li>
<li><p>If you are using tape on the bed, you could remove the tape to remove
the plastic stuck to the tape.</p>
</li>
</ul>
|
<p>I use a razor blade scraper to get stuff off that is sticking.
Priory to printing I heat and level the build plate, then wipe it down with alcohol to get any greasey fingerprints off of it.</p>
<p><a href="http://www.thingiverse.com/make:177038" rel="nofollow">My Scraper</a></p>
| 133
|
<p>(assume php5) consider</p>
<pre><code><?php
$foo = 'some words';
//case 1
print "these are $foo";
//case 2
print "these are {$foo}";
//case 3
print 'these are ' . $foo;
?>
</code></pre>
<p>Is there much of a difference between 1 and 2?</p>
<p>If not, what about between 1/2 and 3?</p>
|
<p>Well, as with all "What might be faster in real life" questions, you can't beat a real life test.</p>
<pre><code>function timeFunc($function, $runs)
{
$times = array();
for ($i = 0; $i < $runs; $i++)
{
$time = microtime();
call_user_func($function);
$times[$i] = microtime() - $time;
}
return array_sum($times) / $runs;
}
function Method1()
{
$foo = 'some words';
for ($i = 0; $i < 10000; $i++)
$t = "these are $foo";
}
function Method2()
{
$foo = 'some words';
for ($i = 0; $i < 10000; $i++)
$t = "these are {$foo}";
}
function Method3()
{
$foo = 'some words';
for ($i = 0; $i < 10000; $i++)
$t = "these are " . $foo;
}
print timeFunc('Method1', 10) . "\n";
print timeFunc('Method2', 10) . "\n";
print timeFunc('Method3', 10) . "\n";
</code></pre>
<p>Give it a few runs to page everything in, then...</p>
<p>0.0035568</p>
<p>0.0035388</p>
<p>0.0025394</p>
<p>So, as expected, the interpolation are virtually identical (noise level differences, probably due to the extra characters the interpolation engine needs to handle). Straight up concatenation is about 66% of the speed, which is no great shock. The interpolation parser will look, find nothing to do, then finish with a simple internal string concat. Even if the concat were expensive, the interpolator will still have to do it, <strong>after</strong> all the work to parse out the variable and trim/copy up the original string.</p>
<p><strong>Updates By Somnath:</strong></p>
<p>I added Method4() to above real time logic.</p>
<pre><code>function Method4()
{
$foo = 'some words';
for ($i = 0; $i < 10000; $i++)
$t = 'these are ' . $foo;
}
print timeFunc('Method4', 10) . "\n";
Results were:
0.0014739
0.0015574
0.0011955
0.001169
</code></pre>
<p>When you are just declaring a string only and no need to parse that string too, then why to confuse PHP debugger to parse. I hope you got my point.</p>
|
<p>Practically there is no difference at all! See the timings: <a href="http://micro-optimization.com/single-vs-double-quotes" rel="nofollow">http://micro-optimization.com/single-vs-double-quotes</a> </p>
| 3,458
|
<pre><code>INSERT INTO tblExcel (ename, position, phone, email) VALUES ('Burton, Andrew', 'Web Developer / Network Assistant', '876-9259', 'aburton@wccs.edu')
</code></pre>
<p>I've got an Access table that has five fields: id, ename, position, phone, and email...each one is plain text field with 50 characters, save for position which is 255 and id which is an autoincrement field. I'm using a VB.NET to read data from an Excel table, which gets pushed into a simple class that's used to fill out that query. I do the same thing with two other tables, whose data are pulled from a DB2 table and a MySQL table through. The other two work, but this simple INSERT loop keeps failing, so I don't think it's my "InsertNoExe" function that handles all the OleDb stuff.</p>
<p>So, um, does that query, any of the field titles, etc. look bogus? I can post other bits of code if anyone wants to see it.</p>
<p><strong>EDIT:</strong> Fixed. I wasn't sure if the wide image counted as a Stack Overflow bug or not, which is why I left it.</p>
<p><strong>EDIT 2:</strong> I'm dense. I use a try...catch to see the bogus query, and don't even check the ex.messsage. Gah.</p>
<pre><code>INSERT INTO tblExcel (ename, position, phone, email) VALUES ('Burton, Andrew', 'Web Developer / Network Assistant', '876-9259', 'aburton@wccs.edu')
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at EmployeeList.EmployeeDatabase.ExeNonQuery(String sql) in C:\andy\html\code\vb\EmployeeList\EmployeeDatabase.vb:line 263
Syntax error in INSERT INTO statement.
</code></pre>
<p><strong>EDIT 3:</strong> Thank you, Chris.</p>
|
<p>I beleive "position" is a reserved word.</p>
<p>Try...</p>
<p>INSERT into tblExcel (ename, [position], phone, email) VALUES (...</p>
<p><a href="http://office.microsoft.com/en-us/access/HP010322491033.aspx" rel="nofollow noreferrer">Reserved Words</a></p>
|
<p>The spacing of "Web Developer / Network Assistant" looks a little wonky, maybe there is a hidden character in there (carriage return?)</p>
<p>I'd try taking the slash out, and see if the insert works, if not try taking all punctuation out. Then add it back and maybe you will be able to identify the bug.</p>
| 6,907
|
<p>I am currently using the following command to upload my site content:</p>
<pre><code>scp -r web/* user@site.com:site.com/
</code></pre>
<p>This works great except that the .htaccess file is not sent. Presumably, this is because it's hidden.</p>
<p>I have tried adding a second line to send the file explicitely:</p>
<pre><code>scp -r web/.htaccess user@site.com:site.com/.htaccess
</code></pre>
<p>This works great except now I have to enter my password twice.</p>
<p>Any thoughts on how to make this deploy with only 1 or 0 entries of my password?</p>
|
<p>Just combine the two commands:</p>
<pre><code>scp -r web/* web/.htaccess user@site.com:site.com/
</code></pre>
<p>If you want 0 entries of your password you can set up <a href="http://sial.org/howto/openssh/publickey-auth/" rel="noreferrer">public key authentication</a> for ssh/scp.</p>
|
<p>A word of caution - don't attempt to match dotted files (like <code>.htaccess</code>) with <code>.*</code> - this inconveniently also matches <code>..</code>, and would result in copying all the files on the path to the root directory. I did this once (with <code>rm</code>, no less!) and I had to rebuild the server because I'd messed with <code>/var</code>.</p>
<p>@jwmittag:</p>
<p>I just did a test on Ubuntu and <code>.*</code> matches when I use <code>cp</code>. Here's an example:</p>
<pre><code>root@krash:/# mkdir a
root@krash:/# mkdir b
root@krash:/# mkdir a/c
root@krash:/# touch a/d
root@krash:/# touch a/c/e
root@krash:/# cp -r a/c/.* b
cp: will not create hard link `b/c' to directory `b/.'
root@krash:/# ls b
d e
</code></pre>
<p>If <code>.*</code> did not match <code>..</code>, then <code>d</code> shouldn't be in <code>b</code>.</p>
| 5,389
|
<p>I'm using namespaces in a project and Eclipse PDT, my IDE of choice, recognizes them as syntax errors. Not only it renders its convenient error checking unusable, but it also ruins Eclipse's PHP explorer.</p>
<p>5.3 features are coming to PDT 2.0 scheduled for release in December. Are there any alternatives for the present moment? I'm looking for 5.3 syntax highlighting and error checking at the least.</p>
|
<p>Some threads that have been addressed by the various PHP IDE developers regarding the status of 5.3 syntax support:</p>
<ul>
<li><strong>PHPEclipse</strong>: <a href="http://www.phpeclipse.net/ticket/636" rel="nofollow noreferrer">http://www.phpeclipse.net/ticket/636</a> or <a href="http://www.google.com.au/search?q=php+5.3+phpeclipse" rel="nofollow noreferrer">google</a></li>
<li><strong>Aptana</strong>: <a href="http://forums.aptana.com/viewtopic.php?t=6538" rel="nofollow noreferrer">http://forums.aptana.com/viewtopic.php?t=6538</a> or <a href="http://www.google.com.au/search?q=php+5.3+aptana" rel="nofollow noreferrer">google</a></li>
<li><strong>PDT</strong>: <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=234938" rel="nofollow noreferrer">http://bugs.eclipse.org/bugs/show_bug.cgi?id=234938</a> or <a href="http://www.google.com.au/search?q=php+pdt+5.3" rel="nofollow noreferrer">google</a></li>
<li><strong>TextMate</strong>: <a href="http://www.nabble.com/PHP-Namespace-Support-td19784898.html" rel="nofollow noreferrer">http://www.nabble.com/PHP-Namespace-Support-td19784898.html</a> (Namespace support) or <a href="http://www.google.com.au/search?q=php+pdt+5.3" rel="nofollow noreferrer">google</a></li>
</ul>
|
<p>Have you tried Aptana Studio or the Aptana plugin for Eclipse? I'm not sure if the Aptana plugin supports PHP, but Aptana Studio does. That might have what you are looking for.</p>
| 8,790
|
<p>I'm using a 200x200 mm PCB Mk2B which connects to the MOSFET of the D8 pin on a RAMPS 1.4 shield. I used 12 V power source for heat bed so I connected positive to pin 1 and negative to both pin 2 & 3 of the bed. Heat bed worked properly. But the wires that connects power source to power supply pin on RAMPS were being heated badly. I think the problem is come from heat bed because when I unplugged heat bed, wires were cool down instantly. </p>
<p>Can someone helps me with this problem. I'm just a newbie in this area.</p>
|
<p>This can be achieved with start G-code adaptations, this requires no software changes. Cura, and most slicers, have the ability to use placeholders (basically variables or maybe better: constants). These placeholders are substituted with the correct value upon slicing.</p>
<p>To sequentially heat the bed and hotend you would need to add the following into your start G-code:</p>
<pre>
M117 Heating bed 1st...
M190 S{material_bed_temperature_layer_0}
M117 Heating core 2nd...
M109 S{material_print_temperature_layer_0}
</pre>
<p>For simultaneous heating you need to add:</p>
<pre>
M140 S{material_bed_temperature_layer_0} ; set bed temperature to e.g. 55 °C and continue
M104 S{material_print_temperature_layer_0} ; set hot end temperature to e.g. 210 °C and continue
M190 S{material_bed_temperature_layer_0} ; wait for bed temperature to reach e.g. 55 °C
M109 S{material_print_temperature_layer_0} ; wait for hot end temperature to reach e.g. 210 °C
</pre>
<p>Note that Cura is very limited in using placeholders. E.g. Slic3r allows for arithmetic using the placeholders. The following example shows heating the bed first to the bed first layer temperature minus 10 degrees Celsius; then the hotend starts heating and heatbed starts further heating up to the final temperature. For my machine this results in the bed and hotend being at final temperature at the same time; so no time is wasted and printing can start.</p>
<pre>
M117 Heating bed...
M190 S{[first_layer_bed_temperature]-10}
M140 S[first_layer_bed_temperature]
M117 Heating core...
M109 S[first_layer_temperature_0]
M190 S[first_layer_bed_temperature]
</pre>
|
<p>It is a little annoying, what <code>Cura</code> is doing for me is forcing to wait. On start G-code I have:</p>
<pre><code>; Ender 3 Custom Start G-code
G92 E0 ; Reset Extruder
;*** Start Dual Nozzle/Bed Preheating ***
M140 S60 ; start preheating the bed
M104 S200 T0 ; start preheating hotend
G28 ; home
M190 S60 ; heat to Cura Bed setting
M109 S200
;*** End Preheating ***M420 S1; Load Mesh Bed Level
</code></pre>
<p>But on the generated G-code I have:</p>
<pre><code>;Generated with Cura_SteamEngine 4.9.0
M140 S60
M105
M190 S60
M104 S200
M105
M109 S200
M82 ;absolute extrusion mode
; Ender 3 Custom Start G-code
G92 E0 ; Reset Extruder
;*** Start Dual Nozzle/Bed Preheating ***
M140 S60 ; start preheating the bed
M104 S200 T0 ; start preheating hotend
G28 ; home
M190 S60 ; heat to Cura Bed setting
M109 S200
</code></pre>
<p>In the end I'm changing it directly on G-code what is a pain</p>
| 1,611
|
<p>Using MVC out of the box I found the generated URLs can be misleading and I wanted to know if this can be fixed or if my approach/understanding is wrong.</p>
<p>Suppose I have a CreateEgg page, which has a form on it, and once the form is filled in and submitted the user is taken to a ListEggs page with the new egg in it.</p>
<p>So my egg controller will look some thing like this:</p>
<pre><code>public class EggController : Controller
{
public void Add()
{
//do stuff
RenderView("CreateEgg", viewData);
}
public void Create()
{
//do stuff
RenderView("ListEggs", viewData);
}
}
</code></pre>
<p>So my first page will have a url of something like <a href="http://localhost/egg/add" rel="nofollow noreferrer">http://localhost/egg/add</a> and the form on the page will have an action of:</p>
<pre><code>using (Html.Form<EggController>(c => c.Create())
</code></pre>
<p>Meaning the second page will have a url of <a href="http://localhost/Egg/Create" rel="nofollow noreferrer">http://localhost/Egg/Create</a>, to me this is misleading, the action should be called Create, because im creating the egg, but a list view is being displayed so the url of <a href="http://localhost/Egg/List" rel="nofollow noreferrer">http://localhost/Egg/List</a> would make more scene. How do I achieve this without making my view or action names misleading?</p>
|
<p>The problem is your action does two things, violating the Single Responsibility Principle.</p>
<p>If your Create action redirects to the List action when it's done creating the item, then this problem disappears.</p>
|
<p>ActionVerbs Outlined in Scott Gu's <a href="http://weblogs.asp.net/scottgu/archive/2008/09/02/asp-net-mvc-preview-5-and-form-posting-scenarios.aspx" rel="nofollow noreferrer">post</a> seem to be a good approch;</p>
<p>Scott says:</p>
<blockquote>
<p>You can create overloaded
implementations of action methods, and
use a new [AcceptVerbs] attribute to
have ASP.NET MVC filter how they are
dispatched. For example, below we can
declare two Create action methods -
one that will be called in GET
scenarios, and one that will be called
in POST scenarios</p>
</blockquote>
<pre><code>[AcceptVerbs("GET")]
public object Create() {}
[AcceptVerbs("POST")]
public object Create(string productName, Decimal unitPrice) {}
</code></pre>
| 5,934
|
<p>Occasionally a program on a Windows machine goes crazy and just hangs. So I'll call up the task manager and hit the "End Process" button for it. However, this doesn't always work; if I try it enough times then it'll usually die eventually, but I'd really like to be able to just kill it immediately. On Linux I could just <code>kill -9</code> to guarantee that a process will die.</p>
<p>This also could be used for writing batch scripts and writing batch scripts is programming.</p>
<p><strong>Is there some</strong> program or <strong>command that comes with Windows that will always kill a process?</strong> A free third-party app would be fine, although I'd prefer to be able to do this on machines I sit down at for the first time.</p>
|
<p>"End Process" on the Processes-Tab calls <code>TerminateProcess</code> which is the most ultimate way Windows knows to kill a process.</p>
<p>If it doesn't go away, it's currently locked waiting on some kernel resource (probably a buggy driver) and there is nothing (short of a reboot) you could do to make the process go away.</p>
<p>Have a look at this blog-entry from wayback when: <a href="http://blogs.technet.com/markrussinovich/archive/2005/08/17/unkillable-processes.aspx" rel="noreferrer">http://blogs.technet.com/markrussinovich/archive/2005/08/17/unkillable-processes.aspx</a></p>
<p>Unix based systems like Linux also have that problem where processes could survive a <code>kill -9</code> if they are in what's known as "Uninterruptible sleep" (shown by top and ps as state <code>D</code>) at which point the processes sleep so well that they can't process incoming signals (which is what <code>kill</code> does - sending signals).</p>
<p>Normally, Uninterruptible sleep should not last long, but as under Windows, broken drivers or broken userpace programs (<code>vfork</code> without <code>exec</code>) can end up sleeping in <code>D</code> forever.</p>
|
<p>When ntsd access is denied, try:</p>
<p>ZeroWave was designed to be a simple tool that will provide a multilevel termination of any kind of process.</p>
<p>ZeroWave is also a easy-to-use program due to its simple installation and its very friendly graphical interface.</p>
<p>ZeroWave has three termination modes and with the "INSANE" mode can terminate any kind of process that can run on Windows.</p>
<p>It seems that ZeroWave can't kill avp.exe</p>
| 7,262
|
<p>When using the app_offline.htm feature of ASP.NET, it only allows html, but no images. Is there a way to get images to display <strong>without having to point them to a different url on another site</strong>?</p>
|
<p>Yes, it just can't come from the site that has the app_offline.htm file. The image would have to be hosted elsewhere. </p>
|
<p>You could just convert your images to base64 and then display them:</p>
<pre><code> <html>
<body>
<h1>
Web under maintenance with image in base64
</h1>
<img src="data:image/png;base64,iVBORw0K...=">
</body>
</html>
</code></pre>
<p>I've created a <a href="https://jsfiddle.net/fh12sujg/" rel="nofollow noreferrer">Fiddle</a> where you can see it in action</p>
| 5,270
|
<p>As part of some error handling in our product, we'd like to dump some stack trace information. However, we experience that many users will simply take a screenshot of the error message dialog instead of sending us a copy of the full report available from the program, and thus I'd like to make some minimal stack trace information available in this dialog.</p>
<p>A .NET stack trace on my machine looks like this:</p>
<pre><code>at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path)
at LVKWinFormsSandbox.MainForm.button1_Click(Object sender, EventArgs e) in C:\Dev\VS.NET\Gatsoft\LVKWinFormsSandbox\MainForm.cs:line 36
</code></pre>
<p>I have this question:</p>
<p>The format looks to be this:</p>
<pre><code>at <class/method> [in file:line ##]
</code></pre>
<p>However, the <em>at</em> and <em>in</em> keywords, I assume these will be localized if they run, say, a norwegian .NET runtime instead of the english one I have installed.</p>
<p>Is there any way for me to pick apart this stack trace in a language-neutral manner, so that I can display only the file and line number for those entries that have this?</p>
<p>In other words, I'd like this information from the above text:</p>
<pre><code>C:\Dev\VS.NET\Gatsoft\LVKWinFormsSandbox\MainForm.cs:line 36
</code></pre>
<p>Any advice you can give will be helpful.</p>
|
<p>You should be able to get a StackTrace object instead of a string by saying</p>
<pre><code>var trace = new System.Diagnostics.StackTrace(exception);
</code></pre>
<p>You can then look at the frames yourself without relying on the framework's formatting.</p>
<p>See also: <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.stacktrace.aspx" rel="noreferrer">StackTrace reference</a></p>
|
<p>As alternative, log4net, though potentially dangerous, has given me better results than System.Diagnostics. Basically in log4net, you have a method for the various log levels, each with an Exception parameter. So, when you pass the second exception, it will print the stack trace to whichever appender you have configured. </p>
<p>example: <code>Logger.Error("Danger!!!", myException );</code></p>
<p>The output, depending on configuration, looks something like</p>
<pre><code>System.ApplicationException: Something went wrong.
at Adapter.WriteToFile(OleDbCommand cmd) in C:\Adapter.vb:line 35
at Adapter.GetDistributionDocument(Int32 id) in C:\Adapter.vb:line 181
...
</code></pre>
| 7,495
|
<p>Let's say, I want to print a box for putting game tokens in.</p>
<p>It is an empty cube, but the top layer is missing.</p>
<p>I do not need full walls. It could have holes in it resulting in a mesh structured wall, like a fence or a shopping cart.</p>
<p>What pattern should I use for the best object stability and print speed?
What programs can I use to design this? (I do not want to manually add 100 holes in my design).</p>
|
<p>Holes in vertical walls will make it take significantly <em>more</em> time to print, not less. Rather than being able to make a continuous path around the box on each layer, keeping the print head at the desired speed the whole time, the printer will have to run around each connected component of the layer separately, slowing down, retracting, speeding up to travel, slowing down at the destination, unretracting, and speeding back up <em>each time</em>.</p>
|
<p>Definitely the speed will be worse after adding holes (or the quality otherwise, if object's skin is printed fast), though some filament savings may appear.</p>
<p>But regarding "object stability": because adding holes will normally cause the slower printing (because of "skin structures" around holes), then walls might get bit stronger or have better layer adhesion (comparing to line speed, the material, the printing temperature, etc.). Then stability might indeed improve, especially when walls are thin. Or may be reduced, depending on the pattern :) Also number of walls may count (n * nozzle diameter) or lack of skin overlap - then printing holes would support consistency of the structure. Thus the question of stability may be significant. Construction sience would most probably lead to <a href="https://sciencemadefun.net/blog/triangles-the-strongest-shape/" rel="nofollow noreferrer">triangles</a>.</p>
| 1,828
|
<pre><code>@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Problem {
@ManyToOne
private Person person;
}
@Entity
@DiscriminatorValue("UP")
public class UglyProblem extends Problem {}
@Entity
public class Person {
@OneToMany(mappedBy="person")
private List< UglyProblem > problems;
}
</code></pre>
<p>I think it is pretty clear what I am trying to do. I expect @ManyToOne person to be inherited by UglyProblem class. But there will be an exception saying something like: "There is no such property found in UglyProblem class (mappedBy="person")".</p>
<p>All I found is <a href="http://opensource.atlassian.com/projects/hibernate/browse/ANN-558" rel="noreferrer">this</a>. I was not able to find the post by Emmanuel Bernard explaining reasons behind this. </p>
<hr>
<blockquote>
<p>Unfortunately, according to the Hibernate documentation "Properties from superclasses not mapped as @MappedSuperclass are ignored."</p>
</blockquote>
<p>Well I think this means that if I have these two classes:</p>
<pre><code>public class A {
private int foo;
}
@Entity
public class B extens A {
}
</code></pre>
<p>then field <code>foo</code> will not be mapped for class B. Which makes sense. But if I have something like this:</p>
<pre><code>@Entity
public class Problem {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@Entity
public class UglyProblem extends Problem {
private int levelOfUgliness;
public int getLevelOfUgliness() {
return levelOfUgliness;
}
public void setLevelOfUgliness(int levelOfUgliness) {
this.levelOfUgliness = levelOfUgliness;
}
}
</code></pre>
<p>I expect the class UglyProblem to have fileds <code>id</code> and <code>name</code> and both classes to be mapped using same table. (In fact, this is exactly what happens, I have just checked again). I have got this table:</p>
<pre><code>CREATE TABLE "problem" (
"DTYPE" varchar(31) NOT NULL,
"id" bigint(20) NOT NULL auto_increment,
"name" varchar(255) default NULL,
"levelOfUgliness" int(11) default NULL,
PRIMARY KEY ("id")
) AUTO_INCREMENT=2;
</code></pre>
<p>Going back to my question:</p>
<blockquote>
<p>I expect @ManyToOne person to be inherited by UglyProblem class.</p>
</blockquote>
<p>I expect that because all other mapped fields are inherited and I do not see any reason to make this exception for ManyToOne relationships.</p>
<hr>
<p>Yeah, I saw that. In fact, I used Read-Only solution for my case. But my question was "Why..." :). I know that there is an explanation given by a member of hibernate team. I was not able to find it and that is why I asked.</p>
<p>I want to find out the motivation of this design decision.</p>
<p>(if you interested how I have faced this problem: I inherited a project built using hibernate 3. It was Jboss 4.0.something + hibernate was already there (you'd download it all together). I was moving this project to Jboss 4.2.2 and I found out that there are inherited mappings of "@OneToMany mappedBy" and it worked fine on old setup...)</p>
|
<p>I think it's a wise decision made by the Hibernate team. They could be less arrogante and make it clear why it was implemented this way, but that's just how Emmanuel, Chris and Gavin works. :)</p>
<p>Let's try to understand the problem. I think your concepts are "lying". First you say that many <strong>Problem</strong>s are associated to <strong>People</strong>. But, then you say that one <strong>Person</strong> have many <strong>UglyProblem</strong>s (and does not relate to other <strong>Problem</strong>s). Something is wrong with that design.</p>
<p>Imagine how it's going to be mapped to the database. You have a single table inheritance, so:</p>
<pre><code> _____________
|__PROBLEMS__| |__PEOPLE__|
|id <PK> | | |
|person <FK> | -------->| |
|problemType | |_________ |
--------------
</code></pre>
<p>How is hibernate going to enforce the database to make <strong>Problem</strong> only relate to <strong>People</strong> if its <strong>problemType</strong> is equal UP? That's a very difficult problem to solve. So, if you want this kind of relation, every subclass must be in it's own table. That's what <code>@MappedSuperclass</code> does.</p>
<p>PS.: Sorry for the ugly drawing :D</p>
|
<p>In my opinion @JoinColumn should at least provide an option to apply the @DiscriminatorColumn = @DiscriminatorValue to the SQL "where" clause, although I would prefer this behaviour to be a default one.</p>
<p>I am very surprised that in the year 2020 this is still an issue.
Since this object design pattern is not so rare, I think it is a disgrace for JPA not yet covering this simple feature in the specs, thus still forcing us to search for ugly workarounds.</p>
<p>Why must this be so difficult? It is just an additional where clause and yes, I do have a db index prepared for @JoinColumn, @DiscriminatorColumn combo.</p>
<p>.i.. JPA</p>
<p>Introduce your own custom annotations and write code that generates native queries. It will be a good exercise.</p>
| 5,899
|
<p>I know I can do most of this by hacking Trac and using Git hooks, but I was wondering if someone has / knows of something ready.</p>
<p>Commenting on (and closing) tickets from commit messages would be nice, specially if the diff appears inline with the comment/closing remark.</p>
<p>sha1 hashes should be auto-linked to gitweb/cigt/custom git browser.</p>
<p>I tried the GitPlugin for Trac, but the code browser was soo slow... any alternatives?</p>
|
<p><a href="http://www.redmine.org/" rel="noreferrer">Redmine</a> can do some of what you're asking for. Integration works in one direction, you must <a href="http://www.redmine.org/projects/redmine/wiki/RedmineSettings#Referencing-issues-in-commit-messages" rel="noreferrer">reference issues in commit messages</a>, and then this data will be available in redmine. </p>
<p>The data is then available in two views. The bug display will include a list of matched commits. The repository display will link commits to bug display pages.</p>
<p>Redmine keeps a local (bare) repository for each project. This can be the primary repo or a remote mirror. On updates, redmine parses the commit messages and updates an internal cross reference table of change_set,issue. </p>
<p>If the redmine repository is only used as a mirror, it will need to be updated. Updates can happen via cron or via external hook. We use a <a href="http://mentalized.net/journal/2009/08/03/redmine_plugin_github_hook/" rel="noreferrer">redmine github plugin</a> and a github post-receive hook to keep redmine in sync with a primary github repository.</p>
<p>It works, but it is still a bit clumsy.</p>
|
<p>Check out this link <a href="http://jazz.net/library/article/194" rel="nofollow noreferrer">here</a>.
It provides a tutorial on how Git can be used to integrate with Rational Team Concert. It will give some basic information which can be used to integrate Git with a wide range of other products.</p>
| 6,173
|
<p>I am currently calling the following line of code:</p>
<pre><code>java.net.URL connection_url = new java.net.URL("http://<ip address>:<port>/path");
</code></pre>
<p>and I get the exception above when it executes. Any ideas as to why this is happening?</p>
|
<p>Your code works perfectly fine for me:</p>
<pre><code>public static void main(String[] args) {
try {
java.net.URL connection_url = new java.net.URL("http://:/path");
System.out.println("Instantiated new URL: " + connection_url);
}
catch (MalformedURLException e) {
e.printStackTrace();
}
}
</code></pre>
<blockquote>
<p>Instantiated new URL: <a href="http://:/path" rel="nofollow noreferrer">http://:/path</a></p>
</blockquote>
<p>Sure you have the right line of code?</p>
|
<p>I have also had the same exception, but in my case the URL which I was trying to execute had a space appended. After removing the space it worked fine for me. Check that the URL does not have any trailing spaces in your case.</p>
| 8,457
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.